summaryrefslogtreecommitdiffhomepage
path: root/gui/ui.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-12-20 18:04:33 +0100
committerStanislaw Halik <sthalik@misaki.pl>2015-12-20 18:17:38 +0100
commit057fe1752477bdaafd2c9ec15f88b750083aff38 (patch)
treebf609051e350e5683232088d93574be7c6e3d35d /gui/ui.cpp
parentc88d7897eec259ea7c649467e01590a08faa2dcb (diff)
gui: don't update main window if we're minimized
Shaves off 12% runtime in minimized case.
Diffstat (limited to 'gui/ui.cpp')
-rw-r--r--gui/ui.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/gui/ui.cpp b/gui/ui.cpp
index c19e4840..31bce40b 100644
--- a/gui/ui.cpp
+++ b/gui/ui.cpp
@@ -122,6 +122,8 @@ MainWindow::MainWindow() :
register_shortcuts();
+ connect(this, &MainWindow::emit_minimized, this, &MainWindow::mark_minimized, Qt::QueuedConnection);
+
ui.btnStartTracker->setFocus();
}
@@ -419,6 +421,9 @@ void MainWindow::set_title(const QString& game_title_)
void MainWindow::showHeadPose()
{
+ if (!ui.video_frame->isEnabled())
+ return;
+
double mapped[6], raw[6];
work->tracker->get_raw_and_mapped_poses(mapped, raw);
@@ -548,15 +553,28 @@ void MainWindow::restore_from_tray(QSystemTrayIcon::ActivationReason)
void MainWindow::changeEvent(QEvent* e)
{
- if (s.tray_enabled && e->type() == QEvent::WindowStateChange && (windowState() & Qt::WindowMinimized))
+ if (e->type() == QEvent::WindowStateChange)
{
- if (!tray)
- ensure_tray();
- hide();
+ const bool is_minimized = windowState() & Qt::WindowMinimized;
+
+ if (s.tray_enabled && is_minimized)
+ {
+ if (!tray)
+ ensure_tray();
+ hide();
+ }
+
+ emit_minimized(is_minimized);
}
+
QMainWindow::changeEvent(e);
}
+void MainWindow::mark_minimized(bool is_minimized)
+{
+ ui.video_frame->setEnabled(!is_minimized);
+}
+
void MainWindow::maybe_start_profile_from_executable()
{
if (!work)