Fix T34255: Modifier keys ignored when activating windows
This commit is contained in:
parent
3abb2e0a3d
commit
cb023ce0fd
Notes:
blender-bot
2023-03-03 13:19:59 +01:00
Referenced by issue #40317, Pressing V key in user preferences is recognized as Ctrl+V Referenced by issue #40059, Switching open windows ignores held modifiers on WIN32 Referenced by issue #34255, Can't Scroll in User Preferences when opening with Shortcut
|
@ -747,6 +747,10 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
|
|||
GHOST_TEventKeyData kdata;
|
||||
wmEvent event;
|
||||
int wx, wy;
|
||||
const int keymodifier = ((query_qual(SHIFT) ? KM_SHIFT : 0) |
|
||||
(query_qual(CONTROL) ? KM_CTRL : 0) |
|
||||
(query_qual(ALT) ? KM_ALT : 0) |
|
||||
(query_qual(OS) ? KM_OSKEY : 0));
|
||||
|
||||
wm->winactive = win; /* no context change! c->wm->windrawable is drawable, or for area queues */
|
||||
|
||||
|
@ -756,25 +760,58 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
|
|||
/* bad ghost support for modifier keys... so on activate we set the modifiers again */
|
||||
|
||||
/* TODO: This is not correct since a modifier may be held when a window is activated...
|
||||
* better solve this at ghost level. attempted fix r54450 but it caused bug [#34255] */
|
||||
* better solve this at ghost level. attempted fix r54450 but it caused bug [#34255]
|
||||
*
|
||||
* For now don't send GHOST_kEventKeyDown events, just set the 'eventstate'.
|
||||
*/
|
||||
kdata.ascii = '\0';
|
||||
kdata.utf8_buf[0] = '\0';
|
||||
if (win->eventstate->shift && !query_qual(SHIFT)) {
|
||||
kdata.key = GHOST_kKeyLeftShift;
|
||||
wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata);
|
||||
|
||||
if (win->eventstate->shift) {
|
||||
if ((keymodifier & KM_SHIFT) == 0) {
|
||||
kdata.key = GHOST_kKeyLeftShift;
|
||||
wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata);
|
||||
}
|
||||
}
|
||||
if (win->eventstate->ctrl && !query_qual(CONTROL)) {
|
||||
kdata.key = GHOST_kKeyLeftControl;
|
||||
wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata);
|
||||
else {
|
||||
if (keymodifier & KM_SHIFT) {
|
||||
win->eventstate->shift = KM_MOD_FIRST;
|
||||
}
|
||||
}
|
||||
if (win->eventstate->alt && !query_qual(ALT)) {
|
||||
kdata.key = GHOST_kKeyLeftAlt;
|
||||
wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata);
|
||||
if (win->eventstate->ctrl) {
|
||||
if ((keymodifier & KM_CTRL) == 0) {
|
||||
kdata.key = GHOST_kKeyLeftControl;
|
||||
wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata);
|
||||
}
|
||||
}
|
||||
if (win->eventstate->oskey && !query_qual(OS)) {
|
||||
kdata.key = GHOST_kKeyOS;
|
||||
wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata);
|
||||
else {
|
||||
if (keymodifier & KM_CTRL) {
|
||||
win->eventstate->ctrl = KM_MOD_FIRST;
|
||||
}
|
||||
}
|
||||
if (win->eventstate->alt) {
|
||||
if ((keymodifier & KM_ALT) == 0) {
|
||||
kdata.key = GHOST_kKeyLeftAlt;
|
||||
wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (keymodifier & KM_ALT) {
|
||||
win->eventstate->alt = KM_MOD_FIRST;
|
||||
}
|
||||
}
|
||||
if (win->eventstate->oskey) {
|
||||
if ((keymodifier & KM_OSKEY) == 0) {
|
||||
kdata.key = GHOST_kKeyOS;
|
||||
wm_event_add_ghostevent(wm, win, GHOST_kEventKeyUp, time, &kdata);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (keymodifier & KM_OSKEY) {
|
||||
win->eventstate->oskey = KM_MOD_FIRST;
|
||||
}
|
||||
}
|
||||
|
||||
/* keymodifier zero, it hangs on hotkeys that open windows otherwise */
|
||||
win->eventstate->keymodifier = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue