diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2019-01-16 07:45:07 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2019-01-16 07:49:13 +0100 |
commit | d091350a69198ef0a00ca89b5ebb504de639f893 (patch) | |
tree | 76b29b301867a29a9d0e31b380ca2e5ffa781610 | |
parent | 3deda2b045ebbcbeaebc55bf9e631f65cc4bf1bc (diff) |
compat/check-visible: fix off-by-one
The case `x+1 + w-1` and similar are wrong.
-rw-r--r-- | compat/check-visible.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/compat/check-visible.cpp b/compat/check-visible.cpp index 1212ab90..f786ca14 100644 --- a/compat/check-visible.cpp +++ b/compat/check-visible.cpp @@ -38,15 +38,15 @@ void set_is_visible(const QWidget& w, bool force) if (RECT r; GetWindowRect(hwnd, &r)) { - const int x = r.left+1, y = r.top+1; - const int w = r.right - x - 1, h = r.bottom - y - 1; + const int x = r.left, y = r.top; + const int w = r.right - x, h = r.bottom - y; const POINT xs[] { - { x + w, y }, - { x, y + h }, - { x + w, h + y }, - { x, y }, - { x + w/2, y + h/2 }, + { x + w - 1, y + 1 }, + { x + 1, y + h - 1 }, + { x + w - 1, y + h - 1 }, + { x + 1, y + 1 }, + { x + w/2, y + h/2 }, }; visible = false; @@ -54,6 +54,7 @@ void set_is_visible(const QWidget& w, bool force) for (const POINT& pt : xs) if (WindowFromPoint(pt) == hwnd) { + visible = true; break; } @@ -69,7 +70,7 @@ void set_is_visible(const QWidget& w, bool force) void set_is_visible(const QWidget& w, bool) { - spinlock_guard l(lock); + QMutexLocker l(&lock); visible = !(w.isHidden() || w.windowState() & Qt::WindowMinimized); } |