[Spice-devel] [PATCH spice-gtk 3/3] win32: clip and move cursor within window region

Marc-André Lureau mlureau at redhat.com
Tue Nov 13 08:57:21 PST 2012



----- Original Message -----
> > +    gint xr, yr;
> >  
> > -    gint xr = gdk_screen_get_width(screen) / 2;
> > -    gint yr = gdk_screen_get_height(screen) / 2;
> > -
> > +#ifdef WIN32
> > +    RECT clip;
> > +    g_return_if_fail(GetClipCursor(&clip));
> > +    xr = clip.left + (clip.right - clip.left) / 2;
> > +    yr = clip.top + (clip.bottom - clip.top) / 2;
> > +#endif
> >      if (xr != (gint)motion->x_root || yr != (gint)motion->y_root)
> >      {
> 
> xr and yr are no longer initialized at this point on !WIN32

oops, indeed! I have a bit too much of a windows centric eye these days..

> Patch looks good otherwise.

I am reworking the patch, since it doesn't work when the viewer is in !primary monitor. Something like that:

-    if (!SystemParametersInfo(SPI_GETWORKAREA, 0, &workarea, 0))
+    monitor = MonitorFromRect(&window, MONITOR_DEFAULTTONEAREST);
+    g_return_val_if_fail(monitor != NULL, false);
+
+    mi.cbSize = sizeof(mi);
+    if (!GetMonitorInfo(monitor, &mi))
         goto error;


Unfortunately, I don't have dual-head physical windows machine atm to really test this patch, but it still seems to fail in some corner-cases..


thanks


More information about the Spice-devel mailing list