summaryrefslogtreecommitdiffhomepage
path: root/pose-widget/glwidget.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-07-21 14:26:10 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-07-23 11:05:33 +0200
commit6a0ead2849c9e0dc3bbefeecf3e36d4f187624ae (patch)
tree7d6e7549d214a56f60a66185242c2d1834995267 /pose-widget/glwidget.cpp
parent9fec162fd5ac3f94850653c63f45ed0a83c5a9d0 (diff)
pose-widget: don't display when window hidden
When the opentrack window isn't displayed (minimized or hidden by some other window), don't bother with refreshing the image.
Diffstat (limited to 'pose-widget/glwidget.cpp')
-rw-r--r--pose-widget/glwidget.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp
index 5de26eef..b9aec303 100644
--- a/pose-widget/glwidget.cpp
+++ b/pose-widget/glwidget.cpp
@@ -6,13 +6,14 @@
*/
#include "glwidget.h"
+#include "opentrack/is-window-visible.hpp"
+#include "opentrack-compat/pi-constant.hpp"
#include <cmath>
#include <algorithm>
-
#include <QPainter>
#include <QPaintEvent>
-GLWidget::GLWidget(QWidget *parent) : QWidget(parent)
+GLWidget::GLWidget(QWidget *parent) : QWidget(parent), visible(true)
{
Q_INIT_RESOURCE(posewidget);
@@ -25,7 +26,8 @@ GLWidget::~GLWidget()
{
}
-void GLWidget::paintEvent ( QPaintEvent * event ) {
+void GLWidget::paintEvent (QPaintEvent * event)
+{
QPainter p(this);
project_quad_texture();
p.drawImage(event->rect(), image);
@@ -33,6 +35,15 @@ void GLWidget::paintEvent ( QPaintEvent * event ) {
void GLWidget::rotateBy(float xAngle, float yAngle, float zAngle, float x, float y, float z)
{
+ if (visible_timer.elapsed_ms() > 2000)
+ {
+ visible = is_window_visible(this);
+ visible_timer.start();
+ }
+
+ if (!visible)
+ return;
+
using std::sin;
using std::cos;