Skip to content

Commit

Permalink
x11 wheel event
Browse files Browse the repository at this point in the history
  • Loading branch information
Try committed Feb 27, 2023
1 parent 1f19640 commit ed685f8
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions Engine/system/api/x11api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,30 +441,24 @@ void X11Api::implProcessEvents(SystemApi::AppCallBack &cb) {
break;
case ButtonPress:
case ButtonRelease: {
bool isWheel = false;
if( xev.type==ButtonPress && XPending(dpy) &&
(xev.xbutton.button == Button4 || xev.xbutton.button == Button5) ){
XEvent ev;
XNextEvent(dpy, &ev);
isWheel = (ev.type==ButtonRelease);
}

if( isWheel ){
if(xev.xbutton.button==Button4 || xev.xbutton.button==Button5) {
int ticks = 0;
if( xev.xbutton.button == Button4 ) {
ticks = 120;
}
else if ( xev.xbutton.button == Button5 ) {
ticks = -120;
}
Tempest::MouseEvent e( xev.xbutton.x,
xev.xbutton.y,
Tempest::Event::ButtonNone,
Event::M_NoModifier,
ticks,
0,
Event::MouseWheel );
SystemApi::dispatchMouseWheel(cb, e);
if(xev.type==ButtonPress) {
Tempest::MouseEvent e( xev.xbutton.x,
xev.xbutton.y,
Tempest::Event::ButtonNone,
Event::M_NoModifier,
ticks,
0,
Event::MouseWheel );
SystemApi::dispatchMouseWheel(cb, e);
}
} else {
MouseEvent e( xev.xbutton.x,
xev.xbutton.y,
Expand Down

0 comments on commit ed685f8

Please sign in to comment.