Bug 478560 - Can't move the pointer pixel-by-pixel on Wayland
Summary: Can't move the pointer pixel-by-pixel on Wayland
Status: RESOLVED INTENTIONAL
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (other bugs)
Version First Reported In: master
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: qt6
Depends on:
Blocks:
 
Reported: 2023-12-15 15:12 UTC by Noah Davis
Modified: 2024-01-12 11:25 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
KRuler on 2x scale screen (2 monitors, 1x and 2x) with issue (63.07 KB, video/webm)
2024-01-10 20:34 UTC, Noah Davis
Details
same, but with even slower movement (48.42 KB, video/webm)
2024-01-10 21:22 UTC, Noah Davis
Details
fractional positions in gammaray (392.69 KB, image/png)
2024-01-12 08:40 UTC, David Redondo
Details
Noah's lack of fractional positions in GammaRay (549.74 KB, image/png)
2024-01-12 11:18 UTC, Noah Davis
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Noah Davis 2023-12-15 15:12:34 UTC
SUMMARY
Unlike X11, it's impossible to move the mouse pixel-by-pixel with a screen scale greater than 100%.

STEPS TO REPRODUCE
1. Using system settings, set a screen's UI scale to 200% on Wayland
2. run `spectacle -r`
3. Try to make a selection and move the mouse pixel-by-pixel on the 200% scale screen.

OBSERVED RESULT
The mouse moves by 2 real pixels at a time.

EXPECTED RESULT
The mouse should move only one real pixel at a time.

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20231212
KDE Plasma Version: 5.90.90
KDE Frameworks Version: 5.247.0
Qt Version: 6.6.1
Kernel Version: 6.6.6-1-default (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 4800H with Radeon Graphics
Memory: 30.8 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Manufacturer: Eluktronics
Product Name: THINN-15
Comment 1 Nate Graham 2023-12-20 22:41:18 UTC
This appears to work for me with today's git master: Shift+arrow keys move the box by single pixels, not by two pixels.
Comment 2 Noah Davis 2023-12-20 22:50:00 UTC
(In reply to Nate Graham from comment #1)
> This appears to work for me with today's git master: Shift+arrow keys move
> the box by single pixels, not by two pixels.

Use the mouse, not arrow keys.
Comment 3 Nate Graham 2024-01-09 22:23:52 UTC
I don't understand what you mean, sorry. Mice are physical devices that don't move by pixels. Do you mean the on-screen pointer? If so, as far as I can tell, I can move the pointer by individual pixels on Wayland with 200% scale.
Comment 4 Noah Davis 2024-01-10 03:36:20 UTC
Yes, I mean the mouse cursor. If you want to test the behavior with a different app, try KRuler.

I should also mention that I have a two monitor setup with 1x scale and 2x scale screens.
Comment 5 Noah Davis 2024-01-10 03:38:27 UTC
"Spectacle" is probably the wrong product for this bug report. This seems like a more general wayland issue, but I initially filed it here because it was a problem for Spectacle.
Comment 6 Nate Graham 2024-01-10 20:20:42 UTC
Unless I'm completely blind or misunderstanding the issue, I can't reproduce the inability to move the pointer by physical pixels (rather than logical pixels) on my 200% scale screen, either along or when plugged into an external 1080p screen set to 100% scale.
Comment 7 Noah Davis 2024-01-10 20:34:02 UTC
Created attachment 164797 [details]
KRuler on 2x scale screen (2 monitors, 1x and 2x) with issue

Maybe this will help you see?
Comment 8 Nate Graham 2024-01-10 21:00:07 UTC
From what I can tell, that's a KRuler bug. When I move my pointer along the ruler as indicated in your screenshot, I do indeed see that the *label* and the red line change by 2px increments, but the pointer appears to be able to move to individual pixel positions finer than what the label and red line show. Because the label and the red line are limited to logical pixels rather than physical pixels, I'm capable of moving the pointer to positions that do not cause the label and the red line to update. I have to move the pointer really really slowly and precisely to see it and shove my face right up against the screen, but I do see it?

Can you confirm that?
Comment 9 Noah Davis 2024-01-10 21:22:08 UTC
Created attachment 164799 [details]
same, but with even slower movement
Comment 10 Noah Davis 2024-01-10 21:27:37 UTC
It's not a KRuler bug. My mouse cursor and the positions Qt is able to detect really are skipping 2 physical pixels a time, so you can't fix the issue in KRuler or Spectacle. Qt's mouse positions are scaled to the device pixel ratio (e.g., the bottom right corner of a 4K@2x screen is considered 1920,1080), but Qt supports fractional mouse positions on X11 when the UI scale is set to 2x.
Comment 11 Nate Graham 2024-01-10 21:29:00 UTC
That is strange, I'm seeing something different.

Anyway, clearly this isn't a Spectacle issue so I'm going to move it to KWin.
Comment 12 Vlad Zahorodnii 2024-01-11 10:40:39 UTC
Mouse moves in the logical pixels. So it's intentional.

If mouse moves in the device pixels, its speed would be affected by the scale factor. For example, if you use x2 scale factor, the UI is going to be enlarged twice, but the pointer speed will be reduced twice, in other words you would need to move the mouse a lot more on such a scaled output. One way to compensate for that would be to increase the pointer speed in system settings, but then it's going to make the pointer too fast on x1 outputs.
Comment 13 Vlad Zahorodnii 2024-01-11 10:46:35 UTC
Also, FTR kwin sends motion events with fractional parts (in logical pixels), so if you have a monitor with x2 scale factor, and receive a motion event with 1.5 delta, then it means that the pointer moved 3 px in device pixels. Make sure that spectacle doesn't round anything on its side. If you've confirmed that spectacle receives motion events without fractional part, then it's probably a qtwayland bug.
Comment 14 Vlad Zahorodnii 2024-01-11 10:48:50 UTC
Also also, I checked that kwin sends motion events with fractional parts on my machine both with a regular mouse and a touchpad
Comment 15 Noah Davis 2024-01-11 21:07:34 UTC
(In reply to Vlad Zahorodnii from comment #12)
> One way to compensate for that would be to increase the pointer speed in system settings, but then it's going to make the pointer too fast on x1 outputs.

Could the mouse speed be scaled by the scale factor only on the scaled screens?

(In reply to Vlad Zahorodnii from comment #13)
> If you've confirmed that spectacle receives motion events without fractional part, then it's probably a qtwayland bug.

Yes, I have confirmed that. I'm even using the new Qt 6 QEvent based APIs that give QPointFs, but still don't get a fractional part. I suppose I'll have to file a bug with Qt Wayland.
Comment 16 David Redondo 2024-01-12 08:40:09 UTC
Created attachment 164838 [details]
fractional positions in gammaray
Comment 17 Vlad Zahorodnii 2024-01-12 10:04:48 UTC
> Could the mouse speed be scaled by the scale factor only on the scaled screens?

It could, but it would make input dispatching code more complex.
Comment 18 David Redondo 2024-01-12 10:20:04 UTC
QtWayland forwards fractional mouse events, see my screenshot and I also confirmed via qDebug() in spectacle
Comment 19 Noah Davis 2024-01-12 11:18:47 UTC
Created attachment 164839 [details]
Noah's lack of fractional positions in GammaRay

(In reply to David Redondo from comment #18)
> QtWayland forwards fractional mouse events, see my screenshot and I also
> confirmed via qDebug() in spectacle

I don't get fractional positions in GammaRay or qDebug (already checked qDebug before posting this report).

I tried unplugging my 2nd screen and setting my main screen to 2x and setting both monitors to 2x. Neither change made a difference.

 Clearly I still have a bug, but we don't know where it comes from. Can we reopen this and move it somewhere out of KWin (if necessary) so that it can be tracked until we find the real source of the problem? I don't think we can consider this intentional behavior if the other people here don't have this problem. I could do it myself, but I'm not sure where the bug should go.
Comment 20 Noah Davis 2024-01-12 11:25:33 UTC
Actually, could it be the mouse driver that's sending non-fractional positions? I'm using libinput for all connected pointing devices, but I just noticed that I can move pixel-by-pixel when I use my touchpad. I've been using my Logitech MX Master 3 this whole time and I can't move that pixel-by-pixel.