summaryrefslogtreecommitdiff
path: root/kde-frameworks/kglobalaccel/files/kglobalaccel-5.95.0-fix-shortcut-conflict-dialog.patch
blob: c39f30d86d3cce082d6cbd3b940ab5e5d5db955b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
From 1a8e8cb00cda5807926a90ae8e5d5597354f3541 Mon Sep 17 00:00:00 2001
From: Ahmad Samir <a.samirh78@gmail.com>
Date: Sat, 4 Jun 2022 23:00:15 +0200
Subject: [PATCH] Fix D-Bus de/marshalling KGlobalAccel::MatchType

Otherwise the globalShortcutsByKey() method is silently skipped, and isn't
visible on the org.kde.KGlobalAccel D-Bus interface.

It turns out that to test changes made in kglobalaccel d-bus interface, you
need to kill the system /usr/bin/kglobalaccel process (be careful as that
breaks the most basic shortcuts, e.g. Alt+Tab), and run the one from the
build-dir, otherwise the session d-bus won't pick up your changes.

To test:
- List all methods on the interface:
  `qdbus org.kde.kglobalaccel /kglobalaccel`
- The followin messages are printed in the system log/journal:
Skipped method "globalShortcutsByKey" : Unregistered input type in parameter list: KGlobalAccel::MatchType
Skipped method "globalShortcutsByKey" : Unregistered input type in parameter list: KGlobalAccel::MatchType

To see the behaviour mentioned in the bug report:
- Create a global shortcut of some kind (e.g. F4 to start some app)
- open the shortcut editor in e.g. Dolphin, and try to assign that same
  shortcut to some other action the conflict shortcut message dialog should
  show a message similar to the one in the attached screenshot at:
  https://bugs.kde.org/show_bug.cgi?id=454704#c0
The list of GlobalShortcutInfo returned by globalShortcutsByKey() is empty
because the method couldn't be found on the d-bus interface.

After applying patch:
- kill the system /usr/bin/kglobalaccel and start the one from the build
  dir
- Start Dolphin with the libs from the build-dir e.g.:
  LD_LIBRARY_PATH=build-dir/bin/ dolphin
- The info about the global shortcut should be shown in the message dialog

BUG: 454704
FIXED-IN: 5.95
---
 src/kglobalaccel.cpp          | 19 +++++++++++++++++++
 src/kglobalaccel.h            |  3 +++
 src/kglobalshortcutinfo_p.h   |  1 +
 src/org.kde.KGlobalAccel.xml  |  3 ++-
 src/runtime/kglobalacceld.cpp |  4 ++--
 5 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/src/kglobalaccel.cpp b/src/kglobalaccel.cpp
index d0d2932..ef51b56 100644
--- a/src/kglobalaccel.cpp
+++ b/src/kglobalaccel.cpp
@@ -147,6 +147,7 @@ KGlobalAccel::KGlobalAccel()
     qDBusRegisterMetaType<QList<QStringList>>();
     qDBusRegisterMetaType<KGlobalShortcutInfo>();
     qDBusRegisterMetaType<QList<KGlobalShortcutInfo>>();
+    qDBusRegisterMetaType<KGlobalAccel::MatchType>();
 }
 
 KGlobalAccel::~KGlobalAccel()
@@ -785,4 +786,22 @@ bool KGlobalAccelPrivate::setShortcutWithDefault(QAction *action, const QList<QK
     return true;
 }
 
+QDBusArgument &operator<<(QDBusArgument &argument, const KGlobalAccel::MatchType &type)
+{
+    argument.beginStructure();
+    argument << static_cast<int>(type);
+    argument.endStructure();
+    return argument;
+}
+
+const QDBusArgument &operator>>(const QDBusArgument &argument, KGlobalAccel::MatchType &type)
+{
+    argument.beginStructure();
+    int arg;
+    argument >> arg;
+    type = static_cast<KGlobalAccel::MatchType>(arg);
+    argument.endStructure();
+    return argument;
+}
+
 #include "moc_kglobalaccel.cpp"
diff --git a/src/kglobalaccel.h b/src/kglobalaccel.h
index 563278b..a74a311 100644
--- a/src/kglobalaccel.h
+++ b/src/kglobalaccel.h
@@ -400,4 +400,7 @@ private:
     friend class KGlobalAccelSingleton;
 };
 
+KGLOBALACCEL_EXPORT QDBusArgument &operator<<(QDBusArgument &argument, const KGlobalAccel::MatchType &type);
+KGLOBALACCEL_EXPORT const QDBusArgument &operator>>(const QDBusArgument &argument, KGlobalAccel::MatchType &type);
+
 #endif // _KGLOBALACCEL_H_
diff --git a/src/kglobalshortcutinfo_p.h b/src/kglobalshortcutinfo_p.h
index 4b9146f..b3fa620 100644
--- a/src/kglobalshortcutinfo_p.h
+++ b/src/kglobalshortcutinfo_p.h
@@ -13,6 +13,7 @@
 
 static const int maxSequenceLength = 4;
 
+#include "kglobalaccel.h"
 #include "kglobalshortcutinfo.h"
 
 class KGlobalShortcutInfoPrivate
diff --git a/src/org.kde.KGlobalAccel.xml b/src/org.kde.KGlobalAccel.xml
index 65f93b8..d48ce87 100644
--- a/src/org.kde.KGlobalAccel.xml
+++ b/src/org.kde.KGlobalAccel.xml
@@ -121,7 +121,8 @@
       <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QList&lt;KGlobalShortcutInfo&gt;"/>
       <arg name="key" type="ai" direction="in"/>
       <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QKeySequence"/>
-      <arg name="type" type="i" direction="in"/>
+      <arg name="matchType" type="KGlobalAccel::MatchType" direction="in"/>
+      <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="KGlobalAccel::MatchType"/>
     </method>
     <method name="globalShortcutAvailable">
       <arg type="b" direction="out"/>
diff --git a/src/runtime/kglobalacceld.cpp b/src/runtime/kglobalacceld.cpp
index cf22d26..e14d419 100644
--- a/src/runtime/kglobalacceld.cpp
+++ b/src/runtime/kglobalacceld.cpp
@@ -13,6 +13,7 @@
 #include "globalshortcut.h"
 #include "globalshortcutcontext.h"
 #include "globalshortcutsregistry.h"
+#include "kglobalaccel.h"
 #include "kserviceactioncomponent.h"
 #include "logging_p.h"
 
@@ -21,8 +22,6 @@
 #include <QMetaMethod>
 #include <QTimer>
 
-#include "kglobalaccel.h"
-
 struct KGlobalAccelDPrivate {
     KGlobalAccelDPrivate(KGlobalAccelD *qq)
         : q(qq)
@@ -175,6 +174,7 @@ bool KGlobalAccelD::init()
     qDBusRegisterMetaType<QStringList>();
     qDBusRegisterMetaType<KGlobalShortcutInfo>();
     qDBusRegisterMetaType<QList<KGlobalShortcutInfo>>();
+    qDBusRegisterMetaType<KGlobalAccel::MatchType>();
 
     GlobalShortcutsRegistry *reg = GlobalShortcutsRegistry::self();
     Q_ASSERT(reg);
-- 
GitLab