Skip to content

Commit

Permalink
Fix: [OSX] Minor 2D scrolling fixes (#6793)
Browse files Browse the repository at this point in the history
* Codechange: Check for scrollwheel_scrolling first when scrolling viewport instead of first setting normal values and then overwriting them.

* Fix #6558: [OSX] Reset 2D scrolling values when not scrolling to prevent unintended window focus changes

* Change: [OSX] Include initial scrolling movement when using 2D scrolling to make it more responsive

* Fix: [OSX] 2D scrolling not working when setting viewport scroll behaviour to use left mouse button
  • Loading branch information
alexanderweiss authored and PeterN committed May 29, 2018
1 parent 3e910a5 commit 2406500
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions src/window.cpp
Expand Up @@ -2457,20 +2457,20 @@ static EventState HandleViewportScroll()
}

Point delta;
if (_settings_client.gui.scroll_mode != VSM_VIEWPORT_RMB_FIXED) {
delta.x = -_cursor.delta.x;
delta.y = -_cursor.delta.y;
} else {
delta.x = _cursor.delta.x;
delta.y = _cursor.delta.y;
}

if (scrollwheel_scrolling) {
/* We are using scrollwheels for scrolling */
delta.x = _cursor.h_wheel;
delta.y = _cursor.v_wheel;
_cursor.v_wheel = 0;
_cursor.h_wheel = 0;
} else {
if (_settings_client.gui.scroll_mode != VSM_VIEWPORT_RMB_FIXED) {
delta.x = -_cursor.delta.x;
delta.y = -_cursor.delta.y;
} else {
delta.x = _cursor.delta.x;
delta.y = _cursor.delta.y;
}
}

/* Create a scroll-event and send it to the window */
Expand Down Expand Up @@ -2866,7 +2866,12 @@ static void MouseLoop(MouseClick click, int mousewheel)
}

if (vp != NULL) {
if (scrollwheel_scrolling) click = MC_RIGHT; // we are using the scrollwheel in a viewport, so we emulate right mouse button
if (scrollwheel_scrolling && !(w->flags & WF_DISABLE_VP_SCROLL)) {
_scrolling_viewport = true;
_cursor.fix_at = true;
return;
}

switch (click) {
case MC_DOUBLE_LEFT:
case MC_LEFT:
Expand All @@ -2885,10 +2890,6 @@ static void MouseLoop(MouseClick click, int mousewheel)
_scrolling_viewport = true;
_cursor.fix_at = (_settings_client.gui.scroll_mode == VSM_VIEWPORT_RMB_FIXED ||
_settings_client.gui.scroll_mode == VSM_MAP_RMB_FIXED);

/* clear 2D scrolling caches before we start a 2D scroll */
_cursor.h_wheel = 0;
_cursor.v_wheel = 0;
return;
}
break;
Expand All @@ -2903,19 +2904,27 @@ static void MouseLoop(MouseClick click, int mousewheel)
case MC_LEFT:
case MC_DOUBLE_LEFT:
DispatchLeftClickEvent(w, x - w->left, y - w->top, click == MC_DOUBLE_LEFT ? 2 : 1);
break;
return;

default:
if (!scrollwheel_scrolling || w == NULL || w->window_class != WC_SMALLMAP) break;
/* We try to use the scrollwheel to scroll since we didn't touch any of the buttons.
* Simulate a right button click so we can get started. */
FALLTHROUGH;

case MC_RIGHT: DispatchRightClickEvent(w, x - w->left, y - w->top); break;
case MC_RIGHT:
DispatchRightClickEvent(w, x - w->left, y - w->top);
return;

case MC_HOVER: DispatchHoverEvent(w, x - w->left, y - w->top); break;
case MC_HOVER:
DispatchHoverEvent(w, x - w->left, y - w->top);
break;
}
}

/* We're not doing anything with 2D scrolling, so reset the value. */
_cursor.h_wheel = 0;
_cursor.v_wheel = 0;
}

/**
Expand Down

0 comments on commit 2406500

Please sign in to comment.