Re: gvncviewer improvement - input grab problems
- From: Michal Suchanek <hramrach centrum cz>
- To: "Daniel P. Berrange" <dan berrange com>
- Cc: gtk-vnc-list gnome org
- Subject: Re: gvncviewer improvement - input grab problems
- Date: Mon, 17 Aug 2009 21:12:30 +0200
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?
Sending rediffed patches with all whitespace as tabs.
Thanks
Michal
diff --git a/examples/gvncviewer.c b/examples/gvncviewer.c
index 6373564..229d5bd 100644
--- a/examples/gvncviewer.c
+++ b/examples/gvncviewer.c
@@ -34,10 +34,10 @@
static gchar **args = NULL;
static const GOptionEntry options [] =
{
- {
- G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
- NULL, "hostname[:display]" },
- { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, 0 }
+ {
+ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
+ NULL, "[hostname][:display]" },
+ { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, 0 }
};
@@ -377,7 +377,7 @@ int main(int argc, char **argv)
return 1;
}
if (!args || (g_strv_length(args) != 1)) {
- fprintf(stderr, "Usage: gvncviewer hostname[:display]\n%s\n", help_msg);
+ fprintf(stderr, "Usage: gvncviewer [hostname][:display]\n%s\n", help_msg);
return 1;
}
@@ -455,6 +455,8 @@ int main(int argc, char **argv)
} else
snprintf(port, sizeof(port), "%d", 5900);
+ 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), TRUE);
vnc_display_set_pointer_grab(VNC_DISPLAY(vnc), TRUE);
diff --git a/examples/gvncviewer.c b/examples/gvncviewer.c
index 229d5bd..bf6d04f 100644
--- a/examples/gvncviewer.c
+++ b/examples/gvncviewer.c
@@ -84,9 +84,12 @@ static void vnc_ungrab(GtkWidget *vncdisplay, GtkWidget *window)
set_title(VNC_DISPLAY(vncdisplay), window, FALSE);
}
+static gboolean connected = FALSE;
+
static void vnc_connected(GtkWidget *vncdisplay G_GNUC_UNUSED)
{
printf("Connected to server\n");
+ connected = TRUE;
}
static void vnc_initialized(GtkWidget *vncdisplay, GtkWidget *window)
@@ -110,7 +113,10 @@ static void vnc_desktop_resize(GtkWidget *vncdisplay G_GNUC_UNUSED,
static void vnc_disconnected(GtkWidget *vncdisplay G_GNUC_UNUSED)
{
- printf("Disconnected from server\n");
+ if(connected)
+ printf("Disconnected from server\n");
+ else
+ printf("Failed to connect to server\n");
gtk_main_quit();
}
diff --git a/examples/gvncviewer.c b/examples/gvncviewer.c
index bf6d04f..44b49cc 100644
--- a/examples/gvncviewer.c
+++ b/examples/gvncviewer.c
@@ -32,8 +32,13 @@
#endif
static gchar **args = NULL;
+static gboolean keyboard_grab = TRUE;
static const GOptionEntry options [] =
{
+ { "no-keyboard-grab", 'k', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE,
+ &keyboard_grab, "Turn off keyboard grab", NULL },
+ { "keyboard-grab", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE,
+ &keyboard_grab, NULL, NULL },
{
G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
NULL, "[hostname][:display]" },
@@ -216,6 +221,16 @@ static void do_scaling(GtkWidget *menu, GtkWidget *vncdisplay)
vnc_display_set_scaling(VNC_DISPLAY(vncdisplay), FALSE);
}
+static void do_keyboard_grab(GtkWidget *menu, GtkWidget *vncdisplay)
+{
+ if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu)))
+ keyboard_grab = TRUE;
+ else
+ keyboard_grab = FALSE;
+
+ vnc_display_set_keyboard_grab(VNC_DISPLAY(vncdisplay), keyboard_grab);;
+}
+
static void vnc_credential(GtkWidget *vncdisplay, GValueArray *credList)
{
GtkWidget *dialog = NULL;
@@ -367,6 +382,7 @@ int main(int argc, char **argv)
GtkWidget *cab;
GtkWidget *fullscreen;
GtkWidget *scaling;
+ GtkWidget *grab_toggle;
const char *help_msg = "Run 'gvncviewer --help' to see a full list of available command line options";
/* Setup command line options */
@@ -441,6 +457,10 @@ int main(int argc, char **argv)
gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), submenu);
+ grab_toggle = gtk_check_menu_item_new_with_mnemonic("Allow Keyboard _Grab");
+ gtk_menu_bar_append(GTK_MENU_BAR(menubar), grab_toggle);
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(grab_toggle), keyboard_grab);
+
#if WITH_LIBVIEW
ViewAutoDrawer_SetActive(VIEW_AUTODRAWER(layout), FALSE);
ViewOvBox_SetOver(VIEW_OV_BOX(layout), menubar);
@@ -464,7 +484,7 @@ int main(int argc, char **argv)
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), TRUE);
+ vnc_display_set_keyboard_grab(VNC_DISPLAY(vnc), keyboard_grab);;
vnc_display_set_pointer_grab(VNC_DISPLAY(vnc), TRUE);
if (!gtk_widget_is_composited(window)) {
@@ -520,6 +540,8 @@ int main(int argc, char **argv)
G_CALLBACK(do_fullscreen), window);
g_signal_connect(scaling, "toggled",
G_CALLBACK(do_scaling), vnc);
+ g_signal_connect(grab_toggle, "toggled",
+ G_CALLBACK(do_keyboard_grab), vnc);
#if WITH_LIBVIEW
g_signal_connect(window, "window-state-event",
G_CALLBACK(window_state_event), layout);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]