static void initialized (VncConnection *conn, gpointer opaque);
static void disconnected (VncConnection *conn, gpointer opaque);
-static int click (struct self_t *self, int x, int y, unsigned mask);
+static int click (struct self_t *self, int x, int y, int b);
static void shutdown (self_t *self);
static callbacks_t callbacks = {
.shutdown = shutdown,
};
+static gchar *vnc;
+static gchar *host;
+static int port;
+
+static GOptionEntry vnc_entries[] = {
+ { "vnc", 0, 0, G_OPTION_ARG_STRING,
+ &vnc, "Connect to VNC server directly", NULL },
+ { NULL }
+};
+static GOptionGroup *vnc_group;
+
+GOptionGroup *
+vc_vnc_cmdline_get_option_group (void)
+{
+ if (vnc_group == NULL) {
+ vnc_group = g_option_group_new ("vnc",
+ _("VNC Options:"),
+ _("Show VNC Options"),
+ NULL, NULL);
+ g_option_group_add_entries (vnc_group, vnc_entries);
+ }
+ return vnc_group;
+}
+
+gboolean
+vc_vnc_is_selected (void)
+{
+ return vnc != NULL;
+}
+
void
-vc_vnc_setup (self_t *self, gchar *vnc)
+vc_vnc_setup (self_t *self)
{
gchar *display;
- gchar *port;
+ gchar *port_str;
+
+ self->callbacks = &callbacks;
if (verbose)
vnc_util_set_debug (TRUE);
if (vnc[0] == ':') {
- self->host = g_strdup ("localhost");
+ host = g_strdup ("localhost");
display = vnc;
} else {
- self->host = g_strdup (vnc);
- display = strchr (self->host, ':');
+ host = g_strdup (vnc);
+ display = strchr (host, ':');
}
if (display) {
*display = 0;
display++;
- self->port = 5900 + atoi (display);
+ port = 5900 + atoi (display);
} else
- self->port = 5900;
+ port = 5900;
self->conn = vnc_connection_new ();
g_signal_connect (self->conn, "vnc-auth-credential",
G_CALLBACK(vc_vnc_auth_credential), self);
- port = g_strdup_printf ("%d", self->port);
- vnc_connection_open_host (self->conn, self->host, port);
-
- self->callbacks = &callbacks;
+ port_str = g_strdup_printf ("%d", port);
+ vnc_connection_open_host (self->conn, host, port_str);
+ g_free (port_str);
}
static void
int n_encodings;
if (verbose)
- fprintf (stderr, "Connected to %s:%d\n", self->host, self->port - 5900);
+ fprintf (stderr, "Connected to %s:%d\n", host, port - 5900);
/* Remember that we managed to connect. */
self->connected = TRUE;
self->ret = EXIT_SUCCESS;
if (verbose)
fprintf (stderr, "Disconnected from %s:%d\n",
- self->host, self->port - 5900);
+ host, port - 5900);
} else {
fprintf (stderr, "vnc: unable to connect to %s:%d\n",
- self->host, self->port - 5900);
+ host, port - 5900);
self->ret = EXIT_FAILURE;
}
{
vnc_connection_shutdown (self->conn);
g_object_unref (self->conn);
- g_free(self->host);
+ g_free (host);
}
-/* To perform a button press in VNC we have to send the button press
- * event, wait a short period, then send a button release event (ie.
- * no buttons pressed).
- */
-static gboolean click_release (gpointer opaque);
-
static int
-click (struct self_t *self, int x, int y, unsigned mask)
+click (struct self_t *self, int x, int y, int b)
{
+ unsigned mask = b > 0 ? 1 << (b-1) : 0;
+
if (!vnc_connection_pointer_event (self->conn, mask, x, y))
return -1;
- g_timeout_add (100, click_release, self);
-}
-
-static gboolean
-click_release (gpointer opaque)
-{
- self_t *self = opaque;
-
- vnc_connection_pointer_event (self->conn, 0,
- self->command.click.x, self->command.click.y);
-
- vnc_connection_shutdown (self->conn);
-
- return FALSE;
+ return 0;
}