Skip to content

[Bug]: Dialogs open in top-left corner under XWayland #702

@kbroulik

Description

@kbroulik

Version

trunk/main

Host OS Type

Linux

Host OS name + version

Kubuntu 26.04 LTS

Host Architecture

x86

Guest OS Type

Windows

Guest Architecture

x86

Guest OS name + version

No response

Component

GUI

What happened?

Most dialog windows, such as the prompt for confirmation whether to shut down the machine, or the progress dialog when restoring a machine snapshot, show in the top left corner of the screen under KDE Plasma Wayland with VirtualBox running under XWayland, when the VirtualBox main window is on a screen other than the left one.

The problem is that QIDialog::showEvent class does not call into the super class QDialog::showEvent. The latter is where Qt does the placement of the dialog ontop of its parent: https://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/dialogs/qdialog.cpp#n867

The fix is to call the super class, like so, and how it is done with the other overriden events in that class:

diff --git a/src/VBox/Frontends/VirtualBox/src/extensions/QIDialog.cpp b/src/VBox/Frontends/VirtualBox/src/extensions/QIDialog.cpp
index 282ba89544f..9736f8731d8 100644
--- a/src/VBox/Frontends/VirtualBox/src/extensions/QIDialog.cpp
+++ b/src/VBox/Frontends/VirtualBox/src/extensions/QIDialog.cpp
@@ -126,6 +126,9 @@ void QIDialog::done(int iResult)
 
 void QIDialog::showEvent(QShowEvent *pEvent)
 {
+    /* Call to base-class: */
+    QDialog::showEvent(pEvent);
+
     /* Make sure we should polish dialog: */
     if (m_fPolished)
         return;

However, chances are that you want your UIDesktopWidgetWatchdog::centerWidget to take care of that and that it has a bug? It shouldn’t even be necessary to use this for QDialog at least since Qt does it all properly on its own.

(I would have submitted a patch myself but I won’t go through the hoops of creating an Oracle account which requires all sorts of personal information just to sign a CLA for a twoliner patch, sorry)

How can we reproduce this?

Have two monitors.
Run VirtualBox under KDE Plasma 6 with a Wayland session.
Start a VM. Move the VM window to the right monitor.
Close the VM window.
The prompt whether to shut down will show up in the top left corner of the left screen instead of centered ontop of the main window

Did you upload all of your necessary log files, screenshots, etc.?

  • Yes, I've uploaded all pertinent files to this issue.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions