Added Tizen hardware button handling.
authorTomasz Olszak <olszak.tomasz@gmail.com>
Tue, 10 Nov 2015 14:41:48 +0000 (15:41 +0100)
committerTomasz Olszak <olszak.tomasz@gmail.com>
Tue, 10 Nov 2015 14:41:48 +0000 (15:41 +0100)
It is mainly the same as in the Android so Android solution
 was adapted.

Change-Id: Ie86c5fdd6e25178054e4df77ec4fe318960461ba
Reviewed-by: Tomasz Olszak <olszak.tomasz@gmail.com>
src/gui/kernel/qguiapplication.cpp
src/plugins/platforms/xcb/qxcbkeyboard.cpp

index d0aab73..08c50de 100644 (file)
@@ -1887,7 +1887,7 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE
     QWindow *window = e->window.data();
     modifier_buttons = e->modifiers;
     if (e->nullWindow()
-#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
+#if (defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)) || defined(Q_OS_LINUX_TIZEN)
            || e->key == Qt::Key_Back || e->key == Qt::Key_Menu
 #endif
             ) {
@@ -1916,7 +1916,7 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE
 
     if (window && !window->d_func()->blockedByModalWindow)
         QGuiApplication::sendSpontaneousEvent(window, &ev);
-#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
+#if (defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)) || defined(Q_OS_LINUX_TIZEN)
     else
         ev.setAccepted(false);
 
index 2e088d3..9e2e298 100644 (file)
 #define XF86XK_TouchpadOff         0x1008FFB1
 #define XF86XK_AudioMicMute        0x1008FFB2
 
+#ifdef Q_OS_LINUX_TIZEN
+#define TIZEN_Key_Back             XF86XK_Stop
+#define TIZEN_Key_Menu             XF86XK_Send
+#endif //Q_OS_LINUX_TIZEN
 
 // end of XF86keysyms.h
 
@@ -428,7 +432,11 @@ static const unsigned int KeyTbl[] = {
         // wireless/bluetooth/uwb keys, special launcher keys, etc.
     XF86XK_Back,                Qt::Key_Back,
     XF86XK_Forward,             Qt::Key_Forward,
+#ifdef Q_OS_LINUX_TIZEN
+    TIZEN_Key_Back,             Qt::Key_Back,
+#else
     XF86XK_Stop,                Qt::Key_Stop,
+#endif //Q_OS_LINUX_TIZEN
     XF86XK_Refresh,             Qt::Key_Refresh,
     XF86XK_Favorites,           Qt::Key_Favorites,
     XF86XK_AudioMedia,          Qt::Key_LaunchMedia,
@@ -511,7 +519,11 @@ static const unsigned int KeyTbl[] = {
     XF86XK_RotationPB,          Qt::Key_RotationPB,
     XF86XK_RotationKB,          Qt::Key_RotationKB,
     XF86XK_Save,                Qt::Key_Save,
+#ifdef Q_OS_LINUX_TIZEN
+    TIZEN_Key_Menu,             Qt::Key_Menu,
+#else
     XF86XK_Send,                Qt::Key_Send,
+#endif //Q_OS_LINUX_TIZEN
     XF86XK_Spell,               Qt::Key_Spell,
     XF86XK_SplitScreen,         Qt::Key_SplitScreen,
     XF86XK_Support,             Qt::Key_Support,
@@ -570,7 +582,6 @@ static const unsigned int KeyTbl[] = {
     XF86XK_LaunchD,             Qt::Key_LaunchF,
     XF86XK_LaunchE,             Qt::Key_LaunchG,
     XF86XK_LaunchF,             Qt::Key_LaunchH,
-
     0,                          0
 };
 
@@ -1450,6 +1461,12 @@ void QXcbKeyboard::handleKeyEvent(xcb_window_t sourceWindow, QEvent::Type type,
         targetWindow->updateNetWmUserTime(time);
 
     xcb_keysym_t sym = xkb_state_key_get_one_sym(xkb_state, code);
+#ifdef Q_OS_LINUX_TIZEN
+    if (type == QEvent::KeyPress && (sym == TIZEN_Key_Back || sym == TIZEN_Key_Menu)) {
+        //silently omit press events for Back and Menu keys
+        return;
+    }
+#endif //Q_OS_LINUX_TIZEN
 
     QPlatformInputContext *inputContext = QGuiApplicationPrivate::platformIntegration()->inputContext();
     QMetaMethod method;