From 485fc5cdb4c474274ea0fcb6184d38a092628539 Mon Sep 17 00:00:00 2001 From: nerix Date: Mon, 25 Dec 2023 18:17:25 +0100 Subject: [PATCH] fix: Tooltip parenting on Windows (#5040) Fixes #5019 --- CHANGELOG.md | 2 +- src/widgets/TooltipWidget.cpp | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f9599002..b8a047e7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,7 +54,7 @@ - Bugfix: Fixed some windows appearing between screens. (#4797) - Bugfix: Fixed a crash that could occur when using certain features in a Usercard after closing the split from which it was created. (#5034) - Bugfix: Fixed a crash that could occur when using certain features in a Reply popup after closing the split from which it was created. (#5036) -- Bugfix: Fixed a bug on Wayland where tooltips would spawn as separate windows instead of behaving like tooltips. (#4998) +- Bugfix: Fixed a bug on Wayland where tooltips would spawn as separate windows instead of behaving like tooltips. (#4998, #5040) - Bugfix: Fixes to section deletion in text input fields. (#5013) - Bugfix: Show user text input within watch streak notices. (#5029) - Dev: Run miniaudio in a separate thread, and simplify it to not manage the device ourselves. There's a chance the simplification is a bad idea. (#4978) diff --git a/src/widgets/TooltipWidget.cpp b/src/widgets/TooltipWidget.cpp index aa4894a8f..7738d3eae 100644 --- a/src/widgets/TooltipWidget.cpp +++ b/src/widgets/TooltipWidget.cpp @@ -10,13 +10,34 @@ // number of columns in grid mode #define GRID_NUM_COLS 3 +namespace { + +#ifdef Q_OS_WIN +template +inline constexpr T *tooltipParentFor(T * /*desiredParent*/) +{ + return nullptr; +} +#else +template +inline constexpr T *tooltipParentFor(T *desiredParent) +{ + return desiredParent; +} +#endif + +} // namespace + namespace chatterino { TooltipWidget::TooltipWidget(BaseWidget *parent) : BaseWindow({BaseWindow::TopMost, BaseWindow::DontFocus, BaseWindow::DisableLayoutSave}, - parent) + tooltipParentFor(parent)) { + assert(parent != nullptr); + QObject::connect(parent, &QObject::destroyed, this, &QObject::deleteLater); + this->setStyleSheet("color: #fff; background: rgba(11, 11, 11, 0.8)"); this->setAttribute(Qt::WA_TranslucentBackground); this->setWindowFlag(Qt::WindowStaysOnTopHint, true);