From bbbfd4b7c8ce26538f6a27752b9180c09053967b Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Wed, 9 Sep 2020 12:58:20 -0400 Subject: [PATCH] vmwindow: Default the console widget to 1024x768 When a VM window is launched for the first for a VM, currently we set the top window size to 800x600 which is small and arbitrary and is universally shrinks the viewer too much to fit any OS installer I can find. Instead do some hacks to resize the window to accomodate a viewer widget of 1024x768 which seems to be what QXL graphics give us for win10 and Fedora 32 installers. So for new VMs hitting the OS installer we don't see scrollbars. Signed-off-by: Cole Robinson --- tests/uitests/test_prefs.py | 3 +-- virtManager/vmwindow.py | 27 ++++++++++++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/tests/uitests/test_prefs.py b/tests/uitests/test_prefs.py index 37a3857ec..2571fd418 100644 --- a/tests/uitests/test_prefs.py +++ b/tests/uitests/test_prefs.py @@ -103,15 +103,14 @@ class VMMPrefs(uiutils.UITestCase): xmleditor = detailswin.find("XML editor") detailswin.find("XML", "page tab").click() - uiutils.drag(detailswin, 400, 400) warnlabel = detailswin.find_fuzzy("XML editing is disabled") uiutils.check(lambda: warnlabel.visible) origtext = xmleditor.text xmleditor.typeText("1234abcd") uiutils.check(lambda: xmleditor.text == origtext) + managerwin.click_title() managerwin.grabFocus() - managerwin.click() managerwin.find("Edit", "menu").click() managerwin.find("Preferences", "menu item").click() prefswin = self.app.root.find_fuzzy("Preferences", "frame") diff --git a/virtManager/vmwindow.py b/virtManager/vmwindow.py index 5fcce1ea5..b49d90d7c 100644 --- a/virtManager/vmwindow.py +++ b/virtManager/vmwindow.py @@ -83,11 +83,10 @@ class vmmVMWindow(vmmGObjectUI): # Set default window size w, h = self.vm.get_details_window_size() - if w <= 0: - w = 800 - if h <= 0: - h = 600 - self.topwin.set_default_size(w, h) + if w <= 0 or h <= 0: + self._set_initial_window_size() + else: + self.topwin.set_default_size(w, h) self._window_size = None self._shutdownmenu = None @@ -190,6 +189,24 @@ class vmmVMWindow(vmmGObjectUI): return self.emit("customize-finished", self.vm) + def _set_initial_window_size(self): + """ + We want the window size for new windows to be 1024x768 viewer + size, plus whatever it takes to fit the toolbar+menubar, etc. + To achieve this, we force the display box to the desired size + with set_size_request, wait for the window to report it has + been resized, and then unset the hardcoded size request so + the user can manually resize the window however they want. + """ + w = 1024 + h = 768 + hid = [] + def win_cb(src, event): + self.widget("details-pages").set_size_request(-1, -1) + self.topwin.disconnect(hid[0]) + self.widget("details-pages").set_size_request(w, h) + hid.append(self.topwin.connect("configure-event", win_cb)) + def _vm_removed_cb(self, _conn, vm): if self.vm == vm: self.cleanup()