billiob pushed a commit to branch master. http://git.enlightenment.org/apps/terminology.git/commit/?id=b09a70f04d8f0f0a6c5ca10da6be40d9ca2a23c2
commit b09a70f04d8f0f0a6c5ca10da6be40d9ca2a23c2 Author: Boris Faure <[email protected]> Date: Wed Feb 13 23:21:32 2019 +0100 termptyext: clean up modifiers parsing --- src/bin/termptyext.c | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/bin/termptyext.c b/src/bin/termptyext.c index fba13f3..69360bc 100644 --- a/src/bin/termptyext.c +++ b/src/bin/termptyext.c @@ -93,6 +93,25 @@ _tytest_arg_get(const Eina_Unicode *buf, int *value) * - ISO_Level3_Shift * - AltGr */ +static int +_tytest_modifiers_get(const Eina_Unicode *buf, Termio_Modifiers *m) +{ + Termio_Modifiers modifier = {}; + int value = 0; + int len = _tytest_arg_get(buf, &value); + + modifier.alt = !!(value & (1 << 0)); + modifier.shift = !!(value & (1 << 1)); + modifier.ctrl = !!(value & (1 << 2)); + modifier.super = !!(value & (1 << 3)); + modifier.meta = !!(value & (1 << 4)); + modifier.hyper = !!(value & (1 << 5)); + modifier.iso_level3_shift = !!(value & (1 << 6)); + modifier.altgr = !!(value & (1 << 7)); + + *m = modifier; + return len; +} /** * FLAGS can be: @@ -127,14 +146,7 @@ _handle_mouse_down(Termpty *ty, buf += _tytest_arg_get(buf, &value); ev.button = value; /* MODIFIERS */ - value = 0; - buf += _tytest_arg_get(buf, &value); - union { - Termio_Modifiers m; - uint8_t u; - } u; - u.u = value; - modifiers = u.m; + buf += _tytest_modifiers_get(buf, &modifiers); /* FLAGS */ value = 0; buf +=_tytest_arg_get(buf, &value); @@ -168,14 +180,7 @@ _handle_mouse_up(Termpty *ty, buf += _tytest_arg_get(buf, &value); ev.button = value; /* MODIFIERS */ - value = 0; - buf += _tytest_arg_get(buf, &value); - union { - Termio_Modifiers m; - uint8_t u; - } u; - u.u = value; - modifiers = u.m; + buf += _tytest_modifiers_get(buf, &modifiers); /* FLAGS */ value = 0; buf +=_tytest_arg_get(buf, &value); @@ -205,14 +210,7 @@ _handle_mouse_move(Termpty *ty, buf += _tytest_arg_get(buf, &value); ev.cur.canvas.y = value; /* MODIFIERS */ - value = 0; - buf += _tytest_arg_get(buf, &value); - union { - Termio_Modifiers m; - uint8_t u; - } u; - u.u = value; - modifiers = u.m; + buf += _tytest_modifiers_get(buf, &modifiers); termio_internal_mouse_move(sd, &ev, modifiers); } --
