Skip to content

On Linux, Dock Manager is erroneously raised on window focus changes #785

@gafusss

Description

@gafusss

Regression introduced by 9f8dd99 936eba0

The Dock Manager window is raised unconditionally on window focus changes, even if the window is unrelated to the docking system (not a floating widget as originally intended by the commit).

Simple reproduction showing unintended raise:

To master, apply:

diff --git a/examples/simple/MainWindow.cpp b/examples/simple/MainWindow.cpp
index 5eb08be..fa66be5 100644
--- a/examples/simple/MainWindow.cpp
+++ b/examples/simple/MainWindow.cpp
@@ -5,6 +5,8 @@
 #include <QLabel>
 #include <QTimer>
 
+#include "dialog.h"
+
 MainWindow::MainWindow(QWidget *parent) :
     QMainWindow(parent),
     ui(new Ui::MainWindow)
@@ -33,6 +35,14 @@ MainWindow::MainWindow(QWidget *parent) :
 
        // Add the dock widget to the top dock widget area
        m_DockManager->addDockWidget(ads::TopDockWidgetArea, DockWidget);
+
+    QAction * asdf = new QAction("dialog");
+    ui->menuView->addAction(asdf);
+
+    connect(asdf, &QAction::triggered, this, []{
+        Dialog dg;
+        dg.exec();
+    });
 }
 
 MainWindow::~MainWindow()
diff --git a/examples/simple/dialog.cpp b/examples/simple/dialog.cpp
new file mode 100644
index 0000000..3f3215f
--- /dev/null
+++ b/examples/simple/dialog.cpp
@@ -0,0 +1,16 @@
+#include "dialog.h"
+#include "ui_dialog.h"
+
+Dialog::Dialog(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::Dialog)
+{
+    ui->setupUi(this);
+
+    ui->comboBox->addItems({"1", "2"});
+}
+
+Dialog::~Dialog()
+{
+    delete ui;
+}
diff --git a/examples/simple/dialog.h b/examples/simple/dialog.h
new file mode 100644
index 0000000..17537d1
--- /dev/null
+++ b/examples/simple/dialog.h
@@ -0,0 +1,22 @@
+#ifndef DIALOG_H
+#define DIALOG_H
+
+#include <QDialog>
+
+namespace Ui {
+class Dialog;
+}
+
+class Dialog : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit Dialog(QWidget *parent = nullptr);
+    ~Dialog();
+
+private:
+    Ui::Dialog *ui;
+};
+
+#endif // DIALOG_H
diff --git a/examples/simple/dialog.ui b/examples/simple/dialog.ui
new file mode 100644
index 0000000..72be6b9
--- /dev/null
+++ b/examples/simple/dialog.ui
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Dialog</class>
+ <widget class="QDialog" name="Dialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <widget class="QComboBox" name="comboBox">
+   <property name="geometry">
+    <rect>
+     <x>90</x>
+     <y>130</y>
+     <width>79</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/simple/simple.pro b/examples/simple/simple.pro
index 92a166b..f52c54e 100644
--- a/examples/simple/simple.pro
+++ b/examples/simple/simple.pro
@@ -14,14 +14,17 @@ adsBuildStatic {
 DEFINES += QT_DEPRECATED_WARNINGS
 
 SOURCES += \
+        dialog.cpp \
         main.cpp \
         MainWindow.cpp
 
 HEADERS += \
-        MainWindow.h
+        MainWindow.h \
+        dialog.h
 
 FORMS += \
-        MainWindow.ui
+        MainWindow.ui \
+        dialog.ui
         
 
 LIBS += -L$${ADS_OUT_ROOT}/lib

run examples/simple, click View->dialog, move dialog window so that it is at least partially above main window, click combo box.

Image

Logging the focusWindow in focusWindowChanged lambda gives:

QWidgetWindow(0xcc3ba0, name="MainWindowWindow")
QWidgetWindow(0xcfba50, name="menuViewWindow")
QWidgetWindow(0xca3750, name="DialogWindow")
QWidgetWindow(0x76acac007460, name="QComboBoxPrivateContainerClassWindow")
QWidgetWindow(0xca3750, name="DialogWindow")
QWidgetWindow(0x76acac007460, name="QComboBoxPrivateContainerClassWindow")
QWidgetWindow(0xca3750, name="DialogWindow")
QWidgetWindow(0xcc3ba0, name="MainWindowWindow")

So I believe it raises the main window, and then the QComboBoxPrivateContainerClassWindow from the dropdown, but then the dialog window goes behind both of those

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions