diff options
| author | Andre Weissflog <floooh@gmail.com> | 2020-09-22 19:24:51 +0200 |
|---|---|---|
| committer | Andre Weissflog <floooh@gmail.com> | 2020-09-22 19:24:51 +0200 |
| commit | 12cfb6e9ff0b4fd6f23326ea91e0ecb9737e6db0 (patch) | |
| tree | 9e9db0b04102b4c355fad595d907418105048e9f | |
| parent | fcacc89864793f5cc571f23e909a6a246a8718a3 (diff) | |
sokol_app.h linux: don't send mouse enter/leave events while buttons are pressed
| -rw-r--r-- | sokol_app.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sokol_app.h b/sokol_app.h index e7def8d7..437ca993 100644 --- a/sokol_app.h +++ b/sokol_app.h @@ -1605,6 +1605,7 @@ typedef struct { } _sapp_xi_t; typedef struct { + uint8_t mouse_buttons; Display* display; int screen; Window root; @@ -8035,6 +8036,7 @@ _SOKOL_PRIVATE void _sapp_x11_process_event(XEvent* event) { const uint32_t mods = _sapp_x11_mod(event->xbutton.state); if (btn != SAPP_MOUSEBUTTON_INVALID) { _sapp_x11_mouse_event(SAPP_EVENTTYPE_MOUSE_DOWN, btn, mods); + _sapp.x11.mouse_buttons |= (1 << btn); } else { /* might be a scroll event */ @@ -8052,14 +8054,20 @@ _SOKOL_PRIVATE void _sapp_x11_process_event(XEvent* event) { const sapp_mousebutton btn = _sapp_x11_translate_button(event); if (btn != SAPP_MOUSEBUTTON_INVALID) { _sapp_x11_mouse_event(SAPP_EVENTTYPE_MOUSE_UP, btn, _sapp_x11_mod(event->xbutton.state)); + _sapp.x11.mouse_buttons &= ~(1 << btn); } } break; case EnterNotify: - _sapp_x11_mouse_event(SAPP_EVENTTYPE_MOUSE_ENTER, SAPP_MOUSEBUTTON_INVALID, _sapp_x11_mod(event->xcrossing.state)); + /* don't send enter/leave events while mouse button held down */ + if (0 == _sapp.x11.mouse_buttons) { + _sapp_x11_mouse_event(SAPP_EVENTTYPE_MOUSE_ENTER, SAPP_MOUSEBUTTON_INVALID, _sapp_x11_mod(event->xcrossing.state)); + } break; case LeaveNotify: - _sapp_x11_mouse_event(SAPP_EVENTTYPE_MOUSE_LEAVE, SAPP_MOUSEBUTTON_INVALID, _sapp_x11_mod(event->xcrossing.state)); + if (0 == _sapp.x11.mouse_buttons) { + _sapp_x11_mouse_event(SAPP_EVENTTYPE_MOUSE_LEAVE, SAPP_MOUSEBUTTON_INVALID, _sapp_x11_mod(event->xcrossing.state)); + } break; case MotionNotify: if (!_sapp.mouse.locked) { |