summaryrefslogtreecommitdiffhomepage
path: root/opentrack/is-window-visible.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-07-21 20:06:22 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-07-23 11:05:33 +0200
commitd613381a46c281d6f96c5b6079b625e85d450ab4 (patch)
tree44258a8bc831cef3a3a16985c1e67717c26f0cc6 /opentrack/is-window-visible.cpp
parent717b39e9bfddd6799318fc1fe2b59abd33825db3 (diff)
api/is-window-visible: move from header
Diffstat (limited to 'opentrack/is-window-visible.cpp')
-rw-r--r--opentrack/is-window-visible.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/opentrack/is-window-visible.cpp b/opentrack/is-window-visible.cpp
new file mode 100644
index 00000000..fc25bb7d
--- /dev/null
+++ b/opentrack/is-window-visible.cpp
@@ -0,0 +1,33 @@
+#include "is-window-visible.hpp"
+#include <QPoint>
+
+#ifdef _WIN32
+
+#include <windows.h>
+
+OPENTRACK_API_EXPORT bool is_window_visible(const QWidget* widget)
+{
+ const QPoint p = widget->mapToGlobal(QPoint(0, 0));
+ const QSize s = widget->size();
+
+ const POINT points[] =
+ {
+ { p.x(), p.y() },
+ { p.x() + s.width(), p.y() },
+ { p.x() + s.width(), p.y() + s.height() },
+ { p.x(), p.y() + s.height() },
+ { p.x() + s.width()/2, p.y() + s.height()/2 },
+ };
+
+ for (const POINT& pt : points)
+ if (WindowFromPoint(pt) == (HWND) widget->winId())
+ return true;
+ return false;
+}
+
+#else
+OPENTRACK_API_EXPORT bool is_window_visible(const QWidget* widget)
+{
+ return true;
+}
+#endif