Skip to content

Fix Compact View Mouse Scroll Direction Handling on Wayland #3636

@Kreevoz

Description

@Kreevoz

Distribution

Arch Linux 6.17.7-arch1-1, labwc composer, Wayland session

Package version

6.4.5

Frequency

Always

Bug description

On Wayland, Nemo does not convert vertical scroll events to horizontal scroll events in Compact View mode.

Steps to reproduce

Install Nemo on a Wayland desktop, switch to Compact View for a folder with a lot of files, and scroll the mousewheel.
Nothing happens. Shift has to be held for anything to happen.

Expected behavior

The scroll direction should be internally mapped to a horizontal scroll action just as it does when running on an X11 desktop, without having to hold Shift.

Additional information

The bug sits here:

nemo/src/nemo-icon-view.c

Lines 1840 to 1854 in 032ce13

/* transform vertical integer smooth scroll events into horizontal events */
if (scroll_event_copy->direction == GDK_SCROLL_SMOOTH &&
scroll_event_copy->delta_x == 0) {
if (scroll_event_copy->delta_y == 1.0) {
scroll_event_copy->direction = GDK_SCROLL_DOWN;
} else if (scroll_event_copy->delta_y == -1.0) {
scroll_event_copy->direction = GDK_SCROLL_UP;
}
}
if (scroll_event_copy->direction == GDK_SCROLL_UP) {
scroll_event_copy->direction = GDK_SCROLL_LEFT;
} else if (scroll_event_copy->direction == GDK_SCROLL_DOWN) {
scroll_event_copy->direction = GDK_SCROLL_RIGHT;
}

The code expects mouse scroll delta values of exactly -1.0 or exactly 1.0 .

Wayland delivers scroll events that don't meet those exact requirements (-15.0 and +15.0 for my mouse, due to the click angle of 15 (24 detents per 360 degree rotation) ) , so the check fails and the conversion never takes place.

Here is information about this: https://wayland.freedesktop.org/libinput/doc/latest/wheel-api.html
The recent addition of high-dpi mouse scroll wheels will further alter this behavior.

Modifying the code to not be pedantic about the actual value, but instead care about whether it is larger or smaller than 0, fixes this behavior and will futureproof it:

	        if (scroll_event_copy->direction == GDK_SCROLL_SMOOTH) {

	            if (scroll_event_copy->delta_y != 0) {
	                if (scroll_event_copy->delta_y > 0) {
	                    scroll_event_copy->direction = GDK_SCROLL_DOWN;
	                } else {
	                    scroll_event_copy->direction = GDK_SCROLL_UP;
	                }
	            } else if (scroll_event_copy->delta_x != 0) {
	                scroll_event_copy->direction = (scroll_event_copy->delta_x > 0) ?
	                                                GDK_SCROLL_RIGHT : GDK_SCROLL_LEFT;
	            }
	        }

This makes the vertical->horizontal mapping work reliably as intended on Wayland. Tested this and it works.

I do not have access to an X11 session to check that this code change retains the intended behavior under X11. From how I understand the problem, it very much should, though.

It would be great if ye could take a look and add that bugfix (or a better version of it) to Nemo because I really like compact view mode. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions