Skip to content

Commit

Permalink
feat(linux): add mouse wheel event handing for x11 (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-soft committed Jul 29, 2018
1 parent 9b4c005 commit 1061592
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/platform/linux/linux_x11mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,29 @@ static void OnMotionNotify(LCUI_Event e, void *arg)
LCUI_DestroyEvent(&sys_ev);
}

#define MOUSE_WHEEL_DELTA 20

static void OnButtonPress(LCUI_Event e, void *arg)
{
XEvent *ev = arg;
LCUI_SysEventRec sys_ev;
sys_ev.type = LCUI_MOUSEDOWN;
sys_ev.button.x = ev->xbutton.x;
sys_ev.button.y = ev->xbutton.y;
sys_ev.button.button = ev->xbutton.button;

if (ev->xbutton.button == Button4) {
sys_ev.type = LCUI_MOUSEWHEEL;
sys_ev.wheel.x = ev->xbutton.x;
sys_ev.wheel.y = ev->xbutton.y;
sys_ev.wheel.delta = MOUSE_WHEEL_DELTA;
} else if (ev->xbutton.button == Button5) {
sys_ev.type = LCUI_MOUSEWHEEL;
sys_ev.wheel.x = ev->xbutton.x;
sys_ev.wheel.y = ev->xbutton.y;
sys_ev.wheel.delta = -MOUSE_WHEEL_DELTA;
} else {
sys_ev.type = LCUI_MOUSEDOWN;
sys_ev.button.x = ev->xbutton.x;
sys_ev.button.y = ev->xbutton.y;
sys_ev.button.button = ev->xbutton.button;
}
LCUI_TriggerEvent(&sys_ev, NULL);
LCUI_DestroyEvent(&sys_ev);
}
Expand Down

0 comments on commit 1061592

Please sign in to comment.