Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Tooltip parenting on Windows #5040

Merged
merged 4 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions src/widgets/TooltipWidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class TooltipWidget : public BaseWindow
Q_OBJECT

public:
/// @param parent The parent of this widget.
/// If this widget is a window, use tooltipParentFor().
Nerixyz marked this conversation as resolved.
Show resolved Hide resolved
/// Remember to delete the widget!
///
/// @see tooltipParentFor()
TooltipWidget(BaseWidget *parent);
~TooltipWidget() override = default;

Expand Down Expand Up @@ -73,4 +78,18 @@ class TooltipWidget : public BaseWindow
pajlada::Signals::SignalHolder connections_;
};

#ifdef Q_OS_WIN
template <typename T>
inline constexpr T *tooltipParentFor(T * /*desiredParent*/)
{
return nullptr;
}
#else
template <typename T>
inline constexpr T *tooltipParentFor(T *desiredParent)
{
return desiredParent;
}
#endif

} // namespace chatterino
7 changes: 6 additions & 1 deletion src/widgets/helper/ChannelView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ ChannelView::ChannelView(InternalCtor /*tag*/, QWidget *parent, Split *split,
, highlightAnimation_(this)
, context_(context)
, messages_(messagesLimit)
, tooltipWidget_(new TooltipWidget(this))
, tooltipWidget_(new TooltipWidget(tooltipParentFor(this)))
{
this->setMouseTracking(true);

Expand Down Expand Up @@ -356,6 +356,11 @@ ChannelView::ChannelView(InternalCtor /*tag*/, QWidget *parent, Split *split,
this->signalHolder_);
}

ChannelView::~ChannelView()
{
this->tooltipWidget_->deleteLater();
}

void ChannelView::initializeLayout()
{
this->goToBottom_ = new EffectLabel(this, 0);
Expand Down
7 changes: 7 additions & 0 deletions src/widgets/helper/ChannelView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ class ChannelView final : public BaseWidget
Context context = Context::None,
size_t messagesLimit = 1000);

~ChannelView() override;

ChannelView(const ChannelView &) = delete;
ChannelView(ChannelView &&) = delete;
ChannelView &operator=(const ChannelView &) = delete;
ChannelView &operator=(ChannelView &&) = delete;

void queueUpdate();
Scrollbar &getScrollBar();

Expand Down
7 changes: 6 additions & 1 deletion src/widgets/splits/SplitHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ namespace chatterino {
SplitHeader::SplitHeader(Split *split)
: BaseWidget(split)
, split_(split)
, tooltipWidget_(new TooltipWidget(this))
, tooltipWidget_(new TooltipWidget(tooltipParentFor(this)))
{
this->initializeLayout();

Expand Down Expand Up @@ -259,6 +259,11 @@ SplitHeader::SplitHeader(Split *split)
getSettings()->headerUptime.connect(_, this->managedConnections_);
}

SplitHeader::~SplitHeader()
{
this->tooltipWidget_->deleteLater();
}

void SplitHeader::initializeLayout()
{
assert(this->layout() == nullptr);
Expand Down
6 changes: 6 additions & 0 deletions src/widgets/splits/SplitHeader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ class SplitHeader final : public BaseWidget

public:
explicit SplitHeader(Split *split);
~SplitHeader() override;

SplitHeader(const SplitHeader &) = delete;
SplitHeader(SplitHeader &&) = delete;
SplitHeader &operator=(const SplitHeader &) = delete;
SplitHeader &operator=(SplitHeader &&) = delete;

void setAddButtonVisible(bool value);
void setChattersButtonVisible(bool value);
Expand Down
Loading