From 754ae1a54132eb41332267fc70a42595017c5a6e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 16 Jul 2016 23:44:31 +0200 Subject: 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. --- opentrack/is-window-visible.hpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 opentrack/is-window-visible.hpp (limited to 'opentrack') 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 +#include +#include +#include + +template +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 +bool is_window_visible(const QWidget* widget) { return true; } +#endif -- cgit v1.2.3