cocoadisplay: Invert direction of horizontal scroll

Now behaves consistent with other applications (tested with Logitech MX Master 3 for Mac on macOS 10.13 in unnatural scrolling configuration).

Set `cocoa-invert-wheel-x true` to revert to old behaviour.
This commit is contained in:
rdb 2022-01-22 15:56:53 +01:00
parent eaa182f310
commit 692221cacb
3 changed files with 17 additions and 5 deletions

View File

@ -2021,8 +2021,10 @@ handle_mouse_moved_event(bool in_window, double x, double y, bool absolute) {
*/
void CocoaGraphicsWindow::
handle_wheel_event(double x, double y) {
cocoadisplay_cat.spam()
<< "Wheel delta " << x << ", " << y << "\n";
if (cocoadisplay_cat.is_spam()) {
cocoadisplay_cat.spam()
<< "Wheel delta " << x << ", " << y << "\n";
}
if (y > 0.0) {
_input->button_down(MouseButton::wheel_up());
@ -2032,11 +2034,14 @@ handle_wheel_event(double x, double y) {
_input->button_up(MouseButton::wheel_down());
}
// TODO: check if this is correct, I don't own a MacBook
if (x > 0.0) {
if (x != 0 && cocoa_invert_wheel_x) {
x = -x;
}
if (x < 0.0) {
_input->button_down(MouseButton::wheel_right());
_input->button_up(MouseButton::wheel_right());
} else if (x < 0.0) {
} else if (x > 0.0) {
_input->button_down(MouseButton::wheel_left());
_input->button_up(MouseButton::wheel_left());
}

View File

@ -20,6 +20,8 @@
NotifyCategoryDecl(cocoadisplay, EXPCL_PANDA_COCOADISPLAY, EXPTP_PANDA_COCOADISPLAY);
extern ConfigVariableBool cocoa_invert_wheel_x;
extern EXPCL_PANDA_COCOADISPLAY void init_libcocoadisplay();
#endif

View File

@ -31,6 +31,11 @@ ConfigureFn(config_cocoadisplay) {
init_libcocoadisplay();
}
ConfigVariableBool cocoa_invert_wheel_x
("cocoa-invert-wheel-x", false,
PRC_DESC("Set this to true to swap the wheel_left and wheel_right mouse "
"button events, to restore to the pre-1.10.12 behavior."));
/**
* Initializes the library. This must be called at least once before any of
* the functions or classes in this library can be used. Normally it will be