| Summary: | Discover Does Not Remember It's Windowed Size If Closed When Maximised | ||
|---|---|---|---|
| Product: | [Applications] Discover | Reporter: | Eamonn Rea <eamonnrea> |
| Component: | discover | Assignee: | Plasma Bugs List <plasma-bugs-null> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | aleixpol, nate |
| Priority: | NOR | ||
| Version First Reported In: | 6.1.4 | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | https://invent.kde.org/plasma/discover/-/commit/9731120606d549c9b2014a49588c9e29a1758a2c | Version Fixed/Implemented In: | 6.2.0 with Frameworks 6.6 |
| Sentry Crash Report: | |||
|
Description
Eamonn Rea
2024-08-26 17:47:31 UTC
Can reproduce. Could this be because Discover stores window geometry and not width, height, and maxmized flags separately as other KDE applications appear to do? For example, `systemmonitorrc` stores window information like this (removed some irrelevant information): ``` [General] height=984 maximized=true width=1866 ``` Note that the "maximized" flag is not present for System Monitor if the application is not windowed, at least in my observations. The "width" and "height" flags do not update. Whereas Discover stores the window's geometry, and this lines up with observations in the code. For example it seems Discover loads the window geometry based on the information in this "geometry" key (https://invent.kde.org/plasma/discover/-/blob/e958c9c1afcf79f09409505ebbf786d5cfc2fe7a/discover/DiscoverObject.cpp#L521), which doesn't contain minimized/maximised information. My understanding in Qt is that you can set the maximised window flag independent of the window geometry, so in theory you could set window geometry while a window is maximised, and once it is not maximised, it will then assume the size and position assigned. ``` [Window] geometry=0,1080,2560,1377 visibility=4 ``` I cannot actually see where in this file that Discover stores whether it was maximised or not, so perhaps this is managed separately. Other applications store window information differently, for example Spectacle (which is generally just a dialog) stores its information differently to Discover and System Monitor. It's also possible I'm looking in the wrong place, as System Settings remembers its window geometry (although not whether it was maximised or not) but it does not seem to store a config rc file in `~/.config`. Similarly, Dolphin stores a dolphinrc file, but it does not seem to get updated and has some window positioning weirdness when unmaximised (which I am planning to file as a separate but.) If this is indeed the cause of the bug, then I guess Discover would need to change how it stores its geometry information. Maybe it shouldn't update the saved geometry if it is closed while maximised? It seems to already be able to know when it was closed while maximised, and I would guess the Discover `window` object should be able to tell when it is maximised. If that would be the fix, I guess it would go somewhere here, when the application checks for a close event: https://invent.kde.org/plasma/discover/-/blob/e958c9c1afcf79f09409505ebbf786d5cfc2fe7a/discover/DiscoverObject.cpp#L550-562 Actually, the solution of not saving window geometry if closing when maximised would not fix the problem. It would introduce a problem where if you resize the window, maximise it, and then close Discover, then you re-open and window it again, it'll remember the old size and not the resized-size from when it was resized before it was maximised. System Monitor appears to save the window width and height on resize, I didn't check the codebase but from examining the `systemmonitorrc` it looks to write these values while the window is being resized. Using auto-reload in Kate I can see that even during resizing the values update, before I let go of the mouse. Maybe if System Monitor is hooking into some event to know when to save width and height, Discover could do something similar. There may have been a similar issue for System Settings in the past actually that was fixed by this PR, purely based on the description: https://invent.kde.org/plasma/plasma-systemmonitor/-/merge_requests/255 Yes, you've figured out what's going on. When the window is maximized, it should stop saving its geometry to the file — both immediately, and on close. Ultimately Discover should be ported to use KConfig.WindowStateSaver which at least centralizes the logic in one place so that bugs like this can be fixed centrally. Git commit 9731120606d549c9b2014a49588c9e29a1758a2c by Nate Graham, on behalf of Eamonn Rea. Committed on 31/08/2024 at 23:37. Pushed by ngraham into branch 'master'. Use KConfig.WindowStateSaver to handle window sizing FIXED-IN: 6.2.0 with Frameworks 6.6 M +0 -17 discover/DiscoverObject.cpp M +0 -2 discover/DiscoverObject.h M +7 -2 discover/qml/DiscoverWindow.qml https://invent.kde.org/plasma/discover/-/commit/9731120606d549c9b2014a49588c9e29a1758a2c |