From 50a84eb32dbb236f8f05babb84d2f3b70d525065 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 21 Jul 2013 18:07:09 +0200 Subject: x11: add key modifiers to mouse button events --- video/out/x11_common.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/video/out/x11_common.c b/video/out/x11_common.c index 528ecd77f9..23ed91ba73 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -687,6 +687,20 @@ static void update_vo_size(struct vo *vo) } } +static int get_mods(unsigned int state) +{ + int modifiers = 0; + if (state & ShiftMask) + modifiers |= MP_KEY_MODIFIER_SHIFT; + if (state & ControlMask) + modifiers |= MP_KEY_MODIFIER_CTRL; + if (state & Mod1Mask) + modifiers |= MP_KEY_MODIFIER_ALT; + if (state & Mod4Mask) + modifiers |= MP_KEY_MODIFIER_META; + return modifiers; +} + int vo_x11_check_events(struct vo *vo) { struct vo_x11_state *x11 = vo->x11; @@ -712,17 +726,9 @@ int vo_x11_check_events(struct vo *vo) case KeyPress: { char buf[100]; KeySym keySym = 0; - int modifiers = 0; + int modifiers = get_mods(Event.xkey.state); if (x11->no_autorepeat) modifiers |= MP_KEY_STATE_DOWN; - if (Event.xkey.state & ShiftMask) - modifiers |= MP_KEY_MODIFIER_SHIFT; - if (Event.xkey.state & ControlMask) - modifiers |= MP_KEY_MODIFIER_CTRL; - if (Event.xkey.state & Mod1Mask) - modifiers |= MP_KEY_MODIFIER_ALT; - if (Event.xkey.state & Mod4Mask) - modifiers |= MP_KEY_MODIFIER_META; if (x11->xic) { Status status; int len = Xutf8LookupString(x11->xic, &Event.xkey, buf, @@ -760,13 +766,13 @@ int vo_x11_check_events(struct vo *vo) break; case ButtonPress: mp_input_put_key(vo->input_ctx, - (MP_MOUSE_BTN0 + Event.xbutton.button - 1) - | MP_KEY_STATE_DOWN); + (MP_MOUSE_BTN0 + Event.xbutton.button - 1) | + get_mods(Event.xbutton.state) | MP_KEY_STATE_DOWN); break; case ButtonRelease: mp_input_put_key(vo->input_ctx, - (MP_MOUSE_BTN0 + Event.xbutton.button - 1) - | MP_KEY_STATE_UP); + (MP_MOUSE_BTN0 + Event.xbutton.button - 1) | + get_mods(Event.xbutton.state) | MP_KEY_STATE_UP); break; case PropertyNotify: { char *name = XGetAtomName(display, Event.xproperty.atom); -- cgit v1.2.3