[MPlayer-cvslog] r34389 - trunk/libvo/x11_common.c

reimar subversion at mplayerhq.hu
Sun Dec 4 14:30:54 CET 2011


Author: reimar
Date: Sun Dec  4 14:30:54 2011
New Revision: 34389

Log:
Add workaround for CTRL key getting stuck for X11 backend
due to the KeyRelease event going somewhere else.

Modified:
   trunk/libvo/x11_common.c

Modified: trunk/libvo/x11_common.c
==============================================================================
--- trunk/libvo/x11_common.c	Sun Dec  4 00:08:03 2011	(r34388)
+++ trunk/libvo/x11_common.c	Sun Dec  4 14:30:54 2011	(r34389)
@@ -812,6 +812,7 @@ int vo_x11_check_events(Display * mydisp
     char buf[100];
     KeySym keySym;
     static XComposeStatus stat;
+    static int ctrl_state;
 
     if (vo_mouse_autohide && mouse_waiting_hide &&
                                  (GetTimerMS() - mouse_timer >= 1000)) {
@@ -858,11 +859,22 @@ int vo_x11_check_events(Display * mydisp
                         ((keySym & 0xff00) !=
                          0 ? ((keySym & 0x00ff) + 256) : (keySym));
                     if (key == wsLeftCtrl || key == wsRightCtrl) {
+                        ctrl_state = Event.type == KeyPress;
                         mplayer_put_key(KEY_CTRL |
-                            (Event.type == KeyPress ? MP_KEY_DOWN : 0));
+                            (ctrl_state ? MP_KEY_DOWN : 0));
                     } else if (Event.type == KeyRelease) {
                         break;
-                    } else if (!vo_x11_putkey_ext(keySym)) {
+                    }
+                    // Attempt to fix if somehow our state got out of
+                    // sync with reality.
+                    // This usually happens when a shortcut involving CTRL
+                    // was used to switch to a different window/workspace.
+                    if (ctrl_state != !!(Event.xkey.state & 4)) {
+                        ctrl_state = !!(Event.xkey.state & 4);
+                        mplayer_put_key(KEY_CTRL |
+                            (ctrl_state ? MP_KEY_DOWN : 0));
+                    }
+                    if (!vo_x11_putkey_ext(keySym)) {
                         vo_x11_putkey(key);
                     }
                     ret |= VO_EVENT_KEYPRESS;


More information about the MPlayer-cvslog mailing list