2 * Copyright (C) 2011 Red Hat Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include <glib/gi18n.h>
31 parse_click (self_t *self, gchar **args, guint nr_args)
35 if (nr_args < 3 || nr_args > 4)
38 if (sscanf (args[1], "%d", &self->command.click.x) != 1 ||
39 sscanf (args[2], "%d", &self->command.click.y) != 1)
44 if (strcasecmp (args[3], "left") == 0)
46 else if (strcasecmp (args[3], "middle") == 0)
48 else if (strcasecmp (args[3], "right") == 0)
50 else if (strcasecmp (args[3], "up") == 0)
52 else if (strcasecmp (args[3], "down") == 0)
54 else if (strcasecmp (args[3], "scrollleft") == 0)
56 else if (strcasecmp (args[3], "scrollright") == 0)
58 else if (sscanf (args[3], "%d", &b) != 1)
62 self->command.click.mask = 1 << (b-1);
63 self->command.cmd = CMD_CLICK;
69 vc_parse_command (self_t *self, gchar **args, guint nr_args)
71 if (strcasecmp (args[0], "click") == 0)
72 return parse_click (self, args, nr_args);
78 vc_issue_command (self_t *self)
82 switch (self->command.cmd) {
85 fprintf (stderr, "click x=%d y=%d mask=0x%x\n",
86 self->command.click.x, self->command.click.y,
87 self->command.click.mask);
89 r = self->callbacks->click (self,
90 self->command.click.x,
91 self->command.click.y,
92 self->command.click.mask);
97 fprintf (stderr, "virt-click: error sending command to remote server\n");
98 self->ret = EXIT_FAILURE;
101 /* XXX Shutdown connection. */