mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-10-02 16:23:57 +08:00
x11: Ignore slave button presses when the window lacks keyboard focus
Build (All) / Create test plan (push) Has been cancelled
Build (All) / level1 (push) Has been cancelled
Build (All) / level2 (push) Has been cancelled
Build (All) / Create test plan (push) Has been cancelled
Build (All) / level1 (push) Has been cancelled
Build (All) / level2 (push) Has been cancelled
XInput2 can send slave button presses before FocusIn events, which can confuse the click-through suppression logic. A window must have keyboard focus to grab the mouse anyway, so ignore slave presses when lacking keyboard focus.
(cherry picked from commit ef9a5b7040)
This commit is contained in:
@@ -611,8 +611,10 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie)
|
||||
int x_ticks = 0, y_ticks = 0;
|
||||
|
||||
if (xev->deviceid != videodata->xinput_master_pointer_device) {
|
||||
// Ignore slave button events on non-focused windows, or focus can be incorrectly set while a grab is active.
|
||||
if (SDL_GetMouseFocus() != windowdata->window) {
|
||||
/* Ignore slave button events on non-focused windows, as they can arrive before FocusIn events,
|
||||
* or result in focus being incorrectly set while a grab is active.
|
||||
*/
|
||||
if (SDL_GetMouseFocus() != windowdata->window || SDL_GetKeyboardFocus() != windowdata->window) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user