diff options
Diffstat (limited to 'opentrack/is-window-visible.hpp')
-rw-r--r-- | opentrack/is-window-visible.hpp | 38 |
1 files changed, 3 insertions, 35 deletions
diff --git a/opentrack/is-window-visible.hpp b/opentrack/is-window-visible.hpp index fa6aeb53..18c9251a 100644 --- a/opentrack/is-window-visible.hpp +++ b/opentrack/is-window-visible.hpp @@ -1,39 +1,7 @@ -#ifdef _WIN32 +#pragma once -#include <windows.h> #include <QWidget> -#include <QRect> -#include <QDebug> -#include <QPoint> -#include <initializer_list> +#include "export.hpp" -template<typename=void> -bool is_window_visible(const QWidget* widget) -{ - const QWidget* window = widget->window(); +OPENTRACK_API_EXPORT bool is_window_visible(const QWidget* widget); - if (!window) - return true; - - const QPoint p = widget->mapToGlobal(QPoint(0, 0)); - const QSize s = widget->size(); - - 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 -template<typename=void> -bool is_window_visible(const QWidget* widget) { return true; } -#endif |