Ticket #1954 (new defect)
default window position on resize issue with qt (3 or 4), compiz and multiple viewports (desktops)
|Reported by:||snadge||Owned by:|
|Version:||VirtualBox 1.6.4||Keywords:||compiz qt resize position|
I post this with as much detail as I can collect, as this problem is a difficult one. First it is important to distinguish the difference between multiple virtual desktops and viewports. Virtual desktops are treated as seperate "screens" by QT, so therefore do not exhibit this problem. If you test with KWin or metacity, you will notice this isn't an issue. Also if you test compiz using multiple desktops instead of virtual horizontal/vertical ones then the problem does not appear.
Viewports are a compiz invention, to combine multiple desktops into a single large desktop, to make plugins like the wall and cube work. If you do not do this, when moving a window half way between two desktops, instead of the window appearing on both desktops, it will get truncated.
Reproduce the problem as follows. Start any guest VM, it will create an initial window (make sure its not full screen or maximised), then switch to another viewport. When the guest resizes its window (eg, changing from BIOS screen to loading windows screen), the window will appear on the currently active viewport, instead of the viewport it was initially created on (before the resize).
I can confirm that the problem is in the function called normalizeGeometry contained in VBox/Frontends/VirtualBox4/src/VBoxConsoleView.cpp on line 921 (svn).. This function is called from the resize event (VBoxDefs::ResizeEventType line 1093), with a default (and unchangeable) parameter of "true". Changing this value to "false" fixes the problem. Obviously this is not ideal, as this will upset the people who complained that sometimes when vbox resizes a window, it goes off the screen. Personally I think if that happens, you should just get over it and use the window move function (right click on the tasks name select move) to move it back on screen again. At the very least, there should be a configurable option (a checkbox) "Place offscreen windows back onscreen again". (To avoid having to do a source compilation to work around this issue)
As for how to fix the problem properly, this is where it becomes far more difficult. Its not QT's job to be aware of what the window manager is doing, how many workspaces there are etc. And its obviously not a portable thing to do anyway (What does this mean on Windows/Mac?).
The normalizeGeometry code uses the window() function to return the position of an uninitialized QWidget object, which defaults to a viewable area within the current "screen" or "desktop". The value of this is then passed to QDesktopWidget::availableGeometry to determine the viewable area where the window should be repositioned.
The problem is, this is not desirable for the compiz/viewport scenario, but works on absolutely everything else. Instead what we need to do, is return a QRect for the "viewport" that the window currently exists on. (No idea how to do this)
Also of note, is that because vbox overrides the window manager's default positioning of the window, you cannot use the window positioning rules in compiz config settings manager to override the default behaviour.
I've spent days on this silly problem, I really wanted to provide a patch to fix it properly but alas it requires further discussion. :(
I hope I have provided enough substance for a proper resolution of this matter, and I thank anyone who wishes to help resolve this for their time in advance. :)