Bug 478647 - Assigned Shortcut in Window Rules does not work after closing and restarting application
Summary: Assigned Shortcut in Window Rules does not work after closing and restarting ...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: rules (show other bugs)
Version: master
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: qt6
Depends on:
Blocks:
 
Reported: 2023-12-17 14:04 UTC by D. Debnath
Modified: 2024-01-15 15:03 UTC (History)
1 user (show)

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


Attachments
Window Rules for Konsole (199.28 KB, image/png)
2024-01-15 11:31 UTC, D. Debnath
Details

Note You need to log in before you can comment on or make changes to this bug.
Description D. Debnath 2023-12-17 14:04:16 UTC
SUMMARY

Shortcut applied through Window Rules only works the first time the application is started. After closing and restarting the application, the shortcut no longer works. It only works again after system reboot.

STEPS TO REPRODUCE

1. Assign shortcut for an application (e.g. Konsole) through Window Rules 
2. Try shortcut
3. Exit application
4. Start application
5. Try shortcut

OBSERVED RESULT

Works first time.
Doesn't work after application restart.

EXPECTED RESULT

Works always.

SOFTWARE/OS VERSIONS

Operating System: KDE neon Unstable Edition
KDE Plasma Version: 5.90.90
KDE Frameworks Version: 5.247.0
Qt Version: 6.6.1
Kernel Version: 6.2.0-34-generic (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-7700HQ CPU @ 2.80GHz
Memory: 23.3 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 630
Comment 1 Vlad Zahorodnii 2024-01-15 10:47:21 UTC
I am unable to reproduce the issue. Please provide all the details about the window rule (type, shortcut, etc)
Comment 2 D. Debnath 2024-01-15 11:31:28 UTC
Created attachment 164912 [details]
Window Rules for Konsole

(In reply to Vlad Zahorodnii from comment #1)
> I am unable to reproduce the issue. Please provide all the details about the
> window rule (type, shortcut, etc)

I hope you're trying this on Wayland. This is an issue on Wayland only. Also, I've the same issue on multiple machines, and multiple distros (Arch Linux and KDE Neon Unstable) and so I'm confident that this should be reproducible.

I've attached a screenshot of the Window Rules I'm using for Konsole. This is my ~/.config/kwinrulesrc

[$Version]
update_info=kwinrules.upd:replace-placement-string-to-enum,kwinrules.upd:use-virtual-desktop-ids

[1]
Description=Application settings for Konsole
above=true
aboverule=3
desktops=\\0
desktopsrule=2
minimize=true
minimizerule=3
placementrule=2
shortcut=Meta+Return
shortcutrule=2
skippager=true
skippagerrule=3
skipswitcher=true
skipswitcherrule=3
skiptaskbar=true
skiptaskbarrule=3
wmclass=konsole org.kde.konsole
wmclasscomplete=true
wmclassmatch=1

[General]
count=1
rules=1
Comment 3 Vlad Zahorodnii 2024-01-15 11:40:01 UTC
Works fine on my machine. Have you tried using other shortcut?
Comment 4 D. Debnath 2024-01-15 11:40:52 UTC
Okay, I've figured out the issue now! This happens when the Shortcut is set to "Force". It works when set to "Apply Initially".

Can you reproduce the problem now? Why does setting it to "Force" create this issue? Is that intended behaviour?
Comment 5 Bug Janitor Service 2024-01-15 12:46:05 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/4926
Comment 6 Vlad Zahorodnii 2024-01-15 14:38:21 UTC
Git commit b98607c6893633e0b5743132049e903ff59f533e by Vlad Zahorodnii.
Committed on 15/01/2024 at 15:24.
Pushed by vladz into branch 'master'.

Fix cleanup of forced window shortcuts

XdgToplevelWindow doesn't call finishWindowRules(). It creates a problem
for Workspace::removeWindow() because it calls setShortcut() to release
the window shortcut.

While one way to fix the bug would be to add a finishWindowRules() call
in XdgToplevelWindow, it would perhaps be not the best one because it
would change the appearance of decoration when the window is closed.

Instead, this change makes the workspace release the shortcut when the
window is closed. It has a couple of advantages: the appearance of the
decoration won't change, shortcut cleanup is better encapsulated.

M  +5    -0    src/useractions.cpp
M  +0    -4    src/workspace.cpp

https://invent.kde.org/plasma/kwin/-/commit/b98607c6893633e0b5743132049e903ff59f533e
Comment 7 Vlad Zahorodnii 2024-01-15 15:03:51 UTC
Git commit b62d212a5833a389b1aaa3a7ad4187e56e729e18 by Vlad Zahorodnii.
Committed on 15/01/2024 at 15:41.
Pushed by vladz into branch 'Plasma/6.0'.

Fix cleanup of forced window shortcuts

XdgToplevelWindow doesn't call finishWindowRules(). It creates a problem
for Workspace::removeWindow() because it calls setShortcut() to release
the window shortcut.

While one way to fix the bug would be to add a finishWindowRules() call
in XdgToplevelWindow, it would perhaps be not the best one because it
would change the appearance of decoration when the window is closed.

Instead, this change makes the workspace release the shortcut when the
window is closed. It has a couple of advantages: the appearance of the
decoration won't change, shortcut cleanup is better encapsulated.


(cherry picked from commit b98607c6893633e0b5743132049e903ff59f533e)

M  +5    -0    src/useractions.cpp
M  +0    -4    src/workspace.cpp

https://invent.kde.org/plasma/kwin/-/commit/b62d212a5833a389b1aaa3a7ad4187e56e729e18