From e54f88f092865cb1239c3fb65a13cb2f9c50fcba Mon Sep 17 00:00:00 2001 From: Yevgeny Makarov Date: Wed, 3 Feb 2021 17:01:14 +0100 Subject: macOS: trackpad scroll direction reversed in list views The 'ui_pan_to_scroll' uses 'WM_event_absolute_delta_y'. For scrolling the List View we need to invert the direction to respect "natural scroll direction" system preferences. Differential Revision: https://developer.blender.org/D10291 --- source/blender/editors/interface/interface_handlers.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index b5aeee3d3bc..97d9b225d3c 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -9005,6 +9005,7 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *regi { int retval = WM_UI_HANDLER_CONTINUE; int type = event->type, val = event->val; + int scroll_dir = 1; bool redraw = false; uiList *ui_list = listbox->custom_data; @@ -9021,6 +9022,11 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *regi if (type == MOUSEPAN) { ui_pan_to_scroll(event, &type, &val); + /* 'ui_pan_to_scroll' gives the absolute direction. */ + if (event->is_direction_inverted) { + scroll_dir = -1; + } + /* If type still is mouse-pan, we call it handled, since delta-y accumulate. */ /* also see wm_event_system.c do_wheel_ui hack */ if (type == MOUSEPAN) { @@ -9115,7 +9121,7 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *regi else if (ELEM(type, WHEELUPMOUSE, WHEELDOWNMOUSE)) { if (dyn_data->height > dyn_data->visual_height) { /* list template will clamp */ - ui_list->list_scroll += (type == WHEELUPMOUSE) ? -1 : 1; + ui_list->list_scroll += scroll_dir * ((type == WHEELUPMOUSE) ? -1 : 1); redraw = true; retval = WM_UI_HANDLER_BREAK; -- cgit v1.2.3