From b98607c6893633e0b5743132049e903ff59f533e Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Mon, 15 Jan 2024 14:36:00 +0200 Subject: [PATCH] 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. BUG: 478647 --- src/useractions.cpp | 5 +++++ src/workspace.cpp | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/useractions.cpp b/src/useractions.cpp index 37794f4e8d..ca738818ea 100644 --- a/src/useractions.cpp +++ b/src/useractions.cpp @@ -1131,6 +1131,11 @@ void Workspace::windowShortcutUpdated(Window *window) if (!window->shortcut().isEmpty()) { if (action == nullptr) { // new shortcut action = new QAction(this); + connect(window, &Window::closed, action, [action]() { + KGlobalAccel::self()->removeAllShortcuts(action); + delete action; + }); + action->setProperty("componentName", QStringLiteral("kwin")); action->setObjectName(key); action->setText(i18n("Activate Window (%1)", window->caption())); diff --git a/src/workspace.cpp b/src/workspace.cpp index 03782a6f61..03734f2204 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -836,10 +836,6 @@ void Workspace::removeWindow(Window *window) if (m_windowKeysWindow == window) { setupWindowShortcutDone(false); } - if (!window->shortcut().isEmpty()) { - window->setShortcut(QString()); // Remove from client_keys - windowShortcutUpdated(window); // Needed, since this is otherwise delayed by setShortcut() and wouldn't run - } if (window->hasStrut()) { updateClientArea(); }