Re: gvncviewer improvement - input grab problems



2009/8/17 Michal Suchanek <hramrach centrum cz>:
> 2009/8/17 Daniel P. Berrange <dan berrange com>:
>> On Sat, Aug 08, 2009 at 04:02:11PM +0200, Michal Suchanek wrote:
>>> Debian package installs the gvncviewer example as an application so I
>>> was trying to use it as a vnc viewer instead of the xvncviewer and
>>> found that it has some advantages and problems.
>>>
>>> The major advantage over xvncviewer version in Debian is support for
>>> resizing the remote desktop.
>>>
>>> The drawback which is easily resolved is that with gvncviewer one
>>> cannot specify local vnc server by display number only.
>>>
>>> There is also another issue that the vnc viewer reports "disconnected
>>> from server" when it in fact did not manage to connect at all.
>>>
>>> The problem I did not manage to resolve is that the viewer grabs the
>>> input on some occasions and I did not manage to turn off this feature
>>> completely.
>>>
>>> The grab comes in two flavours - one is grabbing the keyboard while
>>> the mouse is over the remote display area which prevents using window
>>> manager shortcuts.
>>>
>>> The other is grabbing both keyboard and pointer when Ctrl+Alt is pressed.
>
> Is it also possible to turn off this feature?
>

It's possible with this patch (applies on top of the previous three -
specifically the menu item is required).

It works for me at least for booting grub.

Thanks

Michal
diff --git a/examples/gvncviewer.c b/examples/gvncviewer.c
index 44b49cc..f12a6e6 100644
--- a/examples/gvncviewer.c
+++ b/examples/gvncviewer.c
@@ -221,6 +221,12 @@ static void do_scaling(GtkWidget *menu, GtkWidget *vncdisplay)
 		vnc_display_set_scaling(VNC_DISPLAY(vncdisplay), FALSE);
 }
 
+static void set_grab(GtkWidget *vncdisplay)
+{
+	vnc_display_set_keyboard_grab(VNC_DISPLAY(vncdisplay), keyboard_grab);;
+	vnc_display_set_keyboard_grab_manual(VNC_DISPLAY(vncdisplay), keyboard_grab);;
+}
+
 static void do_keyboard_grab(GtkWidget *menu, GtkWidget *vncdisplay)
 {
 	if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu)))
@@ -228,7 +234,7 @@ static void do_keyboard_grab(GtkWidget *menu, GtkWidget *vncdisplay)
 	else
 		keyboard_grab = FALSE;
 
-	vnc_display_set_keyboard_grab(VNC_DISPLAY(vncdisplay), keyboard_grab);;
+	set_grab(vncdisplay);
 }
 
 static void vnc_credential(GtkWidget *vncdisplay, GValueArray *credList)
@@ -481,10 +487,10 @@ int main(int argc, char **argv)
 	} else
 		snprintf(port, sizeof(port), "%d", 5900);
 
-	if(! *hostname) 
+	if(! *hostname)
 		snprintf(hostname, sizeof(hostname), "%s", "127.0.0.1");
 	vnc_display_open_host(VNC_DISPLAY(vnc), hostname, port);
-	vnc_display_set_keyboard_grab(VNC_DISPLAY(vnc), keyboard_grab);;
+	set_grab(vnc);
 	vnc_display_set_pointer_grab(VNC_DISPLAY(vnc), TRUE);
 
 	if (!gtk_widget_is_composited(window)) {
diff --git a/src/vncdisplay.c b/src/vncdisplay.c
index e587dfb..469b0c1 100644
--- a/src/vncdisplay.c
+++ b/src/vncdisplay.c
@@ -81,6 +81,7 @@ struct _VncDisplayPrivate
 
 	gboolean grab_pointer;
 	gboolean grab_keyboard;
+	gboolean grab_manual;
 	gboolean local_pointer;
 	gboolean read_only;
 	gboolean allow_lossy;
@@ -129,7 +130,8 @@ enum
   PROP_LOSSY_ENCODING,
   PROP_SCALING,
   PROP_SHARED_FLAG,
-  PROP_FORCE_SIZE
+  PROP_FORCE_SIZE,
+  PROP_KEYBOARD_GRAB_MANUAL
 };
 
 /* Signals */
@@ -188,6 +190,9 @@ vnc_display_get_property (GObject    *object,
       case PROP_KEYBOARD_GRAB:
         g_value_set_boolean (value, vnc->priv->grab_keyboard);
 	break;
+      case PROP_KEYBOARD_GRAB_MANUAL:
+        g_value_set_boolean (value, vnc->priv->grab_manual);
+	break;
       case PROP_READ_ONLY:
         g_value_set_boolean (value, vnc->priv->read_only);
 	break;
@@ -237,6 +242,8 @@ vnc_display_set_property (GObject      *object,
       case PROP_KEYBOARD_GRAB:
         vnc_display_set_keyboard_grab (vnc, g_value_get_boolean (value));
         break;
+      case PROP_KEYBOARD_GRAB_MANUAL:
+        vnc_display_set_keyboard_grab_manual (vnc, g_value_get_boolean (value));
       case PROP_READ_ONLY:
         vnc_display_set_read_only (vnc, g_value_get_boolean (value));
         break;
@@ -754,7 +761,7 @@ static gboolean key_event(GtkWidget *widget, GdkEventKey *key)
 	     (keyval == GDK_Alt_L && (key->state & GDK_CONTROL_MASK)))) {
 		if (priv->in_pointer_grab)
 			do_pointer_ungrab(VNC_DISPLAY(widget), FALSE);
-		else if (!priv->grab_keyboard || !priv->absolute)
+		else if ((!priv->grab_keyboard || !priv->absolute) && priv->grab_manual)
 			do_pointer_grab(VNC_DISPLAY(widget), FALSE);
 	}
 
@@ -1626,6 +1633,17 @@ static void vnc_display_class_init(VncDisplayClass *klass)
 								G_PARAM_STATIC_NICK |
 								G_PARAM_STATIC_BLURB));
 	g_object_class_install_property (object_class,
+					 PROP_KEYBOARD_GRAB_MANUAL,
+					 g_param_spec_boolean ( "grab-keyboard-manual",
+								"Grab Keyboard by keypress",
+								"Whether we should allow grabbing the keyboard by key combo",
+								FALSE,
+								G_PARAM_READWRITE |
+								G_PARAM_CONSTRUCT |
+								G_PARAM_STATIC_NAME |
+								G_PARAM_STATIC_NICK |
+								G_PARAM_STATIC_BLURB));
+	g_object_class_install_property (object_class,
 					 PROP_READ_ONLY,
 					 g_param_spec_boolean ( "read-only",
 								"Read Only",
@@ -1901,6 +1919,7 @@ static void vnc_display_init(VncDisplay *display)
 	priv->allow_scaling = FALSE;
 	priv->grab_pointer = FALSE;
 	priv->grab_keyboard = FALSE;
+	priv->grab_manual = TRUE;
 	priv->local_pointer = FALSE;
 	priv->shared_flag = FALSE;
 	priv->force_size = TRUE;
@@ -2040,6 +2059,11 @@ void vnc_display_set_keyboard_grab(VncDisplay *obj, gboolean enable)
 		do_keyboard_ungrab(obj, FALSE);
 }
 
+void vnc_display_set_keyboard_grab_manual(VncDisplay *obj, gboolean enable)
+{
+	obj->priv->grab_manual = enable;
+}
+
 void vnc_display_set_read_only(VncDisplay *obj, gboolean enable)
 {
 	obj->priv->read_only = enable;
diff --git a/src/vncdisplay.h b/src/vncdisplay.h
index 7c6a64e..8c46125 100644
--- a/src/vncdisplay.h
+++ b/src/vncdisplay.h
@@ -109,6 +109,9 @@ gboolean	vnc_display_get_pointer_grab(VncDisplay *obj);
 void		vnc_display_set_keyboard_grab(VncDisplay *obj, gboolean enable);
 gboolean	vnc_display_get_keyboard_grab(VncDisplay *obj);
 
+void		vnc_display_set_keyboard_grab_manual(VncDisplay *obj, gboolean enable);
+gboolean	vnc_display_get_keyboard_grab_manual(VncDisplay *obj);
+
 void		vnc_display_set_read_only(VncDisplay *obj, gboolean enable);
 gboolean	vnc_display_get_read_only(VncDisplay *obj);
 


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