Qt: Fix middle mouse button uncapture
This commit is contained in:
@@ -207,12 +207,12 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
qt_mouse_capture(mouse_capture);
|
qt_mouse_capture(mouse_capture);
|
||||||
if (mouse_capture) {
|
if (mouse_capture) {
|
||||||
this->grabKeyboard();
|
this->grabKeyboard();
|
||||||
if (ui->stackedWidget->mouse_capture)
|
if (ui->stackedWidget->mouse_capture_func)
|
||||||
ui->stackedWidget->mouse_capture(this->windowHandle());
|
ui->stackedWidget->mouse_capture_func(this->windowHandle());
|
||||||
} else {
|
} else {
|
||||||
this->releaseKeyboard();
|
this->releaseKeyboard();
|
||||||
if (ui->stackedWidget->mouse_uncapture)
|
if (ui->stackedWidget->mouse_uncapture_func)
|
||||||
ui->stackedWidget->mouse_uncapture();
|
ui->stackedWidget->mouse_uncapture_func();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -509,8 +509,8 @@ void MainWindow::closeEvent(QCloseEvent *event) {
|
|||||||
}
|
}
|
||||||
qt_nvr_save();
|
qt_nvr_save();
|
||||||
config_save();
|
config_save();
|
||||||
if (ui->stackedWidget->mouse_exit)
|
if (ui->stackedWidget->mouse_exit_func)
|
||||||
ui->stackedWidget->mouse_exit();
|
ui->stackedWidget->mouse_exit_func();
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,6 +42,7 @@ extern "C" {
|
|||||||
#include <86box/video.h>
|
#include <86box/video.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" void macos_poll_mouse();
|
||||||
extern MainWindow *main_window;
|
extern MainWindow *main_window;
|
||||||
RendererStack::RendererStack(QWidget *parent)
|
RendererStack::RendererStack(QWidget *parent)
|
||||||
: QStackedWidget(parent)
|
: QStackedWidget(parent)
|
||||||
@@ -65,30 +66,30 @@ RendererStack::RendererStack(QWidget *parent)
|
|||||||
|
|
||||||
# ifdef WAYLAND
|
# ifdef WAYLAND
|
||||||
if (!stricmp(mouse_type, "wayland")) {
|
if (!stricmp(mouse_type, "wayland")) {
|
||||||
this->mouse_init = wl_init;
|
wl_init();
|
||||||
this->mouse_poll = wl_mouse_poll;
|
this->mouse_poll_func = wl_mouse_poll;
|
||||||
this->mouse_capture = wl_mouse_capture;
|
this->mouse_capture_func = wl_mouse_capture;
|
||||||
this->mouse_uncapture = wl_mouse_uncapture;
|
this->mouse_uncapture_func = wl_mouse_uncapture;
|
||||||
} else
|
} else
|
||||||
# endif
|
# endif
|
||||||
# ifdef EVDEV_INPUT
|
# ifdef EVDEV_INPUT
|
||||||
if (!stricmp(mouse_type, "evdev")) {
|
if (!stricmp(mouse_type, "evdev")) {
|
||||||
this->mouse_init = evdev_init;
|
evdev_init();
|
||||||
this->mouse_poll = evdev_mouse_poll;
|
this->mouse_poll_func = evdev_mouse_poll;
|
||||||
} else
|
} else
|
||||||
# endif
|
# endif
|
||||||
if (!stricmp(mouse_type, "xinput2")) {
|
if (!stricmp(mouse_type, "xinput2")) {
|
||||||
extern void xinput2_init();
|
extern void xinput2_init();
|
||||||
extern void xinput2_poll();
|
extern void xinput2_poll();
|
||||||
extern void xinput2_exit();
|
extern void xinput2_exit();
|
||||||
this->mouse_init = xinput2_init;
|
xinput2_init();
|
||||||
this->mouse_poll = xinput2_poll;
|
this->mouse_poll_func = xinput2_poll;
|
||||||
this->mouse_exit = xinput2_exit;
|
this->mouse_exit_func = xinput2_exit;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __APPLE__
|
||||||
if (this->mouse_init)
|
this->mouse_poll_func = macos_poll_mouse;
|
||||||
this->mouse_init();
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
RendererStack::~RendererStack()
|
RendererStack::~RendererStack()
|
||||||
@@ -96,7 +97,6 @@ RendererStack::~RendererStack()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void macos_poll_mouse();
|
|
||||||
void
|
void
|
||||||
qt_mouse_capture(int on)
|
qt_mouse_capture(int on)
|
||||||
{
|
{
|
||||||
@@ -119,18 +119,16 @@ qt_mouse_capture(int on)
|
|||||||
void
|
void
|
||||||
RendererStack::mousePoll()
|
RendererStack::mousePoll()
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
#ifndef __APPLE__
|
||||||
return macos_poll_mouse();
|
|
||||||
#else /* !defined __APPLE__ */
|
|
||||||
mouse_x = mousedata.deltax;
|
mouse_x = mousedata.deltax;
|
||||||
mouse_y = mousedata.deltay;
|
mouse_y = mousedata.deltay;
|
||||||
mouse_z = mousedata.deltaz;
|
mouse_z = mousedata.deltaz;
|
||||||
mousedata.deltax = mousedata.deltay = mousedata.deltaz = 0;
|
mousedata.deltax = mousedata.deltay = mousedata.deltaz = 0;
|
||||||
mouse_buttons = mousedata.mousebuttons;
|
mouse_buttons = mousedata.mousebuttons;
|
||||||
|
|
||||||
if (this->mouse_poll)
|
if (this->mouse_poll_func)
|
||||||
this->mouse_poll();
|
#endif
|
||||||
#endif /* !defined __APPLE__ */
|
this->mouse_poll_func();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ignoreNextMouseEvent = 1;
|
int ignoreNextMouseEvent = 1;
|
||||||
|
@@ -64,11 +64,10 @@ public:
|
|||||||
rendererWindow->onResize(width, height);
|
rendererWindow->onResize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void (*mouse_init)() = nullptr;
|
void (*mouse_poll_func)() = nullptr;
|
||||||
void (*mouse_poll)() = nullptr;
|
void (*mouse_capture_func)(QWindow *window) = nullptr;
|
||||||
void (*mouse_capture)(QWindow *window) = nullptr;
|
void (*mouse_uncapture_func)() = nullptr;
|
||||||
void (*mouse_uncapture)() = nullptr;
|
void (*mouse_exit_func)() = nullptr;
|
||||||
void (*mouse_exit)() = nullptr;
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void blitToRenderer(int buf_idx, int x, int y, int w, int h);
|
void blitToRenderer(int buf_idx, int x, int y, int w, int h);
|
||||||
|
Reference in New Issue
Block a user