Changeset 91057 in vbox for trunk/src/VBox
- Timestamp:
- Sep 1, 2021 11:57:17 AM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 7 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r91009 r91057 1509 1509 if1of ($(KBUILD_TARGET), freebsd linux netbsd openbsd solaris) # X11 1510 1510 UICommon_SOURCES += \ 1511 src/platform/x11/VBox X11Helper.cpp \1511 src/platform/x11/VBoxUtils-x11.cpp \ 1512 1512 src/platform/x11/XKeyboard-new.cpp 1513 1513 endif -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp
r91009 r91057 85 85 #ifdef VBOX_WS_X11 86 86 # include "UIHostComboEditor.h" 87 # include "VBoxX11Helper.h"88 87 #endif 89 88 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER … … 355 354 #ifdef VBOX_WS_X11 356 355 /* Check whether we have compositing manager running: */ 357 m_fCompositingManagerRunning = X11IsCompositingManagerRunning();356 m_fCompositingManagerRunning = NativeWindowSubsystem::X11IsCompositingManagerRunning(); 358 357 359 358 /* Acquire current Window Manager type: */ 360 m_enmWindowManagerType = X11WindowManagerType();359 m_enmWindowManagerType = NativeWindowSubsystem::X11WindowManagerType(); 361 360 #endif /* VBOX_WS_X11 */ 362 361 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h
r91009 r91057 32 32 #include "UIMediumDefs.h" 33 33 #ifdef VBOX_WS_X11 34 # include "VBox X11Helper.h"34 # include "VBoxUtils-x11.h" 35 35 #endif 36 36 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICursor.cpp
r91003 r91057 39 39 (UICommon::qtRTMajorVersion() == 5 && UICommon::qtRTMinorVersion() < 11)) 40 40 { 41 if ( X11CheckExtension("RENDER"))41 if (NativeWindowSubsystem::X11CheckExtension("RENDER")) 42 42 pWidget->setCursor(cursor); 43 43 } … … 65 65 (UICommon::qtRTMajorVersion() == 5 && UICommon::qtRTMinorVersion() < 11)) 66 66 { 67 if ( X11CheckExtension("RENDER"))67 if (NativeWindowSubsystem::X11CheckExtension("RENDER")) 68 68 pWidget->setCursor(cursor); 69 69 } … … 91 91 (UICommon::qtRTMajorVersion() == 5 && UICommon::qtRTMinorVersion() < 11)) 92 92 { 93 if ( X11CheckExtension("RENDER"))93 if (NativeWindowSubsystem::X11CheckExtension("RENDER")) 94 94 pWidget->unsetCursor(); 95 95 } … … 117 117 (UICommon::qtRTMajorVersion() == 5 && UICommon::qtRTMinorVersion() < 11)) 118 118 { 119 if ( X11CheckExtension("RENDER"))119 if (NativeWindowSubsystem::X11CheckExtension("RENDER")) 120 120 pWidget->unsetCursor(); 121 121 } -
trunk/src/VBox/Frontends/VirtualBox/src/platform/x11/VBoxUtils-x11.cpp
r91056 r91057 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - VBox X11 helper functions.3 * VBox Qt GUI - Declarations of utility classes and functions for handling X11 specific tasks. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2008-202 0Oracle Corporation7 * Copyright (C) 2008-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 17 18 18 /* Qt includes: */ 19 #include <QX11Info>20 19 #include <QtDBus/QDBusConnection> 20 #include <QtDBus/QDBusConnectionInterface> 21 #include <QtDBus/QDBusInterface> 21 22 #include <QtDBus/QDBusReply> 22 #include <QtDBus/QDBusInterface>23 #include <QtDBus/QDBusConnectionInterface>24 23 #include <QtXml/QDomDocument> 25 24 #include <QtXml/QDomElement> 25 #include <QX11Info> 26 26 27 27 /* GUI includes: */ 28 #include "VBox X11Helper.h"28 #include "VBoxUtils-x11.h" 29 29 30 30 /* Other VBox includes: */ 31 31 #include <iprt/cdefs.h> 32 #include <VBox/log.h> 32 33 33 34 // WORKAROUND: … … 40 41 RT_C_DECLS_END 41 42 42 #include <VBox/log.h>43 43 44 44 static int gX11ScreenSaverTimeout; … … 46 46 static BOOL gX11DpmsState; 47 47 48 bool X11IsCompositingManagerRunning() 49 { 50 /* Get display: */ 51 Display *pDisplay = QX11Info::display(); 48 bool NativeWindowSubsystem::X11IsCompositingManagerRunning() 49 { 52 50 /* For each screen it manage, compositing manager MUST acquire ownership 53 51 * of a selection named _NET_WM_CM_Sn, where n is the screen number. */ 52 Display *pDisplay = QX11Info::display(); 54 53 Atom atom_property_name = XInternAtom(pDisplay, "_NET_WM_CM_S0", True); 55 54 return XGetSelectionOwner(pDisplay, atom_property_name); 56 55 } 57 56 58 X11WMType X11WindowManagerType() 59 { 60 /* Get display: */ 61 Display *pDisplay = QX11Info::display(); 62 /* Prepare variables to be reused: */ 57 X11WMType NativeWindowSubsystem::X11WindowManagerType() 58 { 59 /* Ask if root-window supports check for WM name: */ 60 Display *pDisplay = QX11Info::display(); 63 61 Atom atom_property_name; 64 62 Atom atom_returned_type; … … 68 66 unsigned char *pcData = 0; 69 67 X11WMType wmType = X11WMType_Unknown; 70 71 /* Ask if root-window supports check for WM name: */72 68 atom_property_name = XInternAtom(pDisplay, "_NET_SUPPORTING_WM_CHECK", True); 73 69 if (XGetWindowProperty(pDisplay, QX11Info::appRootWindow(), atom_property_name, … … 114 110 } 115 111 116 void X11ScreenSaverSettingsInit() 117 { 118 int dummy; 119 Display *pDisplay = QX11Info::display(); 112 void NativeWindowSubsystem::X11ScreenSaverSettingsInit() 113 { 114 /* Init screen-save availability: */ 115 Display *pDisplay = QX11Info::display(); 116 int dummy; 120 117 gX11ScreenSaverDpmsAvailable = DPMSQueryExtension(pDisplay, &dummy, &dummy); 121 118 } 122 119 123 void X11ScreenSaverSettingsSave()120 void NativeWindowSubsystem::X11ScreenSaverSettingsSave() 124 121 { 125 122 /* Actually this is a big mess. By default the libSDL disables the screen saver … … 132 129 * save and restore the state prior and after each of these function calls. */ 133 130 134 int dummy; 135 CARD16 dummy2; 136 Display *pDisplay = QX11Info::display(); 137 131 Display *pDisplay = QX11Info::display(); 132 int dummy; 133 CARD16 dummy2; 138 134 XGetScreenSaver(pDisplay, &gX11ScreenSaverTimeout, &dummy, &dummy, &dummy); 139 135 if (gX11ScreenSaverDpmsAvailable) … … 141 137 } 142 138 143 void X11ScreenSaverSettingsRestore()144 { 145 int iTimeout, iInterval, iPreferBlank, iAllowExp;146 Display *pDisplay = QX11Info::display(); 147 139 void NativeWindowSubsystem::X11ScreenSaverSettingsRestore() 140 { 141 /* Restore screen-saver settings: */ 142 Display *pDisplay = QX11Info::display(); 143 int iTimeout, iInterval, iPreferBlank, iAllowExp; 148 144 XGetScreenSaver(pDisplay, &iTimeout, &iInterval, &iPreferBlank, &iAllowExp); 149 145 iTimeout = gX11ScreenSaverTimeout; 150 146 XSetScreenSaver(pDisplay, iTimeout, iInterval, iPreferBlank, iAllowExp); 151 152 147 if (gX11DpmsState && gX11ScreenSaverDpmsAvailable) 153 148 DPMSEnable(pDisplay); 154 149 } 155 150 156 bool X11CheckExtension(const char *extensionName) 157 { 151 bool NativeWindowSubsystem::X11CheckExtension(const char *pExtensionName) 152 { 153 /* Check extension: */ 158 154 Display *pDisplay = QX11Info::display(); 159 155 int major_opcode; 160 156 int first_event; 161 157 int first_error; 162 return XQueryExtension(pDisplay, extensionName, &major_opcode, &first_event, &first_error); 163 } 164 165 static bool X11CheckDBusConnection(const QDBusConnection &connection) 166 { 167 if (!connection.isConnected()) { 158 return XQueryExtension(pDisplay, pExtensionName, &major_opcode, &first_event, &first_error); 159 } 160 161 bool NativeWindowSubsystem::X11CheckDBusConnection(const QDBusConnection &connection) 162 { 163 if (!connection.isConnected()) 164 { 168 165 const QDBusError lastError = connection.lastError(); 169 166 if (lastError.isValid()) … … 180 177 } 181 178 182 static QStringListX11FindDBusScreenSaverServices(const QDBusConnection &connection)179 QStringList NativeWindowSubsystem::X11FindDBusScreenSaverServices(const QDBusConnection &connection) 183 180 { 184 181 QStringList serviceNames; … … 205 202 } 206 203 207 bool X11CheckDBusScreenSaverServices()204 bool NativeWindowSubsystem::X11CheckDBusScreenSaverServices() 208 205 { 209 206 QDBusConnection connection = QDBusConnection::sessionBus(); … … 229 226 } 230 227 231 232 static void X11IntrospectInterfaceNode(const QDomElement &interface,233 const QString &strServiceName,QVector<X11ScreenSaverInhibitMethod*> &methods)228 void NativeWindowSubsystem::X11IntrospectInterfaceNode(const QDomElement &interface, 229 const QString &strServiceName, 230 QVector<X11ScreenSaverInhibitMethod*> &methods) 234 231 { 235 232 QDomElement child = interface.firstChildElement(); 236 while (!child.isNull()) {237 233 while (!child.isNull()) 234 { 238 235 if (child.tagName() == "method" && child.attribute("name") == "Inhibit") 239 236 { … … 251 248 } 252 249 253 static void X11IntrospectServices(const QDBusConnection &connection, 254 const QString &strService, const QString &path, QVector<X11ScreenSaverInhibitMethod*> &methods) 255 { 256 QDBusMessage call = QDBusMessage::createMethodCall(strService, path.isEmpty() ? QLatin1String("/") : path, 250 void NativeWindowSubsystem::X11IntrospectServices(const QDBusConnection &connection, 251 const QString &strService, 252 const QString &strPath, 253 QVector<X11ScreenSaverInhibitMethod*> &methods) 254 { 255 QDBusMessage call = QDBusMessage::createMethodCall(strService, strPath.isEmpty() ? QLatin1String("/") : strPath, 257 256 QLatin1String("org.freedesktop.DBus.Introspectable"), 258 257 QLatin1String("Introspect")); … … 270 269 if (child.tagName() == QLatin1String("node")) 271 270 { 272 QString subPath = path + QLatin1Char('/') + child.attribute(QLatin1String("name"));271 QString subPath = strPath + QLatin1Char('/') + child.attribute(QLatin1String("name")); 273 272 X11IntrospectServices(connection, strService, subPath, methods); 274 273 } … … 279 278 } 280 279 281 QVector<X11ScreenSaverInhibitMethod*> X11FindDBusScrenSaverInhibitMethods()280 QVector<X11ScreenSaverInhibitMethod*> NativeWindowSubsystem::X11FindDBusScrenSaverInhibitMethods() 282 281 { 283 282 QVector<X11ScreenSaverInhibitMethod*> methods; … … 293 292 } 294 293 295 void X11InhibitUninhibitScrenSaver(bool fInhibit, QVector<X11ScreenSaverInhibitMethod*> &inOutIhibitMethods)294 void NativeWindowSubsystem::X11InhibitUninhibitScrenSaver(bool fInhibit, QVector<X11ScreenSaverInhibitMethod*> &inOutIhibitMethods) 296 295 { 297 296 QDBusConnection connection = QDBusConnection::sessionBus(); … … 332 331 } 333 332 } 334 335 #ifdef VBOX_WS_X11336 #endif -
trunk/src/VBox/Frontends/VirtualBox/src/platform/x11/VBoxUtils-x11.h
r91056 r91057 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - VBox X11 helper functions.3 * VBox Qt GUI - Declarations of utility classes and functions for handling X11 specific tasks. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2006-202 0Oracle Corporation7 * Copyright (C) 2006-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_platform_x11_VBox X11Helper_h19 #define FEQT_INCLUDED_SRC_platform_x11_VBox X11Helper_h18 #ifndef FEQT_INCLUDED_SRC_platform_x11_VBoxUtils_x11_h 19 #define FEQT_INCLUDED_SRC_platform_x11_VBoxUtils_x11_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once … … 31 31 /* Forward declarations: */ 32 32 class QDBusConnection; 33 class QDomElement; 33 34 34 35 /** X11: Known Window Manager types. */ … … 44 45 }; 45 46 47 /** X11: Screen-saver inhibit methods. */ 46 48 struct SHARED_LIBRARY_STUFF X11ScreenSaverInhibitMethod 47 49 { 48 QString m_strServiceName;49 QString m_strInterface;50 QString m_strPath;51 uint m_iCookie;50 QString m_strServiceName; 51 QString m_strInterface; 52 QString m_strPath; 53 uint m_iCookie; 52 54 }; 53 55 54 /** X11: Determines and returns whether the compositing manager is running. */ 55 SHARED_LIBRARY_STUFF bool X11IsCompositingManagerRunning(); 56 /* Namespace for native window sub-system functions: */ 57 namespace NativeWindowSubsystem 58 { 59 /** X11: Determines and returns whether the compositing manager is running. */ 60 SHARED_LIBRARY_STUFF bool X11IsCompositingManagerRunning(); 56 61 57 /** X11: Determines and returns current Window Manager type. */58 SHARED_LIBRARY_STUFF X11WMType X11WindowManagerType();62 /** X11: Determines and returns current Window Manager type. */ 63 SHARED_LIBRARY_STUFF X11WMType X11WindowManagerType(); 59 64 60 /** X11: Inits the screen saver save/restore mechanism. */61 SHARED_LIBRARY_STUFF void X11ScreenSaverSettingsInit();62 /** X11: Saves screen saver settings. */63 SHARED_LIBRARY_STUFF void X11ScreenSaverSettingsSave();64 /** X11: Restores previously saved screen saver settings. */65 SHARED_LIBRARY_STUFF void X11ScreenSaverSettingsRestore();66 /** X11: Returns true if XLib extension with name @p extensionName is avaible, false otherwise. */67 SHARED_LIBRARY_STUFF bool X11CheckExtension(const char *extensionName);65 /** X11: Inits the screen saver save/restore mechanism. */ 66 SHARED_LIBRARY_STUFF void X11ScreenSaverSettingsInit(); 67 /** X11: Saves screen saver settings. */ 68 SHARED_LIBRARY_STUFF void X11ScreenSaverSettingsSave(); 69 /** X11: Restores previously saved screen saver settings. */ 70 SHARED_LIBRARY_STUFF void X11ScreenSaverSettingsRestore(); 71 /** X11: Returns true if XLib extension with name @p extensionName is avaible, false otherwise. */ 72 SHARED_LIBRARY_STUFF bool X11CheckExtension(const char *extensionName); 68 73 69 /** Returns true if there are any DBus services whose name contains the substring 'screensaver'. */ 70 bool X11CheckDBusScreenSaverServices(); 74 /** X11: Returns whether DBus @a connection is alive. */ 75 bool X11CheckDBusConnection(const QDBusConnection &connection); 76 /** X11: Finds a list of DBus @a connection screen-saver services. */ 77 QStringList X11FindDBusScreenSaverServices(const QDBusConnection &connection); 78 /** X11: Returns whether there are any DBus services whose name contains the substring 'screensaver'. */ 79 bool X11CheckDBusScreenSaverServices(); 80 /** X11: Does something known only to original creator... */ 81 void X11IntrospectInterfaceNode(const QDomElement &interface, 82 const QString &strServiceName, 83 QVector<X11ScreenSaverInhibitMethod*> &methods); 84 /** X11: Does something known only to original creator... */ 85 void X11IntrospectServices(const QDBusConnection &connection, 86 const QString &strService, 87 const QString &strPath, 88 QVector<X11ScreenSaverInhibitMethod*> &methods); 71 89 72 /**Returns the list of Inhibit methods found by introspecting DBus services. */73 SHARED_LIBRARY_STUFF QVector<X11ScreenSaverInhibitMethod*> X11FindDBusScrenSaverInhibitMethods();90 /** X11: Returns the list of Inhibit methods found by introspecting DBus services. */ 91 SHARED_LIBRARY_STUFF QVector<X11ScreenSaverInhibitMethod*> X11FindDBusScrenSaverInhibitMethods(); 74 92 75 /** Disables/enables Screen Saver through QDBus. */ 76 SHARED_LIBRARY_STUFF void X11InhibitUninhibitScrenSaver(bool fInhibit, QVector<X11ScreenSaverInhibitMethod*> &inOutIhibitMethods); 93 /** X11: Disables/enables Screen Saver through QDBus. */ 94 SHARED_LIBRARY_STUFF void X11InhibitUninhibitScrenSaver(bool fInhibit, QVector<X11ScreenSaverInhibitMethod*> &inOutIhibitMethods); 95 } 77 96 78 #endif /* !FEQT_INCLUDED_SRC_platform_x11_VBox X11Helper_h */97 #endif /* !FEQT_INCLUDED_SRC_platform_x11_VBoxUtils_x11_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r90893 r91057 610 610 #if defined(VBOX_WS_X11) 611 611 if (m_methods.isEmpty()) 612 m_methods = X11FindDBusScrenSaverInhibitMethods();613 X11InhibitUninhibitScrenSaver(fDisabled, m_methods);612 m_methods = NativeWindowSubsystem::X11FindDBusScrenSaverInhibitMethods(); 613 NativeWindowSubsystem::X11InhibitUninhibitScrenSaver(fDisabled, m_methods); 614 614 #elif defined(VBOX_WS_WIN) 615 615 NativeWindowSubsystem::setScreenSaverActive(fDisabled); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMouseHandler.cpp
r91003 r91057 54 54 /* External includes: */ 55 55 #ifdef VBOX_WS_X11 56 #include "VBoxX11Helper.h" 57 # include <xcb/xcb.h> 56 #include "VBoxUtils-x11.h" 58 57 #endif 59 58 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsDisplay.cpp
r89910 r91057 29 29 #include "UIScaleFactorEditor.h" 30 30 #ifdef VBOX_WS_X11 31 # include "VBox X11Helper.h"31 # include "VBoxUtils-x11.h" 32 32 #endif 33 33 … … 260 260 m_pCheckBoxDisableHostScreenSaver = new QCheckBox(this); 261 261 #elif defined(VBOX_WS_X11) 262 if ( X11CheckDBusScreenSaverServices())262 if (NativeWindowSubsystem::X11CheckDBusScreenSaverServices()) 263 263 m_pCheckBoxDisableHostScreenSaver = new QCheckBox(this); 264 264 #endif
Note:
See TracChangeset
for help on using the changeset viewer.