[gtk-vnc-devel] [PATCH][RFC] Update keyboard/pointer grab



This patch updates the keyboard/pointer logic as follows:

Pointer grab is only enabled if set_pointer_grab(TRUE) is called. Pointer grab is activated when the guest is in relative mouse mode and the user either 1) clicks on the window or 2) presses ctrl-alt. set_pointer_grab(TRUE) does *not* activate grab.

The same applies to keyboard grab.

If we want to add an additional interface that activates keyboard/pointer grab, I'm certainly happy to do that. This also fixes what I believe is a bug whereas the first mouse click causes grab to be entered when in absolute mode.

What do people think of this?

Regards,

Anthony Liguori
diff -r ec1859fcd58c src/vncdisplay.c
--- a/src/vncdisplay.c	Mon Jan 21 09:00:38 2008 -0600
+++ b/src/vncdisplay.c	Thu Jan 24 10:05:59 2008 -0600
@@ -244,8 +244,7 @@ static gboolean button_event(GtkWidget *
 	if (priv->read_only)
 		return FALSE;
 
-	if ((priv->grab_pointer || !priv->absolute) &&
-	    !priv->in_pointer_grab &&
+	if (priv->grab_pointer && !priv->absolute && !priv->in_pointer_grab &&
 	    button->button == 1 && button->type == GDK_BUTTON_PRESS)
 		do_pointer_grab(VNC_DISPLAY(widget), FALSE);
 
@@ -1339,8 +1338,6 @@ void vnc_display_set_pointer_grab(VncDis
 	priv->grab_pointer = enable;
 	if (!enable && priv->absolute && priv->in_pointer_grab)
 		do_pointer_ungrab(obj, FALSE);
-	if (enable && priv->absolute && !priv->in_pointer_grab)
-		do_pointer_grab(obj, FALSE);
 }
 
 void vnc_display_set_keyboard_grab(VncDisplay *obj, gboolean enable)
@@ -1350,9 +1347,6 @@ void vnc_display_set_keyboard_grab(VncDi
 	priv->grab_keyboard = enable;
 	if (!enable && priv->in_keyboard_grab && !priv->in_pointer_grab)
 		do_keyboard_ungrab(obj, FALSE);
-	if (enable && !priv->in_keyboard_grab)
-		do_keyboard_grab(obj, FALSE);
-
 }
 
 void vnc_display_set_read_only(VncDisplay *obj, gboolean enable)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]