Support mouse wheel events
Emitting button/press release events on buttons 4 to 7 to emulate the vertical and horizontal scrolling.
This commit is contained in:
parent
5d3aa8e7cf
commit
cef62541ce
1 changed files with 21 additions and 3 deletions
|
@ -169,9 +169,27 @@ static void pointerHandleAxis(void *data, wl_pointer *pointer, uint32_t time, ui
|
|||
Q_UNUSED(data)
|
||||
Q_UNUSED(pointer)
|
||||
Q_UNUSED(time)
|
||||
Q_UNUSED(axis)
|
||||
Q_UNUSED(value)
|
||||
// TODO: implement mouse wheel support
|
||||
uint8_t xButton = 0;
|
||||
const int delta = wl_fixed_to_int(value);
|
||||
if (delta == 0) {
|
||||
return;
|
||||
}
|
||||
switch (axis) {
|
||||
case WL_POINTER_AXIS_VERTICAL_SCROLL:
|
||||
xButton = delta > 0 ? XCB_BUTTON_INDEX_5 : XCB_BUTTON_INDEX_4;
|
||||
break;
|
||||
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
|
||||
// no enum values defined for buttons larger than 5
|
||||
xButton = delta > 0 ? 7 : 6;
|
||||
break;
|
||||
default:
|
||||
// doesn't exist
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < qAbs(delta); ++i) {
|
||||
xcb_test_fake_input(connection(), XCB_BUTTON_PRESS, xButton, XCB_TIME_CURRENT_TIME, XCB_WINDOW_NONE, 0, 0, 0);
|
||||
xcb_test_fake_input(connection(), XCB_BUTTON_RELEASE, xButton, XCB_TIME_CURRENT_TIME, XCB_WINDOW_NONE, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void keyboardHandleKeymap(void *data, wl_keyboard *keyboard,
|
||||
|
|
Loading…
Reference in a new issue