Closed oscfdezdz closed 1 year ago
This is a little bit too fast. I think the way to go is to accumulate the deltas until a threshold (then scroll), unless gdk_scroll_event_is_stop
is true, then start again (reset the sum of deltas to 0). That seems to be the way Firefox does it.
I have also just pushed a commit that's relevant to this.
In my case, and taking gnome-text-editor as a reference, with mouse it worked better as it was. In the case of the touchpad, it was too fast, now it's better. Also, gdk_scroll_event_is_stop
~works fine with touchpad, but not with mouse~ makes scrolling not smooth. That's why, the sum of deltas is being reset after scroll.
Maybe changing the threshold depending on the input device? https://lazka.github.io/pgi-docs/Gdk-3.0/enums.html#Gdk.InputSource Although it could be due to the hardware and not the type of input device.
The scrolling must not be smooth, text size should increase in discrete steps. In gnome-text-editor it's also much too fast, und hard to control. It's important to be able to go to 100% for example. What's the problem with mouse in case of a threshold?
I think you have to use gdk_scroll_event_is_stop
, otherwise it will never reset the threshold.
What is the delta with a mouse wheel?
I get good results with "threshold <= -1", or ">= 1".
Also you have to return True from the outer if statement, to avoid the regular scrolling to take effekt.
` def on_scroll(self, widget, event): modifiers = Gtk.accelerator_get_default_mod_mask()
if event.state & modifiers == Gdk.ModifierType.CONTROL_MASK:
font_manager = ServiceLocator.get_font_manager()
self.zoom_threshold += event.delta_y
if event.is_stop:
self.zoom_threshold = 0
if self.zoom_threshold <= -1:
font_manager.zoom_in()
self.zoom_threshold = 0
elif self.zoom_threshold >= 1:
font_manager.zoom_out()
self.zoom_threshold = 0
return True`
This works well for me. I have a trackpoint and a touchpad.
It also works perfectly with a mouse. The wheel on my mouse has a delta of 1 or -1 always.
It's working perfectly now for both cases with the changes you propose.
You should not return True in any case, just if the event was handled (ctrl+scroll). Also can you add the delta before checking for is_stop
? Otherwise perfect.
It should be fixed now.
Cool.
Fix #252