Bug 509282

Summary: When screen configuration changes, desktops are out of whack.
Product: [Plasma] KScreen Reporter: Oded Arbel <oded>
Component: commonAssignee: kscreen-bugs-null <kscreen-bugs-null>
Status: REPORTED ---    
Severity: normal CC: nate, xaver.hugl
Priority: NOR Keywords: multiscreen
Version First Reported In: 6.4.4   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: workflow for restoring sanity
kscreen-doctor -j with only laptop
kscreen-doctor -j with external screens
org.kde.PlasmaShell.dumpCurrentLayoutJS with only laptop
org.kde.PlasmaShell.dumpCurrentLayoutJS with external screens
screenshot with external screens

Description Oded Arbel 2025-09-08 19:00:10 UTC
Created attachment 184816 [details]
workflow for restoring sanity

SUMMARY
This is a new behavior since Plasma 6.4 - I didn't have that problem in 6.3.

I have a laptop and a docking station with 2 external screens. When the dock is connected, the 2 external screens are to the left of the laptop screen, but the laptop screen is always configured as main and should contain the main panel and main widgets.

I have a set of plasma scripts / plasma widets that mess with the wallpaper configuration on my multi-screen setup, so I'm always keenly aware of the desktop "indexes" (i.e. what number the `lastScreen` attribute shows for widget configurations and such).

When the laptop is standalone, its screen is obviously 0. When I dock the laptop, its screen becomes 2, and its desktop configuration (panel and widgets) is moved to the left most screen, that is now shown as 0. My external screens are both vertical, so having the primary desktop widgets and panel on the vertical screen is not even annoying - it is practically useless. To return to a useful setup I have to "enter edit mode", click "Manage desktops and panels", and swap the primary desktop from "Screen 3" to "Internal Screen on eDP-1 (primary)", and also drag the panels around between the screens (I have a secondary panel configured).

When I disconnect the dock - the laptop screen gets the desktop and panel that was on "Screen 3" and the main desktop and widgets and the main panel are hidden. I have to open the "Manage desktop and panels" dialog and do the whole dance in reverse. See attached video for that process. 

STEPS TO REPRODUCE
1. Connect an external screen to a laptop, and set it to the left of the laptop screen, but set the laptop screen as primary.
2. Add a second panel on the external screen, and configure the desktop on the external screen so it is visually different than the primary screen (wallpaper, widgets, etc).
3. disconnect the external screen (it may need to logout/login while docked, before starting to be weird).

OBSERVED RESULT
The desktop configuration of of the external screen is moved to the laptop screen, while the laptop screen configuration is moved to the "disconnected" external screen.

EXPECTED RESULT
The laptop screen configuration should stay the same

SOFTWARE/OS VERSIONS
Operating System: KDE neon User Edition
KDE Plasma Version: 6.4.4
KDE Frameworks Version: 6.17.0
Qt Version: 6.9.2
Kernel Version: 6.14.8-061408-generic (64-bit)
Graphics Platform: Wayland
Processors: 20 × 12th Gen Intel® Core™ i7-12700H
Memory: 32 GiB of RAM (31.0 GiB usable)
Graphics Processor: Intel® Iris® Xe Graphics

ADDITIONAL INFORMATION
I'm going to attach before/after screenshots, `kscreen-doctor -j` outputs and `org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.dumpCurrentLayoutJS` outputs.
Comment 1 Oded Arbel 2025-09-08 19:00:57 UTC
Created attachment 184817 [details]
kscreen-doctor -j with only laptop
Comment 2 Oded Arbel 2025-09-08 19:01:32 UTC
Created attachment 184818 [details]
kscreen-doctor -j with external screens
Comment 3 Oded Arbel 2025-09-08 19:02:06 UTC
Created attachment 184819 [details]
org.kde.PlasmaShell.dumpCurrentLayoutJS with only laptop
Comment 4 Oded Arbel 2025-09-08 19:02:26 UTC
Created attachment 184820 [details]
org.kde.PlasmaShell.dumpCurrentLayoutJS with external screens
Comment 5 Oded Arbel 2025-09-08 19:03:32 UTC
Created attachment 184821 [details]
screenshot with external screens
Comment 6 Oded Arbel 2025-09-18 11:43:25 UTC
As I explained in the OP, I believe the main issue is that the laptop screen (which is defined as "primary" in the display configuration KCM) switches "index" between being 0 when standalone and being 2 when connected to the dock - maybe because it is set as the rightmost screen in the display configuration when connected to the doc.

I tried to workaround the issue by resetting the display and desktop configurations by deleting the following files:

.config/plasmashellrc
.config/plasma-org.kde.plasma.desktop-appletsrc
.config/plasmarc .local/share/kscreen/
.config/kwinrc
.config/kwinoutputconfig.json

After doing that (and rebuilding my setup from scratch, that was frustrating...) it now appears to be working well - the laptop screen stays as index 0 when connected to the dock.

I have backups of the configuration files, in case they are interesting.