[gtk-vnc-devel] [PATCH] Rework cursor grab semantics



Here's how I think the cursor should work in terms of use-case:

For normal VNC servers, keyboard/mouse grab should only be activated when ctrl-alt is clicked. If the server is doing cursor offloading, we should use that cursor.

For servers supporting PointerTypeChange, when in absolute mode, they should behave as above. When in relative mode, pointer grab should also be activated on the first left-click in the window. The cursor should *not* be hidden when cursor grab is not activated.

I know that there is a need for a new interface to grab on full screen. We'll implement that before the next release. I would like to get some input though to make sure this is the right set of use-cases.

I've committed this patch to the tree. Please try it out in your applications and let me know what you need.

Regards,

Anthony Liguori
diff -r e65d8e4758b3 src/vncdisplay.c
--- a/src/vncdisplay.c	Wed Feb 06 18:36:18 2008 -0600
+++ b/src/vncdisplay.c	Wed Feb 06 18:49:48 2008 -0600
@@ -351,8 +351,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);
 
@@ -818,7 +817,7 @@ static gboolean on_resize(void *opaque, 
 		priv->null_cursor = create_null_cursor();
 		if (priv->local_pointer)
 			do_pointer_show(obj);
-		else
+		else if (!priv->absolute)
 			do_pointer_hide(obj);
 		priv->gc = gdk_gc_new(GTK_WIDGET(obj)->window);
 	}
@@ -1810,7 +1809,7 @@ void vnc_display_set_pointer_local(VncDi
 	if (obj->priv->gc) {
 		if (enable)
 			do_pointer_show(obj);
-		else
+		else if (obj->priv->in_pointer_grab || obj->priv->absolute)
 			do_pointer_hide(obj);
 	}
 	obj->priv->local_pointer = enable;
@@ -1823,8 +1822,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)
@@ -1834,9 +1831,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]