mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-05 19:08:12 +00:00
x11: Avoid duplicate mouse events when using a pen device.
Fixes #12968.
This commit is contained in:
@@ -406,11 +406,15 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie)
|
||||
case XI_ButtonRelease:
|
||||
{
|
||||
const XIDeviceEvent *xev = (const XIDeviceEvent *)cookie->data;
|
||||
X11_PenHandle *pen = X11_FindPenByDeviceID(xev->deviceid);
|
||||
X11_PenHandle *pen = X11_FindPenByDeviceID(xev->sourceid);
|
||||
const int button = xev->detail;
|
||||
const bool down = (cookie->evtype == XI_ButtonPress);
|
||||
|
||||
if (pen) {
|
||||
if (xev->deviceid != xev->sourceid) {
|
||||
// Discard events from "Master" devices to avoid duplicates.
|
||||
break;
|
||||
}
|
||||
// Only report button event; if there was also pen movement / pressure changes, we expect an XI_Motion event first anyway.
|
||||
SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event);
|
||||
if (button == 1) { // button 1 is the pen tip
|
||||
@@ -422,11 +426,6 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie)
|
||||
// Otherwise assume a regular mouse
|
||||
SDL_WindowData *windowdata = xinput2_get_sdlwindowdata(videodata, xev->event);
|
||||
|
||||
if (xev->deviceid != xev->sourceid) {
|
||||
// Discard events from "Master" devices to avoid duplicates.
|
||||
break;
|
||||
}
|
||||
|
||||
if (down) {
|
||||
X11_HandleButtonPress(_this, windowdata, (SDL_MouseID)xev->sourceid, button,
|
||||
(float)xev->event_x, (float)xev->event_y, xev->time);
|
||||
@@ -449,7 +448,8 @@ void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie)
|
||||
|
||||
videodata->global_mouse_changed = true;
|
||||
|
||||
X11_PenHandle *pen = X11_FindPenByDeviceID(xev->deviceid);
|
||||
X11_PenHandle *pen = X11_FindPenByDeviceID(xev->sourceid);
|
||||
|
||||
if (pen) {
|
||||
if (xev->deviceid != xev->sourceid) {
|
||||
// Discard events from "Master" devices to avoid duplicates.
|
||||
|
Reference in New Issue
Block a user