[virt-tools-list] [PATCH 1/2] virt-viewer-display-spice: Pass proper x and y coordinates for monitors
Hans de Goede
hdegoede at redhat.com
Tue Jan 22 10:14:09 UTC 2013
Hi,
On 01/19/2013 03:51 AM, Marc-André Lureau wrote:
> Hi
>
> ----- Mensaje original -----
>> Pass something more sensible then +0+0 as coordinates for the monitor
>> to spice-gtk. Note that in windowed mode the coordinates passed do
>> not
>> take the menu + toolbar into account. Just passing the toplevel
>> window
>> coordinates is good enough to make spice-gtk's monitor alignment code
>> work properly.
>>
>> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
>> ---
>> src/virt-viewer-display-spice.c | 8 +++++++-
>> 1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/virt-viewer-display-spice.c
>> b/src/virt-viewer-display-spice.c
>> index 22fde46..e689d9d 100644
>> --- a/src/virt-viewer-display-spice.c
>> +++ b/src/virt-viewer-display-spice.c
>> @@ -189,6 +189,7 @@
>> virt_viewer_display_spice_size_allocate(VirtViewerDisplaySpice
>> *self,
>> gdouble dw = allocation->width, dh = allocation->height;
>> guint zoom = 100;
>> guint nth;
>> + gint x, y;
>>
>> if
>> (virt_viewer_display_get_auto_resize(VIRT_VIEWER_DISPLAY(self))
>> == FALSE)
>> return;
>> @@ -202,8 +203,13 @@
>> virt_viewer_display_spice_size_allocate(VirtViewerDisplaySpice
>> *self,
>> GdkWindow *window =
>> gtk_widget_get_root_window(GTK_WIDGET(self));
>> int n = gdk_screen_get_monitor_at_window(screen, window);
>> gdk_screen_get_monitor_geometry(screen, n, &monitor);
>> + x = monitor.x;
>> + y = monitor.y;
>> dw = monitor.width;
>> dh = monitor.height;
>
> It clearly makes sense in fullscreen / monitor.
Yes, note I think we should also set disable-display-align to false when
going fullscreen after this patch, since this clearly gives us
better monitor coordinates then the align algorithm will. Esp when
using setups with 4 monitors arranged in a 2x2 grid, etc. (not all
that crazy when you look at trading rooms for stock exchanges, etc.).
I'll write a patch for this.
>
>> + } else {
>> + GtkWidget *top = gtk_widget_get_toplevel(GTK_WIDGET(self));
>> + gtk_window_get_position(GTK_WINDOW(top), &x, &y);
>
> However, I really don't think it's a good idea to reorder monitors depending on their window position, even if it may be funny, just 5 sec. ;)
I disagree I wrote this because while testing I noticed the what
was happening was really counter intuitive.
IE: Take a setup with a laptop and a monitor right of the laptop,
with the monitor being used as the primary screen. Now the user starts
remote-viewer on the primary screen, getting display 1 there. Then he
opens a second display and moves that to the laptop (which is left
of the monitor).
Now the display windows are arranged right (monitor, display 1) to left
(laptop, display2). But in the vm they will be arranged left to right.
Until the user goes fullscreen, when we all of a sudden do the right
thing. So not only is this counter intuitive. it will also cause
inconsistencies between windowed and fullscreen mode monitor
arrangement inside the guest.
And in my tests with 3 monitors on a row things became even more
"funny" with windows being dragged over the edge skipping the
middle window and showing up in the right one.
Regards,
Hans
More information about the virt-tools-list
mailing list