Bug 369131 - Closed application keeps its size when closed even if started on another screen
Summary: Closed application keeps its size when closed even if started on another screen
Status: RESOLVED WORKSFORME
Alias: None
Product: kwin
Classification: Plasma
Component: core (show other bugs)
Version: 5.7.5
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-21 02:15 UTC by dbacc
Modified: 2021-12-06 04:38 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch (1.32 KB, patch)
2016-10-02 21:18 UTC, dbacc
Details
xrandr -q (1.07 KB, text/plain)
2016-10-15 02:31 UTC, dbacc
Details
gdb debug output (1.89 KB, text/plain)
2016-10-15 02:36 UTC, dbacc
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dbacc 2016-09-21 02:15:49 UTC
If you open a window on a certain monitor and close it afterwards; the next time you start it it will keep its last known size.

However, if you have two monitors, and reopen the application on the other monitor which has a different resolution (height is smaller), then an application that was maximized before, will have it's titlebar hidden outside of range.

There is a workaround by using the 'Move' feature, but it is not nice.

Also, this behavior might occur, when changing the resolution between closing and reopening.

I suggest to implement a check, whether the window is indeed inside the current screen, and if not, move it inside, and then, resize, if necessary.
There should be at least an option to specify, whether you want this behavior for the 'total screen' or the current screen; monitors might have totally different dpi.

Reproducible: Always

Steps to Reproduce:
1. Open an application on the monitor with larger height
2. Maximize it and close it
3. Open the application on the other monitor

Actual Results:  
Title bar is out of range

Expected Results:  
Title bar is inside current monitor (better even whole window)
Comment 1 Thomas Lübking 2016-09-21 06:01:10 UTC
Please specify "the application" for KDE applications should restore geometry "per screen" anyway and the client may reconfigure itself to that position after mapping (ie. there're several ways to end within this position and one needs to know which in order to tackle it)

Relevant code is in manage.cpp and geometry.cpp
Comment 2 dbacc 2016-10-02 21:18:59 UTC
Created attachment 101380 [details]
Patch

It is basically happening with every application, but might be depending on the specific screen setup.

I have two monitors, where the height of monitor one is greater than height of monitor 2. In addition monitor 2 has a vertical offset and is positioned right of monitor 1. So the titlebar of an application with full height on monitor will disappear on monitor 2 if the window is just shifted horizontally.

The patch resolves this issue for me. However, I don't fully understand the purpose of the heuristic that is applied at that point, so it might screw thing up.
Comment 3 Martin Flöser 2016-10-04 08:06:56 UTC
yeah titlebar should never be outside the area. There is something fishy there.
Comment 4 Thomas Lübking 2016-10-13 15:34:44 UTC
What exactly happens on your side?
Do you enter the branch including "pseudo_max &= ~MaximizeVertical;"?
If yes, keepInArea should be called anyway. If not, the window should be vertically maximized.

Also debug out area around
"if (height() >= area.height())
    pseudo_max |=  MaximizeVertical;"

Could be the placement area is > the screenarea (because of borked struts)

And please dump "xrandr -q"
Comment 5 dbacc 2016-10-15 02:31:49 UTC
Created attachment 101567 [details]
xrandr -q
Comment 6 dbacc 2016-10-15 02:36:14 UTC
Created attachment 101568 [details]
gdb debug output
Comment 7 dbacc 2016-10-15 02:45:07 UTC
I attached the gdb output. So yes, I enter the branch pseudo_max &= ~MaximizeVertical;.

And yes, keepInArea is being called. But as I understand, this is not what actually should be called.

fsa describes the full xrandr rectangle screen area. However,  if you have two completely different screen sizes as in my case, there are lots of rectangle areas, that are not visible.

What is the purpose of keepInArea(fsa,...) here? What are use cases when it makes sense to span the window over the whole fsa?
Comment 8 Thomas Lübking 2016-10-15 06:58:11 UTC
> 1366x768+1920+432
                                ^^^^^
I suppose this to be the troublemaker.

The window asks to be bigger than your screen (no hackish attempt to be maximized) and your screen geometry can support this, so you don't need/want to shrink the window.

Try instead


diff --git a/manage.cpp b/manage.cpp
index 4198e60..3cbfb9e 100644
--- a/manage.cpp
+++ b/manage.cpp
@@ -433,14 +433,14 @@ bool Client::manage(xcb_window_t w, bool isMapped)
             // i intended a second check on cs < area.size() ("the managed client ("minus border") is smaller
             // than the workspace") but gtk / gimp seems to store it's size including the decoration,
             // thus a former maximized window wil become non-maximized
-            bool keepInFsArea = false;
+            bool keepInArea = false;
             if (width() < fsa.width() && (cs.width() > ss.width()+1)) {
                 pseudo_max &= ~MaximizeHorizontal;
-                keepInFsArea = true;
+                keepInArea = true;
             }
             if (height() < fsa.height() && (cs.height() > ss.height()+1)) {
                 pseudo_max &= ~MaximizeVertical;
-                keepInFsArea = true;
+                keepInArea = true;
             }
 
             if (pseudo_max != MaximizeRestore) {
@@ -457,8 +457,8 @@ bool Client::manage(xcb_window_t w, bool isMapped)
                     geom_restore.setWidth(width());
                 }
             }
-            if (keepInFsArea)
-                keepInArea(fsa, partial_keep_in_area);
+            if (keepInArea)
+                keepInArea(area, true);
         }
     }
Comment 9 dbacc 2016-10-15 22:46:36 UTC
Yes, this helps as well. Basically the same thing as my patch (in this case). But why not just replace keepInArea(fsa, partial_keep_in_area); with keepInArea(area, partial_keep_in_area); instead ?
Comment 10 Thomas Lübking 2016-10-16 06:20:28 UTC
If it's not partial, the window would be shrunk (for no reason)
Comment 11 kde.org 2021-11-06 17:45:43 UTC
This issue report is quite old. Can you please confirm, that it still persists with KDE 5.23?
Comment 12 Bug Janitor Service 2021-11-21 04:39:26 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 13 Bug Janitor Service 2021-12-06 04:38:48 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!