Guests don't revert to LastNormalWindowPosition

This is for discussing general topics about how to use VirtualBox.
Post Reply
Duhhh
Posts: 28
Joined: 18. Feb 2010, 04:51
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 7, Windows Vista

Guests don't revert to LastNormalWindowPosition

Post by Duhhh »

I'm running on Ubuntu 11.10, and have a guest (Win7, but it doesn't seem to matter) set to GUI/AutoresizeGuest=off. I start the VM, and VBox positions the windows (guest has 2 monitors) based on GUI\LastNormalWindowPosition. However, as the guest boots, it changes resolution several times, and the windows end up moving and changing size. I move and size them back to where I want, and go fullscreen. When I exit fullscreen, the windows try to grow as large as possible, ignoring the last normal size.

Is there any way I can make these windows behave?
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Guests don't revert to LastNormalWindowPosition

Post by Perryg »

turn GUI/AutoresizeGuest=off back on.
Duhhh
Posts: 28
Joined: 18. Feb 2010, 04:51
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 7, Windows Vista

Re: Guests don't revert to LastNormalWindowPosition

Post by Duhhh »

If I do that, the guests will try to change resolution when they're not fullscreen, which I do *NOT* want. When the guests are in a window, I want the window to resize, and allow me to scroll around and see which part of the display I choose.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Guests don't revert to LastNormalWindowPosition

Post by Perryg »

9.7 Advanced display configuration in your VirtualBox users manual.
Turning auto-resize off takes pretty much all control from VirtualBox and you will need to set custom resolution to control the screen size.
Duhhh
Posts: 28
Joined: 18. Feb 2010, 04:51
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 7, Windows Vista

Re: Guests don't revert to LastNormalWindowPosition

Post by Duhhh »

That's not what 9.7 of MY VBox manual says, but that's OK

For others who want their VB windows to behave, if you're running under linux, you can always write a script that uses:

wmctrl -r "name of VB window" -e 0,x,y,size-x,size-y

and then bind that script to a key-command or mouse-action using metacity. Problem solved.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Guests don't revert to LastNormalWindowPosition

Post by Perryg »

Like I said set a custom resolution.
Duhhh
Posts: 28
Joined: 18. Feb 2010, 04:51
Primary OS: Ubuntu other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 7, Windows Vista

Re: Guests don't revert to LastNormalWindowPosition

Post by Duhhh »

If anyone else wants to do the same, here's how I solved it. I found that I needed both wmctrl and xdotool. For the most part, wmctrl works, but it can't "un-minimize" a window, and sometimes I'll minimize the windows to do other work, and want my script to bring them back. xdotool can do that, but can't "un-maximize," which is needed since restoring from full-screen often leaves a guest window maximized. For a two-monitor guest, the following script will resize them for windowed use.

Remember, I turned off Auto-resize guest window, because my guest apps don't like to resize. This allows me to scroll around on the window.

Code: Select all

#!/bin/bash

# Since Virtualbox won't manage the size & positions of its windows, we have to do it for him.

#if the human has minimized us, restore them
xdotool search --name "VirtualBox : 2" windowactivate
xdotool search --name "VirtualBox : 1" windowactivate

# Sometimes, the windows get maximized. We'll try to fix that
wmctrl -r "VirtualBox : 1" -b remove,maximized_horz
wmctrl -r "VirtualBox : 1" -b remove,maximized_vert
wmctrl -r "VirtualBox : 2" -b remove,maximized_horz
wmctrl -r "VirtualBox : 2" -b remove,maximized_vert

#now move to the correct screen and resize to 1200x800
wmctrl -r "VirtualBox : 1" -e 0,100,80,1200,800
wmctrl -r "VirtualBox : 2" -e 0,1940,80,1200,800
Post Reply