Fwd: Qt 5.7+ and Command+Shift shortcuts on Mac : isShiftAsModifierAllowed() involved.

René J.V. Bertin rjvbertin at gmail.com
Sat Jan 7 21:32:22 UTC 2017


Looking over the kxmlgui code I notice isShiftAsModifierAllowed(), from KWindowSystem.

Have there been recent changes in that function or its use in other places

Applying the patch below has the following effect:

- Command+Shift+, (Command+<) is shown as Command+Shift+, in the shortcut editor
- the shortcut works as intended

After saving the shortcuts to the current scheme and restarting the app:
- the shortcut is shown as Command+<
- it no longer works

This suggests that isShiftAsModifierAllowed() isn't used everywhere where it should or could be used.
Hints where to look would be appreciated!

Thanks,
R.

------
Qt/Mac can support the native cocoa QPA as well as the XCB QPA. Under Cocoa Shift can be used as a modifier
with all keys and has to be to support shortcuts like Command+! (Command+Shift+1) or Command+< (Command+Shift+,).
With the XCB QPA behaviour is as elsewhere under X11.

diff --git a/src/kkeyserver.cpp b/src/kkeyserver.cpp
index c005456..9a2c27e 100644
--- a/src/kkeyserver.cpp
+++ b/src/kkeyserver.cpp
@@ -106,6 +106,17 @@ uint stringUserToMod(const QString &mod)
 
 bool isShiftAsModifierAllowed(int keyQt)
 {
+#ifdef Q_OS_MACOS
+    static enum { unset=0, cocoa=1, xcb=2 } currentPlatform;
+    if (currentPlatform == unset) {
+        const QString platformName = QGuiApplication::platformName();
+        if (platformName == QLatin1String("cocoa")) {
+            currentPlatform = cocoa;
+        } else if (platformName == QLatin1String("xcb")) {
+            currentPlatform = xcb;
+        }
+    }
+#endif
     // remove any modifiers
     keyQt &= ~Qt::KeyboardModifierMask;
 
@@ -285,7 +296,17 @@ bool isShiftAsModifierAllowed(int keyQt)
         return true;
 
     default:
+#ifdef Q_OS_MACOS
+        switch (currentPlatform) {
+            default:
+            case cocoa:
+                return true;
+            case xcb:
+                return false;
+        }
+#else
         return false;
+#endif
     }
 }
 



More information about the Kde-frameworks-devel mailing list