Bug 468783 - When logging out and back in, some apps get moved
Summary: When logging out and back in, some apps get moved
Status: RESOLVED DOWNSTREAM
Alias: None
Product: kwin
Classification: Plasma
Component: core (show other bugs)
Version: 5.27.4
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-21 22:44 UTC by Reg
Modified: 2023-05-19 17:19 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Time stamped sets of configuation files (500.90 KB, application/gzip)
2023-04-21 22:53 UTC, Reg
Details
2023-04-21_15.30.45-Logout (161.57 KB, image/png)
2023-04-21 23:03 UTC, Reg
Details
2023-04-21_15.30.59-Login (198.74 KB, image/png)
2023-04-21 23:04 UTC, Reg
Details
2023-04-21_15.28.30-Login (199.20 KB, image/png)
2023-04-21 23:04 UTC, Reg
Details
2023-04-21_15.28.14-Logout (315.95 KB, image/png)
2023-04-21 23:05 UTC, Reg
Details
2023-04-21_15:29:31-Pre-Logout (3.45 MB, image/jpeg)
2023-04-21 23:06 UTC, Reg
Details
2023-04-21_15:24:11-Pre-Logout (3.51 MB, image/jpeg)
2023-04-21 23:07 UTC, Reg
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Reg 2023-04-21 22:44:02 UTC
SUMMARY
When logging out and back in, some apps get moved and in my case seemingly to the right.

STEPS TO REPRODUCE
1.  Have a whole bunch of things open, probably necessary with multiple monitors.
2. Take a snapshot of your screen
3. Log out and back in
4. See what's moved

OBSERVED RESULT
Things move

EXPECTED RESULT
Windows to come back up in their original place.

SOFTWARE/OS VERSIONS

Operating System: openSUSE Tumbleweed 20230417
KDE Plasma Version: 5.27.4
KDE Frameworks Version: 5.105.0
Qt Version: 5.15.8
Kernel Version: 6.2.10-1-default (64-bit)
Graphics Platform: X11
Processors: 16 × Intel® Core™ i7-5960X CPU @ 3.00GHz
Memory: 30.9 GiB of RAM
Graphics Processor: AMD Radeon HD 7700 Series
Manufacturer: ASUS
Product Name: All Series

ADDITIONAL INFORMATION
I've setup a script to take snapshot of the screen on login and logout. It also gathers as many configuration files as I could. I will put all this in a zip file and upload it. Also, I took snapshots before login out for a full comparison.

QUESTION: Is there any way to run a script pre-logging out? That way I could take a screenshot and gather config info. automatically before the logging out process. Right now, if I want that I have to do it myself. 

The problem with the logout script running as it is, is that most things have been removed from the screen before the script can take a screen snapshot.  That said, it looks to me that the things that are being moved ARE the ones that are still showing when logout script is run so that might be a good clue as to the cause.
Comment 1 Reg 2023-04-21 22:52:16 UTC
There are a few things that have moved and the most obvious visually in the attached files is the clock moving to the right.

I logged out and back in twice so you can see what's happening clearly.

In the attached are images and backups of the KDE configuration all of which are file names with dateTime stamps to make it very easy to see the sequence of events. The images I had to reduce down and upload one at a time so your system would take them, the config files are all in a tar.gz file.
Comment 2 Reg 2023-04-21 22:53:38 UTC
Created attachment 158295 [details]
Time stamped sets of configuation files
Comment 3 Reg 2023-04-21 23:03:42 UTC
Created attachment 158296 [details]
2023-04-21_15.30.45-Logout
Comment 4 Reg 2023-04-21 23:04:05 UTC
Created attachment 158297 [details]
2023-04-21_15.30.59-Login
Comment 5 Reg 2023-04-21 23:04:34 UTC
Created attachment 158298 [details]
2023-04-21_15.28.30-Login
Comment 6 Reg 2023-04-21 23:05:11 UTC
Created attachment 158299 [details]
2023-04-21_15.28.14-Logout
Comment 7 Reg 2023-04-21 23:06:33 UTC
Created attachment 158300 [details]
2023-04-21_15:29:31-Pre-Logout
Comment 8 Reg 2023-04-21 23:07:07 UTC
Created attachment 158301 [details]
2023-04-21_15:24:11-Pre-Logout
Comment 9 Nate Graham 2023-04-25 15:59:51 UTC
On X11 it's up to apps to store and restore their window positions; KWin doesn't and can't do this, due to the way X11 works and what apps expect from it.

On Wayland, it will eventually be possible for KWin to save and restore window positions itself; see Bug 15329.
Comment 10 Reg 2023-05-18 22:01:34 UTC
(In reply to Nate Graham from comment #9)
> On X11 it's up to apps to store and restore their window positions; KWin
> doesn't and can't do this, due to the way X11 works and what apps expect
> from it.
> 
> On Wayland, it will eventually be possible for KWin to save and restore
> window positions itself; see Bug 15329.

Thanks for pointing me to that. Wow! A 20 year old bug, that was quite a read going through all those comments.

One quick question as I asked this before I'll just past the question as asked below:

QUESTION: Is there any way to run a script pre-logging out? That way I could take a screenshot and gather config info. automatically before the logging out process. Right now, if I want that I have to do it myself. 

The problem with the logout script running as it is, is that most things have been removed from the screen before the script can take a screen snapshot.  That said, it looks to me that the things that are being moved ARE the ones that are still showing when logout script is run so that might be a good clue as to the cause.

FOLLOW UP: It's not just for debugging I am asking this. I am software developer and I do run command line scripts for reasons other than debugging and it would be incredibly useful to be able to do this. For example, one I can think of immediately: 

    "If close the apps before the logging out process manually then when I log in most of those apps that moved (maybe all of them, I'll have to check) come back in their right place. It's only when I log out without first closing them that this issue happens."

Hm, maybe that's a nicety that KDE could do for people until there is a proper fix? That is, log all these apps out like a user manually closing the apps before any of the other logging out operation occurs because that solves most if not all of it anyway. My guess is that's probably because the apps have a chance to record their proper position whereas right now something is changing first so that when they get logged out they record a wrong position. Maybe this is a KDE bug after all since a manual operation produces the correct result but just logging out without first closing the apps does not???

Sorry, I didn't think to mention that previously because it just didn't occur to me but I regularly log out of my most important apps that I don't want to change on me, particularly my Jetbrains IDE so that it comes back with all the windows in the right place. Again, sorry I didn't think to mention this previously.

But back to my question, is there way to perform an operation before anything else on a logout? ...because with that I can immediately effect a fix.
Comment 11 Nate Graham 2023-05-19 17:19:56 UTC
Unfortunately I'm not aware of a built-in facility to do that. The logout scripts you can add using System Settings > Startup and Shutdown > Autostart > "Add..." button > "Add Logout Script" run quite late.

If you're a software developer, you may be able to write a small program to do this by listening for a DBus signal sent by ksmserver when the system is told to shut down.