-
Notifications
You must be signed in to change notification settings - Fork 539
Handle smooth scrolling #1464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle smooth scrolling #1464
Conversation
Fixes scrolling under Wayland.
|
Looks reasonable to me, but I'm on Windows. One of the mainteiners using Linux will have to check this and merge it. |
|
|
|
Never mind, scrolling works fine. I should had coffee before testing. It does appear that the scrolling direction has changed for the mousewheel too, but that might be because the of the natural scrolling direction I have configured. +1 on Linux |
|
Can this be merged? |
|
What does this do? It looks trackpad related and I don't have one on my Linux system. Scroll wheel is used for zoom in solvespace, what's this doing? |
|
the same thing as the scroll wheel. on X11, touchpad events are treated as scroll wheel events. on wayland, these events are distinguished and therefore apps need to handle the touchpad 2-finger-scroll gesture if they're handling scrolling events manually and not letting the toolkit manage scrolling for them. someone was complaining about the lack of working scrolling in the Fedora chat. |
|
|
||
| double delta; | ||
| if(dy < 0 || dir == GDK_SCROLL_UP) { | ||
| if(abs(dy) > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the documentation gdk_event_get_scroll_deltas returns "TRUE if the event contains smooth scroll information and FALSE otherwise." Perhaps that is a better way to detect smooth scrolling? I am not on Linux, so I can not test it.
The example in https://docs.gtk.org/gdk3/method.Event.get_scroll_direction.html also suggests using the return value:
GdkScrollDirection direction;
double vscroll_factor = 0.0;
double x_scroll, y_scroll;
if (gdk_event_get_scroll_direction (event, &direction))
{
// Handle discrete scrolling with a known constant delta;
const double delta = 12.0;
switch (direction)
{
case GDK_SCROLL_UP:
vscroll_factor = -delta;
break;
case GDK_SCROLL_DOWN:
vscroll_factor = delta;
break;
default:
// no scrolling
break;
}
}
else if (gdk_event_get_scroll_deltas (event, &x_scroll, &y_scroll))
{
// Handle smooth scrolling directly
vscroll_factor = y_scroll;
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An interesting result from superficial googling that may be relevant :-)
https://stackoverflow.com/questions/11775161/gtk3-get-mouse-scroll-direction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pontaoski I made an alternative implementation based on the above suggestion here:
#1470
Since my only Linux system is a RaspberryPi I have neither Wayland nor a trackpad. gdk_event_get_scroll_deltas does return true and dy is always -1 or 1.
What do you think, which approach is better?
|
For cross reference #825 |
|
What is currently needed now? It would be convenient to have this fixed |
|
@polyfloyd just take a look at (and perhaps test) #1470 and tell me which one you think is better. The only Linux I have is a RP3 so I can not really test these "properly". Once I hear from you I'll merge one and close the other. |
|
@polyfloyd interesting and slightly unexpected. What did you test on? X11, Wayland, touchpad with two finger drag, mouse with a scroll wheel? |
|
Wayland, touchpad with two finger drag |
…heel ... on Linux/GTK The bug was introduced here 31d0c27 solvespace#1464 solvespace#1470 Fixes solvespace#1488
…heel ... on Linux/GTK The bug was introduced here 31d0c27 solvespace#1464 solvespace#1470 Fixes solvespace#1488
…heel ... on Linux/GTK The bug was introduced here 578be2d solvespace#1464 solvespace#1470 Fixes solvespace#1488
Fixes scrolling under Wayland.