Bug 427610 - Konsole manages its own window position even when forcing KWin to manage window placement
Summary: Konsole manages its own window position even when forcing KWin to manage wind...
Status: CONFIRMED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: master
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Kurt Hindenburg
URL:
Keywords: regression
: 427621 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-10-13 00:37 UTC by Qu Wenruo
Modified: 2022-10-15 12:57 UTC (History)
6 users (show)

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


Attachments
video with bug (2.82 MB, application/octet-stream)
2020-10-16 12:57 UTC, Alois Nespor
Details
video showing the bug (785.46 KB, video/mp4)
2021-02-05 10:45 UTC, Jim Jones
Details
video showing the bug (785.46 KB, application/octet-stream)
2021-02-05 10:47 UTC, Jim Jones
Details
resetting the config only works until konsole is closed again (897.18 KB, application/octet-stream)
2021-02-05 10:57 UTC, Jim Jones
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Qu Wenruo 2020-10-13 00:37:33 UTC
SUMMARY
After upgrading to 5.19.5 kwin, the window placement policy seems not working any more for multi-monitor setup.
No matter whatever policy I specify, the new window (in my case, konsole) is always placed at the same position, killing the meaning of "minimal overlapping" policy

Strangely, with the same Archlinux setup on my laptop, even with extra display attached, the window placement policy seems work completely fine.

The not yet updated packages in the laptop seems to be plasma-framwork 5.75.x related packages. The same qt5 and the same kwin is installed on both systems.

So maybe it's a config related problem.

STEPS TO REPRODUCE
1. Install the latest KDE5 from Arch repo
2. Make sure the "minimal overlap" window placement policy is already selected
3. Launch several konsole instances to test the policy

OBSERVED RESULT
All new konsole instances are placed beyond each other, definitely not following
the window placement policy.

EXPECTED RESULT
All new konsole instances are placed with minimal overlap.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.19.5
KDE Frameworks Version: 5.75.0
Qt Version: 5.15.1

ADDITIONAL INFORMATION
KDE frameworks version 5.74 works fine.
Comment 1 Patrick Silva 2020-10-13 10:07:45 UTC
*** Bug 427621 has been marked as a duplicate of this bug. ***
Comment 2 Jim Jones 2020-10-13 10:46:03 UTC
this bug report fixed the placement behavior of apps that use kxmlgui https://bugs.kde.org/show_bug.cgi?id=426725 but it seems konsole uses it's own placement which can't get solved by kxmlgui
Comment 3 Qu Wenruo 2020-10-13 11:32:13 UTC
Does it mean we need to disable the "remember the last window position" option in koncole?
Comment 4 Jim Jones 2020-10-13 14:09:21 UTC
you can only disable it globally, just follow this https://bugs.kde.org/show_bug.cgi?id=426725#c6 for the work around
Comment 5 Nate Graham 2020-10-13 14:25:49 UTC
(In reply to Qu Wenruo from comment #3)
> Does it mean we need to disable the "remember the last window position"
> option in koncole?

Ah, Konsole does indeed have its own code for this! That's definitely a part of the problem. I'm investigating.

Yes, you can unset that for now.
Comment 6 Jim Jones 2020-10-13 14:45:03 UTC
Where can i find the option "remember the last window position" in konsole?
Comment 7 Nate Graham 2020-10-13 15:02:42 UTC
Settings Window > General page > "Remember window size".

The bug is that position remembering was added to the same thing that does size restoring. So Konsole needs to change the text to be accurate, or else manually call only the size restoring code, or something else.

I'm on it.
Comment 8 Qu Wenruo 2020-10-13 23:26:25 UTC
(In reply to Jim Jones from comment #4)
> you can only disable it globally, just follow this
> https://bugs.kde.org/show_bug.cgi?id=426725#c6 for the work around

Thanks a lot!

This really solved the problem!
Comment 9 Alois Nespor 2020-10-16 12:57:45 UTC
Created attachment 132408 [details]
video with bug
Comment 10 Alois Nespor 2020-10-16 12:59:33 UTC
hi, after update to plasma 5.20/ kf 5.75 i have same problem. I have disabled "Remember window size" for own konsole windows's size.
Comment 11 Nate Graham 2020-12-07 19:57:43 UTC
This is fixed now by the fix for Bug 426725. When an app is open and you launch a new instance, the new instances now follows the window placement mode.

If you want apps to *never* remember their window positions and always follow the window placement mode, you can uncheck "Allow KDE apps to remember the positions of their windows" in System Settings > Window Behavior > Advanced

*** This bug has been marked as a duplicate of bug 426725 ***
Comment 12 Jim Jones 2020-12-12 18:36:06 UTC
https://bugs.kde.org/show_bug.cgi?id=427621 got closed as a duplicate of this bug and this bug was closed as a dup of this bug https://bugs.kde.org/show_bug.cgi?id=426725.

Although Nate mentioned in 426725 to create a new bug, https://bugs.kde.org/show_bug.cgi?id=426725#c24

Please reopen this bug, I'm on

KDE Plasma Version: 5.20.0
KDE Frameworks Version: 5.77.0
Qt Version: 5.15.2

and the bug in konsole still exists
Comment 13 Jim Jones 2020-12-12 18:39:04 UTC
Btw I created https://bugs.kde.org/show_bug.cgi?id=427621 because you said so in https://bugs.kde.org/show_bug.cgi?id=426725#c32
Comment 14 Jim Jones 2020-12-13 14:43:35 UTC
correction i'm on:

KDE Plasma Version: 5.20.4
KDE Frameworks Version: 5.77
Qt Version: 5.15.2
Comment 15 Jim Jones 2021-01-19 08:03:08 UTC
konsole window placement still unfixed

I'm currently on:

KDE Plasma Version: 5.20.5
KDE Frameworks Version: 5.78.0
Qt Version: 5.15.2
Comment 16 Alois Nespor 2021-01-19 08:15:22 UTC
for they who have problems read above comments:

If you want apps to *never* remember their window positions and always follow the window placement mode, you can uncheck "Allow KDE apps to remember the positions of their windows" in System Settings > Window Behavior > Advanced

That fix the Konsole problem too... It works (tested) for KDE Plasma Version 5.20.5, KDE Frameworks Version: 5.78.0, Qt Version: 5.15.2 too.
Comment 17 Jim Jones 2021-01-19 09:31:04 UTC
This is a workaround, the bug is still unfixed.
Comment 18 Jim Jones 2021-01-19 09:32:07 UTC
reopened, bug still unfixed, why does this bug report always get closed when a core application only works correctly when the feature is deactived?
Comment 19 Jim Jones 2021-01-19 09:36:31 UTC
I assigned the ticket to the konsole maintainer
Comment 20 Nate Graham 2021-01-19 14:31:21 UTC
That's not a workaround, it's the canonical way to have KWin manage all window placement rather than ever leaving it up to the app.

Is that what you're after, or do you want for just Konsole to be managed exclusively by KWin and for other apps to manage their own positioning?
Comment 21 Jim Jones 2021-01-19 14:47:39 UTC
when i enable the option, all konsole windows get place at the same position ontop of each other, this is clearly a bug imo as it works normally for dolphin for example, the last window gets placed at the stored position the other windows opened afterwards get placed based on the kwin setting

you already mentioned this in another bug - https://bugs.kde.org/show_bug.cgi?id=426725#c24
Comment 22 Jim Jones 2021-01-19 14:52:42 UTC
and i also created a separate bug for konsole (as you stated) which also got closed https://bugs.kde.org/show_bug.cgi?id=427621
Comment 23 Nate Graham 2021-01-19 14:55:48 UTC
Ah ok, so the bug here is that when you use that setting, Konsole manages its own position anyway. Can confirm. Will work on it.
Comment 24 Nate Graham 2021-01-20 00:03:07 UTC
Problem is probably in or around line 68 of MainWindow.cpp
Comment 25 Nate Graham 2021-01-20 00:11:29 UTC
Found the bug. MR incoming.
Comment 26 Bug Janitor Service 2021-01-20 00:12:34 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/konsole/-/merge_requests/331
Comment 27 Nate Graham 2021-01-20 15:23:38 UTC
Git commit 8fa1c4b508b080f958a16d52a1e03bcf9e7e4495 by Nate Graham.
Committed on 20/01/2021 at 05:15.
Pushed by hindenburg into branch 'release/20.12'.

Fix "Remember window size" not working when unchecked

When this feature is turned off, it deletes some keys from Konsole's
config file. However this broke recently for two reasons:

1. The key names changed a few Frameworks releases ago
2. There are new keys that need to be deleted or else position gets
   restored too

This commit fixes that bug by updating the condition to delete all the
config keys required to make the off state for this feature work again.
FIXED-IN: 20.12.2

M  +16   -3    src/MainWindow.cpp

https://invent.kde.org/utilities/konsole/commit/8fa1c4b508b080f958a16d52a1e03bcf9e7e4495
Comment 28 Kurt Hindenburg 2021-01-20 15:29:00 UTC
Git commit d22236c3615ac2189c0254d71614eda316130abd by Kurt Hindenburg, on behalf of Nate Graham.
Committed on 20/01/2021 at 15:25.
Pushed by hindenburg into branch 'master'.

Fix "Remember window size" not working when unchecked

When this feature is turned off, it deletes some keys from Konsole's
config file. However this broke recently for two reasons:

1. The key names changed a few Frameworks releases ago
2. There are new keys that need to be deleted or else position gets
   restored too

This commit fixes that bug by updating the condition to delete all the
config keys required to make the off state for this feature work again.
FIXED-IN: 20.12.2
(cherry picked from commit 8fa1c4b508b080f958a16d52a1e03bcf9e7e4495)

M  +16   -3    src/MainWindow.cpp

https://invent.kde.org/utilities/konsole/commit/d22236c3615ac2189c0254d71614eda316130abd
Comment 29 Jim Jones 2021-01-20 17:43:27 UTC
(In reply to Kurt Hindenburg from comment #28)
> Git commit d22236c3615ac2189c0254d71614eda316130abd by Kurt Hindenburg, on
> behalf of Nate Graham.
> Committed on 20/01/2021 at 15:25.
> Pushed by hindenburg into branch 'master'.
> 
> Fix "Remember window size" not working when unchecked
> 
> When this feature is turned off, it deletes some keys from Konsole's
> config file. However this broke recently for two reasons:
> 
> 1. The key names changed a few Frameworks releases ago
> 2. There are new keys that need to be deleted or else position gets
>    restored too
> 
> This commit fixes that bug by updating the condition to delete all the
> config keys required to make the off state for this feature work again.
> FIXED-IN: 20.12.2
> (cherry picked from commit 8fa1c4b508b080f958a16d52a1e03bcf9e7e4495)
> 
> M  +16   -3    src/MainWindow.cpp
> 
> https://invent.kde.org/utilities/konsole/commit/
> d22236c3615ac2189c0254d71614eda316130abd

When I apply this patch and set "Allow KDE apps to rememeber ..." in the settings and set "Remember window size" in the konsole settings, konsole window still open ontop of each other aka overlap each other

When i disable "Remember window size" in the konsole settings and let "Allow KDE apps to rememeber ..." enabled in the settings, a new konsole window always opens in the top left corner and it doesn't seem to remember it's position at all.

Do i have to apply aother patch too to make it work correctly?





did i do something wrong?
Comment 30 Jim Jones 2021-01-20 18:22:35 UTC
btw dolphin works correctly, it rembers it's window position and places the first window created after the last got closed at the same position and all following windows are handled by kwin
Comment 31 Jim Jones 2021-01-20 18:29:13 UTC
To make i more easy to read:

"Allow KDE apps to rememeber ..." + "Remember window size":
restores the windows the gets opened after the last got closed at the same position, but following windows get opened at the same position aka overlap

"Allow KDE apps to rememeber ..." + ( "Remember window size" disabled ):
doesn't store the last position but doesn't create following windows at the same position aka kwin handles the following window
Comment 32 Nate Graham 2021-01-21 17:16:01 UTC
(In reply to Jim Jones from comment #31)
> To make i more easy to read:
> 
> "Allow KDE apps to rememeber ..." + "Remember window size":
> restores the windows the gets opened after the last got closed at the same
> position, but following windows get opened at the same position aka overlap
What window placement strategy is KWin using? "Minimal overlapping" or something else?

> "Allow KDE apps to rememeber ..." + ( "Remember window size" disabled ):
> doesn't store the last position but doesn't create following windows at the
> same position aka kwin handles the following window
This sounds like the intended behavior, no?
Comment 33 Jim Jones 2021-01-22 00:40:22 UTC
(In reply to Nate Graham from comment #32)
> (In reply to Jim Jones from comment #31)
> > To make i more easy to read:
> > 
> > "Allow KDE apps to rememeber ..." + "Remember window size":
> > restores the windows the gets opened after the last got closed at the same
> > position, but following windows get opened at the same position aka overlap
> What window placement strategy is KWin using? "Minimal overlapping" or
> something else?

"Minimal overlapping"

> > "Allow KDE apps to rememeber ..." + ( "Remember window size" disabled ):
> > doesn't store the last position but doesn't create following windows at the
> > same position aka kwin handles the following window
> This sounds like the intended behavior, no?

The window position of the last closed window doesn't seem to get honored/stored and the first window after the last closed window, always gets created at the same position

aka

last window gets closed at position "A" and the first window afterwards always gets opened at position "B" doesn't matter where the last window got closed
Comment 34 Nate Graham 2021-02-03 01:39:09 UTC
I'm afraid I've read your last few comments several times and I'm still confused, sorry. :( Is there any chance you could attach a screen recording that demonstrates the issue?
Comment 35 Jim Jones 2021-02-03 09:04:14 UTC
"Allow KDE apps to rememeber ..." enabled + "Remember window size" enabled:
1) last konsole window is at position A when it gets closed
2) the next window that gets opened is opened at position A

everything is correct up to this point but

3) following instances that get opened afterwards get also opened at position A aka overlap the last opened window to 100% instead of handling over the window to kwin (which would palce them at a different point)



"Allow KDE apps to rememeber ..." enabled + "Remember window size" disabled:
1) last konsole window is at position A when it gets closed
2) the position isn't stored on exit, following windows always get opened at the same position B
3) but the second instance is handed over to kwin aka they don't overlap like in the case before


is the description better now?
Comment 36 Jim Jones 2021-02-03 09:16:20 UTC
"Allow KDE apps to rememeber ..." enabled + "Remember window size" enabled:

CORRECT: stores the position correctly on exit and opens the first instance at the stored position

ERROR: doesn't hand over the instances after the first instance to kwin aka the following instances overlap each other as they get also opened at the same position


"Allow KDE apps to rememeber ..." enabled + "Remember window size" disabled:

ERROR: doesn't store the position on exit and always opens the first instance at the same position

CORRECT: the instances that gets open afterwards get handed over to kwin
Comment 37 Nate Graham 2021-02-04 03:32:53 UTC
Thanks. I still cannot reproduce that. :( That's why I wanted a screen recording. Sometimes a video reveals extra information that you didn't think to report because it didn't seem unusual to you, because you've set it that way or been living with it for years.
Comment 38 Jim Jones 2021-02-05 10:45:59 UTC
Created attachment 135437 [details]
video showing the bug
Comment 39 Jim Jones 2021-02-05 10:47:33 UTC
Created attachment 135438 [details]
video showing the bug
Comment 40 Jim Jones 2021-02-05 10:54:42 UTC
deleting all konsole related config files with

# rm -rf ./.config/konsolerc ./konsole ./.local/share/konsole

fixes the bug for a short time but after opening and closing konsole a few times, the same behavior is back again
Comment 41 Jim Jones 2021-02-05 10:57:39 UTC
Created attachment 135439 [details]
resetting the config only works until konsole is closed again
Comment 42 Nate Graham 2021-02-07 16:42:37 UTC
Thanks. I wonder if there is a chance that this will be fixed accidentally by the fix for Bug 430521. There were a few more corner cases with this stuff that I fixed in that bug. It should be released in a few days, with Frameworks 5.79. Could you test again with that once it's out?

If it's still broken after that, then I am well and truly stumped. :(
Comment 43 Jim Jones 2021-02-13 19:52:50 UTC
I'm now on 5.79 framework and the bug is still there.

But I'm still on plasma 5.20, maybe 5.21 fixes the bug?
Comment 44 Jim Jones 2021-02-13 19:59:06 UTC
Enabling the option

"Run all Konsole windows in a single process" in konsole fixes the bug for me and windows don't overlap each other after this option is enabled, disabling the option leads to the same broken behavior.
Comment 45 Jim Jones 2021-02-14 16:25:26 UTC
the only bug that still exists:

this command still places two windows on top of each other

for i in {1..2} ; do ( konsole & ) ; done

disabling "Allow KDE apps to remember the position of their own window", places them at different positions aka they don't overlap each other to 100%
Comment 46 Jim Jones 2021-02-15 09:13:22 UTC
btw the same happens for dolphin too


for i in {1..2} ; do ( dolphin & ) ; done

now both dolphin windows overlap each other to 100% aka get placed at the same positon
Comment 47 Jim Jones 2021-03-03 16:23:56 UTC
ping
Comment 48 Nate Graham 2021-03-03 16:35:09 UTC
i can reproduce with that command but I have no idea what the cause might be.
Comment 49 Alec Habig 2021-08-04 16:45:43 UTC
This has been bugging me for a while, but finally started searching around bug reports to see.  plasma version 5.22.4, konsole5 version 21.04.2 (in Fedora 34)

Same behavior as described here towards the end of this thread: selecting "run all konsole instances in a single process" lets the placement do the "minimal overlapping" I've asked of kWin, but without that they all end up stacked in one place.  Which might even be a fine workaround, we'll see if this causes problems for me long term.

As for a why: sounds like a race condition in konsole writing its state out for future use that's triggered by having multiple processes trying to do it.  A wild guess: is konsole one of the few programs that users tend to have a lot of open at once, while for most plasma applications you're happy with only one of them running at a time?  Maybe if Dolphin et al ran as separate processes per open window they'd do the same.
Comment 50 Jim Jones 2021-10-15 19:50:56 UTC
any updates on this bug?
Comment 51 Jim Jones 2022-04-22 07:55:06 UTC
ping