[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [plasma-desktop] /: [kcm/keyboard] Port X11Helper::setGroup to xcb.
From:       Àlex_Fiestas <afiestas () kde ! org>
Date:       2014-04-15 13:31:29
Message-ID: E1Wa3ST-0001Zt-D6 () scm ! kde ! org
[Download RAW message or body]

Git commit d5a61432ca84b7babca8b190d2590072b6705977 by Àlex Fiestas.
Committed on 15/04/2014 at 13:24.
Pushed by afiestas into branch 'master'.

[kcm/keyboard] Port X11Helper::setGroup to xcb.

The X11 version of it had some delay flushing the request
which make the experience suck and since this code is async
(we expect the event after the request) it was making it look
like it did not work.

Porting the code to xcb fixed it.

M  +1    -1    CMakeLists.txt
M  +6    -0    kcms/keyboard/CMakeLists.txt
M  +21   -2    kcms/keyboard/x11_helper.cpp

http://commits.kde.org/plasma-desktop/d5a61432ca84b7babca8b190d2590072b6705977

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9e30263..8018e70 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -74,7 +74,7 @@ set_package_properties(X11 PROPERTIES DESCRIPTION "X11 libraries"
                         PURPOSE "Required for building the X11 based workspace"
                       )
 if(X11_FOUND)
-  find_package(XCB REQUIRED COMPONENTS XCB XFIXES DAMAGE COMPOSITE SHAPE SYNC RENDER \
RANDR KEYSYMS IMAGE SHM XTEST) +  find_package(XCB REQUIRED COMPONENTS XCB XFIXES \
DAMAGE COMPOSITE SHAPE SYNC RENDER RANDR KEYSYMS IMAGE SHM XTEST XKB)  \
set_package_properties(XCB PROPERTIES TYPE REQUIRED)  find_package(XCB COMPONENTS \
ICCCM)  add_feature_info("XCB-ICCCM" XCB_ICCCM_FOUND "Required for building test \
                applications for KWin")
diff --git a/kcms/keyboard/CMakeLists.txt b/kcms/keyboard/CMakeLists.txt
index de382c5..478bace 100644
--- a/kcms/keyboard/CMakeLists.txt
+++ b/kcms/keyboard/CMakeLists.txt
@@ -48,6 +48,8 @@ target_link_libraries(kded_keyboard
     KF5::Plasma
     KF5::XmlGui
     KF5::KDE4Support
+    XCB::XCB
+    XCB::XKB
     ${X11_LIBRARIES}
     ${X11_Xkbfile_LIB}
  )
@@ -106,6 +108,8 @@ target_link_libraries(keyboard_layout_widget
     KF5::I18n
     KF5::Service
     KF5::Plasma
+    XCB::XCB
+    XCB::XKB
     KF5::KDE4Support
     ${X11_LIBRARIES}
     ${X11_Xkbfile_LIB}
@@ -157,6 +161,8 @@ target_link_libraries(kcm_keyboard
     KF5::WindowSystem
     KF5::Plasma
     KF5::XmlGui
+    XCB::XCB
+    XCB::XKB
     KF5::KDE4Support
     ${X11_Xkbfile_LIB}
     ${X11_LIBRARIES}
diff --git a/kcms/keyboard/x11_helper.cpp b/kcms/keyboard/x11_helper.cpp
index de9f768..7790902 100644
--- a/kcms/keyboard/x11_helper.cpp
+++ b/kcms/keyboard/x11_helper.cpp
@@ -18,6 +18,10 @@
 
 #include "x11_helper.h"
 
+#define explicit explicit_is_keyword_in_cpp
+#include <xcb/xkb.h>
+#undef explicit
+
 #include <kdebug.h>
 
 #include <QX11Info>
@@ -29,7 +33,6 @@
 #include <X11/XKBlib.h>
 #include <X11/extensions/XKBrules.h>
 #include <xcb/xcb.h>
-//#include <xcb/xkb.h>
 #include <fixx11h.h>
 
 
@@ -191,7 +194,23 @@ QList<LayoutUnit> X11Helper::getLayoutsList()
 
 bool X11Helper::setGroup(unsigned int group)
 {
-	return XkbLockGroup(QX11Info::display(), XkbUseCoreKbd, group);
+    qDebug() << group;
+    xcb_void_cookie_t cookie;
+    cookie = xcb_xkb_latch_lock_state(QX11Info::connection(),
+        XCB_XKB_ID_USE_CORE_KBD,
+        0, 0,
+        1,
+        group,
+        0, 0, 0
+    );
+    xcb_generic_error_t *error = nullptr;
+    error = xcb_request_check(QX11Info::connection(), cookie);
+    if (error) {
+        qDebug() << "Couldn't change the group" << error->error_code;
+        return false;
+    }
+
+    return true;
 }
 
 unsigned int X11Helper::getGroup()


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic