Skip to content

Scale down MacOS scrolling from event controllers#20710

Open
dtorop wants to merge 1 commit intodarktable-org:masterfrom
dtorop:scroll-controller-fixes-macos
Open

Scale down MacOS scrolling from event controllers#20710
dtorop wants to merge 1 commit intodarktable-org:masterfrom
dtorop:scroll-controller-fixes-macos

Conversation

@dtorop
Copy link
Copy Markdown
Contributor

@dtorop dtorop commented Mar 31, 2026

MacOS trackpad scroll events appear to be of much greater magnitude than those on other systems. To make them usable, we need to scale down the scroll deltas. For traditional GTK 3 code, dt_gui_get_scroll_unit_deltas() took care of this. Unfortunately, this code depends on the scroll-event signal. To make the code GTK 4 ready, we need to handle the scroll signal generated by a GtkEventControllerScroll.

For discrete scrolls, we can handle this transparently via the dt_gui_connect_scroll_discrete() setup function. This new function is similar to dt_gui_connect_scroll(). There is no need to call it with the GTK_EVENT_CONTROLLER_SCROLL_DISCRETE flag, as it adds this automatically. If darktable is compiled for MacOS, a proxy function will scale down the scroll events.

Note that this commit doesn't do anything to help scale down scroll events from a non-discrete GtkEventControllerScroll.

Also: In bauhaus _widget_scroll(), actually warn if called an a non-scroll event or no event rather than having a useless NOP conditional. Don't free the event in unlikely case we can't retrieve it.

Also: Update/remove a couple comments. In GTK4 it seems preferable to target events directly to widgets (as gtk_propagate_event and gtk_event_controller_handle_event are gone) so don't apologize in comments for using gtk_widget_event().

Fixes: #20698

See #20701 for discussion

MacOS trackpad scroll events appear to be of much greater magnitude
than those on other systems. To make them usable, we need to scale
down the scroll deltas. For traditional GTK 3 code,
dt_gui_get_scroll_unit_deltas() took care of this. Unfortunately, this
code depends on the "scroll-event" signal. To make the code GTK 4
ready, we need to handle the "scroll" signal generated by a
GtkEventControllerScroll.

For discrete scrolls, we can handle this transparently via the
dt_gui_connect_scroll_discrete() setup function. This new function is
similar to dt_gui_connect_scroll(). There is no need to call it with
the GTK_EVENT_CONTROLLER_SCROLL_DISCRETE flag, as it adds this
automatically. If darktable is compiled for MacOS, a proxy function
will scale down the scroll events.

Note that this commit doesn't do anything to help scale down scroll
events from a non-discrete GtkEventControllerScroll.

Also: In bauhaus _widget_scroll, actually warn if called an a
non-scroll event or no event rather than having a useless NOP
conditional. Don't free the event in unlikely case we can't retrieve
it.

Also: Update/remove a couple comments. In GTK4 it seems preferable to
target events directly to widgets (as gtk_propagate_event and
gtk_event_controller_handle_event are gone) so don't apologize in
comments for using gtk_widget_event().

Fixes: darktable-org#20698
@MStraeten
Copy link
Copy Markdown
Collaborator

no decrease of sensitivity on sliders and also scope (color harmony rotation) with this fix

@dtorop
Copy link
Copy Markdown
Contributor Author

dtorop commented Mar 31, 2026

@MStraeten: Drat! So it doesn't fix anything?

Would you have time to add a bit of diagnostic code in and send the output when scrolling a slider? Something like:

modified   src/gui/gtk.c
@@ -4699,6 +4699,7 @@ static void _scroll_discrete_proxy(GtkEventControllerScroll* self,
                                     gdouble dy,
                                     _scroll_handler_proxy_t *h)
 {
+  dt_print_ext("proxy dx %f dy %f cur_dx %f cur_dy %f", dx, dy, h->cur_dx, h->cur_dy);
   // Even though the event controller has already accumulated smooth
   // scroll events to discrete dx/dy, MacOS smooth scrolling events
   // are too fast so scale them down via another accumulating stage.
@@ -4722,6 +4723,7 @@ static void _scroll_discrete_proxy(GtkEventControllerScroll* self,
       h->cur_dy -= steps;
       dy = steps;
     }
+    dt_print_ext("smooth dx %f dy %f cur_dx %f cur_dy %f", dx, dy, h->cur_dx, h->cur_dy);
   }
   if(dx != 0.0 || dy != 0.0)
     h->scroll_callback_real(self, dx, dy, h->scroll_data_real);

I also realize there might be a slightly nicer way to implement this (only accumulate scrolling at the darktable level, not at the GTK level), but not material unless this actually works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macos: sensitivity of trackpad / magic mouse increased

2 participants