Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-02-04 11:51:01 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-02-04 11:51:01 +0400
commit0515f933d93903446c3d0ee8903e48e53c081217 (patch)
tree4446354ea5aeddb65c0fc1d56d4488ee3be3a4c8 /intern/ghost/intern/GHOST_SystemX11.cpp
parent69993c5d4089bb58758f9a190237dc4651d72d44 (diff)
fix [#33831] "Alt" key is "Alt Window Deactivated"
update to the ubuntu workaround from Shinsuke Irie.
Diffstat (limited to 'intern/ghost/intern/GHOST_SystemX11.cpp')
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp46
1 files changed, 27 insertions, 19 deletions
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 6902b2e8347..661f5e70dc6 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -77,7 +77,7 @@
// #define USE_X11_ERROR_HANDLERS
/* see [#34039] Fix Alt key glitch on Unity desktop */
-// #define USE_UNITY_WORKAROUND
+#define USE_UNITY_WORKAROUND
static GHOST_TKey convertXKey(KeySym key);
@@ -569,30 +569,38 @@ processEvents(
/* the X server generates KeymapNotify event immediately after
* every EnterNotify and FocusIn event. we handle this event
* to correct modifier states. */
- if ((xevent.type == FocusIn || xevent.type == EnterNotify)) {
+ if (xevent.type == FocusIn) {
/* use previous event's window, because KeymapNotify event
* has no window information. */
GHOST_WindowX11 *window = findGhostWindow(xevent.xany.window);
- if (window) {
+ if (window && XPending(m_display) >= 2) {
XNextEvent(m_display, &xevent);
if (xevent.type == KeymapNotify) {
- /* XK_Hyper_L/R currently unused */
- const static KeySym modifiers[8] = {XK_Shift_L, XK_Shift_R,
- XK_Control_L, XK_Control_R,
- XK_Alt_L, XK_Alt_R,
- XK_Super_L, XK_Super_R};
-
- for (int i = 0; i < (sizeof(modifiers) / sizeof(*modifiers)); i++) {
- KeyCode kc = XKeysymToKeycode(m_display, modifiers[i]);
- if (((xevent.xkeymap.key_vector[kc >> 3] >> (kc & 7)) & 1) != 0) {
- pushEvent(new GHOST_EventKey(
- getMilliSeconds(),
- GHOST_kEventKeyDown,
- window,
- convertXKey(modifiers[i]),
- '\0',
- NULL));
+ XEvent xev_next;
+
+ /* check if KeyPress or KeyRelease event was generated
+ * in order to confirm the window is active. */
+ XPeekEvent(m_display, &xev_next);
+
+ if (xev_next.type == KeyPress || xev_next.type == KeyRelease) {
+ /* XK_Hyper_L/R currently unused */
+ const static KeySym modifiers[8] = {XK_Shift_L, XK_Shift_R,
+ XK_Control_L, XK_Control_R,
+ XK_Alt_L, XK_Alt_R,
+ XK_Super_L, XK_Super_R};
+
+ for (int i = 0; i < (sizeof(modifiers) / sizeof(*modifiers)); i++) {
+ KeyCode kc = XKeysymToKeycode(m_display, modifiers[i]);
+ if (((xevent.xkeymap.key_vector[kc >> 3] >> (kc & 7)) & 1) != 0) {
+ pushEvent(new GHOST_EventKey(
+ getMilliSeconds(),
+ GHOST_kEventKeyDown,
+ window,
+ convertXKey(modifiers[i]),
+ '\0',
+ NULL));
+ }
}
}
}