Bug 434116 - De-maximizing a window that was maximized on launch positions it according to the placement mode even if the window wants to position itself
Summary: De-maximizing a window that was maximized on launch positions it according to...
Status: CONFIRMED
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: 5.21.4
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 435666 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-03-07 16:24 UTC by Nate Graham
Modified: 2023-12-13 08:10 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nate Graham 2021-03-07 16:24:57 UTC
STEPS TO REPRODUCE
1. Open Dolphin (app doesn't matter; any KXMLGui-using app that calls kwindowconfig::restoreWindowPosition() will do)
2. Move it to a distinctive place on screen
3. Maximize the window
4. Quit Dolphin
5. Re-open Dolphin
6. De-maximize Dolphin


EXPECTED RESULT
Dolphin is un-maximized to the position it was moved to in step 2.


ACTUAL RESULT
Dolphin is un-maximized to a position chosen by the current window placement mode.


ADDITIONAL INFORMATION
If you omit steps 4 and 5 (i.e you un-maximize it right after maximizing it), the bug is not seen.
Comment 1 Nate Graham 2021-04-12 19:45:40 UTC
*** Bug 435666 has been marked as a duplicate of this bug. ***
Comment 2 Nate Graham 2021-05-05 03:59:33 UTC
Looks like this is a two-part bug:

1. When the window is maximized, we write new position data to the config file even though this doesn't make sense (maximization and position on screen are mutually exclusive concepts). When a window is maximized, we should write to the config file only the fact that the window is maximized and not write out any new position data.

2. When KWin maximizes a window, it remembers the window's prior position internally but only while the window's app is open. If a window is closed while maximized, KWin forgets where the window was last located if that window is re-opened and de-maximized. It needs to be taught how to ask the app to position itself or read the config file itself in this case.
Comment 3 Nate Graham 2021-05-05 04:01:24 UTC
Git commit f5f12926b1ead2f36b2f7e8fc34ff864b5b6d60e by Nate Graham.
Committed on 05/05/2021 at 03:59.
Pushed by ngraham into branch 'master'.

Don't write position data for maximized windows

A window that is maximized does not really have a position on screen
other then the fact that it's maximized, and writing out position data
in this case anyway will only serve to mis-position the window once
da-maximized, should KWin ever stop remembering de-maximized window
positions internally.

M  +6    -0    src/gui/kwindowconfig.cpp

https://invent.kde.org/frameworks/kconfig/commit/f5f12926b1ead2f36b2f7e8fc34ff864b5b6d60e
Comment 4 Nate Graham 2021-05-05 04:01:51 UTC
That fixes part 1; now we need a KWin change for part 2.
Comment 5 Nate Graham 2021-05-05 04:05:44 UTC
Moving to KWin now.
Comment 6 Nate Graham 2021-05-05 04:18:25 UTC
So basically the bug is that when a window is opened in a maximized state, de-maximizing it unconditionally positions it according to the active placement mode rather than first asking the window if it wants to position itself (which is what correctly happens for windows that are not opened in a maximized state).