diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2018-12-28 02:07:50 +0100 | 
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-12-28 02:07:50 +0100 | 
| commit | 9a11ce772cacea29e31a399059e25f93c14f6dcc (patch) | |
| tree | b15bf8261df18f3fa1679f543e359d24ac89ce09 /compat | |
| parent | c70bad117607af272f5b96a05d938830c286645b (diff) | |
compat/check-visible: really fix this time
Diffstat (limited to 'compat')
| -rw-r--r-- | compat/check-visible.cpp | 47 | 
1 files changed, 28 insertions, 19 deletions
| diff --git a/compat/check-visible.cpp b/compat/check-visible.cpp index 9afdbb76..4cdb1b46 100644 --- a/compat/check-visible.cpp +++ b/compat/check-visible.cpp @@ -3,12 +3,14 @@  #if defined _WIN32  #include "timer.hpp" +#include "math.hpp"  #include <QMutex> +#include <QDebug>  #include <windows.h> -constexpr int visible_timeout = 5000; +constexpr int visible_timeout = 1000;  constexpr int invisible_timeout = 250;  static Timer timer; @@ -23,27 +25,34 @@ void set_is_visible(const QWidget& w, bool force)          return;      timer.start(); +    HWND hwnd = (HWND)w.winId(); -    HWND id = (HWND) w.winId(); -    const QPoint pt = w.mapToGlobal({ 0, 0 }); -    const QPoint pt2 = w.mapToGlobal({ w.width(), w.height() }); - -    const int W = pt2.x(), H = pt2.y(); - -    const QPoint points[] = +    if (RECT r; GetWindowRect(hwnd, &r))      { -        pt, -        pt + QPoint(W - 1, 0), -        pt + QPoint(0, H - 1), -        pt + QPoint(W - 1, H - 1), -        pt + QPoint(W / 2, H / 2), -    }; - -    for (const QPoint& pt : points) +        const int x = r.left+1, y = r.top+1; +        const int w = r.right - x - 1, h = r.bottom - y - 1; + +        const POINT xs[] { +            { x + w, y }, +            { x, y + h }, +            { x + w, h + y }, +            { x, y }, +            { x + w/2, y + h/2 }, +        }; + +        visible = false; + +        for (const POINT& pt : xs) +            if (WindowFromPoint(pt) == hwnd) +            { +                visible = true; +                break; +            } +    } +    else      { -        visible = WindowFromPoint({ pt.x(), pt.y() }) == id; -        if (visible) -            break; +        eval_once(qDebug() << "check-visible: GetWindowRect failed"); +        visible = true;      }  } | 
