Merge pull request #4968 from TheBombSquad/linux-mouse-fixes
Linux mouse fixes
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -62,3 +62,6 @@ CMakeLists.txt.user
|
|||||||
|
|
||||||
# clangd
|
# clangd
|
||||||
.cache
|
.cache
|
||||||
|
|
||||||
|
# Jetbrains CLion
|
||||||
|
.idea
|
||||||
|
|||||||
@@ -200,10 +200,14 @@ RendererStack::mousePressEvent(QMouseEvent *event)
|
|||||||
void
|
void
|
||||||
RendererStack::wheelEvent(QWheelEvent *event)
|
RendererStack::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
|
if (!mouse_capture) {
|
||||||
|
event->ignore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
double numSteps = (double) event->angleDelta().y() / 120.0;
|
double numSteps = (double) event->angleDelta().y() / 120.0;
|
||||||
|
|
||||||
mouse_set_z((int) numSteps);
|
mouse_set_z((int) numSteps);
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ xinput2_proc()
|
|||||||
XGenericEventCookie *cookie = (XGenericEventCookie *) &ev.xcookie;
|
XGenericEventCookie *cookie = (XGenericEventCookie *) &ev.xcookie;
|
||||||
XNextEvent(disp, (XEvent *) &ev);
|
XNextEvent(disp, (XEvent *) &ev);
|
||||||
|
|
||||||
if (XGetEventData(disp, cookie) && (cookie->type == GenericEvent) && (cookie->extension == xi2opcode)) {
|
if (XGetEventData(disp, cookie) && (cookie->type == GenericEvent) && (cookie->extension == xi2opcode) && mouse_capture) {
|
||||||
const XIRawEvent *rawev = (const XIRawEvent *) cookie->data;
|
const XIRawEvent *rawev = (const XIRawEvent *) cookie->data;
|
||||||
double coords[2] = { 0.0 };
|
double coords[2] = { 0.0 };
|
||||||
|
|
||||||
@@ -214,8 +214,6 @@ common_motion:
|
|||||||
}
|
}
|
||||||
|
|
||||||
prev_time = rawev->time;
|
prev_time = rawev->time;
|
||||||
if (!mouse_capture)
|
|
||||||
break;
|
|
||||||
XWindowAttributes winattrib {};
|
XWindowAttributes winattrib {};
|
||||||
if (XGetWindowAttributes(disp, main_window->winId(), &winattrib)) {
|
if (XGetWindowAttributes(disp, main_window->winId(), &winattrib)) {
|
||||||
auto globalPoint = main_window->mapToGlobal(QPoint(main_window->width() / 2, main_window->height() / 2));
|
auto globalPoint = main_window->mapToGlobal(QPoint(main_window->width() / 2, main_window->height() / 2));
|
||||||
|
|||||||
Reference in New Issue
Block a user