From: Michael D. Lowis Date: Wed, 24 May 2017 20:24:12 +0000 (-0400) Subject: updated button tracking code to accurately reflect button state X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=0c4034ca64ec81648a668388e791d5e730b4e92a;p=projs%2Ftide.git updated button tracking code to accurately reflect button state --- diff --git a/lib/win.c b/lib/win.c index 0f2ac7b..f6cfc62 100644 --- a/lib/win.c +++ b/lib/win.c @@ -53,8 +53,7 @@ static bool update_focus(void) { int ptr_x, ptr_y; bool changed = false; /* dont change focus if any mouse buttons are pressed */ - if ((x11_keybtnstate() & 0x1f00) == 0) - { + if ((x11_keybtnstate() & 0x1f00) == 0) { x11_mouse_get(&ptr_x, &ptr_y); if (prev_x != ptr_x || prev_y != ptr_y) changed = win_setregion(getregion(ptr_x, ptr_y)); diff --git a/lib/x11.c b/lib/x11.c index 2c89062..38d3dc1 100644 --- a/lib/x11.c +++ b/lib/x11.c @@ -280,16 +280,17 @@ static void handle_key(XEvent* event) { } static void handle_mouse(XEvent* e) { - int x = 0, y = 0; + KeyBtnState = e->xbutton.state; + int x = e->xbutton.x; + int y = e->xbutton.y; + if (e->type == MotionNotify) { - KeyBtnState = e->xmotion.state; - x = e->xmotion.x; - y = e->xmotion.y; Config->mouse_drag(KeyBtnState, x, y); } else { - KeyBtnState = e->xbutton.state; - x = e->xbutton.x; - y = e->xbutton.y; + if (e->type == ButtonRelease) + KeyBtnState &= ~(1 << (e->xbutton.button + 7)); + else + KeyBtnState |= (1 << (e->xbutton.button + 7)); Config->mouse_btn(e->xbutton.button, (e->type == ButtonPress), x, y); } }