summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-12-29 17:19:47 +0100
committerStanislaw Halik <sthalik@misaki.pl>2019-01-16 07:48:19 +0100
commita36b1129f21760513e5ab4f0f3f984b820132979 (patch)
tree813902eb300ca7f4661b2bc4cfa79144e1ef9082
parent54d738ae4762298f0a8b8926da33b0eb4c37ea5b (diff)
compat/check-visible: add generic impl
-rw-r--r--compat/check-visible.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/compat/check-visible.cpp b/compat/check-visible.cpp
index 0a759a3e..2772c9ae 100644
--- a/compat/check-visible.cpp
+++ b/compat/check-visible.cpp
@@ -1,27 +1,35 @@
#include "check-visible.hpp"
-#include "macros.hpp"
-#include "timer.hpp"
-#include "spinlock.hpp"
-
#include <QWidget>
#include <QDebug>
-constexpr int visible_timeout = 1000;
-constexpr int invisible_timeout = 250;
+#include "spinlock.hpp"
-static Timer timer;
static std::atomic_flag lock = ATOMIC_FLAG_INIT;
static bool visible = true;
#if defined _WIN32
+#include "timer.hpp"
+#include "macros.hpp"
+
+static Timer timer;
+
+constexpr int visible_timeout = 1000;
+constexpr int invisible_timeout = 250;
+
#include <windows.h>
void set_is_visible(const QWidget& w, bool force)
{
spinlock_guard l(lock);
+ if (w.isHidden() || w.windowState() & Qt::WindowMinimized)
+ {
+ visible = false;
+ return;
+ }
+
HWND hwnd = (HWND)w.winId();
if (!force && timer.elapsed_ms() < (visible ? visible_timeout : invisible_timeout))
@@ -60,12 +68,10 @@ void set_is_visible(const QWidget& w, bool force)
#else
-void set_is_visible(const QWidget&, bool)
-{
-}
-
-void check_is_visible(bool)
+void set_is_visible(const QWidget& w, bool)
{
+ spinlock_guard l(lock);
+ visible = !(w.isHidden() || w.windowState() & Qt::WindowMinimized);
}
#endif
@@ -81,4 +87,3 @@ void force_is_visible(bool value)
spinlock_guard l(lock);
visible = value;
}
-