Bug 401103 - Rule "Apply Initially" on size does not work anymore for several KDE applications
Summary: Rule "Apply Initially" on size does not work anymore for several KDE applicat...
Status: RESOLVED WORKSFORME
Alias: None
Product: kwin
Classification: Plasma
Component: rules (show other bugs)
Version: 5.20.4
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-16 11:14 UTC by Till Schäfer
Modified: 2021-01-07 17:53 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
kwinrulesrc (3.30 KB, text/plain)
2018-11-16 12:38 UTC, Till Schäfer
Details
kate xprop output (33.68 KB, text/plain)
2018-11-16 12:41 UTC, Till Schäfer
Details
kate xwininfo output (729 bytes, text/plain)
2018-11-16 12:41 UTC, Till Schäfer
Details
kate xprop output with deleted katerc (33.61 KB, text/plain)
2018-11-16 16:48 UTC, Till Schäfer
Details
kate xwininfo output with deleted katerc (743 bytes, text/plain)
2018-11-16 16:49 UTC, Till Schäfer
Details
kwin support information (5.78 KB, text/plain)
2018-11-21 10:58 UTC, Till Schäfer
Details
screenshot of okular settings (119.82 KB, image/png)
2021-01-06 08:56 UTC, Till Schäfer
Details
problematic okularrc (1.30 KB, text/plain)
2021-01-06 09:49 UTC, Till Schäfer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Till Schäfer 2018-11-16 11:14:12 UTC
I have noticed that several kwin window rules, that force an initial size of a window do have no effect anymore. I have also tried to force "ignore requested geometry" to yes, but with no effect. I can reproduce this behavior for kate and okular, but it works with nfoviewer (gtk). 


SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.14.3
KDE Frameworks Version: 5.52
Qt Version: 5.11.2
Comment 1 Martin Flöser 2018-11-16 11:54:08 UTC
Please provide xprop and xwininfo for an affected application and also add the rule for it.
Comment 2 Till Schäfer 2018-11-16 12:38:47 UTC
Created attachment 116345 [details]
kwinrulesrc

(see kate rule)
Comment 3 Till Schäfer 2018-11-16 12:41:03 UTC
Created attachment 116346 [details]
kate xprop output
Comment 4 Till Schäfer 2018-11-16 12:41:24 UTC
Created attachment 116347 [details]
kate xwininfo output
Comment 5 Till Schäfer 2018-11-16 12:51:30 UTC
I have notice, that the windows always start maximized. Even, if I have closed them in an unmaximized state before. 

On another computer, the kwin rules and the maximization state works correctly. Thus, i was wandering, what might be the difference. One thing, that came into my mind was, that I had installed a tilling kwin scrip before on the broken system, but uninstalled it, since it was not working propertly. Maybe that script left something flying around?
Comment 6 Till Schäfer 2018-11-16 13:04:14 UTC
installed scripts were: 

https://store.kde.org/p/1187647
https://store.kde.org/p/1112554
Comment 7 Martin Flöser 2018-11-16 15:03:59 UTC
you could check in ~/.config/katerc in section [MainWindow] whether it tries to start in maximized state. For a test you could remove katerc.
Comment 8 Till Schäfer 2018-11-16 16:47:59 UTC
(In reply to Martin Flöser from comment #7)
> you could check in ~/.config/katerc in section [MainWindow] whether it tries
> to start in maximized state. For a test you could remove katerc.

That was indeed the case. After removing katerc completely, it does not start maximized anymore. However, it still does not respect the window rule.
Comment 9 Till Schäfer 2018-11-16 16:48:41 UTC
Created attachment 116352 [details]
kate xprop output with deleted katerc
Comment 10 Till Schäfer 2018-11-16 16:49:08 UTC
Created attachment 116353 [details]
kate xwininfo output with deleted katerc
Comment 11 Martin Flöser 2018-11-17 19:51:00 UTC
I added a similar rule for kate to my system and the geometry was also not applied. I'll add this to our window rules test set, so that we can either figure out whether it's a problem on the client or kwin side.
Comment 12 Martin Flöser 2018-11-18 09:36:17 UTC
Just created the test case and it passes.
Comment 13 Martin Flöser 2018-11-18 14:39:18 UTC
After further testing I conclude that my kate also reacts properly on the size rule I create.
Comment 14 Martin Flöser 2018-11-18 14:44:39 UTC
could you please provide the output of:
qdbus org.kde.KWin /KWin supportInformation
Comment 15 Till Schäfer 2018-11-21 10:58:39 UTC
Created attachment 116441 [details]
kwin support information

sorry i was a bit late, since the affected computer is only accessible (Wednesday to Friday to me)
Comment 16 Martin Flöser 2018-11-21 16:04:50 UTC
I can only conclude that this must be a change in Qt.
Comment 17 Till Schäfer 2018-11-21 16:20:13 UTC
(In reply to Martin Flöser from comment #16)
> I can only conclude that this must be a change in Qt.

I have another system with identical qt version, where the rule works as expected (I copied the config from kwinrulesrc, thus is should be identical)
Comment 18 Martin Flöser 2018-11-23 04:55:33 UTC
What is different in the systems?
Comment 19 Till Schäfer 2018-11-23 12:56:36 UTC
They both run the same stack of kde software and xorg-server. Thus, this might be some "old config flying around" problem...
Comment 20 Alexander Ewering 2019-10-20 15:43:53 UTC
I have exactly the same problem with multiple applications (Dolphin, KMail, and I'm sure others). Windows always start maximized no matter which window rules or sizes you had set, EXCEPT if I use "Force". THEN it works, but obviously it's now non-resizable, which is a problem.

Operating System: KDE neon 5.17
KDE Plasma Version: 5.17.0
KDE Frameworks Version: 5.63.0
Qt Version: 5.13.1
Kernel Version: 5.0.0-31-generic
OS Type: 64-bit
Processors: 4 × Intel® Core™ i5-2430M CPU @ 2.40GHz
Memory: 3.8 GiB of RAM
Comment 21 Alexander Ewering 2019-10-20 20:14:47 UTC
If it helps: It seems like window rules will be working, and as soon as ANOTHER window rule is added, ALL rules suddenly stop working, at least their "size" parts ("No borders" for example continues to work for ALL rules). Very strange. (all "size" related rules stopped working for me when I added an additional rule for Discover.)
Comment 22 Ismael Asensio 2021-01-04 20:13:09 UTC
I cannot reproduce this when forcing "ignore requested geometry" to yes.

Without this setting, the application can override the initial size property by setting a different geometry.

Is this still happening to you?
Comment 23 Till Schäfer 2021-01-06 08:56:02 UTC
Created attachment 134604 [details]
screenshot of okular settings

It works for kate in my case, but still fails for okular. 

Operating System: Gentoo Linux
KDE Plasma Version: 5.20.4
KDE Frameworks Version: 5.77.0
Qt Version: 5.15.2
Kernel Version: 5.9.14-gentoo
OS Type: 64-bit
Processors: 8 × Intel® Core™ i7-3770 CPU @ 3.40GHz
Memory: 30.9 GiB of RAM
Graphics Processor: Mesa DRI Intel® HD Graphics 4000
Comment 24 Till Schäfer 2021-01-06 09:03:28 UTC
Since Ismael reported that the rule misfunction might be related to other rules, if have tested if the rule ordering has an effect. 

Result: Geometry is not applied, regardless if the rule is placed first and last in the rule list.
Comment 25 Till Schäfer 2021-01-06 09:49:07 UTC
Created attachment 134606 [details]
problematic okularrc

removing the okularrc file did resolve the issue for me. Thus, this might be an Okular issue not requesting a certain geometry, but setting it manually after start. I have attached the problematic okularrc file (with removed recent files)
Comment 26 Alexander Ewering 2021-01-06 11:12:59 UTC
I'm not sure if this is related, but I remember that I had the general problem that KDE applications would randomly revert to launching maximized, no matter how many window rules I defined for them.

I fixed it by running the following script one a minute from Cron:

cd /home/intrr/.config
sed -i 's/^Window-Maximized.*true//' konsolerc dolphinrc systemsettingsrc okularrc gwenviewrc kolourpaintrc kwriterc kdialogrc
Comment 27 Till Schäfer 2021-01-06 11:25:49 UTC
(In reply to Alexander Ewering from comment #26)
> I'm not sure if this is related, but I remember that I had the general
> problem that KDE applications would randomly revert to launching maximized,
> no matter how many window rules I defined for them.
> 
> I fixed it by running the following script one a minute from Cron:
> 
> cd /home/intrr/.config
> sed -i 's/^Window-Maximized.*true//' konsolerc dolphinrc systemsettingsrc
> okularrc gwenviewrc kolourpaintrc kwriterc kdialogrc

that analysis would fit my case
Comment 28 Alexander Ewering 2021-01-06 11:35:33 UTC
(In reply to Till Schäfer from comment #27)
> (In reply to Alexander Ewering from comment #26)
> > I'm not sure if this is related, but I remember that I had the general
> > problem that KDE applications would randomly revert to launching maximized,
> > no matter how many window rules I defined for them.
> > 
> > I fixed it by running the following script one a minute from Cron:
> > 
> > cd /home/intrr/.config
> > sed -i 's/^Window-Maximized.*true//' konsolerc dolphinrc systemsettingsrc
> > okularrc gwenviewrc kolourpaintrc kwriterc kdialogrc
> 
> that analysis would fit my case

Okay... so this is odd then. Of course, user-defined window rules should always have priority over anything the app itself decides. I know, I'm probably missing technical details (sorry!), but yeah... in essence, that should be the outcome. From what I understand, some apps change the window size very quickly after launch, but unfortunately also AFTER the "Apply initially" rules have been applied. So, a classical race condition then.
Comment 29 Ismael Asensio 2021-01-06 22:23:39 UTC
> From what I understand, some apps change the window
> size very quickly after launch, but unfortunately also AFTER the "Apply
> initially" rules have been applied. So, a classical race condition then.

That is right. All those applications are remembering their own geometry/state and trying to set it at launch, but after kwin has applied the `Apply Initially` rules.

To overcome this, there's the setting `Ignore requested geometry`, which makes kwin to ignore size and position requests from the app.

As I understand from the comments, it's just only `Window-Maximized=true` the remaining issue. Is that right?

If in general you don't want any KDE apps to remember their last position (and set it back when re-lauched), you can disable this behavior in `Window Behavior->Advanced->Allow apps to remember the position ...`

You can also override this for specific ones setting the rule properties "Vertically Maximized" and "Horizontally Maximized", both to `Apply Initially: No`.
Comment 30 Till Schäfer 2021-01-07 12:26:55 UTC
Reading again through this report, I think that the original problem is indeed resolved (kate did not act on rules despite deleting katerc in the beginning). 

Should I open another bug report, that matches the current behavior more closely? I still think there are some problems remaining here.  
a) okular always starts in maximized state even if it was closed in unmaximized state. Thus, it remembered the maximization in the first place, but not the demaximization ... 
b) "Ignore requested geometry" does not help. See screenshot of okular settings (I have already forced it). Does this ignore setting include the maximized state? I still think, that apply initially rules should always work with this setting forced.  At least the description of the feature should be a little bit more clear about the affected rules (size, position, maximized?). Currently the description only mentions position, but I think it will at least affect size, too.
Comment 31 Ismael Asensio 2021-01-07 14:35:39 UTC
Thanks a lot for summarizing up!

> Should I open another bug report, that matches the current behavior more
> closely? I still think there are some problems remaining here.

Yes, I think there's more chances to get the remaining issues solved by filling two focused bug reports, especially if one of them only affects okular.

> a) okular always starts in maximized state even if it was closed in
> unmaximized state. Thus, it remembered the maximization in the first place,
> but not the demaximization ... 

I cannot reproduce this, so there must be some other differences in our setups (multi-screen?) and/or okular internals. Filling a bug against it can help figuring out the problem.

> b) "Ignore requested geometry" does not help. See screenshot of okular
> settings (I have already forced it). Does this ignore setting include the
> maximized state? I still think, that apply initially rules should always
> work with this setting forced.  At least the description of the feature
> should be a little bit more clear about the affected rules (size, position,
> maximized?). Currently the description only mentions position, but I think
> it will at least affect size, too.

This is a very good point. I would also assume that the geometry also affects maximize state, but it in fact doesn't. It is worth looking for a possible solution, or at least disambiguate it as you propose.
Comment 32 Ismael Asensio 2021-01-07 17:53:37 UTC
If you don't mind I'll be closing this, as the initial issue doesn't seem to reproduce in those terms, and you already submitted follow-up bugs.

For reference:

* Window rule "Ignore requested geometry" has unclear effect: bug#431265
* Okular always starts in maximized state: bug#431267

Thanks!