summaryrefslogtreecommitdiffstats
path: root/kxkb
diff options
context:
space:
mode:
Diffstat (limited to 'kxkb')
-rw-r--r--kxkb/CMakeLists.txt3
-rw-r--r--kxkb/kcmmisc.cpp22
2 files changed, 24 insertions, 1 deletions
diff --git a/kxkb/CMakeLists.txt b/kxkb/CMakeLists.txt
index 703591ad3..f36a003bd 100644
--- a/kxkb/CMakeLists.txt
+++ b/kxkb/CMakeLists.txt
@@ -22,6 +22,7 @@ include_directories(
link_directories(
${TQT_LIBRARY_DIRS}
+ ${XTEST_LIBDIR}
)
@@ -39,7 +40,7 @@ tde_add_kpart( kcm_keyboard AUTOMOC
extension.cpp x11helper.cpp rules.cpp kxkbconfig.cpp
pixmap.cpp kcmlayout.cpp kcmlayoutwidget.ui
kcmmisc.cpp kcmmiscwidget.ui
- LINK kio-shared xkbfile
+ LINK kio-shared xkbfile ${XTEST_LIBRARIES}
DESTINATION ${PLUGIN_INSTALL_DIR}
)
diff --git a/kxkb/kcmmisc.cpp b/kxkb/kcmmisc.cpp
index b4c18a483..8850d8906 100644
--- a/kxkb/kcmmisc.cpp
+++ b/kxkb/kcmmisc.cpp
@@ -344,6 +344,21 @@ int xkb_set_off()
return 1;
}
+int xkb_state()
+ {
+ unsigned int mask;
+ unsigned int numlockState;
+ XkbStateRec xkbState;
+ if( !xkb_init())
+ return 0;
+ mask = xkb_numlock_mask();
+ if( mask == 0 )
+ return 0;
+ XkbGetState( dpy, XkbUseCoreKbd, &xkbState);
+ numlockState = xkbState.locked_mods & mask;
+ return numlockState;
+ }
+
int xkb_toggle()
{
unsigned int mask;
@@ -443,7 +458,14 @@ void numlock_toggle()
return;
#endif
#ifdef HAVE_XTEST
+#ifdef HAVE_XKB
+ if (xkb_state())
+ xtest_set_on();
+ else
+ xtest_set_off();
+#else // HAVE_XKB
xtest_toggle();
+#endif // HAVE_XKB
#endif
}
// This code is taken from xset utility from XFree 4.3 (http://www.xfree86.org/)