summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-07-21 14:30:09 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-07-23 11:05:33 +0200
commit72f7a1b07d393e6cfdbac1ecb168a703919fd03e (patch)
tree50f8140ca7d8da526b0496d0d10a26bb9ecfa303
parent79b283bfe9efc3bca1ff84ad3d5065f01a6d385c (diff)
api/is-window-visible: check for more window positions
Having the window center invisible making the feed not refresh is confusing. Also check for all the corners.
-rw-r--r--opentrack/is-window-visible.hpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/opentrack/is-window-visible.hpp b/opentrack/is-window-visible.hpp
index 300e541a..fa6aeb53 100644
--- a/opentrack/is-window-visible.hpp
+++ b/opentrack/is-window-visible.hpp
@@ -4,6 +4,8 @@
#include <QWidget>
#include <QRect>
#include <QDebug>
+#include <QPoint>
+#include <initializer_list>
template<typename=void>
bool is_window_visible(const QWidget* widget)
@@ -13,11 +15,22 @@ bool is_window_visible(const QWidget* widget)
if (!window)
return true;
- const QPoint p = widget->mapToGlobal(widget->pos());
+ const QPoint p = widget->mapToGlobal(QPoint(0, 0));
const QSize s = widget->size();
- POINT pt = { p.x() + s.width()/2, p.y() + s.height()/2 };
- return WindowFromPoint(pt) == (HWND) widget->winId();
+ const std::initializer_list<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