Bug 27291 - [KDE Frameworks 5.74] New instance of QWidgets-based KDE apps (only on X11) starts in the last known position and size, overlapping the existing instance
Summary: [KDE Frameworks 5.74] New instance of QWidgets-based KDE apps (only on X11) s...
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: Cauldron
Hardware: x86_64 Linux
Priority: Normal normal
Target Milestone: Mageia 8
Assignee: KDE maintainers
QA Contact:
URL: https://bugs.kde.org/show_bug.cgi?id=...
Whiteboard:
Keywords: UPSTREAM
Depends on:
Blocks:
 
Reported: 2020-09-19 10:22 CEST by Shlomi Fish
Modified: 2020-10-30 14:38 CET (History)
3 users (show)

See Also:
Source RPM: KF5.74
CVE:
Status comment: Update will be available upstream KF5.75


Attachments
Tentative mgarepo patch for a fix (5.19 KB, patch)
2020-10-02 21:32 CEST, Shlomi Fish
Details | Diff

Description Shlomi Fish 2020-09-19 10:22:02 CEST
Description of problem:

When invoked inside an X.org WM/DE konsole always starts in the middle-top of the screen (in a new user too). This bug seems to have started to happen only recently. Invoking newer konsoles overlap with the old ones.

Version-Release number of selected component (if applicable):

Cauldron.

How reproducible:


Steps to Reproduce:
1. Use startx
2. Alt+f2 "konsole" or similar
3.
Comment 1 Shlomi Fish 2020-09-19 10:39:04 CEST
Note that downgrading konsole to version 20.04.03 and moving away ~/.config/konsolerc did not help. What I want is for konsole windows to be tiled on the screen / virtual workspace when invoked.
Comment 2 Aurelien Oudelet 2020-09-19 16:22:20 CEST
Hi, thanks for reporting this.

KDE Plasma Version: 5.19.5
KDE Frameworks Version: 5.74.0
Qt Version: 5.15.1
Kernel Version: 5.8.10-desktop-1.mga8
OS Type: 64-bit

Can't reproduce this at all on Plasma.
Konsole opens always here I left it. Not on centre of screen.

Therefore, Plasma has an option in:
systemsettings5 > Workspace > Window Management > Window Behavior > Advanced > Window placement: Centered
I know GNOME has similar function in GNOME Tweaks.

This needs testing for GNOME / XFCE / Cinnamon.
Leaving this in Bugsquad for additional tests

CC: (none) => ouaurelien

Comment 3 Shlomi Fish 2020-09-19 16:36:32 CEST
(In reply to Aurelien Oudelet from comment #2)
> Hi, thanks for reporting this.
> 
> KDE Plasma Version: 5.19.5
> KDE Frameworks Version: 5.74.0
> Qt Version: 5.15.1
> Kernel Version: 5.8.10-desktop-1.mga8
> OS Type: 64-bit
> 
> Can't reproduce this at all on Plasma.
> Konsole opens always here I left it. Not on centre of screen.
> 
> Therefore, Plasma has an option in:
> systemsettings5 > Workspace > Window Management > Window Behavior > Advanced
> > Window placement: Centered
> I know GNOME has similar function in GNOME Tweaks.
> 
> This needs testing for GNOME / XFCE / Cinnamon.
> Leaving this in Bugsquad for additional tests

The main issue is that new instances of konsole's windows are placed exactly on top of the previous ones instead of being tiled side by side for better visibility. This doesn't happen on my fedora 32 sysetm.
Comment 4 Aurelien Oudelet 2020-09-19 16:47:31 CEST
(In reply to Shlomi Fish from comment #3)
> The main issue is that new instances of konsole's windows are placed exactly
> on top of the previous ones instead of being tiled side by side for better
> visibility. This doesn't happen on my fedora 32 sysetm.

Yeah, I confirm this on Plasma, whatever we choose on option in:
systemsettings5 > Workspace > Window Management > Window Behavior > Advanced > Window placement.
And also, whatever the size of the Konsole, it is the same.

Assigning to KDE Maintainers.

(Packagers: Please set the status to 'assigned' if you are working on it)

Keywords: (none) => Triaged

Aurelien Oudelet 2020-09-19 16:47:38 CEST

Target Milestone: --- => Mageia 8

Comment 5 Lewis Smith 2020-09-19 21:31:38 CEST
> The main issue is that new instances of konsole's windows are placed
> exactly on top of the previous ones
Running M8 Mate. 
I confirm this on a wider scale: it is not just Konsole, it happens also with for example Dolphine. Initially, every new Konsole window was centred. I then used the KDE System Settings-Window Management-Window Behaviour-Advanced tab-Window placement to change the given 'Minimal overlapping' to 'Random'. That worked for the first instance, but afterwards new windows were always centred and on top of each other.

But wait! The same happened with Mate terminals. And many (most?) other applications. Resetting 'Random' to 'Minimal overlapping' changed nothing.
So I do not see this as a Plasma problem, but much wider.

@ Shlomi & Aurelien : can you try this with other applications, KDE or not?

I will try this on M7 when next there.

CC: (none) => lewyssmith
Keywords: Triaged => (none)

Comment 6 Aurelien Oudelet 2020-09-20 00:01:50 CEST
Searching this.

It is a new FEATURE on X11 from KDE Frameworks 5.74 (currently on Cauldron)
See: https://bugs.kde.org/show_bug.cgi?id=415150

Also, this Git commit adds a GUI toggle on Plasma 5.20 version in KCM window Management to deactivate this functionality.

Git commit 5ba3793cf977479faf70075de09d21577514b457 by Nate Graham.
Committed on 28/08/2020 at 16:43.
Pushed by ngraham into branch 'master'.

[kcmkwin/kwinoptions] Add option to disable window position memory for KDE apps

This adds a setting to the window options KCM to disable KDE apps
remembering their own window positions on X11, and instead always use
the KWin placement modes.

The setting sets an option in `kdeglobals`, rather than kwinrc, as it is not
a KWin-specific option *per se*. The UI is also hidden on Wayland, as it it
not relevant there because the functionality it disables does not work on
Wayland. Instead, remembering window positions will eventually be implemented
in a different way and affect all windows, not just KDE windows.

See https://invent.kde.org/frameworks/kxmlgui/-/merge_requests/14 for
more details.

URL: (none) => https://bugs.kde.org/show_bug.cgi?id=415150
Keywords: (none) => UPSTREAM

Comment 7 Aurelien Oudelet 2020-09-20 00:08:54 CEST
Mageia 7 unaffected for now.

This needs a release note for Mageia 8 if we can't ship Plasma Workspace 5.20 (previsible release date October 13th, 2020).

A Plasma 5.20 with a GUI control of this functionality is available and Plasma Workspace is currently shipped upstream in Beta form, pretty stable but a beta...

Summary: when invoked inside an X.org WM/DE konsole always starts in the middle-top of the screen (in a new user too) => [KDE Frameworks 5.74] QWidgets-based KDE apps (only on X11) start in last position, overlapping existing instance
Assignee: bugsquad => kde

Aurelien Oudelet 2020-09-20 00:10:48 CEST

Summary: [KDE Frameworks 5.74] QWidgets-based KDE apps (only on X11) start in last position, overlapping existing instance => [KDE Frameworks 5.74] New instance of QWidgets-based KDE app (only on X11) starts in last know position and size, overlapping existing instance

Aurelien Oudelet 2020-09-20 00:11:34 CEST

Status comment: (none) => Complained upstream on mentioned bug report.

Comment 8 Aurelien Oudelet 2020-09-20 00:23:01 CEST
Nate Graham answered:

"As for the mismatch in schedules, it's a frustrating thing. I couldn't land the
Frameworks change in 5.75 because technically Plasma 5.20 depends on Frameworks
5.74. Shipping a Plasma feature that has no effect unless you actually have
5.75 is not technically appropriate, even if by happenstance it would probably
work because those versions would be released close together. A distro could
theoretically package Plasma 5.20 with Frameworks 5.74 and then the new
checkbox in the KWin KCM wouldn't work.

Maybe someday I'll achieve my dream of unifying the Plasma, Release Service,
and Frameworks schedules so that this class of bug is entirely eliminated.
Someday..."

So waiting for Plasma 5.20 to have GUI to toggle or not this function (remark: that's why on Fedora 32 this is not the case)
Comment 9 Lewis Smith 2020-09-21 21:03:26 CEST
@Aurelien : impressive research ! And thanks for same.

@Shlomi : you did not say what desktop; nor whether it happens with applications other than Konsole.

FWIW I did not see the problem in M7. Under Plasma, it does happen if you specify 'centred' for new windows, which is to be expected. New window placement had an option which has disappeared in M8, 'intelligent', which cascaded multiple Konsoles.

Playing more on Mageia 8 (currently Mate, with no visible means of specifying new window placement) reveals variable behaviour. Some applications resist being loaded more than once; many are centred, some top-left, some elsewhere, and if you can start another instance, it always seems to sit exactly on top of the original.

CC: lewyssmith => (none)

Comment 10 Shlomi Fish 2020-09-22 08:10:25 CEST
(In reply to Lewis Smith from comment #9)
> @Aurelien : impressive research ! And thanks for same.
> 
> @Shlomi : you did not say what desktop; nor whether it happens with
> applications other than Konsole.
> 

@Lewis: it happens in plasma5+kwin, xfce and jwm (all from startx). I've now checked and "kate" exhibits the same issue on jwm.
Shlomi Fish 2020-10-02 20:49:43 CEST

Summary: [KDE Frameworks 5.74] New instance of QWidgets-based KDE app (only on X11) starts in last know position and size, overlapping existing instance => [KDE Frameworks 5.74] New instance of QWidgets-based KDE apps (only on X11) starts in the last known position and size, overlapping the existing instance

Comment 11 Shlomi Fish 2020-10-02 21:32:36 CEST
Created attachment 11897 [details]
Tentative mgarepo patch for a fix

This is a tentative mgarepo svn diff patch that contains the reversed merge req patch (minus some comment change that didn't apply cleanly). I tested it on plasma5 , jwm and xfce and it seems to work fine. Hopefully, we have one less problem now and I can more confidently update my fedora 32 system to f33 beta .

CC: (none) => shlomif

Comment 12 Aurelien Oudelet 2020-10-03 09:57:26 CEST
(In reply to Shlomi Fish from comment #11)
> Created attachment 11897 [details]
> Tentative mgarepo patch for a fix
> 
> This is a tentative mgarepo svn diff patch that contains the reversed merge
> req patch (minus some comment change that didn't apply cleanly). I tested it
> on plasma5 , jwm and xfce and it seems to work fine. Hopefully, we have one
> less problem now and I can more confidently update my fedora 32 system to
> f33 beta .

Thanks proposing this.
Therefore, it seems there will be GUI-toogle for Plasma 5.20 due to be published on October 13th, 2020. This GUI should add some config in KDE/Plasma/KDE Frameworks somewhere that will prevent this functionality.

Here is upstream comment about that:
https://invent.kde.org/plasma/kwin/-/merge_requests/211/commits

Here again pinpoint a function in ~/.config/kdeglobals :
AllowKDEAppsToRememberWindowPositions=false
Comment 13 Aurelien Oudelet 2020-10-03 10:05:21 CEST
After testing option in Comment 12.

Patch is not needed !

Simply add AllowKDEAppsToRememberWindowPositions=false in ~/.config/kdeglobals

In systemsettings5 (System Settings), systemsettings5 > Workspace > Window Management > Window Behavior > Advanced > Window placement: Set it to minimal overlapping.

Konsole no longer opens new instance overlapping last one. If you set "Centered", mac-like placement, each new instance overlaps last one as it was centered on screen. You can also set other tilling function and they work!
Comment 14 Aurelien Oudelet 2020-10-03 15:00:12 CEST
@ Shlomi

Upstream update available in KF5.75 due to be released around October 10th/11th ore 12th, 2020, according to previous KF5 release date.

https://bugs.kde.org/show_bug.cgi?id=426725

On above upstream bug report, this is fixed. See Comment 16 reproduced here:

Git commit ab43b986f3de20ff15b6438e56bfe29428bee3b1 by Nate Graham.
Committed on 01/10/2020 at 22:43.
Pushed by ngraham into branch 'master'.

Don't overlap main windows when opening additional instances

Right now when restoring the position of main windows, we do it
unconditionally. This means that if you have a KXMLGui-using app
open and you open a new instance, the new instance gets position-
restored and totally overlaps the existing window. This is not
very nice.

With this commit, that issue is fixed.

Technical explanation: To accomplish this, now every time the
window position data is read, we write out a value to the config
file that indicates that we should not restore the position of the
next window to be opened. This ensures that after opening one
instance, the next one will never cover it up completely. Whenever
any window is closed, we clear the config file value so that the
next-opened window can once again restore the position of the last-
opened one.

This is functionally equivalent to clearing the position config
data on disk after reading it, but is simpler and does not result
in that data being lost if the app crashes (in which case the main
window wouldn't get closed nicely to write the data out again).

UX explanation: Apps where you regularly open multiple instances will
no longer overlap one another, and the last-closed instance will be
the one which gets its position saved. When you re-open that app
after closing all instances, it will remember the last position of
that window, but opening additional instances will let the window
manager position them according to its own window placement settings.
FIXED-IN: 5.75

M  +15   -30   src/kmainwindow.cpp
M  +0    -2    src/kmainwindow_p.h

https://invent.kde.org/frameworks/kxmlgui/commit/ab43b986f3de20ff15b6438e56bfe29428bee3b1

Cc'ing this to david_david who does excellent job on packaging Plasma each month.

CC: (none) => geiger.david68210
Status comment: Complained upstream on mentioned bug report. => Update will be available upstream KF5.75
Source RPM: konsole-20.08.1-1.mga8.src.rpm => KF5.74
Status: NEW => ASSIGNED
URL: https://bugs.kde.org/show_bug.cgi?id=415150 => https://bugs.kde.org/show_bug.cgi?id=426725

Comment 15 Shlomi Fish 2020-10-04 08:34:48 CEST
(In reply to Aurelien Oudelet from comment #13)
> After testing option in Comment 12.
> 
> Patch is not needed !
> 
> Simply add AllowKDEAppsToRememberWindowPositions=false in
> ~/.config/kdeglobals
> 
> In systemsettings5 (System Settings), systemsettings5 > Workspace > Window
> Management > Window Behavior > Advanced > Window placement: Set it to
> minimal overlapping.
> 
> Konsole no longer opens new instance overlapping last one. If you set
> "Centered", mac-like placement, each new instance overlaps last one as it
> was centered on screen. You can also set other tilling function and they
> work!

Thanks for the info! Do you happen to know how to set the "systemsettings5 > Workspace > Window > Management > Window Behavior > Advanced > Window placement"
option from the command line or using a script? I tried grepping the systemsettings5's sources but could not find anything.

I'm going to try it anyway.
Comment 16 Shlomi Fish 2020-10-04 12:36:27 CEST
An update: it appears to work with the unpatched package and this program: https://github.com/shlomif/shlomif-computer-settings/blob/f9ec6983cb2d692302d23307be2ee017f9b8b5b8/shlomif-settings/home-bin-executables/bin/fix-kdeglobals.pl . Here is the code for reference:

```
#! /usr/bin/env perl
#
# Short description for fix-kdeglobals.pl
#
# Version 0.0.1
# Copyright (C) 2020 Shlomi Fish < https://www.shlomifish.org/ >
#
# Licensed under the terms of the MIT license.

use strict;
use warnings;
use 5.014;
use autodie;

use Path::Tiny qw/ path tempdir tempfile cwd /;

# See https://bugs.mageia.org/show_bug.cgi?id=27291

path("$ENV{HOME}/.config/kdeglobals")->edit_utf8(
    sub {
        my $KEY = "AllowKDEAppsToRememberWindowPositions";
        s#^(\[General\].*?)(^\[|\z)#
    my ($sect, $suffix )=($1, $2);
    if ($sect !~ s/^(\Q$KEY\E=)[^\n]*/${1}false/ms)
    {
        $sect =~ s/\K\n*\z/\n$KEY=false\n/ms;
    }
    $sect =~ s/\n*\z/\n\n/ms;
    $sect.$suffix
    #ems;
    }
);

```
Comment 17 Aurelien Oudelet 2020-10-30 14:30:46 CET
Have you tried to set:

Simply add AllowKDEAppsToRememberWindowPositions=false in
~/.config/kdeglobals ?

Also KDE Frameworks 5.75 have landed in Cauldron since a while.
Patch in Comment 14 should be here too.

Mine testing:
Leaving systemsettings5 > Workspace > Window Management > Window Behavior > Advanced > Window placement:

1) Setting it to "centered" reproduces "bug" but this is feature to have window centered onscreen.

2) But, setting to "minimal overlapping", "cascade", "random" or "under mouse" results to have GOOD tiling feature: new Konsole instances are not overlapping previous instance. This is also true to other Applications.

So Closing this fixed.
Feel free to reopen if not really fixed.

Resolution: (none) => FIXED
Status: ASSIGNED => RESOLVED

Comment 18 Aurelien Oudelet 2020-10-30 14:38:51 CET
If this really does still occur, you should be affected by this upstream bug:

https://bugs.kde.org/show_bug.cgi?id=427610
Konsole no longer follows window placement policy

They are on it.

Note You need to log in before you can comment on or make changes to this bug.