--- sourceforge.net/trunk/rdesktop/xkeymap.c 2002/09/01 12:03:33 111 +++ sourceforge.net/trunk/rdesktop/xkeymap.c 2002/09/11 11:11:27 116 @@ -41,6 +41,8 @@ static int min_keycode; static uint16 remote_modifier_state = 0; +static void update_modifier_state(uint16 modifiers, BOOL pressed); + static void add_to_keymap(char *keyname, uint8 scancode, uint16 modifiers, char *mapname) { @@ -175,6 +177,11 @@ MASK_ADD_BITS(modifiers, MapLocalStateMask); } + if (strstr(line_rest, "inhibit")) + { + MASK_ADD_BITS(modifiers, MapInhibitMask); + } + add_to_keymap(keyname, scancode, modifiers, mapname); if (strstr(line_rest, "addupper")) @@ -229,6 +236,13 @@ tr = keymap[keysym & KEYMAP_MASK]; + if (tr.modifiers & MapInhibitMask) + { + DEBUG_KBD(("Inhibiting key\n")); + tr.scancode = 0; + return tr; + } + if (tr.modifiers & MapLocalStateMask) { /* The modifiers to send for this key should be obtained @@ -296,22 +310,6 @@ return ksname; } -BOOL -inhibit_key(KeySym keysym) -{ - switch (keysym) - { - case XK_Caps_Lock: - return True; - break; - case XK_Multi_key: - return True; - break; - default: - break; - } - return False; -} void ensure_remote_modifiers(uint32 ev_time, key_translation tr) @@ -372,30 +370,33 @@ != MASK_HAS_BITS(remote_modifier_state, MapNumLockMask)) { /* The remote modifier state is not correct */ - DEBUG_KBD(("Remote NumLock state is incorrect. Toggling\n")); + uint16 new_remote_state = 0; + if (MASK_HAS_BITS(tr.modifiers, MapNumLockMask)) { - /* Needs this modifier. Toggle */ - rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_NUMLOCK); - rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_NUMLOCK); + DEBUG_KBD(("Remote NumLock state is incorrect, activating NumLock.\n")); + new_remote_state |= KBD_FLAG_NUMLOCK; } else { - /* Should not use this modifier. Toggle */ - rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_NUMLOCK); - rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_NUMLOCK); + DEBUG_KBD(("Remote NumLock state is incorrect, deactivating NumLock.\n")); } - } + rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, new_remote_state, 0); + update_modifier_state(SCANCODE_CHAR_NUMLOCK, True); + } } static void update_modifier_state(uint16 modifiers, BOOL pressed) { +#ifdef WITH_DEBUG_KBD + uint16 old_modifier_state; + + old_modifier_state = remote_modifier_state; +#endif - DEBUG_KBD(("Before updating modifier_state:0x%x, pressed=0x%x\n", - remote_modifier_state, pressed)); switch (modifiers) { case SCANCODE_CHAR_LSHIFT: @@ -436,7 +437,15 @@ } break; } - DEBUG_KBD(("After updating modifier_state:0x%x\n", remote_modifier_state)); + +#ifdef WITH_DEBUG_KBD + if (old_modifier_state != remote_modifier_state) + { + DEBUG_KBD(("Before updating modifier_state:0x%x, pressed=0x%x\n", + old_modifier_state, pressed)); + DEBUG_KBD(("After updating modifier_state:0x%x\n", remote_modifier_state)); + } +#endif }