Windows: Change cursor clipping from cursor warping to ClipCursor(), fixes #5498.
This commit is contained in:
@@ -61,6 +61,11 @@ struct mouseinputdata {
|
|||||||
static mouseinputdata mousedata;
|
static mouseinputdata mousedata;
|
||||||
|
|
||||||
extern MainWindow *main_window;
|
extern MainWindow *main_window;
|
||||||
|
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
HWND rw_hwnd;
|
||||||
|
#endif
|
||||||
|
|
||||||
RendererStack::RendererStack(QWidget *parent, int monitor_index)
|
RendererStack::RendererStack(QWidget *parent, int monitor_index)
|
||||||
: QStackedWidget(parent)
|
: QStackedWidget(parent)
|
||||||
, ui(new Ui::RendererStack)
|
, ui(new Ui::RendererStack)
|
||||||
@@ -251,7 +256,9 @@ RendererStack::mouseMoveEvent(QMouseEvent *event)
|
|||||||
leaveEvent((QEvent *) event);
|
leaveEvent((QEvent *) event);
|
||||||
ignoreNextMouseEvent--;
|
ignoreNextMouseEvent--;
|
||||||
}
|
}
|
||||||
|
#if !defined _WIN32
|
||||||
QCursor::setPos(mapToGlobal(QPoint(width() / 2, height() / 2)));
|
QCursor::setPos(mapToGlobal(QPoint(width() / 2, height() / 2)));
|
||||||
|
#endif
|
||||||
ignoreNextMouseEvent = 2;
|
ignoreNextMouseEvent = 2;
|
||||||
oldPos = event->pos();
|
oldPos = event->pos();
|
||||||
#endif
|
#endif
|
||||||
@@ -405,8 +412,15 @@ RendererStack::createRenderer(Renderer renderer)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (current.get() == nullptr)
|
if (current.get() == nullptr) {
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
rw_hwnd = NULL;
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
rw_hwnd = (HWND) this->winId();
|
||||||
|
#endif
|
||||||
current->setFocusPolicy(Qt::NoFocus);
|
current->setFocusPolicy(Qt::NoFocus);
|
||||||
current->setFocusProxy(this);
|
current->setFocusProxy(this);
|
||||||
current->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
current->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
#include "qt_mainwindow.hpp"
|
#include "qt_mainwindow.hpp"
|
||||||
#include "qt_machinestatus.hpp"
|
#include "qt_machinestatus.hpp"
|
||||||
@@ -122,6 +123,8 @@ plat_resize(int w, int h, int monitor_index)
|
|||||||
main_window->resizeContents(w, h);
|
main_window->resizeContents(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern HWND rw_hwnd;
|
||||||
|
|
||||||
void
|
void
|
||||||
plat_mouse_capture(int on)
|
plat_mouse_capture(int on)
|
||||||
{
|
{
|
||||||
@@ -129,6 +132,26 @@ plat_mouse_capture(int on)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
main_window->setMouseCapture(on > 0 ? true : false);
|
main_window->setMouseCapture(on > 0 ? true : false);
|
||||||
|
|
||||||
|
#if defined _WIN32
|
||||||
|
if (on) {
|
||||||
|
QCursor cursor(Qt::BlankCursor);
|
||||||
|
|
||||||
|
QApplication::setOverrideCursor(cursor);
|
||||||
|
QApplication::changeOverrideCursor(cursor);
|
||||||
|
|
||||||
|
RECT rect;
|
||||||
|
|
||||||
|
GetWindowRect(rw_hwnd, &rect);
|
||||||
|
|
||||||
|
ClipCursor(&rect);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ClipCursor(NULL);
|
||||||
|
|
||||||
|
QApplication::restoreOverrideCursor();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|||||||
@@ -395,7 +395,7 @@ WindowsRawInputFilter::mouse_handle(PRAWINPUT raw)
|
|||||||
|
|
||||||
mouse_scale(delta_x, delta_y);
|
mouse_scale(delta_x, delta_y);
|
||||||
|
|
||||||
HWND wnd = (HWND)window->winId();
|
/* HWND wnd = (HWND)window->winId();
|
||||||
|
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
|
||||||
@@ -404,5 +404,5 @@ WindowsRawInputFilter::mouse_handle(PRAWINPUT raw)
|
|||||||
int left = rect.left + (rect.right - rect.left) / 2;
|
int left = rect.left + (rect.right - rect.left) / 2;
|
||||||
int top = rect.top + (rect.bottom - rect.top) / 2;
|
int top = rect.top + (rect.bottom - rect.top) / 2;
|
||||||
|
|
||||||
SetCursorPos(left, top);
|
SetCursorPos(left, top); */
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user