Fix T66088: Modifier keys ignored when the window doesn't have focus

Always use modifier keys from the active window, as changes to the
modifiers aren't sent to inactive windows.

Also resolves modifier keys being lost on window de-activation.
Activating the window again would check the previous state of the
modifiers which was always cleared as of [0],
now clearing is no longer needed.

[0]: 472595f1d3
This commit is contained in:
2022-08-11 15:06:13 +10:00
parent 51381c94d8
commit 8bc76bf4b9
2 changed files with 24 additions and 6 deletions

View File

@@ -5214,6 +5214,13 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
event.prev_type = event.type;
event.prev_val = event.val;
/* Always use modifiers from the active window since
changes to modifiers aren't sent to inactive windows, see: T66088. */
if ((wm->winactive != win) && (wm->winactive && wm->winactive->eventstate)) {
event.modifier = wm->winactive->eventstate->modifier;
event.keymodifier = wm->winactive->eventstate->keymodifier;
}
/* Ensure the event state is correct, any deviation from this may cause bugs.
*
* NOTE: #EVENT_NONE is set when unknown keys are pressed,
@@ -5256,6 +5263,10 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
if (win_other) {
wmEvent event_other = *win_other->eventstate;
/* Use the modifier state of this window. */
event_other.modifier = event.modifier;
event_other.keymodifier = event.keymodifier;
/* See comment for this operation on `event` for details. */
event_other.prev_type = event_other.type;
event_other.prev_val = event_other.val;
@@ -5345,6 +5356,10 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
if (win_other) {
wmEvent event_other = *win_other->eventstate;
/* Use the modifier state of this window. */
event_other.modifier = event.modifier;
event_other.keymodifier = event.keymodifier;
/* See comment for this operation on `event` for details. */
event_other.prev_type = event_other.type;
event_other.prev_val = event_other.val;