1 From b9e64417e4c33e2c17e060aa482519c2c8c7d416 Mon Sep 17 00:00:00 2001
2 From: Christian Hesse <mail@eworm.de>
3 Date: Tue, 17 Jan 2023 22:04:08 +0100
4 Subject: [PATCH] properly handle i3wm
7 .../VirtualBox/src/globals/UIDesktopWidgetWatchdog.cpp | 3 ++-
8 .../Frontends/VirtualBox/src/platform/x11/VBoxUtils-x11.cpp | 3 +++
9 .../Frontends/VirtualBox/src/platform/x11/VBoxUtils-x11.h | 3 ++-
10 src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.cpp | 4 ++++
11 4 files changed, 11 insertions(+), 2 deletions(-)
13 diff --git a/src/VBox/Frontends/VirtualBox/src/globals/UIDesktopWidgetWatchdog.cpp b/src/VBox/Frontends/VirtualBox/src/globals/UIDesktopWidgetWatchdog.cpp
14 index c27ff6f6..066a80e0 100644
15 --- a/src/VBox/Frontends/VirtualBox/src/globals/UIDesktopWidgetWatchdog.cpp
16 +++ b/src/VBox/Frontends/VirtualBox/src/globals/UIDesktopWidgetWatchdog.cpp
17 @@ -385,7 +385,8 @@ QRect UIDesktopWidgetWatchdog::availableGeometry(QScreen *pScreen) const
18 /* Get cached available-geometry: */
19 const QRect availableGeometry = m_availableGeometryData.value(screenToIndex(pScreen));
20 /* Return cached available-geometry if it's valid or screen-geometry otherwise: */
21 - return availableGeometry.isValid() ? availableGeometry : screenGeometry(pScreen);
22 + return availableGeometry.isValid() && NativeWindowSubsystem::X11WindowManagerType() != X11WMType_i3 ?
23 + availableGeometry : screenGeometry(pScreen);
24 # endif /* !VBOX_GUI_WITH_CUSTOMIZATIONS1 */
25 #else /* !VBOX_WS_X11 */
26 /* Just return screen available-geometry: */
27 diff --git a/src/VBox/Frontends/VirtualBox/src/platform/x11/VBoxUtils-x11.cpp b/src/VBox/Frontends/VirtualBox/src/platform/x11/VBoxUtils-x11.cpp
28 index 2443af89..6cfcff74 100644
29 --- a/src/VBox/Frontends/VirtualBox/src/platform/x11/VBoxUtils-x11.cpp
30 +++ b/src/VBox/Frontends/VirtualBox/src/platform/x11/VBoxUtils-x11.cpp
31 @@ -109,6 +109,9 @@ X11WMType NativeWindowSubsystem::X11WindowManagerType()
33 if (QString((const char*)pcData).contains("Xfwm4", Qt::CaseInsensitive))
34 wmType = X11WMType_Xfwm4;
36 + if (QString((const char*)pcData).contains("i3", Qt::CaseInsensitive))
37 + wmType = X11WMType_i3;
41 diff --git a/src/VBox/Frontends/VirtualBox/src/platform/x11/VBoxUtils-x11.h b/src/VBox/Frontends/VirtualBox/src/platform/x11/VBoxUtils-x11.h
42 index 66504c71..f83b5c85 100644
43 --- a/src/VBox/Frontends/VirtualBox/src/platform/x11/VBoxUtils-x11.h
44 +++ b/src/VBox/Frontends/VirtualBox/src/platform/x11/VBoxUtils-x11.h
45 @@ -49,6 +49,7 @@ enum X11WMType
52 /** X11: Screen-saver inhibit methods. */
53 @@ -95,7 +96,7 @@ namespace NativeWindowSubsystem
54 /** X11: Determines and returns whether the compositing manager is running. */
55 bool X11IsCompositingManagerRunning();
56 /** X11: Determines and returns current Window Manager type. */
57 - X11WMType X11WindowManagerType();
58 + SHARED_LIBRARY_STUFF X11WMType X11WindowManagerType();
60 /** X11: Returns true if XLib extension with name @p extensionName is avaible, false otherwise. */
61 bool X11CheckExtension(const char *extensionName);
62 diff --git a/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.cpp b/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.cpp
63 index 7b37d46b..b838ad07 100644
64 --- a/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.cpp
65 +++ b/src/VBox/Frontends/VirtualBox/src/widgets/UIMiniToolBar.cpp
66 @@ -1076,6 +1076,10 @@ void UIMiniToolBar::prepare()
67 /* Enable translucency through Qt API if supported: */
68 if (uiCommon().isCompositingManagerRunning())
69 setAttribute(Qt::WA_TranslucentBackground);
71 + if (NativeWindowSubsystem::X11WindowManagerType() == X11WMType_i3)
72 + setWindowFlags(Qt::FramelessWindowHint);
74 #endif /* VBOX_WS_X11 */
76 /* Make sure we have no focus: */