[ooo-build-commit] .: patches/dev300
Kohei Yoshida
kohei at kemper.freedesktop.org
Mon Mar 1 11:40:00 PST 2010
patches/dev300/apply | 1
patches/dev300/autocorrect-accidental-caps-lock-vcl-xkb.diff | 90 +++++++++++
2 files changed, 91 insertions(+)
New commits:
commit 4436133104a77953a12b846f5be6eade8094344f
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Mon Mar 1 14:36:50 2010 -0500
Re-implemented auto caps lock toggling without using XTest API.
* patches/dev300/apply:
* patches/dev300/autocorrect-accidental-caps-lock-vcl-xkb.diff: let's
not use XTest API to toggle caps lock key, since using it can cause
the logical and physical states of the keyboard LEDs to go out of
sync. (n#394949)
diff --git a/patches/dev300/apply b/patches/dev300/apply
index 9e0aab7..ea8dcbb 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -2521,6 +2521,7 @@ autocorrect-accidental-caps-lock-sc.diff
autocorrect-accidental-caps-lock-sw.diff
autocorrect-accidental-caps-lock-svx.diff
autocorrect-accidental-caps-lock-vcl.diff
+autocorrect-accidental-caps-lock-vcl-xkb.diff
# cbosdo01 cws: add non breaking spaces before :;?! in french text
cws-cbosdo01.diff, cbosdo
diff --git a/patches/dev300/autocorrect-accidental-caps-lock-vcl-xkb.diff b/patches/dev300/autocorrect-accidental-caps-lock-vcl-xkb.diff
new file mode 100644
index 0000000..cfd544b
--- /dev/null
+++ b/patches/dev300/autocorrect-accidental-caps-lock-vcl-xkb.diff
@@ -0,0 +1,90 @@
+diff --git vcl/unx/source/app/saldisp.cxx vcl/unx/source/app/saldisp.cxx
+index 8ef3762..cbcb0e6 100644
+--- vcl/unx/source/app/saldisp.cxx
++++ vcl/unx/source/app/saldisp.cxx
+@@ -60,7 +60,7 @@
+ #define XK_KOREAN
+ #endif
+ #include <X11/keysym.h>
+-
++#include <X11/XKBlib.h>
+ #include <X11/Xatom.h>
+
+ #ifdef USE_XINERAMA
+@@ -81,12 +81,6 @@ Status XineramaGetInfo(Display*, int, XRectangle*, unsigned char*, int*);
+ #endif
+ #endif
+
+-#if __XTestExtension__
+-#include <X11/extensions/XTest.h>
+-#include <X11/extensions/XKB.h>
+-#include <X11/XKBlib.h>
+-#endif
+-
+ #include <tools/postx.h>
+
+ #include <salunx.h>
+@@ -1052,16 +1046,58 @@ void SalDisplay::Beep() const
+ // Keyboard
+ // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
++namespace {
++
++bool InitXkb(Display* dpy)
++{
++ int nOpcode, nEvent, nError;
++ int nXkbMajor = XkbMajorVersion;
++ int nXkbMinor = XkbMinorVersion;
++
++ if (!XkbLibraryVersion(&nXkbMajor, &nXkbMinor))
++ return false;
++
++ return XkbQueryExtension(
++ dpy, &nOpcode, &nEvent, &nError, &nXkbMajor, &nXkbMinor);
++}
++
++unsigned int GetKeySymMask(Display* dpy, KeySym nKeySym)
++{
++ int nMask = 0;
++ XModifierKeymap* pXmkMap = XGetModifierMapping(dpy);
++ KeyCode nKeyCode = XKeysymToKeycode(dpy, nKeySym);
++ if (nKeyCode == NoSymbol)
++ return 0;
++
++ for (int i = 0; i < 8; ++i)
++ {
++ KeyCode nThisKeyCode = pXmkMap->modifiermap[pXmkMap->max_keypermod*i];
++ if (nThisKeyCode == nKeyCode)
++ nMask = 1 << i;
++ }
++ XFreeModifiermap(pXmkMap);
++ return nMask;
++}
++
++}
++
+ void SalDisplay::SimulateKeyPress( USHORT nKeyCode )
+ {
+-#if __XTestExtension__
+ if (nKeyCode == KEY_CAPSLOCK)
+ {
+- XLIB_KeyCode keyCaps = XKeysymToKeycode(GetDisplay(), XK_Caps_Lock);
+- if (XTestFakeKeyEvent(GetDisplay(), keyCaps, true, CurrentTime))
+- XTestFakeKeyEvent(GetDisplay(), keyCaps, false, CurrentTime);
++ Display* dpy = GetDisplay();
++ if (!InitXkb(dpy))
++ return;
++
++ unsigned int nMask = GetKeySymMask(dpy, XK_Caps_Lock);
++ XkbStateRec xkbState;
++ XkbGetState(dpy, XkbUseCoreKbd, &xkbState);
++ unsigned int nCapsLockState = xkbState.locked_mods & nMask;
++ if (nCapsLockState)
++ XkbLockModifiers (dpy, XkbUseCoreKbd, nMask, 0);
++ else
++ XkbLockModifiers (dpy, XkbUseCoreKbd, nMask, nMask);
+ }
+-#endif
+ }
+
+ USHORT SalDisplay::GetIndicatorState() const
More information about the ooo-build-commit
mailing list