summaryrefslogtreecommitdiffhomepage
path: root/opentrack
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-07-16 23:44:31 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-07-16 23:54:27 +0200
commit754ae1a54132eb41332267fc70a42595017c5a6e (patch)
tree78e3dc7284d396f22d69230661176218f73f18f7 /opentrack
parent16bb3e13dd2a7ed8fa3652e313d592dd81c73a07 (diff)
gui, tracker/{aruco,pt}, api: detect whether widget is visible on screen
Sadly, it's only implemented right now on win32. Remove "set enabled" code for the video widget since it only works for explicit window minimization, not covering by other windows.
Diffstat (limited to 'opentrack')
-rw-r--r--opentrack/is-window-visible.hpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/opentrack/is-window-visible.hpp b/opentrack/is-window-visible.hpp
new file mode 100644
index 00000000..300e541a
--- /dev/null
+++ b/opentrack/is-window-visible.hpp
@@ -0,0 +1,26 @@
+#ifdef _WIN32
+
+#include <windows.h>
+#include <QWidget>
+#include <QRect>
+#include <QDebug>
+
+template<typename=void>
+bool is_window_visible(const QWidget* widget)
+{
+ const QWidget* window = widget->window();
+
+ if (!window)
+ return true;
+
+ const QPoint p = widget->mapToGlobal(widget->pos());
+ const QSize s = widget->size();
+ POINT pt = { p.x() + s.width()/2, p.y() + s.height()/2 };
+
+ return WindowFromPoint(pt) == (HWND) widget->winId();
+}
+
+#else
+template<typename=void>
+bool is_window_visible(const QWidget* widget) { return true; }
+#endif