@@ -21,6 +21,20 @@
2121
2222#include "globalshortcutregistry.h"
2323
24+namespace {
25+QWindow* windowForShortcut(GlobalShortcut *sc) {
26+ QObject* parent= sc;
27+ while(parent) {
28+ if (auto item = qobject_cast<QQuickItem*>(parent)) {
29+ auto window = item->window();
30+ if (window) return window;
31+ }
32+ parent = parent->parent();
33+ }
34+ return nullptr;
35+}
36+} // namespace
37+
2438GlobalShortcutRegistry::GlobalShortcutRegistry(QObject *parent)
2539 : QObject(parent)
2640{
@@ -90,8 +104,11 @@ bool GlobalShortcutRegistry::eventFilter(QObject *obj, QEvent *event)
90104 if (m_shortcuts.contains(seq)) {
91105 const auto shortcuts = m_shortcuts.value(seq);
92106 Q_FOREACH(const auto &shortcut, shortcuts) {
93− if (shortcut && shortcut->window() == obj) {
94− qApp->sendEvent(shortcut, &eCopy);
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.
110+ qApp->sendEvent(shortcut, &eCopy);
111+ }
95112 }
96113 }
97114 }