summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
Diffstat (limited to 'compat')
-rw-r--r--compat/check-visible.cpp47
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;
}
}