summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-02-19 11:57:48 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-02-19 13:28:43 +0000
commit47d4b0a9a476eb41a4472c5f2bb64040044f0e8a (patch)
tree7bed53c0b0023a668f013e3ce9322c04c12b7093 /src
parent3cdb053571a755672cb49b259b9fac91b708cf43 (diff)
Fix modifier key handling in input aspect
Relying on Alt press/releases has the annoying side effect that some systems (X11) will not give a KeyRelease for Alt when pressing Alt+Tab. It is better to handle such keys based on the modifier state. This avoids getting into an "Alt is stuck" situation when switching back to the application's window. Change-Id: I8e1675d9d4093e162fe0e42a2def26737d7a7467 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/input/cameracontroller.cpp19
1 files changed, 3 insertions, 16 deletions
diff --git a/src/input/cameracontroller.cpp b/src/input/cameracontroller.cpp
index 379b2c41a..27f8988ae 100644
--- a/src/input/cameracontroller.cpp
+++ b/src/input/cameracontroller.cpp
@@ -161,6 +161,9 @@ void CameraController::update(double dt)
bool CameraController::keyPressEvent( QKeyEvent* e )
{
+ m_translateFast = e->modifiers().testFlag(Qt::AltModifier);
+ m_viewCenterFixed = e->modifiers().testFlag(Qt::ShiftModifier);
+
switch ( e->key() )
{
case Qt::Key_Right:
@@ -187,14 +190,6 @@ bool CameraController::keyPressEvent( QKeyEvent* e )
m_vy = -m_linearSpeed;
break;
- case Qt::Key_Shift:
- m_viewCenterFixed = true;
- break;
-
- case Qt::Key_Alt:
- m_translateFast = true;
- break;
-
case Qt::Key_A:
toggleMSAA();
break;
@@ -225,14 +220,6 @@ bool CameraController::keyReleaseEvent( QKeyEvent* e )
m_vy = 0.0;
break;
- case Qt::Key_Shift:
- m_viewCenterFixed = false;
- break;
-
- case Qt::Key_Alt:
- m_translateFast = false;
- break;
-
default:
return false;
}