fix(issue-350): on RedHat/CentOS, sometimes there will be one more move event after user release their mouse which will cause the floating overlay can not be hide. Here we use the WindowActivate and WindowDeactivate event to check whether user release their mouse. (#401)

This commit is contained in:
ruffianhy 2022-03-14 04:22:07 +08:00 committed by GitHub
parent 6a1ea6c7de
commit ad06241c9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -1239,12 +1239,12 @@ void CFloatingDockContainer::resizeEvent(QResizeEvent *event)
Super::resizeEvent(event); Super::resizeEvent(event);
} }
static bool s_mousePressed = false;
//============================================================================ //============================================================================
void CFloatingDockContainer::moveEvent(QMoveEvent *event) void CFloatingDockContainer::moveEvent(QMoveEvent *event)
{ {
Super::moveEvent(event); Super::moveEvent(event);
if (!d->IsResizing && event->spontaneous()) if (!d->IsResizing && event->spontaneous() && s_mousePressed)
{ {
d->DraggingState = DraggingFloatingWidget; d->DraggingState = DraggingFloatingWidget;
d->updateDropOverlays(QCursor::pos()); d->updateDropOverlays(QCursor::pos());
@ -1252,6 +1252,23 @@ void CFloatingDockContainer::moveEvent(QMoveEvent *event)
d->IsResizing = false; d->IsResizing = false;
} }
//============================================================================
bool CFloatingDockContainer::event(QEvent *e)
{
bool result = Super::event(e);
switch (e->type())
{
case QEvent::WindowActivate:
s_mousePressed = false;
break;
case QEvent::WindowDeactivate:
s_mousePressed = true;
break;
default:
break;
}
return result;
}
//============================================================================ //============================================================================
bool CFloatingDockContainer::hasNativeTitleBar() bool CFloatingDockContainer::hasNativeTitleBar()

View File

@ -188,6 +188,7 @@ protected: // reimplements QWidget
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
virtual void moveEvent(QMoveEvent *event) override; virtual void moveEvent(QMoveEvent *event) override;
virtual void resizeEvent(QResizeEvent *event) override; virtual void resizeEvent(QResizeEvent *event) override;
virtual bool event(QEvent *e) override;
#endif #endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN