Skip to content

Conversation

@sowelipililimute
Copy link
Contributor

Fixes scrolling under Wayland.

Fixes scrolling under Wayland.
@ruevs ruevs requested review from phkahler and rpavlik June 3, 2024 05:47
@ruevs
Copy link
Member

ruevs commented Jun 3, 2024

Looks reasonable to me, but I'm on Windows. One of the mainteiners using Linux will have to check this and merge it.

@polyfloyd
Copy link
Contributor

polyfloyd commented Jun 4, 2024

This does make touchpad scrolling do something now, but it does not appear to be giving the right input. I do not know what is happening. Scrolling with a mouse wheel is broken in a similar way :|

@polyfloyd
Copy link
Contributor

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

@erentar
Copy link

erentar commented Jun 22, 2024

Can this be merged?

@phkahler
Copy link
Member

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?

@sowelipililimute
Copy link
Contributor Author

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) {
Copy link
Member

@ruevs ruevs Jul 1, 2024

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;
    }

Copy link
Member

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

Copy link
Member

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?

@ruevs
Copy link
Member

ruevs commented Jul 7, 2024

For cross reference #825

@polyfloyd
Copy link
Contributor

What is currently needed now? It would be convenient to have this fixed

@ruevs
Copy link
Member

ruevs commented Aug 16, 2024

@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
Copy link
Contributor

@ruevs Thanks! I compared the proposed changes and your alternative seems to be working better. The patch proposed here has a kind of "jerk" motion when scrolling stops that I did not noticed earlier.
#1470 does not have this and scrolls as expected.

@ruevs
Copy link
Member

ruevs commented Aug 16, 2024

@polyfloyd interesting and slightly unexpected. What did you test on? X11, Wayland, touchpad with two finger drag, mouse with a scroll wheel?

@polyfloyd
Copy link
Contributor

polyfloyd commented Aug 16, 2024

Wayland, touchpad with two finger drag

@ruevs
Copy link
Member

ruevs commented Aug 17, 2024

Closing since I merged #1470.
@pontaoski if you find/think that this is better than #1470 for some reason please let us know.

@ruevs ruevs closed this Aug 17, 2024
ruevs added a commit to ruevs/solvespace that referenced this pull request Oct 7, 2024
devin-ai-integration bot pushed a commit to erkinalp/solvespace that referenced this pull request Apr 3, 2025
dennisyangji pushed a commit to Orthogonalpub/ode_solvespace that referenced this pull request Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants