Bug 402139 - Kwin Window Rules working initially but get deleted after some time
Summary: Kwin Window Rules working initially but get deleted after some time
Status: RESOLVED NOT A BUG
Alias: None
Product: kwin
Classification: Plasma
Component: rules (show other bugs)
Version: 5.14.4
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-14 22:08 UTC by laxmanpradhan
Modified: 2019-01-30 12:45 UTC (History)
1 user (show)

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


Attachments
Kwin Window Rules Files (1.81 KB, text/plain)
2018-12-17 18:10 UTC, laxmanpradhan
Details
This is the kwinrulesrc file when the rules are no longer working (1.39 KB, text/plain)
2018-12-17 18:15 UTC, laxmanpradhan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description laxmanpradhan 2018-12-14 22:08:28 UTC
SUMMARY
I have some kwin Window Rules, basically for certain firefox windows, if the title of the window matches a string it will force the size and position so that it always appears on the screen where I want. This part works perfectly. The problem is that it seems to forget the rules.

The rules will be working perfectly, then suddenly it stops working. When I go back to the settings window, some of the rules will ramdomly be gone, different ones every time.

The issue seems to be that it can't save all the rules properly, they keep getting deleted. 

STEPS TO REPRODUCE
1. Make several Window Rules from System Settings-> Window Mnagement->window rules. 
2. Wait a bit and they will dissapear and the rules stop working.

OBSERVED RESULT
Windows not getting their positions and size set based on the rules, works initially, then suddenly stops working. 


EXPECTED RESULT
Windows should continue to have their size and position set based on the rules


SOFTWARE/OS VERSIONS
Operating System: Kubuntu 18.10
KDE Plasma Version: 5.14.4
Qt Version: 5.11.1
KDE Frameworks Version: 5.52.0
Kernel Version: 4.18.0-11-generic
OS Type: 64-bit
Processors: 8 × AMD Ryzen 5 2400G with Radeon Vega Graphics
Memory: 14.7 GiB of RAM

ADDITIONAL INFORMATION
My ~/.config/ foler has the following:
-rw------- 1 xx xx 1502 Dec  3 15:05 kwinrc
-rw------- 1 xx xx 1007 Dec  7 16:35 kwinrulesrc

where xx is my username.
Sometime the kwinrulesrc file will have a few rules rndomly missing.
I even tried to chmod 000 the file after importing all my rules again to make sure it can't be modified by another file, and the problem persisted, the rules were still in the file but the windows were not being positioned correctly. Of course now I can't use the gui to 'refresh' the rules so I had to change the permissions back and I now keep using the above workaround to refresh the rules.

Work around
At first, I would leave the settings window open in another activity and then just press 'move up' and 'move down' to force and change, hit apply and it will keep working as normal. Sometimes this stops working just 1-2 mins later so I have exported all my rules so that I can reimport them quickly.
Comment 1 Martin Flöser 2018-12-15 06:26:26 UTC
please attach both a working and a broken kwinrulesrc
Comment 2 laxmanpradhan 2018-12-17 18:10:01 UTC
Created attachment 116970 [details]
Kwin Window Rules Files

These are all the rules I am using, I import them into the Window Rules via the GUI. All of the rules work, initially, after a time some of the rules stop working. If I reimport the rules, they start working again. Which ones stop working seems to be random.
Comment 3 laxmanpradhan 2018-12-17 18:15:10 UTC
Created attachment 116971 [details]
This is the kwinrulesrc file when the rules are no longer working

Notice the [Oscar - Main] rule is no longer present and it is not working.
Comment 4 Martin Flöser 2018-12-17 19:57:02 UTC
The rules in the first attachment look slightly wrong to me. The groups should be [1] and there should be a General section. In the second file what strikes me as odd is XftSubPixel[$d] and similar. These should not be there and I don't know how they get in there.
Comment 5 laxmanpradhan 2018-12-17 20:35:22 UTC
I just tried erasing the kwinrulesrc file, then reimporting just my rules from the first file. The [general[ and [kde] part got added in again, same as before. Also within a few minutes the [Oscar -Labs] rules was releted from the kwinrulesrc file and stopped working. Re-importing all my rules again and it works again.
Comment 6 David Edmundson 2018-12-17 20:49:17 UTC
>These should not be there and I don't know how they get in there.


These keys presumably exist in the global defualts (probably /etc/kde5rc)
Our code must be wiping the group. KConfig writes  adds a marker rather than deleting the local entry so that it knows to override them with the face that they're deleted.

We probably want:
KConfig cfg("kwinrulesrc", NoGlobals); 

Which I can do now.

Though fixing this won't apply retro-actively to broken configs.
Comment 7 David Edmundson 2018-12-17 20:50:49 UTC
*When KConfig writes it adds a marker rather than deleting the local entry so that it knows to override them with the fact that they're deleted.
Comment 8 Martin Flöser 2018-12-18 06:43:45 UTC
Do I see correctly that you use force temporarily rules?
Comment 9 David Edmundson 2018-12-19 13:08:23 UTC
Git commit f3060723e126909a19d221401a473d4e2d3999b7 by David Edmundson.
Committed on 19/12/2018 at 13:07.
Pushed by davidedmundson into branch 'master'.

[kcmkwin/kwinrules] Don't include kdeglobals in rules config

Summary:
There's nothing relevant in kdeglobals and loading it can lead to noise
when deleting groups that override a system default.

We still cascade which will allow kiosk keys to work as well as relevant
system defaults.

Import/Export is unchanged as that already uses SimpleConfig which
includes this flag.

I don't know if it will fix the relevant issue in the bug or just
reduce noise.

Test Plan: Compiled.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17645

M  +1    -1    data/update_default_rules.cpp
M  +1    -1    kcmkwin/kwinrules/kcm.cpp
M  +2    -2    kcmkwin/kwinrules/main.cpp

https://commits.kde.org/kwin/f3060723e126909a19d221401a473d4e2d3999b7
Comment 10 laxmanpradhan 2019-01-10 20:47:16 UTC
>Do I see correctly that you use force temporarily rules?

Yes, I wanted the behaviour to be that when the window first opens, it triggers the resize and reposition based on the rules, but then after than I wanted to still be able to move the windows around and resize them manually. I went through all the options and could not get it to work that way, with force temporary the windows were getting set according to the rules but then the rules were being 'erased'. 

Over the last week I changed all my rules to 'force' and I haven't had the problem with the rules getting erased or forgotten. It was been working perfectly as it should. 

So it seems like the issue is with 'force temporary' rules.
Comment 11 Vlad Zahorodnii 2019-01-27 11:15:58 UTC
(In reply to laxmanpradhan from comment #10)
> Yes, I wanted the behaviour to be that when the window first opens, it
> triggers the resize and reposition based on the rules, but then after than I
> wanted to still be able to move the windows around and resize them manually.
> I went through all the options and could not get it to work that way, with
> force temporary the windows were getting set according to the rules but then
> the rules were being 'erased'. 
You should use "Apply Initially" rules for that purpose.

> So it seems like the issue is with 'force temporary' rules.
No, they work as expected.
Comment 12 Vlad Zahorodnii 2019-01-30 12:45:51 UTC
Marking as NOT A BUG per comment 11.