Changeset 99434 in vbox
- Timestamp:
- Apr 18, 2023 6:51:53 AM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 156893
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.cpp
r99381 r99434 245 245 #ifdef VBOX_WS_X11 246 246 /* Detect display server type: */ 247 m_enmDisplayServerType = NativeWindowSubsystem:: X11DetectDisplayServerType();247 m_enmDisplayServerType = NativeWindowSubsystem::detectDisplayServerType(); 248 248 #endif 249 249 … … 331 331 #ifdef VBOX_WS_X11 332 332 /* Check whether we have compositing manager running: */ 333 m_fCompositingManagerRunning = NativeWindowSubsystem:: IsCompositingManagerRunning(X11XServerAvailable());333 m_fCompositingManagerRunning = NativeWindowSubsystem::isCompositingManagerRunning(X11XServerAvailable()); 334 334 335 335 /* Acquire current Window Manager type: */ 336 m_enmWindowManagerType = NativeWindowSubsystem:: WindowManagerType(X11XServerAvailable());336 m_enmWindowManagerType = NativeWindowSubsystem::windowManagerType(X11XServerAvailable()); 337 337 #endif /* VBOX_WS_X11 */ 338 338 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UICursor.cpp
r98103 r99434 49 49 (UICommon::qtRTMajorVersion() == 5 && UICommon::qtRTMinorVersion() < 11)) 50 50 { 51 if (NativeWindowSubsystem:: X11CheckExtension("RENDER"))51 if (NativeWindowSubsystem::checkExtension(uiCommon().X11XServerAvailable(), "RENDER")) 52 52 pWidget->setCursor(cursor); 53 53 } … … 75 75 (UICommon::qtRTMajorVersion() == 5 && UICommon::qtRTMinorVersion() < 11)) 76 76 { 77 if (NativeWindowSubsystem:: X11CheckExtension("RENDER"))77 if (NativeWindowSubsystem::checkExtension(uiCommon().X11XServerAvailable(), "RENDER")) 78 78 pWidget->setCursor(cursor); 79 79 } … … 101 101 (UICommon::qtRTMajorVersion() == 5 && UICommon::qtRTMinorVersion() < 11)) 102 102 { 103 if (NativeWindowSubsystem:: X11CheckExtension("RENDER"))103 if (NativeWindowSubsystem::checkExtension(uiCommon().X11XServerAvailable(), "RENDER")) 104 104 pWidget->unsetCursor(); 105 105 } … … 127 127 (UICommon::qtRTMajorVersion() == 5 && UICommon::qtRTMinorVersion() < 11)) 128 128 { 129 if (NativeWindowSubsystem:: X11CheckExtension("RENDER"))129 if (NativeWindowSubsystem::checkExtension(uiCommon().X11XServerAvailable(), "RENDER")) 130 130 pWidget->unsetCursor(); 131 131 } -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIDesktopWidgetWatchdog.cpp
r99407 r99434 861 861 862 862 #elif defined(VBOX_WS_X11) 863 if (uiCommon().X11XServerAvailable()) 864 fResult &= NativeWindowSubsystem::X11ActivateWindow(wId, fSwitchDesktop);863 864 fResult &= NativeWindowSubsystem::activateWindow(uiCommon().X11XServerAvailable(), wId, fSwitchDesktop); 865 865 866 866 #else -
trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
r99372 r99434 396 396 if (!MakeSureMultiThreadingIsSafe()) 397 397 break; 398 DisplayServerType enmDisplayServerType = NativeWindowSubsystem:: X11DetectDisplayServerType();398 DisplayServerType enmDisplayServerType = NativeWindowSubsystem::detectDisplayServerType(); 399 399 if (NativeWindowSubsystem::X11XServerAvailable(enmDisplayServerType)) 400 400 /* Force using Qt platform plugin 'xcb', we have X11 specific code: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r99390 r99434 2146 2146 { 2147 2147 #ifdef VBOX_WS_X11 2148 NativeWindowSubsystem:: SetWMClass(uiCommon().X11XServerAvailable(), this, "VirtualBox Manager", "VirtualBox Manager");2148 NativeWindowSubsystem::setWMClass(uiCommon().X11XServerAvailable(), this, "VirtualBox Manager", "VirtualBox Manager"); 2149 2149 #endif 2150 2150 -
trunk/src/VBox/Frontends/VirtualBox/src/platform/x11/VBoxUtils-x11.cpp
r99381 r99434 60 60 61 61 62 bool NativeWindowSubsystem:: IsCompositingManagerRunning(bool fIsXServerAvailable)62 bool NativeWindowSubsystem::isCompositingManagerRunning(bool fIsXServerAvailable) 63 63 { 64 64 if (fIsXServerAvailable) … … 81 81 } 82 82 83 X11WMType NativeWindowSubsystem:: WindowManagerType(bool fIsXServerAvailable)83 X11WMType NativeWindowSubsystem::windowManagerType(bool fIsXServerAvailable) 84 84 { 85 85 if (fIsXServerAvailable) … … 90 90 X11WMType NativeWindowSubsystem::WaylandWindowManagerType() 91 91 { 92 /// @ todoimplement92 /// @wayland implement 93 93 return X11WMType_Unknown; 94 94 } … … 150 150 } 151 151 152 bool NativeWindowSubsystem::checkExtension(bool fIsXServerAvailable, const char *pExtensionName) 153 { 154 if (fIsXServerAvailable) 155 return X11CheckExtension(pExtensionName); 156 return WaylandCheckExtension(pExtensionName); 157 } 158 152 159 bool NativeWindowSubsystem::X11CheckExtension(const char *pExtensionName) 153 160 { … … 158 165 int first_error; 159 166 return XQueryExtension(pDisplay, pExtensionName, &major_opcode, &first_event, &first_error); 167 } 168 169 bool NativeWindowSubsystem::WaylandCheckExtension(const char *pExtensionName) 170 { 171 Q_UNUSED(pExtensionName); 172 /// @todo implement 173 return false; 160 174 } 161 175 … … 385 399 } 386 400 401 bool NativeWindowSubsystem::activateWindow(bool fIsXServerAvailable, WId wId, bool fSwitchDesktop) 402 { 403 if (fIsXServerAvailable) 404 return X11ActivateWindow(wId, fSwitchDesktop); 405 return WaylandActivateWindow(wId, fSwitchDesktop); 406 } 407 387 408 bool NativeWindowSubsystem::X11ActivateWindow(WId wId, bool fSwitchDesktop) 388 409 { … … 422 443 XRaiseWindow(pDisplay, wId); 423 444 return fResult; 445 } 446 447 bool NativeWindowSubsystem::WaylandActivateWindow(WId wId, bool fSwitchDesktop) 448 { 449 /// @todo implement 450 Q_UNUSED(wId); 451 Q_UNUSED(fSwitchDesktop); 452 return false; 424 453 } 425 454 … … 615 644 } 616 645 617 void NativeWindowSubsystem:: SetWMClass(bool fIsXServerAvailable, QWidget *pWidget, const QString &strNameString, const QString &strClassString)646 void NativeWindowSubsystem::setWMClass(bool fIsXServerAvailable, QWidget *pWidget, const QString &strNameString, const QString &strClassString) 618 647 { 619 648 if (fIsXServerAvailable) … … 655 684 } 656 685 657 void NativeWindowSubsystem::X11SetXwaylandMayGrabKeyboardFlag(QWidget *pWidget) 658 { 659 XXSendClientMessage(NativeWindowSubsystem::X11GetDisplay(), pWidget->window()->winId(), 660 "_XWAYLAND_MAY_GRAB_KEYBOARD", 1); 686 void NativeWindowSubsystem::setXwaylandMayGrabKeyboardFlag(bool fIsXServerAvailable, QWidget *pWidget) 687 { 688 if (fIsXServerAvailable) 689 XXSendClientMessage(NativeWindowSubsystem::X11GetDisplay(), pWidget->window()->winId(), 690 "_XWAYLAND_MAY_GRAB_KEYBOARD", 1); 661 691 } 662 692 … … 708 738 } 709 739 710 DisplayServerType NativeWindowSubsystem:: X11DetectDisplayServerType()740 DisplayServerType NativeWindowSubsystem::detectDisplayServerType() 711 741 { 712 742 const char *pSessionType = RTEnvGet("XDG_SESSION_TYPE"); -
trunk/src/VBox/Frontends/VirtualBox/src/platform/x11/VBoxUtils-x11.h
r99381 r99434 105 105 { 106 106 /** Wrapper function for X11IsCompositingManagerRunning and WaylandIsCompositingManagerRunning. */ 107 bool IsCompositingManagerRunning(bool fIsXServerAvailable);107 bool isCompositingManagerRunning(bool fIsXServerAvailable); 108 108 /** X11: Determines and returns whether the compositing manager is running. */ 109 109 bool X11IsCompositingManagerRunning(); … … 112 112 113 113 /** Wrapper for window manager type functions. */ 114 X11WMType WindowManagerType(bool fIsXServerAvailable);114 X11WMType windowManagerType(bool fIsXServerAvailable); 115 115 /** X11: Determines and returns current Window Manager type. */ 116 116 X11WMType X11WindowManagerType(); … … 118 118 X11WMType WaylandWindowManagerType(); 119 119 120 /** Wrapper for X11CheckExtension and WaylandCheckExtension functions. */ 121 bool checkExtension(bool fIsXServerAvailable, const char *extensionName); 120 122 /** X11: Returns true if XLib extension with name @p extensionName is avaible, false otherwise. */ 121 bool X11CheckExtension(const char *extensionName); 123 bool X11CheckExtension(const char *pExtensionName); 124 bool WaylandCheckExtension(const char *pExtensionName); 125 122 126 123 127 /** X11: Returns whether there are any DBus services whose name contains the substring 'screensaver'. */ … … 128 132 SHARED_LIBRARY_STUFF void X11InhibitUninhibitScrenSaver(bool fInhibit, QVector<X11ScreenSaverInhibitMethod*> &inOutInhibitMethods); 129 133 134 /** Wrapper function for X11ActivateWindow or WaylandActivateWindow. */ 135 bool activateWindow(bool fIsXServerAvailable, WId wId, bool fSwitchDesktop); 130 136 /** Activates window with certain @a wId, @a fSwitchDesktop if requested. */ 131 137 bool X11ActivateWindow(WId wId, bool fSwitchDesktop); 138 /** Activates window with certain @a wId, @a fSwitchDesktop if requested. */ 139 bool WaylandActivateWindow(WId wId, bool fSwitchDesktop); 132 140 133 141 /** X11: Test whether the current window manager supports full screen mode. */ … … 142 150 143 151 /** Wrapper function for WMClass setters. */ 144 SHARED_LIBRARY_STUFF void SetWMClass(bool fIsXServerAvailable, QWidget *pWidget, const QString &strNameString, const QString &strClassString);152 SHARED_LIBRARY_STUFF void setWMClass(bool fIsXServerAvailable, QWidget *pWidget, const QString &strNameString, const QString &strClassString); 145 153 /** X11: Assigns WM_CLASS property for passed @a pWidget. */ 146 154 SHARED_LIBRARY_STUFF void X11SetWMClass(QWidget *pWidget, const QString &strNameString, const QString &strClassString); … … 152 160 * so that e.g. alt+tab will get send to the VM instead of moving the 153 161 * focus away from the VM. */ 154 SHARED_LIBRARY_STUFF void X11SetXwaylandMayGrabKeyboardFlag(QWidget *pWidget);162 SHARED_LIBRARY_STUFF void setXwaylandMayGrabKeyboardFlag(bool fIsXServerAvailable, QWidget *pWidget); 155 163 156 164 /** X11: Gets the X11 display pointer. */ … … 161 169 SHARED_LIBRARY_STUFF uint32_t X11GetAppRootWindow(); 162 170 /** Detects and returns display server type. */ 163 SHARED_LIBRARY_STUFF DisplayServerType X11DetectDisplayServerType();171 SHARED_LIBRARY_STUFF DisplayServerType detectDisplayServerType(); 164 172 /** Returns true if @a enmDisplayServerType is either xorg or xwayland. */ 165 173 SHARED_LIBRARY_STUFF bool X11XServerAvailable(DisplayServerType enmDisplayServerType); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp
r99407 r99434 266 266 267 267 #elif defined(VBOX_WS_X11) 268 269 /* On X11, we are using XCB stuff to grab the keyboard. 270 * This stuff is a part of the active keyboard grabbing functionality. 271 * Active keyboard grabbing causes a problems on many window managers - a window cannot 272 * be moved using the mouse. So we additionally grab the mouse buttons as well to detect 273 * that the user is trying to click outside of the internal window geometry and release 274 * the keyboard before the target window sees the click. (GNOME Shell's hot corner has 275 * the same problem. At present we just let that problem be.) */ 268 if (uiCommon().X11XServerAvailable()) 269 { 270 /* On X11, we are using XCB stuff to grab the keyboard. 271 * This stuff is a part of the active keyboard grabbing functionality. 272 * Active keyboard grabbing causes a problems on many window managers - a window cannot 273 * be moved using the mouse. So we additionally grab the mouse buttons as well to detect 274 * that the user is trying to click outside of the internal window geometry and release 275 * the keyboard before the target window sees the click. (GNOME Shell's hot corner has 276 * the same problem. At present we just let that problem be.) */ 276 277 277 278 # if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) 278 /* Make sure we really do still have the focus. Qt as of version 5.13 started279 * reporting it with delay, so ask the X server directly. We could remove the280 * version check some time in the future. If we do, remove the comment above281 * about the focus notification dance, as it will no longer be relevant. */282 xcb_get_input_focus_cookie_t xcbFocusCookie = xcb_get_input_focus(NativeWindowSubsystem::X11GetConnection());283 xcb_get_input_focus_reply_t *pFocusReply = xcb_get_input_focus_reply(NativeWindowSubsystem::X11GetConnection(),284 xcbFocusCookie, 0);285 xcb_window_t xcbFocusWindow = pFocusReply->focus;286 free(pFocusReply);287 if (xcbFocusWindow != m_windows[m_iKeyboardCaptureViewIndex]->winId())288 return true;279 /* Make sure we really do still have the focus. Qt as of version 5.13 started 280 * reporting it with delay, so ask the X server directly. We could remove the 281 * version check some time in the future. If we do, remove the comment above 282 * about the focus notification dance, as it will no longer be relevant. */ 283 xcb_get_input_focus_cookie_t xcbFocusCookie = xcb_get_input_focus(NativeWindowSubsystem::X11GetConnection()); 284 xcb_get_input_focus_reply_t *pFocusReply = xcb_get_input_focus_reply(NativeWindowSubsystem::X11GetConnection(), 285 xcbFocusCookie, 0); 286 xcb_window_t xcbFocusWindow = pFocusReply->focus; 287 free(pFocusReply); 288 if (xcbFocusWindow != m_windows[m_iKeyboardCaptureViewIndex]->winId()) 289 return true; 289 290 # endif 290 291 291 /* Grab the mouse button. 292 * We do not check for failure as we do not currently implement a back-up plan. */ 293 /* If any previous grab is still in process, release it. */ 294 if (m_hButtonGrabWindow != 0) 295 xcb_ungrab_button_checked(NativeWindowSubsystem::X11GetConnection(), XCB_BUTTON_INDEX_ANY, 296 m_hButtonGrabWindow, XCB_MOD_MASK_ANY); 297 m_hButtonGrabWindow = NativeWindowSubsystem::X11GetAppRootWindow(); 298 xcb_grab_button_checked(NativeWindowSubsystem::X11GetConnection(), 0, m_hButtonGrabWindow, 299 XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, 300 XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_ANY, XCB_MOD_MASK_ANY); 301 /* And grab the keyboard, using XCB directly, as Qt does not report failure. */ 302 xcb_grab_keyboard_cookie_t xcbGrabCookie = xcb_grab_keyboard(NativeWindowSubsystem::X11GetConnection(), false, 303 m_views[m_iKeyboardCaptureViewIndex]->winId(), 304 XCB_TIME_CURRENT_TIME, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC); 305 xcb_grab_keyboard_reply_t *pGrabReply = xcb_grab_keyboard_reply(NativeWindowSubsystem::X11GetConnection(), 306 xcbGrabCookie, NULL); 307 if (pGrabReply == NULL || pGrabReply->status != XCB_GRAB_STATUS_SUCCESS) 308 { 309 /* Release the mouse button grab. 292 /* Grab the mouse button. 310 293 * We do not check for failure as we do not currently implement a back-up plan. */ 311 xcb_ungrab_button_checked(NativeWindowSubsystem::X11GetConnection(), XCB_BUTTON_INDEX_ANY, 312 m_hButtonGrabWindow, XCB_MOD_MASK_ANY); 313 m_hButtonGrabWindow = 0; 314 /* Try again later: */ 294 /* If any previous grab is still in process, release it. */ 295 if (m_hButtonGrabWindow != 0) 296 xcb_ungrab_button_checked(NativeWindowSubsystem::X11GetConnection(), XCB_BUTTON_INDEX_ANY, 297 m_hButtonGrabWindow, XCB_MOD_MASK_ANY); 298 m_hButtonGrabWindow = NativeWindowSubsystem::X11GetAppRootWindow(); 299 xcb_grab_button_checked(NativeWindowSubsystem::X11GetConnection(), 0, m_hButtonGrabWindow, 300 XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, 301 XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_ANY, XCB_MOD_MASK_ANY); 302 /* And grab the keyboard, using XCB directly, as Qt does not report failure. */ 303 xcb_grab_keyboard_cookie_t xcbGrabCookie = xcb_grab_keyboard(NativeWindowSubsystem::X11GetConnection(), false, 304 m_views[m_iKeyboardCaptureViewIndex]->winId(), 305 XCB_TIME_CURRENT_TIME, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC); 306 xcb_grab_keyboard_reply_t *pGrabReply = xcb_grab_keyboard_reply(NativeWindowSubsystem::X11GetConnection(), 307 xcbGrabCookie, NULL); 308 if (pGrabReply == NULL || pGrabReply->status != XCB_GRAB_STATUS_SUCCESS) 309 { 310 /* Release the mouse button grab. 311 * We do not check for failure as we do not currently implement a back-up plan. */ 312 xcb_ungrab_button_checked(NativeWindowSubsystem::X11GetConnection(), XCB_BUTTON_INDEX_ANY, 313 m_hButtonGrabWindow, XCB_MOD_MASK_ANY); 314 m_hButtonGrabWindow = 0; 315 /* Try again later: */ 316 free(pGrabReply); 317 return false; 318 } 315 319 free(pGrabReply); 316 return false; 317 } 318 free(pGrabReply); 319 320 } 320 321 #else 321 322 … … 370 371 371 372 #elif defined(VBOX_WS_X11) 372 373 /* On X11, we are using XCB stuff to grab the keyboard. 374 * This stuff is a part of the active keyboard grabbing functionality. 375 * Active keyboard grabbing causes a problems on many window managers - a window cannot 376 * be moved using the mouse. So we finally releasing additionally grabbed mouse as well 377 * to allow further user interactions. */ 378 379 /* Ungrab using XCB: */ 380 xcb_ungrab_keyboard(NativeWindowSubsystem::X11GetConnection(), XCB_TIME_CURRENT_TIME); 381 /* Release the mouse button grab. 382 * We do not check for failure as we do not currently implement a back-up plan. */ 383 xcb_ungrab_button_checked(NativeWindowSubsystem::X11GetConnection(), XCB_BUTTON_INDEX_ANY, 384 m_hButtonGrabWindow, XCB_MOD_MASK_ANY); 385 m_hButtonGrabWindow = 0; 386 373 if (uiCommon().X11XServerAvailable()) 374 { 375 /* On X11, we are using XCB stuff to grab the keyboard. 376 * This stuff is a part of the active keyboard grabbing functionality. 377 * Active keyboard grabbing causes a problems on many window managers - a window cannot 378 * be moved using the mouse. So we finally releasing additionally grabbed mouse as well 379 * to allow further user interactions. */ 380 381 /* Ungrab using XCB: */ 382 xcb_ungrab_keyboard(NativeWindowSubsystem::X11GetConnection(), XCB_TIME_CURRENT_TIME); 383 /* Release the mouse button grab. 384 * We do not check for failure as we do not currently implement a back-up plan. */ 385 xcb_ungrab_button_checked(NativeWindowSubsystem::X11GetConnection(), XCB_BUTTON_INDEX_ANY, 386 m_hButtonGrabWindow, XCB_MOD_MASK_ANY); 387 m_hButtonGrabWindow = 0; 388 } 387 389 #else 388 390 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineWindow.cpp
r99407 r99434 149 149 if (gEDataManager->distinguishMachineWindowGroups(uiCommon().managedVMUuid())) 150 150 strWindowName = QString("VirtualBox Machine UUID: %1").arg(uiCommon().managedVMUuid().toString()); 151 if (uiCommon().X11XServerAvailable()) 152 { 153 /* Assign WM_CLASS property: */ 154 NativeWindowSubsystem::X11SetWMClass(this, strWindowName, strWindowClass); 155 /* Tell the WM we are well behaved wrt Xwayland keyboard-grabs: */ 156 NativeWindowSubsystem::X11SetXwaylandMayGrabKeyboardFlag(this); 157 } 151 /* Assign WM_CLASS property: */ 152 NativeWindowSubsystem::setWMClass(uiCommon().X11XServerAvailable(), this, strWindowName, strWindowClass); 153 /* Tell the WM we are well behaved wrt Xwayland keyboard-grabs: */ 154 NativeWindowSubsystem::setXwaylandMayGrabKeyboardFlag(uiCommon().X11XServerAvailable(), this); 158 155 #endif 159 156 }
Note:
See TracChangeset
for help on using the changeset viewer.