[Spice-commits] 3 commits - gtk/keymaps.csv gtk/spice-widget.c

Marc-André Lureau elmarco at kemper.freedesktop.org
Tue Dec 13 14:46:00 PST 2011


 gtk/keymaps.csv    |    1 +
 gtk/spice-widget.c |   42 ++++++++++++++++++++++++++++++------------
 2 files changed, 31 insertions(+), 12 deletions(-)

New commits:
commit 1b93c17f65750c39daf6aa5c0f3192cc5ff37e0c
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Tue Dec 13 23:18:53 2011 +0100

    windows: fix broken left shift
    
    On Windows, the received key when pressing left shift is VK_SHIFT 0x10

diff --git a/gtk/keymaps.csv b/gtk/keymaps.csv
index c447f46..98c723b 100644
--- a/gtk/keymaps.csv
+++ b/gtk/keymaps.csv
@@ -42,6 +42,7 @@ KEY_L,38,ANSI_L,0x25,38,75,75,38,38,15,VK_L,0x4c,38,38
 KEY_SEMICOLON,39,ANSI_Semicolon,0x29,39,76,76,39,39,51,VK_OEM_1,0xba,39,39
 KEY_APOSTROPHE,40,ANSI_Quote,0x27,40,82,82,40,40,52,VK_OEM_2,0xbf,40,40
 KEY_GRAVE,41,ANSI_Grave,0x32,41,14,14,41,41,53,VK_OEM_3,0xc0,41,41
+KEY_SHIFT,42,Shift,0x38,42,18,18,42,42,225,VK_SHIFT,0x10,42,42
 KEY_LEFTSHIFT,42,Shift,0x38,42,18,18,42,42,225,VK_LSHIFT,0xa0,42,42
 KEY_BACKSLASH,43,ANSI_Backslash,0x2a,43,93,93,43,43,50,VK_OEM_5,0xdc,43,43
 KEY_Z,44,ANSI_Z,0x6,44,26,26,44,44,29,VK_Z,0x5a,44,44
commit bc48229cc5c27822dcdac0baabbdbdab2d13a795
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Tue Dec 13 17:20:22 2011 +0100

    Wrap in window, because windows doens't receive mouse events outside it

diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index 83339e3..d2d09af 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -628,27 +628,31 @@ static void mouse_check_edges(GtkWidget *widget, GdkEventMotion *motion)
     SpiceDisplay *display = SPICE_DISPLAY(widget);
     SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
     GdkScreen *screen = gtk_widget_get_screen(widget);
-    int x = (int)motion->x_root;
-    int y = (int)motion->y_root;
+    gint ww, wh;
 
-    /* from gtk-vnc:
-     * In relative mode check to see if client pointer hit one of the
-     * screen edges, and if so move it back by 100 pixels. This is
+    gdk_drawable_get_size(gtk_widget_get_window(widget), &ww, &wh);
+    int x = (int)motion->x;
+    int y = (int)motion->y;
+    int xr = (int)motion->x_root;
+    int yr = (int)motion->y_root;
+
+    /* from gtk-vnc: In relative mode check to see if client pointer
+     * hit the window edges, and if so move it back by 100px. This is
      * important because the pointer in the server doesn't correspond
      * 1-for-1, and so may still be only half way across the
      * screen. Without this warp, the server pointer would thus appear
      * to hit an invisible wall */
-    if (x <= 0) x += 100;
-    if (y <= 0) y += 100;
-    if (x >= (gdk_screen_get_width(screen) - 1)) x -= 100;
-    if (y >= (gdk_screen_get_height(screen) - 1)) y -= 100;
+    if (x <= 0) xr += 100;
+    if (y <= 0) yr += 100;
+    if (x >= (ww - 1)) xr -= 100;
+    if (y >= (wh - 1)) yr -= 100;
 
-    if (x != (int)motion->x_root || y != (int)motion->y_root) {
+    if (xr != (int)motion->x_root || yr != (int)motion->y_root) {
         /* FIXME: we try our best to ignore that next pointer move event.. */
         gdk_display_sync(gdk_screen_get_display(screen));
 
         gdk_display_warp_pointer(gtk_widget_get_display(widget),
-                                 screen, x, y);
+                                 screen, xr, yr);
         d->mouse_last_x = -1;
         d->mouse_last_y = -1;
     }
commit 832f7fc1889a1d1d697232af211dab5b18bc06fa
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Tue Dec 13 17:21:03 2011 +0100

    windows: clip pointer when grabbed, so it stays inside widget

diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index f5be849..83339e3 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -554,7 +554,18 @@ static GdkGrabStatus do_pointer_grab(SpiceDisplay *display)
         d->mouse_grab_active = true;
         g_signal_emit(display, signals[SPICE_DISPLAY_MOUSE_GRAB], 0, true);
     }
-
+#ifdef WIN32
+    {
+        RECT client_rect;
+        POINT origin;
+
+        origin.x = origin.y = 0;
+        ClientToScreen(focus_window, &origin);
+        GetClientRect(focus_window, &client_rect);
+        OffsetRect(&client_rect, origin.x, origin.y);
+        ClipCursor(&client_rect);
+    }
+#endif
     gtk_grab_add(GTK_WIDGET(display));
 
     gdk_cursor_unref(blank);
@@ -652,6 +663,9 @@ static void try_mouse_ungrab(SpiceDisplay *display)
 
     gdk_pointer_ungrab(GDK_CURRENT_TIME);
     gtk_grab_remove(GTK_WIDGET(display));
+#ifdef WIN32
+    ClipCursor(NULL);
+#endif
 
     d->mouse_grab_active = false;
 


More information about the Spice-commits mailing list