mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 19:57:11 +02:00
Mouse coordinate fix.
This commit is contained in:
parent
5bdad18ade
commit
c2cd23a54c
4 changed files with 28 additions and 6 deletions
|
@ -1166,8 +1166,7 @@ void Application::mouseMoveEvent(QMouseEvent* event, unsigned int deviceID) {
|
||||||
_seenMouseMove = true;
|
_seenMouseMove = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_mouseX = event->x();
|
setMousePosition(event, deviceID);
|
||||||
_mouseY = event->y();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {
|
void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {
|
||||||
|
@ -1181,8 +1180,7 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {
|
||||||
|
|
||||||
if (activeWindow() == _window) {
|
if (activeWindow() == _window) {
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
_mouseX = event->x();
|
setMousePosition(event, deviceID);
|
||||||
_mouseY = event->y();
|
|
||||||
_mouseDragStartedX = _mouseX;
|
_mouseDragStartedX = _mouseX;
|
||||||
_mouseDragStartedY = _mouseY;
|
_mouseDragStartedY = _mouseY;
|
||||||
_mousePressed = true;
|
_mousePressed = true;
|
||||||
|
@ -1213,8 +1211,7 @@ void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {
|
||||||
|
|
||||||
if (activeWindow() == _window) {
|
if (activeWindow() == _window) {
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
_mouseX = event->x();
|
setMousePosition(event, deviceID);
|
||||||
_mouseY = event->y();
|
|
||||||
_mousePressed = false;
|
_mousePressed = false;
|
||||||
checkBandwidthMeterClick();
|
checkBandwidthMeterClick();
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {
|
||||||
|
@ -2328,6 +2325,18 @@ int Application::sendNackPackets() {
|
||||||
return packetsSent;
|
return packetsSent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::setMousePosition(QMouseEvent* event, unsigned int deviceID) {
|
||||||
|
if (deviceID > 0) {
|
||||||
|
// simulated events are in device coordinates
|
||||||
|
_mouseX = event->x();
|
||||||
|
_mouseY = event->y();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_mouseX = _glWidget->getDeviceX(event->x());
|
||||||
|
_mouseY = _glWidget->getDeviceY(event->y());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Application::queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions) {
|
void Application::queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions) {
|
||||||
|
|
||||||
//qDebug() << ">>> inside... queryOctree()... _viewFrustum.getFieldOfView()=" << _viewFrustum.getFieldOfView();
|
//qDebug() << ">>> inside... queryOctree()... _viewFrustum.getFieldOfView()=" << _viewFrustum.getFieldOfView();
|
||||||
|
|
|
@ -435,6 +435,8 @@ private:
|
||||||
|
|
||||||
int sendNackPackets();
|
int sendNackPackets();
|
||||||
|
|
||||||
|
void setMousePosition(QMouseEvent* event, unsigned int deviceID);
|
||||||
|
|
||||||
MainWindow* _window;
|
MainWindow* _window;
|
||||||
GLCanvas* _glWidget; // our GLCanvas has a couple extra features
|
GLCanvas* _glWidget; // our GLCanvas has a couple extra features
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,14 @@ int GLCanvas::getDeviceHeight() const {
|
||||||
return height() * (windowHandle() ? windowHandle()->devicePixelRatio() : 1.0f);
|
return height() * (windowHandle() ? windowHandle()->devicePixelRatio() : 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GLCanvas::getDeviceX(int x) const {
|
||||||
|
return x * getDeviceWidth() / width();
|
||||||
|
}
|
||||||
|
|
||||||
|
int GLCanvas::getDeviceY(int y) const {
|
||||||
|
return y * getDeviceHeight() / height();
|
||||||
|
}
|
||||||
|
|
||||||
void GLCanvas::initializeGL() {
|
void GLCanvas::initializeGL() {
|
||||||
Application::getInstance()->initializeGL();
|
Application::getInstance()->initializeGL();
|
||||||
setAttribute(Qt::WA_AcceptTouchEvents);
|
setAttribute(Qt::WA_AcceptTouchEvents);
|
||||||
|
|
|
@ -26,6 +26,9 @@ public:
|
||||||
int getDeviceHeight() const;
|
int getDeviceHeight() const;
|
||||||
QSize getDeviceSize() const { return QSize(getDeviceWidth(), getDeviceHeight()); }
|
QSize getDeviceSize() const { return QSize(getDeviceWidth(), getDeviceHeight()); }
|
||||||
|
|
||||||
|
int getDeviceX(int x) const;
|
||||||
|
int getDeviceY(int y) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
QTimer _frameTimer;
|
QTimer _frameTimer;
|
||||||
|
|
Loading…
Reference in a new issue