Bug 449105 - Dragging a window that was opened maximized moves the mouse cursor to the top left corner of the window
Summary: Dragging a window that was opened maximized moves the mouse cursor to the top...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 5.23.90
Platform: Other Linux
: NOR minor
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 453447 457601 462262 470838 471342 471884 473084 475871 478197 478886 480585 482465 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-01-24 22:01 UTC by indecisiveautomator
Modified: 2024-04-26 17:18 UTC (History)
29 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.1


Attachments
reproducer (243 bytes, text/x-python)
2022-10-10 03:19 UTC, hexchain
Details
dragging window (3.43 MB, video/mp4)
2023-06-10 18:27 UTC, Ondřej Niesner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description indecisiveautomator 2022-01-24 22:01:01 UTC
SUMMARY
In the Plasma 5.24 beta, when dragging a window's titlebar to "unsnap" it and make it windowed, the mouse cursor seems to pretty much always move to the top left corner instead of trying to keep a sensible cursor position relative to the new window size. This does not seem to affect Xwayland applications such as Steam or Chromium running without Wayland Ozone, only Wayland applications both GTK and Qt.

Tested Firefox with Wayland enabled, Dolphin, Konsole and System Settings.


STEPS TO REPRODUCE
1. Maximise a native Wayland application, such as System Settings
2. Drag the window down from the top of the screen to make it windowed
3. Mouse cursor will move to the top left corner and window position will be offset.


OBSERVED RESULT
Mouse cursor position almost always moves to the top left corner when "unsnapping" a window, the only reliable exception being some Xwayland applications I have tested. However, there are instances where this simply doesn't happen with native Wayland applications. It happened once when Konsole when testing for this report. I had two Konsole windows open, one produced the incorrect behaviour and one worked correctly. When opening several new Konsole windows after this, all of them exhibited the buggy behaviour. This is the only instance where a native Wayland application has had this problem.


EXPECTED RESULT
Dragging maximised windows from the top should place the mouse cursor in a more sane position, which was the behaviour in the latest stable Plasma 5.23.5.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 5.16.2-arch1-1
KDE Plasma Version: 5.23.90
KDE Frameworks Version: 5.90
Qt Version: 5.15.2

ADDITIONAL INFORMATION
- Have not tested X11
- Affects both my multi-monitor PC setup and my single-display laptop
Comment 1 Nate Graham 2022-01-24 23:06:12 UTC
Cannot reproduce with a single screen.
Comment 2 Vlad Zahorodnii 2022-01-25 07:36:22 UTC
Fixed in 5.24
Comment 3 deresiant 2022-04-24 06:20:28 UTC
I'm still having a problem with this on plasma 5.24.4. It happens to me consistently on Dolphin but only if the window is opened in maximised form:

1. Open plasma wayland session
2. Open Dolphin file manager (for example)
3. Maximise Dolphin
4. Close Dolphin
5. Open Dolphin again
6. Try to move the window by dragging.
Comment 4 Nate Graham 2022-04-25 15:27:22 UTC
Ah, I can reproduce the issue with those exact steps too.
Comment 5 Nate Graham 2022-05-06 15:20:48 UTC
*** Bug 453447 has been marked as a duplicate of this bug. ***
Comment 6 indecisiveautomator 2022-05-20 02:49:25 UTC
Still applies to windows that open maximised in 5.24.90
Comment 7 Nate Graham 2022-08-08 17:40:44 UTC
*** Bug 457601 has been marked as a duplicate of this bug. ***
Comment 8 indecisiveautomator 2022-09-15 22:11:55 UTC
Can't reproduce in 5.26 Beta.
Comment 9 Nate Graham 2022-09-15 22:25:07 UTC
Me neither, looks like it's fixed now, hooray!
Comment 10 ghoste 2022-09-24 01:29:00 UTC
(In reply to Nate Graham from comment #9)
> Me neither, looks like it's fixed now, hooray!
Oddly, I can still easily reproduce it. Tried the latest Neon Unstable and Testing builds in a VM as well as the latest Manjaro Plasma daily build in live boot (as it includes the proprietary NVIDIA driver OOB), same result in all of them. Took the exact same steps as listed in comment 3.
Comment 11 hexchain 2022-10-10 03:19:50 UTC
Created attachment 152678 [details]
reproducer

I still see this issue with this reproducer script in 5.25.90 on Arch.

kwin 5.25.90-1
qt5-base 5.15.6+kde+r177-1
qt5-wayland 5.15.6+kde+r50-1
Comment 12 Nate Graham 2022-10-11 16:27:09 UTC
Interesting. I can reproduce it with that script too (after changing it to use PyQt5). Thanks!
Comment 13 serfreeman1337 2022-11-26 11:20:38 UTC
*** Bug 462262 has been marked as a duplicate of this bug. ***
Comment 14 Alessandro Astone 2023-02-18 23:37:10 UTC
After living a long time with this bug assuming it'd eventually be fixed I finally decided to take look it up on the bug tracker... and to my surprise it does not have a lot of attention?
It's been happening forever on all my machines, where display scaling, gtk vs qt, multiple monitors vs single monitor, all don't matter. I can assume everyone is affected.
Super annoying. I would argue this a 15-minute bug.
Comment 15 ghoste 2023-02-19 00:22:12 UTC
(In reply to Alessandro Astone from comment #14)
> After living a long time with this bug assuming it'd eventually be fixed I
> finally decided to take look it up on the bug tracker... and to my surprise
> it does not have a lot of attention?
> It's been happening forever on all my machines, where display scaling, gtk
> vs qt, multiple monitors vs single monitor, all don't matter. I can assume
> everyone is affected.
> Super annoying. I would argue this a 15-minute bug.

I'm running 5.27 and it's still an issue. It's not functionality breaking but you do notice it quickly and it's quite annoying. I'm seeing it right now when opening new Firefox windows. It's happened on every system I've tried including Intel, AMD, NVIDIA Graphics, Virtualbox too.
Comment 16 xbb 2023-05-03 11:49:48 UTC
I can reproduce it easily on any Wayland application in Plasma 5.27.4

As reported by another user above, it happens only when dragging a new window that opens maximized (also with meta+left click drag from any position inside the window, not just from the titlebar)

Can confirm also that XWayland applications are unaffected

Only workaround is to not use drag to unsnap the window

Tested single/multi-screen, no maximize animations, NVIDIA/Intel

My steps to reproduce it:

1. Open Konsole
2. Maximize Konsole (no need to close it)
3. Open new Konsole window
4. Drag to unsnap the window
Comment 17 miranda 2023-05-20 20:58:23 UTC
(In reply to Alessandro Astone from comment #14)
> After living a long time with this bug assuming it'd eventually be fixed I
> finally decided to take look it up on the bug tracker... and to my surprise
> it does not have a lot of attention?

I'm similarly surprised. I'm constantly opening new windows and moving them around to other monitors. Those windows are almost always maximized. As a result there's this weird dance I have to do with the mouse each time. How so few are reporting this is kinda wild.

Do KDE users (and KDE maintainers in particular) not use large or multimonitor setups? Or just not have many open maximized windows?

I could see someone exclusively alt-tabbing and/or switching virtual desktops if you almost always rock a single moderate screen, like on a laptop. I'm curious what the statistics would look like for user screen arrangement data, that is if there was any sort of opt-in metrics collecting.
Comment 18 Nate Graham 2023-05-22 17:47:28 UTC
Since the issue only happens when dragging specific windows that were opened in specific circumstances from their titlebars, we can assume that many people don't do exactly those things.

Personally I maximize and de-maximize windows all the time but I do it via the keyboard, not the mouse.

We do in fact have telemetry for screen usage and though I can't give exact numbers because the data isn't public, I can tell you that the percentage of users of multi-screen setups and large screens is indeed fairly low. Not "single digits" low, but low nonetheless.
Comment 19 ghoste 2023-05-23 02:23:37 UTC
(In reply to miranda from comment #17)
> (In reply to Alessandro Astone from comment #14)
> Do KDE users (and KDE maintainers in particular) not use large or
> multimonitor setups? Or just not have many open maximized windows?

FWIW, whether one uses a large screen or a multi-monitor setup is irrelevant for this bug. It happens on any number of screens and any size/resolution of display(s). Just tested the latest Neon user edition in a VM with it's default screen setup of 1 display at 1024x768 and it occurs there.

(In reply to Nate Graham from comment #18)
> Since the issue only happens when dragging specific windows that were opened
> in specific circumstances from their titlebars, we can assume that many
> people don't do exactly those things.
> 
> Personally I maximize and de-maximize windows all the time but I do it via
> the keyboard, not the mouse.

I don't believe it requires as complex circumstances as you may be suggesting. All it takes to trigger it is a window opening in maximized state, that's it. If you try moving the window with your mouse after that, you'll see the bug and will continue to every time without fail until the application is re-opened in a de-maximized state. If a window is opened in a de-maximized state, then maximized and moved with the mouse, the bug does not trigger.

If one is using keybinds to move windows around, they won't experience this bug of course. However, I'd think it's a (poweruser) minority of users who are doing that compared to those who are using the mouse. 

While relatively minor, I'd argue this should be on the 15-minute bug list with as little as it takes to trigger it, for how often and basic the action of moving a window is, and for how annoying it can become in rather short time.
Comment 20 Patrick Silva 2023-06-09 18:35:19 UTC
*** Bug 470838 has been marked as a duplicate of this bug. ***
Comment 21 Ondřej Niesner 2023-06-10 18:25:09 UTC
Same was also happening on GNOME. It doesn't matter how many screens you have. I have this issue on my laptop which has just one builtin display. This is really annoying bug especially with touchpad when you always need to grab the window from wrong position. Also the window is totally messing it's position when you try to resize it. 

In mutter it was fixed https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2942?commit_id=7eb01304259b5977feaee3b2d0a2073b70312d89

Is it possible to use in in kwin?
Comment 22 Ondřej Niesner 2023-06-10 18:27:53 UTC
Created attachment 159586 [details]
dragging window
Comment 23 Henry 2023-06-15 13:06:32 UTC
(In reply to Ondřej Niesner from comment #21)
> Same was also happening on GNOME. It doesn't matter how many screens you
> have. I have this issue on my laptop which has just one builtin display.
> This is really annoying bug especially with touchpad when you always need to
> grab the window from wrong position. Also the window is totally messing it's
> position when you try to resize it. 
> 
> In mutter it was fixed
> https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/
> 2942?commit_id=7eb01304259b5977feaee3b2d0a2073b70312d89
> 
> Is it possible to use in in kwin?

Hello,

I also have this problem.

Maybe an easier approach is to check in `void Window::startDelayedInteractiveMoveResize()` to determine if the window was maximized (and then doing the anchor coordinates) similar to how it is done in `bool Window::startInteractiveMoveResize()` in `window.cpp`.

It is my first time posting, please correct me if I did anything wrong
Comment 24 Patrick Silva 2023-06-23 07:59:33 UTC
*** Bug 471342 has been marked as a duplicate of this bug. ***
Comment 25 Bug Janitor Service 2023-08-06 16:50:25 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/4302
Comment 26 Nate Graham 2023-08-07 21:47:57 UTC
*** Bug 473084 has been marked as a duplicate of this bug. ***
Comment 27 Nate Graham 2023-09-13 18:49:12 UTC
*** Bug 471884 has been marked as a duplicate of this bug. ***
Comment 28 Nate Graham 2023-10-20 16:47:42 UTC
*** Bug 475871 has been marked as a duplicate of this bug. ***
Comment 29 Nate Graham 2023-12-07 22:45:26 UTC
*** Bug 478197 has been marked as a duplicate of this bug. ***
Comment 30 Zamundaaa 2023-12-25 21:35:40 UTC
*** Bug 478886 has been marked as a duplicate of this bug. ***
Comment 31 Zamundaaa 2023-12-27 19:43:22 UTC
*** Bug 478886 has been marked as a duplicate of this bug. ***
Comment 32 Sollace 2023-12-27 20:16:15 UTC
Hello!

I previously reported a bug that was similar to this that was merged as a duplicate. After reading through the comments, I feel I should add a few of my observations that don't seem to be reflected here:

1. The issue appears to occur on any window that is opened in the maximised state **BUT is resolved by clicking "restore down" and clicking "maximise"**

2. Whilst the bug is in effect, dragging the window by the title bar moves the cursor to the top left and offsets the window, as documented
3. After dragging the window, if you release the mouse and attempt to resize the window by dragging the top-left corner or left/top edges will cause the window to jump to the opposite side of the cursor. [screenshot attached]


I've found that the bug is also prevented if you drag either the bottom or right edges of the window.
Comment 33 Sollace 2023-12-27 20:20:06 UTC
(In reply to Sollace from comment #32)
> Hello!
> 
> I previously reported a bug that was similar to this that was merged as a
> duplicate. After reading through the comments, I feel I should add a few of
> my observations that don't seem to be reflected here:
> 
> 1. The issue appears to occur on any window that is opened in the maximised
> state **BUT is resolved by clicking "restore down" and clicking "maximise"**
> 
> 2. Whilst the bug is in effect, dragging the window by the title bar moves
> the cursor to the top left and offsets the window, as documented
> 3. After dragging the window, if you release the mouse and attempt to resize
> the window by dragging the top-left corner or left/top edges will cause the
> window to jump to the opposite side of the cursor. [screenshot attached]
> 
> 
> I've found that the bug is also prevented if you drag either the bottom or
> right edges of the window.

Addendum: switching focus to another window ALSO appears to resolve the bug.
Comment 34 Patrick Silva 2024-01-31 09:23:27 UTC
*** Bug 480585 has been marked as a duplicate of this bug. ***
Comment 35 Vlad Zahorodnii 2024-03-05 13:26:42 UTC
*** Bug 482465 has been marked as a duplicate of this bug. ***
Comment 36 Bug Janitor Service 2024-03-09 11:42:57 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/5399
Comment 37 Bug Janitor Service 2024-03-10 11:53:09 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/5404
Comment 38 Vlad Zahorodnii 2024-03-11 20:25:41 UTC
Git commit 2c7301b3eea93e345c36cd89a72e41ec5d421861 by Vlad Zahorodnii.
Committed on 11/03/2024 at 20:16.
Pushed by vladz into branch 'master'.

Make Window::interactiveMoveOffset() relative

Window::interactiveMoveOffset() stores the move offset in pixels, but it
is somewhat annoying to deal with when the window size changes, for example
when the window is unmaximized.

This change makes Window::interactiveMoveOffset() store a ratio where
the move offset can be found. This simplifies the code a bit and fixes
the cursor jumping to the topleft window corner. Although there are other
glitches.

M  +1    -2    src/events.cpp
M  +14   -23   src/window.cpp
M  +0    -9    src/window.h
M  +1    -2    src/xdgshellwindow.cpp

https://invent.kde.org/plasma/kwin/-/commit/2c7301b3eea93e345c36cd89a72e41ec5d421861
Comment 39 Sollace 2024-03-11 22:33:52 UTC
(In reply to Vlad Zahorodnii from comment #38)
> Git commit 2c7301b3eea93e345c36cd89a72e41ec5d421861 by Vlad Zahorodnii.
> Committed on 11/03/2024 at 20:16.
> Pushed by vladz into branch 'master'.
> 
> Make Window::interactiveMoveOffset() relative
> 
> Window::interactiveMoveOffset() stores the move offset in pixels, but it
> is somewhat annoying to deal with when the window size changes, for example
> when the window is unmaximized.
> 
> This change makes Window::interactiveMoveOffset() store a ratio where
> the move offset can be found. This simplifies the code a bit and fixes
> the cursor jumping to the topleft window corner. Although there are other
> glitches.
> 
> M  +1    -2    src/events.cpp
> M  +14   -23   src/window.cpp
> M  +0    -9    src/window.h
> M  +1    -2    src/xdgshellwindow.cpp
> 
> https://invent.kde.org/plasma/kwin/-/commit/
> 2c7301b3eea93e345c36cd89a72e41ec5d421861

I want to confim: this issue isn't only about the cursor jumping to the top-left, right? It is also that the entire window gets displaced to the far top-left past the cursor when attempting to resize it by dragging either the top or left edge or corner handles.
Comment 40 Vlad Zahorodnii 2024-03-14 11:30:22 UTC
(In reply to Sollace from comment #39)
> I want to confim: this issue isn't only about the cursor jumping to the
> top-left, right? It is also that the entire window gets displaced to the far
> top-left past the cursor when attempting to resize it by dragging either the
> top or left edge or corner handles.

this bug report is about the issue described in https://bugs.kde.org/show_bug.cgi?id=449105#c0

if there are other issues, file separate bug reports
Comment 41 Sollace 2024-03-14 12:12:09 UTC
(In reply to Vlad Zahorodnii from comment #40)
> (In reply to Sollace from comment #39)
> > I want to confim: this issue isn't only about the cursor jumping to the
> > top-left, right? It is also that the entire window gets displaced to the far
> > top-left past the cursor when attempting to resize it by dragging either the
> > top or left edge or corner handles.
> 
> this bug report is about the issue described in
> https://bugs.kde.org/show_bug.cgi?id=449105#c0
> 
> if there are other issues, file separate bug reports

I did, however my report was marked as a duplicate of this one.
Comment 42 Nate Graham 2024-03-14 17:14:05 UTC
Feel free to unmark it as a duplicate if you feel it reports something different.
Comment 43 Vlad Zahorodnii 2024-03-15 18:11:15 UTC
Git commit 11a5513e789e2bd9a99f19d2b8477ca4700ab46d by Vlad Zahorodnii.
Committed on 15/03/2024 at 18:00.
Pushed by vladz into branch 'master'.

Avoid moving the window while it's maximized

Unlike X11, on Wayland, the window won't change its maximize mode until
it renders a new buffer. This creates a problem for interactive move
because if it's not careful and moves the window while it's still effectively
maximized, it will look as if the window has leaked to other screens.

This change fixes the problem by making Window::handleInteractiveMoveResize()
avoid move() if the window needs to be unmaximized.

As a bonus, it also allows to unmaximize the windows that are maximized
along only one dimension by dragging them.

Unfortunately, tiling stuff still suffers from the same issue. In order
to fix it, Window::tile() has to be part of double buffered state, like
Window::maximizeMode().
Related: bug 459218, bug 482085

M  +1    -0    autotests/integration/kwin_wayland_test.h
M  +18   -0    autotests/integration/test_helpers.cpp
M  +312  -0    autotests/integration/xdgshellwindow_test.cpp
M  +28   -13   src/window.cpp
M  +9    -0    src/x11window.cpp
M  +11   -0    src/xdgshellwindow.cpp

https://invent.kde.org/plasma/kwin/-/commit/11a5513e789e2bd9a99f19d2b8477ca4700ab46d
Comment 44 Simone 2024-03-27 10:03:44 UTC
was the fix merged for 6.0.3?
Comment 45 Vlad Zahorodnii 2024-03-27 12:21:24 UTC
No. 6.1
Comment 46 Nate Graham 2024-04-26 17:18:10 UTC
*** Bug 475871 has been marked as a duplicate of this bug. ***