diff --git a/src/FloatingDockContainer.cpp b/src/FloatingDockContainer.cpp index fa2510be..34fd4959 100644 --- a/src/FloatingDockContainer.cpp +++ b/src/FloatingDockContainer.cpp @@ -57,6 +57,7 @@ namespace ads { #ifdef Q_OS_WIN +#if 0 // set to 1 if you need this function for debugging /** * Just for debuging to convert windows message identifiers to strings */ @@ -350,6 +351,7 @@ static const char* windowsMessageString(int MessageId) return "unknown WM_ message"; } #endif +#endif static unsigned int zOrderCounter = 0; @@ -713,7 +715,6 @@ bool CFloatingDockContainer::nativeEvent(const QByteArray &eventType, void *mess if (d->isState(DraggingMousePressed)) { ADS_PRINT("CFloatingDockContainer::nativeEvent WM_ENTERSIZEMOVE" << e->type()); - qApp->installEventFilter(this); d->setState(DraggingFloatingWidget); d->updateDropOverlays(QCursor::pos()); } @@ -722,8 +723,15 @@ bool CFloatingDockContainer::nativeEvent(const QByteArray &eventType, void *mess case WM_EXITSIZEMOVE: if (d->isState(DraggingFloatingWidget)) { - ADS_PRINT("CFloatingDockContainer::nativeEvent WM_EXITSIZEMOVE" << e->type());; - d->titleMouseReleaseEvent(); + ADS_PRINT("CFloatingDockContainer::nativeEvent WM_EXITSIZEMOVE" << e->type()); + if (GetAsyncKeyState(VK_ESCAPE) & 0x8000) + { + d->handleEscapeKey(); + } + else + { + d->titleMouseReleaseEvent(); + } } break; } @@ -796,43 +804,6 @@ void CFloatingDockContainer::showEvent(QShowEvent *event) } -//============================================================================ -bool CFloatingDockContainer::eventFilter(QObject *watched, QEvent *e) -{ - Q_UNUSED(watched); - // I have not found a way to detect non client area key press events to - // handle escape key presses. On Windows, if the escape key is pressed while - // dragging around a widget, the widget position is reset to its start position - // which in turn generates a QEvent::NonClientAreaMouseButtonRelease event - // if the mouse is outside of the widget after the move to its initial position - // or a QEvent::MouseButtonRelease event, if the mouse is inside of teh widget - // after the position has been reset. - // So we can install an event filter on the application to get these events - // here to properly cancel dragging and hide the overlays. - // If we are in DraggingFloatingWidget state, it means the widget - // has been dragged already but if the position is the same like - // the start position, then this is an indication that the escape - // key has been pressed. - if (e->type() == QEvent::MouseButtonRelease || e->type() == QEvent::NonClientAreaMouseButtonRelease) - { - ADS_PRINT("CFloatingDockContainer::eventFilter QEvent::MouseButtonRelease or" - "QEvent::NonClientAreaMouseButtonRelease" << "d->DragggingState " << d->DraggingState); - qApp->removeEventFilter(this); - if (d->DragStartPos == pos()) - { - d->handleEscapeKey(); - return true; - } - return false; - } - -#if (ADS_DEBUG_LEVEL > 0) - qDebug() << QTime::currentTime() << "CFloatingDockContainer::eventFilter " << e->type(); -#endif - return false; -} - - //============================================================================ void CFloatingDockContainer::startFloating(const QPoint &DragStartMousePos, const QSize &Size, eDragState DragState, QWidget *MouseEventHandler) diff --git a/src/FloatingDockContainer.h b/src/FloatingDockContainer.h index d4cfc21a..e462a5bc 100644 --- a/src/FloatingDockContainer.h +++ b/src/FloatingDockContainer.h @@ -180,7 +180,6 @@ private slots: virtual void closeEvent(QCloseEvent *event) override; virtual void hideEvent(QHideEvent *event) override; virtual void showEvent(QShowEvent *event) override; - virtual bool eventFilter(QObject *watched, QEvent *event) override; #ifdef Q_OS_WIN /**