@@ -411,7 +411,8 @@ struct FloatingDockContainerPrivate
411
411
void setWindowTitle (const QString &Text)
412
412
{
413
413
#ifdef Q_OS_LINUX
414
- if (TitleBar){
414
+ if (TitleBar)
415
+ {
415
416
TitleBar->setTitle (Text);
416
417
}
417
418
#endif
@@ -610,24 +611,40 @@ CFloatingDockContainer::CFloatingDockContainer(CDockManager *DockManager) :
610
611
QDockWidget::setFloating (true );
611
612
QDockWidget::setFeatures (QDockWidget::AllDockWidgetFeatures);
612
613
613
- // KDE doesn't seem to fire MoveEvents while moving windows, so for now no native titlebar for everything using KWin.
614
- QString window_manager = internal::windowManager ().toUpper ().split (" " )[0 ];
615
- bool native_window = window_manager != " KWIN" ;
614
+ bool native_window = true ;
615
+
616
616
// FloatingContainerForce*TitleBar is overwritten by the "ADS_UseNativeTitle" environment variable if set.
617
617
auto env = qgetenv (" ADS_UseNativeTitle" ).toUpper ();
618
- if (env == " 1" ){
618
+ if (env == " 1" )
619
+ {
619
620
native_window = true ;
620
- } else if (env == " 0" ){
621
+ }
622
+ else if (env == " 0" )
623
+ {
621
624
native_window = false ;
622
- } else if ( DockManager->testConfigFlag ( CDockManager::FloatingContainerForceNativeTitleBar )){
625
+ }
626
+ else if (DockManager->testConfigFlag (CDockManager::FloatingContainerForceNativeTitleBar))
627
+ {
623
628
native_window = true ;
624
- } else if ( DockManager->testConfigFlag ( CDockManager::FloatingContainerForceCustomTitleBar )){
629
+ }
630
+ else if (DockManager->testConfigFlag (CDockManager::FloatingContainerForceCustomTitleBar))
631
+ {
625
632
native_window = false ;
626
633
}
627
- if (native_window){
634
+ else
635
+ {
636
+ // KDE doesn't seem to fire MoveEvents while moving windows, so for now no native titlebar for everything using KWin.
637
+ QString window_manager = internal::windowManager ().toUpper ().split (" " )[0 ];
638
+ bool native_window = window_manager != " KWIN" ;
639
+ }
640
+
641
+ if (native_window)
642
+ {
628
643
setTitleBarWidget (new QWidget ());
629
644
setWindowFlags (Qt::Window | Qt::WindowMaximizeButtonHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
630
- } else {
645
+ }
646
+ else
647
+ {
631
648
d->TitleBar = new CFloatingWidgetTitleBar (this );
632
649
setTitleBarWidget (d->TitleBar );
633
650
setWindowFlags (Qt::Window | Qt::WindowMinMaxButtonsHint | Qt::FramelessWindowHint);
@@ -705,7 +722,8 @@ void CFloatingDockContainer::changeEvent(QEvent *event)
705
722
d->zOrderIndex = ++zOrderCounter;
706
723
707
724
#ifdef Q_OS_LINUX
708
- if (d->DraggingState == DraggingFloatingWidget){
725
+ if (d->DraggingState == DraggingFloatingWidget)
726
+ {
709
727
d->titleMouseReleaseEvent ();
710
728
d->DraggingState = DraggingInactive;
711
729
}
@@ -848,20 +866,13 @@ void CFloatingDockContainer::showEvent(QShowEvent *event)
848
866
void CFloatingDockContainer::startFloating (const QPoint &DragStartMousePos,
849
867
const QSize &Size, eDragState DragState, QWidget *MouseEventHandler)
850
868
{
851
- #ifndef Q_OS_LINUX
852
- Q_UNUSED (MouseEventHandler)
853
- #endif
854
869
#ifdef Q_OS_LINUX
855
- if (!isMaximized ()) {
870
+ if (!isMaximized ())
871
+ {
856
872
resize (Size);
857
873
d->DragStartMousePosition = DragStartMousePos;
858
874
}
859
- #else
860
- resize (Size);
861
- d->DragStartMousePosition = DragStartMousePos;
862
- #endif
863
875
d->setState (DragState);
864
- #ifdef Q_OS_LINUX
865
876
if (DraggingFloatingWidget == DragState)
866
877
{
867
878
d->MouseEventHandler = MouseEventHandler;
@@ -870,15 +881,20 @@ void CFloatingDockContainer::startFloating(const QPoint &DragStartMousePos,
870
881
d->MouseEventHandler ->grabMouse ();
871
882
}
872
883
}
873
- # endif
874
- # ifdef Q_OS_LINUX
875
- if (! isMaximized ()) {
884
+
885
+ if (! isMaximized ())
886
+ {
876
887
moveFloating ();
877
888
}
889
+ show ();
878
890
#else
891
+ Q_UNUSED (MouseEventHandler)
892
+ resize (Size);
893
+ d->DragStartMousePosition = DragStartMousePos;
894
+ d->setState (DragState);
879
895
moveFloating ();
880
- #endif
881
896
show ();
897
+ #endif
882
898
}
883
899
884
900
// ============================================================================
@@ -988,7 +1004,8 @@ bool CFloatingDockContainer::restoreState(CDockingStateReader &Stream,
988
1004
}
989
1005
onDockAreasAddedOrRemoved ();
990
1006
#ifdef Q_OS_LINUX
991
- if (d->TitleBar ){
1007
+ if (d->TitleBar )
1008
+ {
992
1009
d->TitleBar ->setMaximizedIcon (windowState () == Qt::WindowMaximized);
993
1010
}
994
1011
#endif
@@ -1134,15 +1151,21 @@ void CFloatingDockContainer::moveEvent(QMoveEvent *event)
1134
1151
1135
1152
1136
1153
#ifdef Q_OS_LINUX
1154
+ // ============================================================================
1137
1155
void CFloatingDockContainer::onMaximizeRequest ()
1138
1156
{
1139
- if (windowState () == Qt::WindowMaximized){
1157
+ if (windowState () == Qt::WindowMaximized)
1158
+ {
1140
1159
showNormal ();
1141
- }else {
1160
+ }
1161
+ else
1162
+ {
1142
1163
showMaximized ();
1143
1164
}
1144
1165
}
1145
1166
1167
+
1168
+ // ============================================================================
1146
1169
void CFloatingDockContainer::showNormal (bool fixGeometry)
1147
1170
{
1148
1171
if (windowState () == Qt::WindowMaximized)
@@ -1154,45 +1177,65 @@ void CFloatingDockContainer::showNormal(bool fixGeometry)
1154
1177
setGeometry (oldNormal);
1155
1178
}
1156
1179
}
1157
- if (d->TitleBar ){
1180
+ if (d->TitleBar )
1181
+ {
1158
1182
d->TitleBar ->setMaximizedIcon (false );
1159
1183
}
1160
1184
}
1161
1185
1186
+
1187
+ // ============================================================================
1162
1188
void CFloatingDockContainer::showMaximized ()
1163
1189
{
1164
1190
Super::showMaximized ();
1165
- if (d->TitleBar ){
1191
+ if (d->TitleBar )
1192
+ {
1166
1193
d->TitleBar ->setMaximizedIcon (true );
1167
1194
}
1168
1195
}
1169
1196
1197
+
1198
+ // ============================================================================
1170
1199
bool CFloatingDockContainer::isMaximized () const
1171
1200
{
1172
1201
return windowState () == Qt::WindowMaximized;
1173
1202
}
1174
1203
1175
- void CFloatingDockContainer::show (){
1204
+
1205
+ // ============================================================================
1206
+ void CFloatingDockContainer::show ()
1207
+ {
1176
1208
// Prevent this window from showing in the taskbar and pager (alt+tab)
1177
1209
internal::xcb_add_prop (true , winId (), " _NET_WM_STATE" , " _NET_WM_STATE_SKIP_TASKBAR" );
1178
1210
internal::xcb_add_prop (true , winId (), " _NET_WM_STATE" , " _NET_WM_STATE_SKIP_PAGER" );
1179
1211
Super::show ();
1180
1212
}
1181
- void CFloatingDockContainer::resizeEvent (QResizeEvent *event){
1213
+
1214
+
1215
+ // ============================================================================
1216
+ void CFloatingDockContainer::resizeEvent (QResizeEvent *event)
1217
+ {
1182
1218
d->IsResizing = true ;
1183
1219
Super::resizeEvent (event);
1184
1220
}
1185
1221
1186
- void CFloatingDockContainer::moveEvent (QMoveEvent *event){
1222
+
1223
+ // ============================================================================
1224
+ void CFloatingDockContainer::moveEvent (QMoveEvent *event)
1225
+ {
1187
1226
Super::moveEvent (event);
1188
- if (!d->IsResizing && event->spontaneous ()){
1227
+ if (!d->IsResizing && event->spontaneous ())
1228
+ {
1189
1229
d->DraggingState = DraggingFloatingWidget;
1190
1230
d->updateDropOverlays (QCursor::pos ());
1191
1231
}
1192
1232
d->IsResizing = false ;
1193
1233
}
1194
1234
1195
- bool CFloatingDockContainer::hasNativeTitleBar (){
1235
+
1236
+ // ============================================================================
1237
+ bool CFloatingDockContainer::hasNativeTitleBar ()
1238
+ {
1196
1239
return d->TitleBar == nullptr ;
1197
1240
}
1198
1241
#endif
0 commit comments