mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 06:10:52 +02:00
Check if our main window is our application window within Application's event handling functions.
This commit is contained in:
parent
51340452df
commit
7cefa3fe7b
1 changed files with 301 additions and 301 deletions
|
@ -104,40 +104,28 @@ void GLCanvas::resizeGL(int width, int height) {
|
|||
}
|
||||
|
||||
void GLCanvas::keyPressEvent(QKeyEvent* event) {
|
||||
if (Application::activeWindow() != 0) {
|
||||
Application::getInstance()->keyPressEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void GLCanvas::keyReleaseEvent(QKeyEvent* event) {
|
||||
if (Application::activeWindow() != 0) {
|
||||
Application::getInstance()->keyReleaseEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void GLCanvas::mouseMoveEvent(QMouseEvent* event) {
|
||||
if (Application::activeWindow() != 0) {
|
||||
Application::getInstance()->mouseMoveEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void GLCanvas::mousePressEvent(QMouseEvent* event) {
|
||||
if (Application::activeWindow() != 0) {
|
||||
Application::getInstance()->mousePressEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void GLCanvas::mouseReleaseEvent(QMouseEvent* event) {
|
||||
if (Application::activeWindow() != 0) {
|
||||
Application::getInstance()->mouseReleaseEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void GLCanvas::wheelEvent(QWheelEvent* event) {
|
||||
if (Application::activeWindow() != 0) {
|
||||
Application::getInstance()->wheelEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||
QApplication(argc, argv),
|
||||
|
@ -433,6 +421,7 @@ static void sendVoxelServerAddScene() {
|
|||
}
|
||||
|
||||
void Application::keyPressEvent(QKeyEvent* event) {
|
||||
if (activeWindow() == _window) {
|
||||
if (_chatEntryOn) {
|
||||
if (_chatEntry.keyPressEvent(event)) {
|
||||
_myAvatar.setKeyState(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete ?
|
||||
|
@ -638,8 +627,10 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Application::keyReleaseEvent(QKeyEvent* event) {
|
||||
if (activeWindow() == _window) {
|
||||
if (_chatEntryOn) {
|
||||
_myAvatar.setKeyState(NO_KEY_DOWN);
|
||||
return;
|
||||
|
@ -695,8 +686,10 @@ void Application::keyReleaseEvent(QKeyEvent* event) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Application::mouseMoveEvent(QMouseEvent* event) {
|
||||
if (activeWindow() == _window) {
|
||||
_mouseX = event->x();
|
||||
_mouseY = event->y();
|
||||
|
||||
|
@ -711,8 +704,10 @@ void Application::mouseMoveEvent(QMouseEvent* event) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Application::mousePressEvent(QMouseEvent* event) {
|
||||
if (activeWindow() == _window) {
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
_mouseX = event->x();
|
||||
_mouseY = event->y();
|
||||
|
@ -723,16 +718,20 @@ void Application::mousePressEvent(QMouseEvent* event) {
|
|||
deleteVoxelUnderCursor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Application::mouseReleaseEvent(QMouseEvent* event) {
|
||||
if (activeWindow() == _window) {
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
_mouseX = event->x();
|
||||
_mouseY = event->y();
|
||||
_mousePressed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Application::wheelEvent(QWheelEvent* event) {
|
||||
if (activeWindow() == _window) {
|
||||
if (checkedVoxelModeAction() == 0) {
|
||||
event->ignore();
|
||||
return;
|
||||
|
@ -743,6 +742,7 @@ void Application::wheelEvent(QWheelEvent* event) {
|
|||
decreaseVoxelSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Every second, check the frame rates and other stuff
|
||||
void Application::timer() {
|
||||
|
@ -888,7 +888,7 @@ void Application::idle() {
|
|||
|
||||
// Update from Mouse
|
||||
if (_mouseLook->isChecked()) {
|
||||
QPoint mouse = QPoint(_mouseX, _mouseY);
|
||||
QPoint mouse(_mouseX, _mouseY);
|
||||
_myAvatar.updateFromMouse(_glWidget->mapFromGlobal(mouse).x(),
|
||||
_glWidget->mapFromGlobal(mouse).y(),
|
||||
_glWidget->width(),
|
||||
|
|
Loading…
Reference in a new issue