57
57
namespace ads
58
58
{
59
59
#ifdef Q_OS_WIN
60
+ #if 0 // set to 1 if you need this function for debugging
60
61
/**
61
62
* Just for debuging to convert windows message identifiers to strings
62
63
*/
@@ -350,6 +351,7 @@ static const char* windowsMessageString(int MessageId)
350
351
return "unknown WM_ message";
351
352
}
352
353
#endif
354
+ #endif
353
355
354
356
355
357
static unsigned int zOrderCounter = 0 ;
@@ -713,7 +715,6 @@ bool CFloatingDockContainer::nativeEvent(const QByteArray &eventType, void *mess
713
715
if (d->isState (DraggingMousePressed))
714
716
{
715
717
ADS_PRINT (" CFloatingDockContainer::nativeEvent WM_ENTERSIZEMOVE" << e->type ());
716
- qApp->installEventFilter (this );
717
718
d->setState (DraggingFloatingWidget);
718
719
d->updateDropOverlays (QCursor::pos ());
719
720
}
@@ -722,8 +723,15 @@ bool CFloatingDockContainer::nativeEvent(const QByteArray &eventType, void *mess
722
723
case WM_EXITSIZEMOVE:
723
724
if (d->isState (DraggingFloatingWidget))
724
725
{
725
- ADS_PRINT (" CFloatingDockContainer::nativeEvent WM_EXITSIZEMOVE" << e->type ());;
726
- d->titleMouseReleaseEvent ();
726
+ ADS_PRINT (" CFloatingDockContainer::nativeEvent WM_EXITSIZEMOVE" << e->type ());
727
+ if (GetAsyncKeyState (VK_ESCAPE) & 0x8000 )
728
+ {
729
+ d->handleEscapeKey ();
730
+ }
731
+ else
732
+ {
733
+ d->titleMouseReleaseEvent ();
734
+ }
727
735
}
728
736
break ;
729
737
}
@@ -796,43 +804,6 @@ void CFloatingDockContainer::showEvent(QShowEvent *event)
796
804
}
797
805
798
806
799
- // ============================================================================
800
- bool CFloatingDockContainer::eventFilter (QObject *watched, QEvent *e)
801
- {
802
- Q_UNUSED (watched);
803
- // I have not found a way to detect non client area key press events to
804
- // handle escape key presses. On Windows, if the escape key is pressed while
805
- // dragging around a widget, the widget position is reset to its start position
806
- // which in turn generates a QEvent::NonClientAreaMouseButtonRelease event
807
- // if the mouse is outside of the widget after the move to its initial position
808
- // or a QEvent::MouseButtonRelease event, if the mouse is inside of teh widget
809
- // after the position has been reset.
810
- // So we can install an event filter on the application to get these events
811
- // here to properly cancel dragging and hide the overlays.
812
- // If we are in DraggingFloatingWidget state, it means the widget
813
- // has been dragged already but if the position is the same like
814
- // the start position, then this is an indication that the escape
815
- // key has been pressed.
816
- if (e->type () == QEvent::MouseButtonRelease || e->type () == QEvent::NonClientAreaMouseButtonRelease)
817
- {
818
- ADS_PRINT (" CFloatingDockContainer::eventFilter QEvent::MouseButtonRelease or"
819
- " QEvent::NonClientAreaMouseButtonRelease" << " d->DragggingState " << d->DraggingState );
820
- qApp->removeEventFilter (this );
821
- if (d->DragStartPos == pos ())
822
- {
823
- d->handleEscapeKey ();
824
- return true ;
825
- }
826
- return false ;
827
- }
828
-
829
- #if (ADS_DEBUG_LEVEL > 0)
830
- qDebug () << QTime::currentTime () << " CFloatingDockContainer::eventFilter " << e->type ();
831
- #endif
832
- return false ;
833
- }
834
-
835
-
836
807
// ============================================================================
837
808
void CFloatingDockContainer::startFloating (const QPoint &DragStartMousePos,
838
809
const QSize &Size, eDragState DragState, QWidget *MouseEventHandler)
0 commit comments