summaryrefslogtreecommitdiffhomepage
path: root/opentrack/is-window-visible.hpp
blob: 300e541a1f9b1d11ec53cf883346455c3f18c51a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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