@@ -21,6 +21,20 @@
22#include "globalshortcutregistry.h"
22#include "globalshortcutregistry.h"
25+QWindow* windowForShortcut(GlobalShortcut *sc) {
28+ if (auto item = qobject_cast<QQuickItem*>(parent)) {
29+ auto window = item->window();
30+ if (window) return window;
32+ parent = parent->parent();
24GlobalShortcutRegistry::GlobalShortcutRegistry(QObject *parent)
38GlobalShortcutRegistry::GlobalShortcutRegistry(QObject *parent)
25 : QObject(parent)
39 : QObject(parent)
@@ -90,8 +104,11 @@ bool GlobalShortcutRegistry::eventFilter(QObject *obj, QEvent *event)
90 if (m_shortcuts.contains(seq)) {
104 if (m_shortcuts.contains(seq)) {
91 const auto shortcuts = m_shortcuts.value(seq);
105 const auto shortcuts = m_shortcuts.value(seq);
92 Q_FOREACH(const auto &shortcut, shortcuts) {
106 Q_FOREACH(const auto &shortcut, shortcuts) {
93− if (shortcut && shortcut->window() == obj) {
107+ if (shortcut) {
108+ auto window = windowForShortcut(shortcut);
109+ if (!window || window == obj) { // accept shortcut if it's not attached to a window or it's window is active.
94− qApp->sendEvent(shortcut, &eCopy);
110+ qApp->sendEvent(shortcut, &eCopy);