Ticket #15863: setGeometry.patch
File setGeometry.patch, 9.4 KB (added by , 8 years ago) |
---|
-
src/VBox/Frontends/VirtualBox/src/extensions/QIMainWindow.cpp
21 21 22 22 /* GUI includes: */ 23 23 # include "QIMainWindow.h" 24 # include "VBoxGlobal.h" 24 25 25 26 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 26 27 … … 38 39 resize(m_geometry.size()); 39 40 #else /* VBOX_WS_MAC */ 40 41 /* Use the new approach for Windows/X11: */ 41 setGeometry(m_geometry);42 VBoxGlobal::setTopLevelGeometry(this, m_geometry); 42 43 #endif /* !VBOX_WS_MAC */ 43 44 44 45 /* Maximize (if necessary): */ -
src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
36 36 # include <QDir> 37 37 # include <QLocale> 38 38 # include <QSpinBox> 39 # include <QMainWindow> 39 40 # ifdef VBOX_WS_WIN 40 41 # include <QEventLoop> 41 42 # endif /* VBOX_WS_WIN */ … … 49 50 # endif /* VBOX_GUI_WITH_PIDFILE */ 50 51 # if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000 51 52 # include <QScreen> 53 # include <xcb/xcb.h> 54 # include <xcb/xcb_icccm.h> 52 55 # endif /* VBOX_WS_X11 && QT_VERSION >= 0x050000 */ 53 56 54 57 /* GUI includes: */ … … 3702 3705 pSpinBox->setMinimumWidth(iTextWidth + iSpinBoxDelta); 3703 3706 } 3704 3707 3708 /* static */ 3709 void VBoxGlobal::setTopLevelGeometry(QMainWindow *window, int x, int y, int w, int h) 3710 { 3711 #if defined(VBOX_WS_X11) && QT_VERSION >= 0x050000 3712 # define QWINDOWSIZE_MAX ((1<<24)-1) 3713 if (window->isVisible()) 3714 { 3715 /* X11 window managers are not required to accept geometry changes on 3716 * the top-level window. Unfortunately, current at Qt 5.6 and 5.7, Qt 3717 * assumes that the change will succeed, and resizes all sub-windows 3718 * unconditionally. By calling ConfigureWindow directly, Qt will see 3719 * our change request as an externally triggered one on success and not 3720 * at all if it is rejected. */ 3721 uint16_t fMask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y 3722 | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; 3723 uint32_t values[] = { (uint32_t)x, (uint32_t)y, (uint32_t)w, (uint32_t)h }; 3724 xcb_configure_window(QX11Info::connection(), (xcb_window_t)window->winId(), 3725 fMask, values); 3726 xcb_size_hints_t hints; 3727 hints.flags = XCB_ICCCM_SIZE_HINT_US_POSITION | XCB_ICCCM_SIZE_HINT_US_SIZE; 3728 hints.x = x; 3729 hints.y = y; 3730 hints.width = w; 3731 hints.height = h; 3732 hints.min_width = window->minimumSize().width(); 3733 hints.min_height = window->minimumSize().height(); 3734 hints.max_width = window->maximumSize().width(); 3735 hints.max_height = window->maximumSize().height(); 3736 if (hints.min_width > 0 && hints.min_height > 0) 3737 hints.flags |= XCB_ICCCM_SIZE_HINT_P_MIN_SIZE; 3738 if (hints.max_width < QWINDOWSIZE_MAX && hints.max_height < QWINDOWSIZE_MAX) 3739 hints.flags |= XCB_ICCCM_SIZE_HINT_P_MAX_SIZE; 3740 xcb_change_property(QX11Info::connection(), XCB_PROP_MODE_REPLACE, 3741 (xcb_window_t)window->winId(), XCB_ATOM_WM_NORMAL_HINTS, 3742 XCB_ATOM_WM_SIZE_HINTS, 32, sizeof(hints) >> 2, &hints); 3743 xcb_flush(QX11Info::connection()); 3744 } 3745 else 3746 /* Call the Qt method if the window is not visible as otherwise no 3747 * Configure event will arrive to tell Qt what geometry we want. */ 3748 window->setGeometry(x, y, w, h); 3749 # else 3750 window->setGeometry(x, y, w, h); 3751 # endif 3752 } 3753 3754 /* static */ 3755 void VBoxGlobal::setTopLevelGeometry(QMainWindow *window, QRect rect) 3756 { 3757 VBoxGlobal::setTopLevelGeometry(window, rect.x(), rect.y(), rect.width(), rect.height()); 3758 } 3759 3705 3760 // Public slots 3706 3761 //////////////////////////////////////////////////////////////////////////////// 3707 3762 -
src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
26 26 #include <QHash> 27 27 #include <QFileIconProvider> 28 28 #include <QReadWriteLock> 29 # include <QMainWindow> 29 30 #ifdef VBOX_WS_MAC 30 31 # include <QSet> 31 32 #endif /* VBOX_WS_MAC */ … … 442 443 * to strict the minimum width to reflect at least [n] symbols. */ 443 444 static void setMinimumWidthAccordingSymbolCount(QSpinBox *pSpinBox, int cCount); 444 445 446 /** Set top-level window geometry, taking into account that this may fail 447 * on X11. */ 448 static void setTopLevelGeometry(QMainWindow *window, int x, int y, int w, int h); 449 static void setTopLevelGeometry(QMainWindow *window, QRect rect); 450 445 451 signals: 446 452 447 453 /** Notifies listeners about the VBoxSVC availability change. */ -
src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineWindowFullscreen.cpp
350 350 geo = QRect(QPoint(0, 0), QSize(800, 600).boundedTo(workingArea.size())); 351 351 /* Move window to the center of working-area: */ 352 352 geo.moveCenter(workingArea.center()); 353 setGeometry(geo);353 VBoxGlobal::setTopLevelGeometry(this, geo); 354 354 } 355 355 356 356 #elif defined(VBOX_WS_WIN) -
src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineWindowNormal.cpp
371 371 { 372 372 /* Restore window geometry: */ 373 373 m_normalGeometry = geo; 374 setGeometry(m_normalGeometry);374 VBoxGlobal::setTopLevelGeometry(this, m_normalGeometry); 375 375 } 376 376 /* If previous machine-state was NOT SAVED: */ 377 377 else … … 378 378 { 379 379 /* Restore only window position: */ 380 380 m_normalGeometry = QRect(geo.x(), geo.y(), width(), height()); 381 setGeometry(m_normalGeometry);381 VBoxGlobal::setTopLevelGeometry(this, m_normalGeometry); 382 382 /* And normalize to the optimal-size: */ 383 383 normalizeGeometry(false /* adjust position */); 384 384 } … … 400 400 /* Move newly created window to the screen-center: */ 401 401 m_normalGeometry = geometry(); 402 402 m_normalGeometry.moveCenter(availableGeo.center()); 403 setGeometry(m_normalGeometry);403 VBoxGlobal::setTopLevelGeometry(this, m_normalGeometry); 404 404 } 405 405 406 406 /* Normalize to the optimal size: */ … … 574 574 frGeo = VBoxGlobal::normalizeGeometry(frGeo, gpDesktop->overallAvailableRegion()); 575 575 576 576 /* Finally, set the frame geometry: */ 577 setGeometry(frGeo.left() + dl, frGeo.top() + dt,578 frGeo.width() - dl - dr, frGeo.height() - dt - db);577 VBoxGlobal::setTopLevelGeometry(this, frGeo.left() + dl, frGeo.top() + dt, 578 frGeo.width() - dl - dr, frGeo.height() - dt - db); 579 579 #else /* VBOX_GUI_WITH_CUSTOMIZATIONS1 */ 580 580 /* Customer request: There should no be 581 581 * machine-window resize/move on machine-view resize: */ -
src/VBox/Frontends/VirtualBox/src/runtime/scale/UIMachineWindowScale.cpp
101 101 { 102 102 /* Restore window geometry: */ 103 103 m_normalGeometry = geo; 104 setGeometry(m_normalGeometry);104 VBoxGlobal::setTopLevelGeometry(this, m_normalGeometry); 105 105 106 106 /* Maximize (if necessary): */ 107 107 if (gEDataManager->machineWindowShouldBeMaximized(machineLogic()->visualStateType(), … … 120 120 /* Move newly created window to the screen-center: */ 121 121 m_normalGeometry = geometry(); 122 122 m_normalGeometry.moveCenter(availableGeo.center()); 123 setGeometry(m_normalGeometry);123 VBoxGlobal::setTopLevelGeometry(this, m_normalGeometry); 124 124 } 125 125 126 126 /* Normalize to the optimal size: */ … … 201 201 frGeo = VBoxGlobal::normalizeGeometry(frGeo, gpDesktop->overallAvailableRegion()); 202 202 203 203 /* Finally, set the frame geometry: */ 204 setGeometry(frGeo.left() + dl, frGeo.top() + dt,205 frGeo.width() - dl - dr, frGeo.height() - dt - db);204 VBoxGlobal::setTopLevelGeometry(this, frGeo.left() + dl, frGeo.top() + dt, 205 frGeo.width() - dl - dr, frGeo.height() - dt - db); 206 206 #else /* VBOX_GUI_WITH_CUSTOMIZATIONS1 */ 207 207 /* Customer request: There should no be 208 208 * machine-window resize/move on machine-view resize: */