@@ -978,6 +978,109 @@ void CFloatingDockContainer::finishDragging()
978
978
d->titleMouseReleaseEvent ();
979
979
}
980
980
981
+
982
+ #ifdef Q_OS_MACOS
983
+ // ============================================================================
984
+ bool CFloatingDockContainer::event (QEvent *e)
985
+ {
986
+ switch (d->DraggingState )
987
+ {
988
+ case DraggingInactive:
989
+ {
990
+ // Normally we would check here, if the left mouse button is pressed.
991
+ // But from QT version 5.12.2 on the mouse events from
992
+ // QEvent::NonClientAreaMouseButtonPress return the wrong mouse button
993
+ // The event always returns Qt::RightButton even if the left button
994
+ // is clicked.
995
+ // It is really great to work around the whole NonClientMouseArea
996
+ // bugs
997
+ #if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 2))
998
+ if (e->type () == QEvent::NonClientAreaMouseButtonPress /* && QGuiApplication::mouseButtons().testFlag(Qt::LeftButton)*/ )
999
+ #else
1000
+ if (e->type () == QEvent::NonClientAreaMouseButtonPress && QGuiApplication::mouseButtons ().testFlag (Qt::LeftButton))
1001
+ #endif
1002
+ {
1003
+ ADS_PRINT (" FloatingWidget::event Event::NonClientAreaMouseButtonPress" << e->type ());
1004
+ d->DragStartPos = pos ();
1005
+ d->setState (DraggingMousePressed);
1006
+ }
1007
+ }
1008
+ break ;
1009
+
1010
+ case DraggingMousePressed:
1011
+ switch (e->type ())
1012
+ {
1013
+ case QEvent::NonClientAreaMouseButtonDblClick:
1014
+ ADS_PRINT (" FloatingWidget::event QEvent::NonClientAreaMouseButtonDblClick" );
1015
+ d->setState (DraggingInactive);
1016
+ break ;
1017
+
1018
+ case QEvent::Resize:
1019
+ // If the first event after the mouse press is a resize event, then
1020
+ // the user resizes the window instead of dragging it around.
1021
+ // But there is one exception. If the window is maximized,
1022
+ // then dragging the window via title bar will cause the widget to
1023
+ // leave the maximized state. This in turn will trigger a resize event.
1024
+ // To know, if the resize event was triggered by user via moving a
1025
+ // corner of the window frame or if it was caused by a windows state
1026
+ // change, we check, if we are not in maximized state.
1027
+ if (!isMaximized ())
1028
+ {
1029
+ d->setState (DraggingInactive);
1030
+ }
1031
+ break ;
1032
+
1033
+ default :
1034
+ break ;
1035
+ }
1036
+ break ;
1037
+
1038
+ case DraggingFloatingWidget:
1039
+ if (e->type () == QEvent::NonClientAreaMouseButtonRelease)
1040
+ {
1041
+ ADS_PRINT (" FloatingWidget::event QEvent::NonClientAreaMouseButtonRelease" );
1042
+ d->titleMouseReleaseEvent ();
1043
+ }
1044
+ break ;
1045
+
1046
+ default :
1047
+ break ;
1048
+ }
1049
+
1050
+ #if (ADS_DEBUG_LEVEL > 0)
1051
+ qDebug () << QTime::currentTime () << " CFloatingDockContainer::event " << e->type ();
1052
+ #endif
1053
+ return QWidget::event (e);
1054
+ }
1055
+
1056
+
1057
+ // ============================================================================
1058
+ void CFloatingDockContainer::moveEvent (QMoveEvent *event)
1059
+ {
1060
+ QWidget::moveEvent (event);
1061
+ switch (d->DraggingState )
1062
+ {
1063
+ case DraggingMousePressed:
1064
+ d->setState (DraggingFloatingWidget);
1065
+ d->updateDropOverlays (QCursor::pos ());
1066
+ break ;
1067
+
1068
+ case DraggingFloatingWidget:
1069
+ d->updateDropOverlays (QCursor::pos ());
1070
+ // In OSX when hiding the DockAreaOverlay the application would set
1071
+ // the main window as the active window for some reason. This fixes
1072
+ // that by resetting the active window to the floating widget after
1073
+ // updating the overlays.
1074
+ QApplication::setActiveWindow (this );
1075
+ break ;
1076
+ default :
1077
+ break ;
1078
+ }
1079
+
1080
+
1081
+ }
1082
+ #endif
1083
+
981
1084
} // namespace ads
982
1085
983
1086
// ---------------------------------------------------------------------------
0 commit comments