Bug 409919 - [Wayland] KDE application don't remember maximization state after closing and re-opening
Summary: [Wayland] KDE application don't remember maximization state after closing and...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: platform-wayland-nested (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: wayland
: 409516 410061 419471 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-07-17 21:43 UTC by Marc-Antoine M.
Modified: 2020-11-10 12:13 UTC (History)
13 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.20.1


Attachments
Screenshot 1 (363.17 KB, image/png)
2019-07-20 07:22 UTC, Yogesh Marwaha
Details
Screenshot 2 (192.65 KB, image/png)
2019-07-20 07:22 UTC, Yogesh Marwaha
Details
Screenshot 3 (198.76 KB, image/png)
2019-07-20 07:23 UTC, Yogesh Marwaha
Details
Screenshot of the problem (3.18 MB, image/png)
2020-10-22 13:42 UTC, Claudius Ellsel
Details
wayland debug output of dolphin with Claudius Ellsel's screen layout (49.77 KB, text/plain)
2020-10-22 14:32 UTC, Vlad Zahorodnii
Details
with my screen layout, dolphin sends set_maximized() requests (26.24 KB, image/png)
2020-10-22 14:34 UTC, Vlad Zahorodnii
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marc-Antoine M. 2019-07-17 21:43:32 UTC
SUMMARY
KDE application like dolphin, discover and konsole have a really strange behavior in plasma-wayland. But, it doesn't happen with other app like firefox and chromium.

STEPS TO REPRODUCE
1. Maximize a KDE application
2. Close the application
3. Reopen the application
4. Minimize the application

OBSERVED RESULT
The minimized application have the size of the maximized application.

EXPECTED RESULT
The minimized application have the size of the initial minimized application.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.16.3
KDE Frameworks Version: 5.60
Qt Version: 5.12.3

ADDITIONAL INFORMATION
Comment 1 Martin Flöser 2019-07-18 03:51:09 UTC
Restoring the size is the task of the applications.
Comment 2 Yogesh Marwaha 2019-07-20 07:22:19 UTC
Created attachment 121636 [details]
Screenshot 1
Comment 3 Yogesh Marwaha 2019-07-20 07:22:42 UTC
Created attachment 121637 [details]
Screenshot 2
Comment 4 Yogesh Marwaha 2019-07-20 07:23:02 UTC
Created attachment 121638 [details]
Screenshot 3
Comment 5 Yogesh Marwaha 2019-07-20 07:23:23 UTC
I'll try to rephrase (or may be explain better) the problem being faced by OP and me.

Prerequisite info:
-----------------
Operating System: Arch Linux 
KDE Plasma Version: 5.16.3
KDE Frameworks Version: 5.59.0
Qt Version: 5.13.0
Kernel Version: 4.19.57-1-lts
OS Type: 64-bit
Processors: 4 × Intel® Core™ i5-6500 CPU @ 3.20GHz
Memory: 14.6 GiB

Disclaimer:
----------
1. Assuming that the OP wants to restore the application window (from maximized state) not minimize it; for me minimizing works fine.
2. This only seems to happen on KDE applications under wayland. Other non-KDE applications I use seem to work fine (e.g. Firefox, Gnu Cash, FileZilla, Chromium, Android Studio)

Steps to reproduce:
------------------
1. Maximize a KDE application (Ref. screenshot 1)
2. Close it
3. Reopen the application (Note: Now the application seems to be opened with a size which would be if it was started maximized, but it does not actually start maximized, as is evident from titlebar buttons' state) (Ref. screenshot 2)
4. Try to maximize window by clicking on relevant button in titlebar. Window is resize in a weird way. (Ref. screenshot 3) If the window is resized (dragging from edges) before maximizing, it is maximized properly.


Effects of behavior mentioned above:
-----------------------------------
1. Since the application window is started with a size of a maximized application (while not actually maximized as per KWin), it cannot be restored to a smaller size.
2. Since KWin thinks the window is not maximized, shown windows (i) have borders around them and (ii) are shown with a titlebar even if showing titlebars for maximized applications is disabled.

Possible cause of problem:
-------------------------
Application indeed opens its window in maximized position but either KWin does not get the message or it forgets later that the window is maximized.


I hope I'm clear enough. 

Regards.
Comment 6 Martin Flöser 2019-07-20 07:28:41 UTC
Well, as I said: restoring size (including maximized state) is task of the applications.
Comment 7 Yogesh Marwaha 2019-07-20 07:40:23 UTC
All right then.
Since this bug affects multiple KDE applications (tested on dolphin, konsole, ksysguard, system settings, many KDE games) and needs to be worked on each one of them separately, does this bug needs to be reported separately for all those applications? If the answer is no, can you guide how can this be done.
Comment 8 Marc-Antoine M. 2019-07-20 14:16:42 UTC
Thanks Yogesh Marwaha, that what I wanted to say. It's not minimizing, it's restoring to the non-fullscreen size.
Comment 9 Martin Flöser 2019-07-20 19:36:54 UTC
I assume the problem lies in a library. Either Qt or a KDE Framework. Unfortunately I do not know which part is responsible here. So I would suggest to report against an application so that they can investigate.
Comment 10 Yogesh Marwaha 2019-07-21 09:31:02 UTC
I have filed a report against dolphin (https://bugs.kde.org/show_bug.cgi?id=410061).

Can you have a look at screenshot 3 and confirm whether incorrect drawing along the right edge and bottom edge of the window is a fault of KWin or not? Judging from the mouse actions on that area, it is still part of the application window.
Comment 11 Nate Graham 2019-07-21 23:21:22 UTC
> Well, as I said: restoring size (including maximized state) is task of the
> applications.
On X11, KWin currently takes care of maximizing windows that were maximized when they were closed (IIRC it compares the window size to the screen size and maximizes the window if they're equal). It should have the same behavior on Wayland.
Comment 12 Martin Flöser 2019-07-22 14:32:28 UTC
Actually no. KWin only performs a sanity check for windows requesting a size larger than the screen. This isn't meant for restore of windows, but for screen layout changes. Such a sanity check is useful, but shouldn't replace a correct implementation in the applications.
Comment 13 Nate Graham 2019-07-22 17:22:32 UTC
*** Bug 410061 has been marked as a duplicate of this bug. ***
Comment 14 Nate Graham 2019-07-22 17:24:24 UTC
Yeah, if non-KDE apps remember their maximization state correctly, I guess you're right.

Moving to frameworks-kxmlgui for initial triage.
Comment 15 Yogesh Marwaha 2019-11-21 16:42:22 UTC
I tried to look for the problem and it looks like kxmlgui (or any part of KDE) is not to be blamed here. 

Following are the few observations (while on plasma-wayland session): -
#1: Applications correctly save window size/maximized state on close, but they somehow cannot restore maximized window state
#2: Vanilla Qt5 applications also fail to set maximized window state on open
#3: For example, 
    with 'qdbusviewer --platform xcb', window is maximized on open
    with 'qdbusviewer --platform wayland', window is not maximized on open (but still has proportions of maximized window)

So, either Qt(wayland) is not setting the window state properly or there is a communication gap between KWin and Qt5 (wayland) clients.

I've tried to look into the qtwayland source, but that's probably too much for me.

Thanks for your time.
Comment 16 smit 2020-06-09 06:38:54 UTC
This also happens on WayFire. KDE apps don't remember remember size but other apps like qBitorrent and thunar do.

Also konsole don't follow initial terminal size on WayFire. it always opens with 138x18 regardless of initial terminal size setting.
Comment 17 Yogesh Marwaha 2020-06-09 15:10:28 UTC
Just updated my (Arch Linux) installation and the bug has disappeared (at least for all  the KDE/non-KDE apps I use). A big thumbs-up for everyone involved!

Operating System: Arch Linux 
KDE Plasma Version: 5.19.0
KDE Frameworks Version: 5.70.0
Qt Version: 5.15.0
Kernel Version: 5.4.45-1-lts
OS Type: 64-bit
Processors: 4 × Intel® Core™ i5-6500 CPU @ 3.20GHz
Memory: 15.5 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 530
Comment 18 Nate Graham 2020-06-09 22:53:40 UTC
Yep, this was fixed in 5.19!
Comment 19 Nate Graham 2020-06-09 23:22:20 UTC
Scratch that. It's only working for XWayland apps. Full Wayland apps are still broken in the way described here.
Comment 20 Yogesh Marwaha 2020-06-10 07:19:37 UTC
It seems to work for KDE apps(In reply to Nate Graham from comment #19)
> Scratch that. It's only working for XWayland apps. Full Wayland apps are
> still broken in the way described here.

Is xeyes method valid to check whether an app is wayland native? If not, how can one verify that?
PS: xeyes doesn't move on KDE apps and firefox (under wayland)
Comment 21 Nate Graham 2020-10-16 03:32:08 UTC
Fixed by Vlad Zahorodnii with https://invent.kde.org/plasma/kwin/-/commit/a195223a8d581e0d6d36374771c939414c7c036d in Plasma 5.20.1!
Comment 22 Patrick Silva 2020-10-16 19:12:39 UTC
possibly dupes: bug 427808 and bug 409516
Comment 23 Nate Graham 2020-10-16 20:03:49 UTC
*** Bug 427808 has been marked as a duplicate of this bug. ***
Comment 24 Nate Graham 2020-10-16 20:03:59 UTC
*** Bug 409516 has been marked as a duplicate of this bug. ***
Comment 25 Nate Graham 2020-10-16 20:04:04 UTC
*** Bug 419471 has been marked as a duplicate of this bug. ***
Comment 26 Claudius Ellsel 2020-10-22 11:00:09 UTC
I tested yesterday on Manjaro unstable with 5.20.1 and it didn't seem to work for me (tested with Dolphin). Maybe not all required packages were available then, though, so leaving this bug at the current state for now.
Comment 27 Yogesh Marwaha 2020-10-22 11:13:17 UTC
It didn't work with Dolphin (Konsole too) for me also. Since other applications (which I use) seem to work fine, I tried some tricks. I manually resized application window and then closed it. Again started, maximised and closed. Afterwards it functioned as intended. 

PS: A bit unrelated, Firefox with custom title bar cannot determine that it's  maximised.
Comment 28 Claudius Ellsel 2020-10-22 11:25:19 UTC
(In reply to Yogesh Marwaha from comment #27)
> It didn't work with Dolphin (Konsole too) for me also. Since other
> applications (which I use) seem to work fine, I tried some tricks. I
> manually resized application window and then closed it. Again started,
> maximised and closed. Afterwards it functioned as intended. 

Ah, thanks for the hint. Sounds like old configs have to be overwritten to get it working properly. I assume deleting the dolphinrc file from the .config folder has a similar effect.
Comment 29 Claudius Ellsel 2020-10-22 13:26:30 UTC
Neither resizing dolphin nor deleting dolphinrc helped. Maybe that has something to do with me running a multi-screen setup and is not really related to this?
Comment 30 Vlad Zahorodnii 2020-10-22 13:30:54 UTC
(In reply to Claudius Ellsel from comment #29)
> Neither resizing dolphin nor deleting dolphinrc helped. Maybe that has
> something to do with me running a multi-screen setup and is not really
> related to this?

On my dual-monitor setup, dolphin preserves the maximized state across application launches.
Comment 31 Claudius Ellsel 2020-10-22 13:42:54 UTC
Created attachment 132637 [details]
Screenshot of the problem

This is how my setup looks like (with dolphin opened after being closed maximized).

[clel@claudius-pc ~]$ kwin_wayland -v
kwin 5.20.1
Comment 32 Vlad Zahorodnii 2020-10-22 14:32:15 UTC
Created attachment 132639 [details]
wayland debug output of dolphin with Claudius Ellsel's screen layout

If I arrange my screens similar to Claudius' setup, this issue surfaces. The most interesting thing is that dolphin doesn't issue any set_maximized() request.
Comment 33 Vlad Zahorodnii 2020-10-22 14:34:20 UTC
Created attachment 132640 [details]
with my screen layout, dolphin sends set_maximized() requests
Comment 34 Vlad Zahorodnii 2020-10-22 14:36:43 UTC
So yeah, dolphin restores its maximized state based on the screen layout. Weird.
Comment 35 Claudius Ellsel 2020-10-22 15:05:04 UTC
Shell we track this in a different bug report?

In the meantime while testing other stuff, now Dolphin seems to remember the maximized state, but opens always on the left screen, similar to https://bugs.kde.org/show_bug.cgi?id=427875.

The testing had me build and run Dolphin from master, so that might have changed stuff in the config files, maybe?
Comment 36 Nate Graham 2020-10-22 15:07:43 UTC
(In reply to Vlad Zahorodnii from comment #34)
> So yeah, dolphin restores its maximized state based on the screen layout.
> Weird.

Yes, that was a recent intentional change. See https://invent.kde.org/frameworks/kconfig/-/merge_requests/17
Comment 37 Claudius Ellsel 2020-10-22 15:11:42 UTC
(In reply to Nate Graham from comment #36)
> Yes, that was a recent intentional change. See
> https://invent.kde.org/frameworks/kconfig/-/merge_requests/17

Not sure whether that introduced it, but the current behavior seems to be buggy for me.
Comment 38 Christoph Feck 2020-11-09 23:12:30 UTC
I suggest to report any issues that you are still noticing as a separate ticket.
Comment 39 Claudius Ellsel 2020-11-10 12:13:08 UTC
(In reply to Christoph Feck from comment #38)
> I suggest to report any issues that you are still noticing as a separate
> ticket.

Sure. We can use https://bugs.kde.org/show_bug.cgi?id=427808 for that (I will undupe it) and also there is https://bugs.kde.org/show_bug.cgi?id=427875.