On Jun 13, 2011, at 2:07 PM, Vincent Povirk wrote:
> <0005-winex11.drv-Grab-registered-hotkeys-in-the-X-server.txt>
Is it necessary to test QS_HOTKEY in dlls/winex11.drv/event.c:filter_event, where QS_KEY is currently tested? If somebody calls MsgWaitForMultipleObjectsEx with QS_HOTKEY but not QS_KEY, shouldn't KeyPress events be accepted?
> +static void update_modifier_state(int modifier_mask, int actual_mask,
> + BYTE *keystate, WORD vkey, WORD alt_vkey, WORD scan, DWORD event_time)
> +{
> + int key_pressed = (actual_mask & modifier_mask) != 0;
> + int vkey_pressed = (keystate[vkey] & 0x80) == 0x80 ||
> + (keystate[alt_vkey] & 0x80) == 0x80;
> + DWORD flags;
> +
> + if (key_pressed != vkey_pressed)
> + {
> + if (key_pressed)
> + flags = 0;
> + else
> + flags = KEYEVENTF_KEYUP;
> + TRACE_(key)("Adjusting modifier state vkey=0x%x, state=%i\n", vkey, key_pressed);
> + X11DRV_send_keyboard_input( NULL, vkey, scan, flags, event_time );
> + }
> +}
> + update_modifier_state(MetaMask, event->state, keystate, VK_LMENU, VK_RMENU, 0x38, event_time);
> + update_modifier_state(ControlMask, event->state, keystate, VK_LCONTROL, VK_RCONTROL, 0x1D, event_time);
> + update_modifier_state(ShiftMask, event->state, keystate, VK_LSHIFT, VK_RSHIFT, 0x2A, event_time);
> + update_modifier_state(SuperMask, event->state, keystate, VK_LWIN, VK_RWIN, 0x15b, event_time);
You may be able to use the non-left-right-sensitive vkeys (e.g. VK_MENU) here, and thus eliminate the alt_vkey parameter. And if you can't, then update_modifier_state doesn't do the right thing when alt_vkey is the one that's pressed in the keystate but it's no longer pressed in event->state. In that case, you send a key-up for vkey, when you should send it for alt_vkey. If both were down and now neither is, you'll need to send a key-up for both. Note, to send keyboard input for a right-hand modifier, you'll need to include KEYEVENTF_EXTENDEDKEY in the flags and different scan codes.
-Ken