Bug 298646 - Mouse pointer moves to left border of window title when dragging away a maximized window (window was maximized to left- or right-half of screen by magic borders)
Summary: Mouse pointer moves to left border of window title when dragging away a maxim...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: core (show other bugs)
Version: 4.8.2
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: 4.8.4
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-23 09:20 UTC by Florian Dittmer
Modified: 2012-04-30 20:38 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 4.9
thomas.luebking: ReviewRequest+


Attachments
Patch for KDE 4.8.2 (contents of review request 104715) (1.06 KB, patch)
2012-04-25 05:42 UTC, Florian Dittmer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Dittmer 2012-04-23 09:20:33 UTC
Mouse pointer moves occassionaly to the left border of window caption when dragging away a maximized window which was previously maximized to the left- or right-half of the screen by magic border functions.




Reproducible: Sometimes

Steps to Reproduce:
1. Drag an application window to the left or right border to automatically maximize it to the left- or right-half of the screen (using the magic-borders functions)

2. Press mouse on the middle of window decoration (title bar) and drag it.
Actual Results:  
Window would be demiximized as expected, but _sometimes_ mouse pointer would hold the window by the left edge of the decoration. 



Expected Results:  
Mouse pointer should hold the window by its middle. 

If I remember correctly this behaviour first appeared in KDE 4.7.x and is still happening in KDE 4.8.2

The behaviour cannot be reproduced every time, but happens occassionally and is quiete annoying.

The behaviour of the mouse pointer described here is probably the same as described by Bug 233164.
Comment 1 Thomas Lübking 2012-04-23 10:20:28 UTC
depends on the position of the window: fix is known (but stashed in other commit)

diff --git a/kwin/geometry.cpp b/kwin/geometry.cpp
index b562195..c1c13e3 100644
--- a/kwin/geometry.cpp
+++ b/kwin/geometry.cpp
@@ -2230,8 +2230,8 @@ void Client::changeMaximize(bool vertical, bool horizontal, bool adjust)
         QSize adjSize = adjustedSize(clientArea.size(), SizemodeMax);
         QRect r = QRect(clientArea.topLeft(), adjSize);
         if (r.size() != clientArea.size()) { // to avoid off-by-one errors...
-            if (isElectricBorderMaximizing())
-                r.moveLeft(qMax(clientArea.x(), QCursor::pos().x() - r.width()/2));
+            if (isElectricBorderMaximizing() && r.width() < clientArea.width())
+                r.moveLeft(QCursor::pos().x() - r.width()/2);
             else
                 r.moveCenter(clientArea.center());
         }


-> will make RR for 4.8.3 tonight
Comment 2 Florian Dittmer 2012-04-23 19:04:26 UTC
Hi Thomas,

thank you for your response.

I tried out the patch (I only re-compiled kwin, or do I need to compile other packages from kde-workspace?), but it doesn't seem to help me with this issue.

For the good news, I found a way to reproduce this behaviour every time: It only happens when the program starts completly maximized to full screen (covering the whole desktop).

Steps to reproduce:

1. Start Konsole, Dolphin or other program.. 
2. Maximize the program's window to full screen.
3. Close the program
4. Start program again (it will remember maximized mode and start as such)
5. Click in the middle of the title bar and hold mouse button to drag the window. You will notice, that the mouse pointer jumps now to the left border while moving.

You can move the window now e.g. to the left electric border to automatically maximize in left-half of the screen. If you try to move it again to another location, the same effect with the mouse cursor will happen. 

This effect continues to happen while moving this specific window until it was once un-maximized. Afterwards the effect disappears for that specific window.

I hope this helps you. Thanks again. 
Florian
Comment 3 Thomas Lübking 2012-04-23 19:27:19 UTC
(In reply to comment #2)

> Steps to reproduce:
> 
> 1. Start Konsole, Dolphin or other program.. 
> 2. Maximize the program's window to full screen.
> 3. Close the program
> 4. Start program again (it will remember maximized mode and start as such)
> 5. Click in the middle of the title bar and hold mouse button to drag the
> window. You will notice, that the mouse pointer jumps now to the left border
> while moving.

- Then you actually saw sth. different - do you have "Display borders on maximized windows" enabled in "kcmshell4 kwinoptions" / "Moving" tab?
- I read that it's NOT related to Quick maximization (drag window to screen top to maximize it, "kcmshell4 kwinscreenedges")?
- Is this a multiscreen setup?

This is however at least not reproducible here (are you on git master or 4.8?)
Comment 4 Florian Dittmer 2012-04-23 19:51:01 UTC
Hi Thomas,

(In reply to comment #3)
> - Then you actually saw sth. different - do you have "Display borders on
> maximized windows" enabled in "kcmshell4 kwinoptions" / "Moving" tab?

No, this option is disabled.

> - I read that it's NOT related to Quick maximization (drag window to screen
> top to maximize it, "kcmshell4 kwinscreenedges")?

Well, it is related in a way, because if I disable the Quick maximization options, I am not able to drag the window with a single click-and-hold. 

But as I stated, the effect is related more to the fact that the program was initially started in maximized mode rathen then the Quick maximization.

> - Is this a multiscreen setup?

No.

> 
> This is however at least not reproducible here (are you on git master or
> 4.8?)

I use KDE4.8.2 from Gentoo.

I noticed the behaviour is slightly different if I enable the "Display borders on  maximized windows" option. In this case, also under the condition that the program was initially started with a fully maximized window, the mouse cursor does not jump to the left edge when i move the fully maximized window. But, if I move this fully maximized window to the left or right border to auto-maximize in the left-half or right-half of the screen, and then again try to move it away from there, the effect will happen again.
Comment 5 Thomas Lübking 2012-04-24 18:10:43 UTC
(In reply to comment #4)
> Hi Thomas,
You're replying to a bugtracker, there's not much need for formal stuff ;-)

> > do you have "Display borders on maximized windows" enabled
> No, this option is disabled.
> ..
> Well, it is related in a way, because if I disable the Quick maximization
> options, I am not able to drag the window with a single click-and-hold. 

You're actually not supposed to be able to drag windows out of maximization then at all (or to be more precise, the code doesn't support such - actually i always wanted to unify "regular" and "quick" maximization)

> fully maximized window. But, if I move this fully maximized window to the
> left or right border to auto-maximize in the left-half or right-half of the
> screen, and then again try to move it away from there, the effect will

Yes, i can reproduce (and fix ;-) that (without "show borders ...") - happens because there restore size is not initiated for maximized windows.

-> The window does NOT get resized to its minimum size with dragging out of maximization directly?
-> since that should not be possible in the first place: do you know whether and what patches gentoo applied to kwin?
Comment 6 Thomas Lübking 2012-04-24 18:41:25 UTC
Git commit 462bb665c79bc7699962ae7c578e99e848b0368b by Thomas Lübking.
Committed on 23/04/2012 at 12:13.
Pushed by luebking into branch 'master'.

fix quick unmaximization position
REVIEW: 104702

M  +2    -2    kwin/geometry.cpp

http://commits.kde.org/kde-workspace/462bb665c79bc7699962ae7c578e99e848b0368b
Comment 7 Florian Dittmer 2012-04-24 18:56:39 UTC
(In reply to comment #5)
> > 
> You're actually not supposed to be able to drag windows out of maximization
> then at all (or to be more precise, the code doesn't support such - actually
> i always wanted to unify "regular" and "quick" maximization)
> 

To be honest, I love this behaviour.  This is actually the reason why I did not activate the "show borders" option. In case you change it, I would really appreciate if there would be an option  to reactivate it ;-)

> 
> Yes, i can reproduce (and fix ;-) that (without "show borders ...") -
> happens because there restore size is not initiated for maximized windows.

Sounds good, thanks. While writing this comment, I noticed you did a submit. I will try that out afterwards..

> 
> -> The window does NOT get resized to its minimum size with dragging out of
> maximization directly?

The window gets resized to its previous size (the size it had before maximizing it) while dragging out of the maximization. I think there is nothing wrong with this behaviour. Only problem is the mouse cursor.

> -> since that should not be possible in the first place: do you know whether
> and what patches gentoo applied to kwin?

When I compile KWIN, the two patches from this directory are applied:
http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/kde-base/kwin/files/

To demonstrate the behaviour and to avoid misunderstandings, I posted a video in youtube:

http://www.youtube.com/watch?v=7aGDd507CpI
Comment 8 Florian Dittmer 2012-04-24 19:25:11 UTC
(In reply to comment #6)
> Git commit 462bb665c79bc7699962ae7c578e99e848b0368b by Thomas Lübking.
> Committed on 23/04/2012 at 12:13.
> Pushed by luebking into branch 'master'.

(In reply to comment #7)
> Sounds good, thanks. While writing this comment, I noticed you did a submit.
> I will try that out afterwards..

Sorry, my mistake. I thought your commit it is a new patch. I cannot notice any difference with this patch applied.
Comment 9 Thomas Lübking 2012-04-24 19:31:27 UTC
(In reply to comment #7)

> To be honest, I love this behaviour.  This is actually the reason why I did
> not activate the "show borders" option. In case you change it, I would
> really appreciate if there would be an option  to reactivate it ;-)
Iff we change things, we'd change it to work this way regularly (as mentioned, right NOW it should not be possible, but only if the window was dragged there to be maximized, not when started this way)

> Sounds good, thanks. While writing this comment, I noticed you did a submit.
That's the first (and still correct) patch.
New patch is here https://git.reviewboard.kde.org/r/104715/ but does not apply to 4.8 (or at least not affect it)

> When I compile KWIN, the two patches from this directory are applied:
Thanks - irrelevant build logic stuff.

> http://www.youtube.com/watch?v=7aGDd507CpI
Many thanks, the window gets unmaximized and then untiled - i'll have to check the actual 4.8 behavior on this (could be affected by several git master and even local only changes) but checking the 4.8 code it doesn't seem intended.
Comment 10 Florian Dittmer 2012-04-24 20:28:05 UTC
(In reply to comment #9)
> New patch is here https://git.reviewboard.kde.org/r/104715/ but does not
> apply to 4.8 (or at least not affect it)

Just want to let you know that I patched my 4.8.2's geometry.cpp with the new patch (just added your two lines of code) and now the problem is partly fixed:
1. max'd closed
2. opened
3. dragging from fullscreen to screen edge - cursor problem still exists 
4. dragging from screen edge to somewhere else - cursor problem is now fixed in this situation with new patch

Thank you so far.
Comment 11 Thomas Lübking 2012-04-24 21:03:08 UTC
ok, actually what you describe works with vanilla git master - so it's one of the local patches (and i've an idea which) and i also can reproduce the issue.
Comment 12 Thomas Lübking 2012-04-24 21:35:27 UTC
.. and i can still fix what i can see ;-)
see updated new patch, no guarantee for 4.8(.3) though
Comment 13 Florian Dittmer 2012-04-25 05:42:41 UTC
Created attachment 70639 [details]
Patch for KDE 4.8.2 (contents of review request 104715)

I can confirm that the new patch provided with review request 104715 can be applied to KDE 4.8.2 sources and fixes the problem of this bug report. The test case described in comment #10 now passes completly and leads to the expected results.
I didn't notice any side effects. If the  "window borders" option is enabled, the bug as described in comment #4, is fixed as well.
Thank you very much for your support.
Comment 14 Thomas Lübking 2012-04-30 20:38:10 UTC
Git commit e1854596d6703462d0c2b4643ccddaa95bcbc4f9 by Thomas Lübking.
Committed on 24/04/2012 at 20:17.
Pushed by luebking into branch 'master'.

sanitize geom_restore if the window gets quickly untiled after initially being maximized
REVIEW: 104715
FIXED-IN: 4.9

M  +3    -0    kwin/geometry.cpp

http://commits.kde.org/kde-workspace/e1854596d6703462d0c2b4643ccddaa95bcbc4f9