Mercurial > mplayer.hg
changeset 34301:d3488ac22468
Add workaround for CTRL key getting stuck for X11 backend
due to the KeyRelease event going somewhere else.
author | reimar |
---|---|
date | Sun, 04 Dec 2011 13:30:54 +0000 |
parents | 77976b68285b |
children | 945ef73454c4 |
files | libvo/x11_common.c |
diffstat | 1 files changed, 14 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libvo/x11_common.c Sat Dec 03 23:08:03 2011 +0000 +++ b/libvo/x11_common.c Sun Dec 04 13:30:54 2011 +0000 @@ -812,6 +812,7 @@ 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 @@ ((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;