Ignore invisible widgets when hit testing (#4873)

Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com>
This commit is contained in:
nerix
2023-10-06 23:26:25 +02:00
committed by GitHub
parent 7c8cabaa42
commit 752825793a
2 changed files with 22 additions and 12 deletions
+21 -12
View File
@@ -379,7 +379,7 @@ void BaseWindow::mousePressEvent(QMouseEvent *event)
{
std::function<bool(QWidget *)> recursiveCheckMouseTracking;
recursiveCheckMouseTracking = [&](QWidget *widget) {
if (widget == nullptr)
if (widget == nullptr || widget->isHidden())
{
return false;
}
@@ -934,19 +934,25 @@ bool BaseWindow::handleNCHITTEST(MSG *msg, long *result)
{
bool client = false;
for (QWidget *widget : this->ui_.buttons)
{
if (widget->geometry().contains(point))
{
client = true;
}
}
// Check the main layout first, as it's the largest area
if (this->ui_.layoutBase->geometry().contains(point))
{
client = true;
}
// Check the titlebar buttons
if (!client && this->ui_.titlebarBox->geometry().contains(point))
{
for (QWidget *widget : this->ui_.buttons)
{
if (widget->isVisible() &&
widget->geometry().contains(point))
{
client = true;
}
}
}
if (client)
{
*result = HTCLIENT;
@@ -959,16 +965,17 @@ bool BaseWindow::handleNCHITTEST(MSG *msg, long *result)
return true;
}
else if (this->flags_.has(FramelessDraggable))
if (this->flags_.has(FramelessDraggable))
{
*result = 0;
bool client = false;
if (auto widget = this->childAt(point))
if (auto *widget = this->childAt(point))
{
std::function<bool(QWidget *)> recursiveCheckMouseTracking;
recursiveCheckMouseTracking = [&](QWidget *widget) {
if (widget == nullptr)
if (widget == nullptr || widget->isHidden())
{
return false;
}
@@ -998,6 +1005,8 @@ bool BaseWindow::handleNCHITTEST(MSG *msg, long *result)
return true;
}
// don't handle the message
return false;
#else
return false;