summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-07-28 16:23:55 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-07-28 16:23:55 +0200
commit7a60015ba99125b493d1cb85afc072bcebb97681 (patch)
treec161b23b42e46cac98093f8cb0940fe35c42e0a1 /gui
parent720026a79cd6aa33c4180f2241425cdd8829b36b (diff)
gui: don't update the main window if it's hidden
Diffstat (limited to 'gui')
-rw-r--r--gui/main-window.cpp29
-rw-r--r--gui/main-window.hpp1
2 files changed, 30 insertions, 0 deletions
diff --git a/gui/main-window.cpp b/gui/main-window.cpp
index 225d0629..49de59d1 100644
--- a/gui/main-window.cpp
+++ b/gui/main-window.cpp
@@ -12,6 +12,8 @@
#include "opentrack-library-path.h"
#include "new_file_dialog.h"
#include "migration/migration.hpp"
+#include "compat/check-visible.hpp"
+
#include <QFile>
#include <QFileDialog>
#include <QDesktopServices>
@@ -561,6 +563,11 @@ void MainWindow::set_title(const QString& game_title_)
void MainWindow::showHeadPose()
{
+ set_is_visible(*this);
+
+ if (!check_is_visible())
+ return;
+
double mapped[6], raw[6];
work->tracker->raw_and_mapped_pose(mapped, raw);
@@ -840,6 +847,28 @@ void MainWindow::closeEvent(QCloseEvent*)
exit();
}
+bool MainWindow::event(QEvent* event)
+{
+ using t = QEvent::Type;
+
+ if (work)
+ {
+ switch (event->type())
+ {
+ case t::Show:
+ case t::Hide:
+ case t::WindowActivate:
+ case t::WindowDeactivate:
+ case t::WindowStateChange:
+ set_is_visible(*this, true);
+ /*FALLTHROUGH*/
+ default:
+ break;
+ }
+ }
+ return QMainWindow::event(event);
+}
+
bool MainWindow::is_tray_enabled()
{
return s.tray_enabled && QSystemTrayIcon::isSystemTrayAvailable();
diff --git a/gui/main-window.hpp b/gui/main-window.hpp
index d49be9c1..02e65d4c 100644
--- a/gui/main-window.hpp
+++ b/gui/main-window.hpp
@@ -95,6 +95,7 @@ class MainWindow : public QMainWindow, private State
void changeEvent(QEvent* e) override;
void closeEvent(QCloseEvent*) override;
+ bool event(QEvent *event) override;
bool maybe_hide_to_tray(QEvent* e);
// only use in impl file since no definition in header!