XQuartz: translate additional mouse buttons

Old behavior was to translate the middle mouse button, as well as
every other button that isn't the left or right mouse button,
to act as the middle mouse button (2).

New behavior is to translate only the middle mouse button to 2,
and translate higher-numbered buttons to 8 and higher.
This allows additional mouse buttons to behave under XQuartz
more like they do by default under X11 on other platforms
(e.g. Linux and BSD distributions).

Signed-off-by: Christopher Chavez <chrischavez@gmx.us>
This commit is contained in:
Christopher Chavez 2019-07-27 10:51:57 -05:00
parent 436fd7e8b4
commit 4f27d1e05f

View File

@ -1473,7 +1473,16 @@ wait_for_mieq_init(void);
goto handle_mouse;
case NSOtherMouseDown:
ev_button = 2;
// Get the AppKit button number, and convert it from 0-based to 1-based
ev_button = [e buttonNumber] + 1;
/* Translate middle mouse button (3 in AppKit) to button 2 in X11,
* and translate additional mouse buttons (4 and higher in AppKit)
* to buttons 8 and higher in X11, to match default behavior of X11
* on other platforms
*/
ev_button = (ev_button == 3) ? 2 : (ev_button + 4);
ev_type = ButtonPress;
goto handle_mouse;
@ -1488,7 +1497,9 @@ wait_for_mieq_init(void);
goto handle_mouse;
case NSOtherMouseUp:
ev_button = 2;
// See above comments for NSOtherMouseDown
ev_button = [e buttonNumber] + 1;
ev_button = (ev_button == 3) ? 2 : (ev_button + 4);
ev_type = ButtonRelease;
goto handle_mouse;
@ -1503,7 +1514,9 @@ wait_for_mieq_init(void);
goto handle_mouse;
case NSOtherMouseDragged:
ev_button = 2;
// See above comments for NSOtherMouseDown
ev_button = [e buttonNumber] + 1;
ev_button = (ev_button == 3) ? 2 : (ev_button + 4);
ev_type = MotionNotify;
goto handle_mouse;