devdraw: fix stuck mouse button when using Ctrl/Alt+Click
When physical button 1 is remapped to button 2 (Ctrl) or 3 (Alt) on ButtonPress, the ButtonRelease event still reports the physical button 1. This caused the release to clear the wrong bit, leaving the simulated button permanently stuck. Fix by recording the button mapping on press and applying it on release. Written mostly by Claude, but I've reviewed the code and it seems like the right kind of fix, and it works for me. Fixes #714. Change-Id: I9f465e1dcbe766531a37088e0fc9df2570e1c01d
This commit is contained in:
@@ -67,6 +67,7 @@ struct Xprivate {
|
|||||||
int kbuttons;
|
int kbuttons;
|
||||||
int kstate;
|
int kstate;
|
||||||
int altdown;
|
int altdown;
|
||||||
|
int button1map; /* logical button that physical button 1 maps to */
|
||||||
|
|
||||||
Xwin* windows;
|
Xwin* windows;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -408,9 +408,20 @@ runxevent(XEvent *xev)
|
|||||||
be->button = 2;
|
be->button = 2;
|
||||||
else if(_x.kstate & Mod1Mask)
|
else if(_x.kstate & Mod1Mask)
|
||||||
be->button = 3;
|
be->button = 3;
|
||||||
|
_x.button1map = be->button;
|
||||||
}
|
}
|
||||||
// fall through
|
// fall through
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
|
/*
|
||||||
|
* X reports the physical button on release, but ButtonPress
|
||||||
|
* may have remapped button 1 to 2 or 3 (via Ctrl or Alt).
|
||||||
|
* Use the same mapping so we clear the correct bit.
|
||||||
|
*/
|
||||||
|
if(xev->type == ButtonRelease) {
|
||||||
|
be = (XButtonEvent*)xev;
|
||||||
|
if(be->button == 1 && _x.button1map != 0)
|
||||||
|
be->button = _x.button1map;
|
||||||
|
}
|
||||||
_x.altdown = 0;
|
_x.altdown = 0;
|
||||||
// fall through
|
// fall through
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
|
|||||||
Reference in New Issue
Block a user