Skip to content

Commit 7f58877

Browse files
UweUwe
authored andcommitted
Added FloatingWidgetDragStartEvent to hide AutoHideContainer if user drags floating widget
1 parent b50e201 commit 7f58877

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

src/AutoHideDockContainer.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ void CAutoHideDockContainer::setSize(int Size)
471471
//============================================================================
472472
bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
473473
{
474-
if (event->type() == QEvent::Resize)
474+
if (event->type() == QEvent::Resize)
475475
{
476476
if (!d->ResizeHandle->isResizing())
477477
{
@@ -539,6 +539,10 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event)
539539
collapseView(true);
540540
}
541541
}
542+
else if (event->type() == internal::FloatingWidgetDragStartEvent)
543+
{
544+
collapseView(true);
545+
}
542546

543547
return Super::eventFilter(watched, event);
544548
}

src/FloatingDockContainer.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,13 @@ struct FloatingDockContainerPrivate
406406

407407
void setState(eDragState StateId)
408408
{
409+
auto OldState = DraggingState;
409410
DraggingState = StateId;
411+
if (DraggingInactive == OldState && DraggingFloatingWidget == DraggingState)
412+
{
413+
qDebug() << "Start dragging floating widget " << internal::FloatingWidgetDragStartEvent;
414+
qApp->postEvent(DockManager, new QEvent((QEvent::Type)internal::FloatingWidgetDragStartEvent));
415+
}
410416
}
411417

412418
void setWindowTitle(const QString &Text)
@@ -1281,12 +1287,13 @@ void CFloatingDockContainer::moveEvent(QMoveEvent *event)
12811287
Super::moveEvent(event);
12821288
if (!d->IsResizing && event->spontaneous() && s_mousePressed)
12831289
{
1284-
d->DraggingState = DraggingFloatingWidget;
1290+
d->setState(DraggingFloatingWidget);
12851291
d->updateDropOverlays(QCursor::pos());
12861292
}
12871293
d->IsResizing = false;
12881294
}
12891295

1296+
12901297
//============================================================================
12911298
bool CFloatingDockContainer::event(QEvent *e)
12921299
{

src/ads_globals.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ namespace internal
5353
#ifdef Q_OS_LINUX
5454
static QString _window_manager;
5555
static QHash<QString, xcb_atom_t> _xcb_atom_cache;
56+
const int FloatingWidgetDragStartEvent = QEvent::registerEventType();
5657

5758

5859
//============================================================================

src/ads_globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ static const bool RestoreTesting = true;
151151
static const bool Restore = false;
152152
static const char* const ClosedProperty = "close";
153153
static const char* const DirtyProperty = "dirty";
154+
extern const int FloatingWidgetDragStartEvent;
154155

155156
#ifdef Q_OS_LINUX
156157
// Utils to directly communicate with the X server

0 commit comments

Comments
 (0)