From 2f4f8bcc74b4b70311197c837f54cd567511dff6 Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Tue, 13 Aug 2024 21:38:39 +0200 Subject: [PATCH] Add IsCursorInWidgetArea() --- lib/utils/ui-helpers.cpp | 8 ++++++++ lib/utils/ui-helpers.hpp | 2 ++ 2 files changed, 10 insertions(+) diff --git a/lib/utils/ui-helpers.cpp b/lib/utils/ui-helpers.cpp index 3a91c3cc..f7f5bb02 100644 --- a/lib/utils/ui-helpers.cpp +++ b/lib/utils/ui-helpers.cpp @@ -160,4 +160,12 @@ void QeueUITask(void (*task)(void *param), void *param) obs_queue_task(OBS_TASK_UI, task, param, false); } +bool IsCursorInWidgetArea(QWidget *widget) +{ + const auto cursorPos = QCursor::pos(); + const auto widgetPos = widget->mapFromGlobal(cursorPos); + const auto widgetRect = widget->rect(); + return widgetRect.contains(widgetPos); +} + } // namespace advss diff --git a/lib/utils/ui-helpers.hpp b/lib/utils/ui-helpers.hpp index 89742946..62bcf503 100644 --- a/lib/utils/ui-helpers.hpp +++ b/lib/utils/ui-helpers.hpp @@ -33,4 +33,6 @@ EXPORT std::string GetThemeTypeName(); void QeueUITask(void (*task)(void *param), void *param); +bool IsCursorInWidgetArea(QWidget *widget); + } // namespace advss