Commit 29f24263 authored by Jeremy White's avatar Jeremy White

Revise coding style to conform to the spice project coding style.

This was not a great deal of change; mostly braces at the end of the
line.  The GNU indent tool was used as an aid for this process.
parent a75556cc
#!/bin/bash
#
# spice_indent
# This utility was used by Jeremy White to attempt to make the
# x11spice code largely conform to the Spice Project Coding Style.
# It's preserved here as a form of documentation.
if [ ! -f "$1" ] ; then
echo Error: specify a filename to process with indent
exit 1
fi
indent "$1" \
--no-space-after-function-call-names \
--dont-break-procedure-type \
--braces-after-func-def-line \
--braces-on-if-line \
--braces-on-struct-decl-line \
--line-length 100 \
--no-space-after-parentheses \
--no-tabs \
--case-indentation 4 \
--tab-size 4\
--indent-label 0\
--indent-level 4\
--declaration-indentation 1 \
--space-after-for \
--space-after-while \
--space-after-casts \
--space-after-if \
-T agent_t \
-T SpiceCharDeviceInstance \
-T SpiceChannelEventInfo \
-T QXLInstance \
-T QXLWorker \
-T QXLDevInitInfo \
-T VDAgentMonitorsConfig \
-T SpiceTimer \
-T SpiceKbdInstance \
-T SpiceTabletInstance \
-T SpiceWatch \
-T GIOChannel \
-T spice_t \
-T options_t \
-T uint8_t \
-T uint16_t \
-T uint32_t \
-T scan_type_t \
-T scan_report_t \
-T scanner_t \
-T session_t \
-T shm_image_t \
-T spice_release_t \
-T xcb_connection_t \
-T xcb_xfixes_cursor_notify_event_t \
-T xcb_damage_notify_event_t \
-T xcb_damage_notify_event_t \
-T xcb_configure_notify_event_t \
-T display_t \
-T gui_t \
-T GKeyFile \
-T gchar \
......@@ -40,8 +40,7 @@ static void uinput_handle_key(agent_t *agent, struct input_event *ev)
{
int button = 0;
switch (ev->code)
{
switch (ev->code) {
case BTN_LEFT:
button = 1 << 0;
break;
......@@ -77,8 +76,7 @@ static void uinput_handle_relative(agent_t *agent, struct input_event *ev)
static void uinput_handle_absolute(agent_t *agent, struct input_event *ev)
{
switch (ev->code)
{
switch (ev->code) {
case ABS_X:
agent->uinput_x = ev->value;
break;
......@@ -90,7 +88,8 @@ static void uinput_handle_absolute(agent_t *agent, struct input_event *ev)
return;
break;
}
session_handle_mouse_position(agent->spice->session, agent->uinput_x, agent->uinput_y, agent->uinput_buttons_state);
session_handle_mouse_position(agent->spice->session, agent->uinput_x, agent->uinput_y,
agent->uinput_buttons_state);
}
static void uinput_read_cb(int fd, int event, void *opaque)
......@@ -100,8 +99,8 @@ static void uinput_read_cb(int fd, int event, void *opaque)
int rc;
rc = read(agent->uinput_fd, agent->uinput_buffer + agent->uinput_offset,
sizeof(agent->uinput_buffer) - agent->uinput_offset);
if (rc == -1) {
sizeof(agent->uinput_buffer) - agent->uinput_offset);
if (rc == -1) {
if (errno != EAGAIN && errno != EINTR && errno != EWOULDBLOCK) {
fprintf(stderr, "x11spice: uinput read failed: %s\n", strerror(errno));
}
......@@ -110,16 +109,13 @@ static void uinput_read_cb(int fd, int event, void *opaque)
agent->uinput_offset += rc;
while (agent->uinput_offset >= sizeof(*ev))
{
while (agent->uinput_offset >= sizeof(*ev)) {
ev = (struct input_event *) agent->uinput_buffer;
agent->uinput_offset -= sizeof(*ev);
if (agent->uinput_offset > 0)
memmove(agent->uinput_buffer, agent->uinput_buffer + sizeof(*ev),
agent->uinput_offset);
memmove(agent->uinput_buffer, agent->uinput_buffer + sizeof(*ev), agent->uinput_offset);
switch (ev->type)
{
switch (ev->type) {
case EV_KEY:
uinput_handle_key(agent, ev);
break;
......@@ -143,23 +139,22 @@ static int start_uinput(agent_t *agent, const char *uinput_filename)
int rc;
rc = mkfifo(uinput_filename, 0666);
if (rc != 0)
{
if (rc != 0) {
fprintf(stderr, "spice: failed to create uinput fifo %s: %s\n",
uinput_filename, strerror(errno));
return -1;
}
agent->uinput_fd = open(uinput_filename, O_RDONLY | O_NONBLOCK, 0666);
if (agent->uinput_fd == -1)
{
if (agent->uinput_fd == -1) {
fprintf(stderr, "spice: failed creating uinput file %s: %s\n",
uinput_filename, strerror(errno));
uinput_filename, strerror(errno));
return -1;
}
agent->uinput_watch = agent->spice->core->watch_add(agent->uinput_fd,
SPICE_WATCH_EVENT_READ, uinput_read_cb, agent);
SPICE_WATCH_EVENT_READ, uinput_read_cb,
agent);
return 0;
}
......@@ -185,14 +180,13 @@ static void stop_virtio(agent_t *agent)
agent->spice->core->watch_remove(agent->virtio_listen_watch);
agent->virtio_listen_watch = NULL;
if (agent->virtio_client_fd != -1)
{
if (agent->virtio_client_fd != -1) {
spice_server_remove_interface(&agent->base.base);
close(agent->virtio_client_fd);
}
if (agent->virtio_listen_fd != -1)
close(agent->virtio_listen_fd);
agent->virtio_client_fd = agent->virtio_listen_fd -1;
agent->virtio_client_fd = agent->virtio_listen_fd - 1;
}
......@@ -264,7 +258,8 @@ static void on_accept(int fd, int event, void *opaque)
// FIXME - not cool to accept more than one connection?
agent->virtio_client_fd = accept(agent->virtio_listen_fd, (struct sockaddr *)&address, &length);
agent->virtio_client_fd =
accept(agent->virtio_listen_fd, (struct sockaddr *) &address, &length);
if (agent->virtio_client_fd == -1) {
fprintf(stderr, "error accepting on unix domain socket: %s\n", strerror(errno));
return;
......@@ -283,8 +278,9 @@ static void on_accept(int fd, int event, void *opaque)
return;
}
agent->virtio_client_watch = agent->spice->core->watch_add(agent->virtio_client_fd, SPICE_WATCH_EVENT_READ,
on_read_available, agent);
agent->virtio_client_watch =
agent->spice->core->watch_add(agent->virtio_client_fd, SPICE_WATCH_EVENT_READ,
on_read_available, agent);
spice_server_add_interface(agent->spice->server, &agent->base.base);
}
......@@ -301,7 +297,7 @@ static int start_virtio(agent_t *agent, const char *virtio_path)
}
address.sun_family = AF_UNIX;
snprintf(address.sun_path, sizeof(address.sun_path), "%s", virtio_path);
rc = bind(agent->virtio_listen_fd, (struct sockaddr *)&address, sizeof(address));
rc = bind(agent->virtio_listen_fd, (struct sockaddr *) &address, sizeof(address));
if (rc != 0) {
fprintf(stderr, "error binding unix domain socket to %s: %s\n",
virtio_path, strerror(errno));
......@@ -315,7 +311,8 @@ static int start_virtio(agent_t *agent, const char *virtio_path)
}
agent->virtio_listen_watch = agent->spice->core->watch_add(agent->virtio_listen_fd,
SPICE_WATCH_EVENT_READ, on_accept, agent);
SPICE_WATCH_EVENT_READ, on_accept,
agent);
return 0;
......@@ -327,16 +324,16 @@ int agent_start(spice_t *spice, options_t *options, agent_t *agent)
const static SpiceCharDeviceInterface agent_sif = {
.base = {
.type = SPICE_INTERFACE_CHAR_DEVICE,
.description = "x11spice vdagent",
.major_version = SPICE_INTERFACE_CHAR_DEVICE_MAJOR,
.minor_version = SPICE_INTERFACE_CHAR_DEVICE_MINOR,
},
.state = agent_char_state,
.write = agent_char_write,
.read = agent_char_read,
.type = SPICE_INTERFACE_CHAR_DEVICE,
.description = "x11spice vdagent",
.major_version = SPICE_INTERFACE_CHAR_DEVICE_MAJOR,
.minor_version = SPICE_INTERFACE_CHAR_DEVICE_MINOR,
},
.state = agent_char_state,
.write = agent_char_write,
.read = agent_char_read,
#if SPICE_SERVER_VERSION >= 0x000c02
.event = agent_char_event,
.event = agent_char_event,
#endif
};
......@@ -346,7 +343,7 @@ int agent_start(spice_t *spice, options_t *options, agent_t *agent)
agent->base.subtype = "vdagent";
agent->virtio_listen_fd = agent->virtio_client_fd = agent->uinput_fd = -1;
if (! options->virtio_path || ! options->uinput_path)
if (!options->virtio_path || !options->uinput_path)
return 0;
rc = start_virtio(agent, options->virtio_path);
......@@ -354,8 +351,7 @@ int agent_start(spice_t *spice, options_t *options, agent_t *agent)
return rc;
rc = start_uinput(agent, options->uinput_path);
if (rc)
{
if (rc) {
stop_virtio(agent);
return rc;
}
......
......@@ -27,8 +27,7 @@
/*----------------------------------------------------------------------------
** Structure definitions
**--------------------------------------------------------------------------*/
typedef struct
{
typedef struct {
SpiceCharDeviceInstance base;
int virtio_listen_fd;
......
......@@ -63,18 +63,16 @@ int auto_parse(const char *auto_spec, char **addr, int *port_start, int *port_en
p = auto_spec + strlen(auto_spec) - 1;
/* Look for a form of NNNN-NNNN at the end of the line */
for (; p >= auto_spec && *p; p--)
{
for (; p >= auto_spec && *p; p--) {
/* Skip trailing white space */
if (isspace(*p) && ! hyphen && ! trailing)
if (isspace(*p) && !hyphen && !trailing)
continue;
/* We're looking for only digits and a hyphen */
if (*p != '-' && !isdigit(*p))
break;
if (*p == '-')
{
if (*p == '-') {
if (hyphen)
return X11SPICE_ERR_PARSE;
hyphen++;
......@@ -96,11 +94,11 @@ int auto_parse(const char *auto_spec, char **addr, int *port_start, int *port_en
*port_end = strtol(p + 1, NULL, 0);
/* If we had a hyphen, make sure we had a NNNN-NNN pattern too... */
if (hyphen && (! leading || ! trailing))
if (hyphen && (!leading || !trailing))
return X11SPICE_ERR_PARSE;
/* If we got a port range, make sure we had either no address provided,
or a clear addr:NNNN-NNNN specficiation */
or a clear addr:NNNN-NNNN specficiation */
if (leading || trailing)
if (p > auto_spec && *p != ':')
return X11SPICE_ERR_PARSE;
......@@ -109,8 +107,7 @@ int auto_parse(const char *auto_spec, char **addr, int *port_start, int *port_en
p--;
len = p - auto_spec + 1;
if (len > 0)
{
if (len > 0) {
*addr = calloc(1, len + 1);
memcpy(*addr, auto_spec, len);
}
......@@ -142,15 +139,15 @@ static int try_port(const char *addr, int port)
if (sock < 0)
continue;
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*)&on, sizeof(on));
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &on, sizeof(on));
/* listen on both ipv4 and ipv6 */
if (e->ai_family == PF_INET6)
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&off, sizeof(off));
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void *) &off, sizeof(off));
if (bind(sock, e->ai_addr, e->ai_addrlen) == 0) {
char uaddr[INET6_ADDRSTRLEN+1];
char uaddr[INET6_ADDRSTRLEN + 1];
char uport[33];
rc = getnameinfo((struct sockaddr*)e->ai_addr, e->ai_addrlen,
rc = getnameinfo((struct sockaddr *) e->ai_addr, e->ai_addrlen,
uaddr, INET6_ADDRSTRLEN, uport, sizeof(uport) - 1,
NI_NUMERICHOST | NI_NUMERICSERV);
if (rc == 0)
......@@ -187,11 +184,9 @@ int auto_listen_port_fd(const char *addr, int start, int end)
if (end == -1)
end = start;
for (i = start; i <= end; i++)
{
for (i = start; i <= end; i++) {
rc = try_port(addr, i);
if (rc >= 0)
{
if (rc >= 0) {
printf("URI=%s:%d\n", addr ? addr : "", i);
return rc;
}
......
This diff is collapsed.
......@@ -31,8 +31,7 @@ typedef struct session_struct session_t;
/*----------------------------------------------------------------------------
** Structure definitions
**--------------------------------------------------------------------------*/
typedef struct
{
typedef struct {
int shmid;
int w;
int h;
......@@ -40,10 +39,9 @@ typedef struct
xcb_shm_seg_t shmseg;
void *shmaddr;
void *drawable_ptr;
}shm_image_t;
} shm_image_t;
typedef struct
{
typedef struct {
xcb_connection_t *c;
xcb_window_t root;
int width;
......@@ -76,7 +74,7 @@ int display_start_event_thread(display_t *d);
int display_find_changed_tiles(display_t *d, int row, int *tiles, int tiles_across);
void display_copy_image_into_fullscreen(display_t *d, shm_image_t *shmi, int x, int y);
shm_image_t * create_shm_image(display_t *d, int w, int h);
shm_image_t *create_shm_image(display_t *d, int w, int h);
int read_shm_image(display_t *d, shm_image_t *shmi, int x, int y);
void destroy_shm_image(display_t *d, shm_image_t *shmi);
......
......@@ -53,7 +53,7 @@ void gui_remote_disconnected(gui_t *gui)
int gui_create(gui_t *gui, int argc, char *argv[], int minimize, int hidden)
{
if (! gtk_init_check(&argc, &argv))
if (!gtk_init_check(&argc, &argv))
return X11SPICE_ERR_GTK_FAILED;
gui->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
......@@ -71,14 +71,15 @@ int gui_create(gui_t *gui, int argc, char *argv[], int minimize, int hidden)
gui->quit_button = gtk_button_new_from_stock(GTK_STOCK_QUIT);
gtk_container_add(GTK_CONTAINER(gui->button_box), gui->quit_button);
g_signal_connect_swapped(gui->quit_button, "clicked", G_CALLBACK (gtk_widget_destroy), gui->window);
g_signal_connect_swapped(gui->quit_button, "clicked", G_CALLBACK(gtk_widget_destroy),
gui->window);
gtk_widget_show(gui->status_label);
gtk_widget_show(gui->disconnect_button);
gtk_widget_show(gui->quit_button);
gtk_widget_show(gui->button_box);
if (! hidden)
if (!hidden)
gtk_widget_show(gui->window);
if (minimize)
gtk_window_iconify(GTK_WINDOW(gui->window));
......@@ -105,7 +106,7 @@ int main(int argc, char *argv[])
{
gui_t gui;
setlocale (LC_ALL, "");
setlocale(LC_ALL, "");
gui_create(&gui, argc, argv, 0, 0);
gui_run(&gui);
gui_destroy(&gui);
......
......@@ -26,8 +26,7 @@
/*----------------------------------------------------------------------------
** Structure definitions
**--------------------------------------------------------------------------*/
typedef struct
{
typedef struct {
GtkWidget *window;
GtkWidget *button_box;
GtkWidget *quit_button;
......
......@@ -31,8 +31,7 @@ typedef struct session_struct session_t;
/*----------------------------------------------------------------------------
** Structure definitions
**--------------------------------------------------------------------------*/
typedef struct
{
typedef struct {
SpiceServer *server;
SpiceCoreInterface *core;
QXLInstance display_sin;
......@@ -54,8 +53,7 @@ typedef struct
typedef enum { RELEASE_SHMI, RELEASE_MEMORY } release_type_t;
typedef struct
{
typedef struct {
release_type_t type;
void *data;
spice_t *s;
......
......@@ -45,7 +45,7 @@ static void sigterm_handler(int arg)
static void handle_sigterm(void)
{
struct sigaction act = {};
struct sigaction act = { };
act.sa_handler = sigterm_handler;
sigaction(SIGTERM, &act, NULL);
}
......@@ -54,13 +54,13 @@ int main(int argc, char *argv[])
{
int rc;
session_t session;
session_t session;
int display_opened = 0;
int spice_started = 0;
int gui_created = 0;
int session_created = 0;
int session_started = 0;
int display_opened = 0;
int spice_started = 0;
int gui_created = 0;
int session_created = 0;
int session_started = 0;
/*------------------------------------------------------------------------
** Parse arguments
......@@ -125,8 +125,7 @@ exit:
if (session_started)
session_end(&session);
if (spice_started)
{
if (spice_started) {
agent_stop(&session.agent);
spice_end(&session.spice);
}
......
......@@ -40,8 +40,7 @@ void options_init(options_t *options)
void options_free(options_t *options)
{
if (options->display)
{
if (options->display) {
free(options->display);
options->display = NULL;
}
......@@ -69,14 +68,14 @@ void options_free(options_t *options)
}
static gchar * string_option(GKeyFile *u, GKeyFile *s, const gchar *section, const gchar *key)
static gchar *string_option(GKeyFile *u, GKeyFile *s, const gchar *section, const gchar *key)
{
gchar *ret = NULL;
GError *error = NULL;
if (u)
ret = g_key_file_get_string(u, section, key, &error);
if ((! u || error) && s)
if ((!u || error) && s)
ret = g_key_file_get_string(s, section, key, NULL);
if (error)
g_error_free(error);
......@@ -91,7 +90,7 @@ static gint int_option(GKeyFile *u, GKeyFile *s, const gchar *section, const gch
if (u)
ret = g_key_file_get_integer(u, section, key, &error);
if ((! u || error) && s)
if ((!u || error) && s)
ret = g_key_file_get_integer(s, section, key, NULL);
if (error)
g_error_free(error);
......@@ -106,13 +105,14 @@ static gboolean bool_option(GKeyFile *u, GKeyFile *s, const gchar *section, cons
if (u)
ret = g_key_file_get_boolean(u, section, key, &error);
if ((! u || error) && s)
if ((!u || error) && s)
ret = g_key_file_get_boolean(s, section, key, NULL);
if (error)
g_error_free(error);
return ret;
}
static void usage(options_t *options, char *argv0)
{
int len = strlen(argv0);
......@@ -120,7 +120,8 @@ static void usage(options_t *options, char *argv0)
fprintf(stderr, "%*.*s [--auto=<listen-spec>] [--generate-passcode]\n", len, len, "");
fprintf(stderr, "%*.*s [--hide] [--minimize]\n", len, len, "");
fprintf(stderr, "Command line parameters override settings in %s\n", options->user_config_file);
fprintf(stderr, "which overrides settings in %s\n", options->system_config_file ? options->system_config_file : "the system config file");
fprintf(stderr, "which overrides settings in %s\n",
options->system_config_file ? options->system_config_file : "the system config file");
}
int options_parse_arguments(int argc, char *argv[], options_t *options)
......@@ -146,17 +147,14 @@ int options_parse_arguments(int argc, char *argv[], options_t *options)
{0, 0, 0, 0}
};
while (1)
{
while (1) {
rc = getopt_long_only(argc, argv, "", long_options, &longindex);
if (rc == -1)
{
if (rc == -1) {
rc = 0;
break;
}
switch (rc)
{
switch (rc) {
case OPTION_VIEWONLY:
/* FIXME - implement --viewonly */
options->viewonly = 1;
......@@ -199,20 +197,19 @@ int options_parse_arguments(int argc, char *argv[], options_t *options)
void options_from_config(options_t *options)
{
GKeyFile * userkey = g_key_file_new();
GKeyFile * systemkey = g_key_file_new();
GKeyFile *userkey = g_key_file_new();
GKeyFile *systemkey = g_key_file_new();
options->user_config_file = g_build_filename(g_get_user_config_dir(), "x11spice", NULL);
if(!g_key_file_load_from_file(userkey, options->user_config_file, G_KEY_FILE_NONE, NULL))
{
if (!g_key_file_load_from_file(userkey, options->user_config_file, G_KEY_FILE_NONE, NULL)) {
g_key_file_free(userkey);
userkey = NULL;
}
if (!g_key_file_load_from_dirs(systemkey, "x11spice", (const char**)g_get_system_config_dirs(),
&options->system_config_file, G_KEY_FILE_NONE, NULL))
{
if (!g_key_file_load_from_dirs(systemkey, "x11spice",
(const char **) g_get_system_config_dirs(),
&options->system_config_file, G_KEY_FILE_NONE, NULL)) {
g_key_file_free(systemkey);
systemkey = NULL;
}
......@@ -238,7 +235,8 @@ void options_from_config(options_t *options)
if (userkey)
g_key_file_free(userkey);
g_debug("options addr '%s', disable_ticketing %d, port %d", options->spice_addr, options->disable_ticketing, options->spice_port);
g_debug("options addr '%s', disable_ticketing %d, port %d", options->spice_addr,
options->disable_ticketing, options->spice_port);
}
#if defined(OPTIONS_MAIN)
......
......@@ -24,23 +24,22 @@
/*----------------------------------------------------------------------------
** Structure definitions
**--------------------------------------------------------------------------*/
typedef struct
{
typedef struct {
/* Both config and command line arguments */
long timeout;
int minimize;
int viewonly;
int generate_passcode;
int hide;
int minimize;
int viewonly;
int generate_passcode;
int hide;
char *display;
char *autouri;
/* config only */
char *spice_addr;
int spice_port;
int spice_port;
char *spice_password;
int disable_ticketing;
int exit_on_disconnect;
int disable_ticketing;
int exit_on_disconnect;
char *virtio_path;
char *uinput_path;
......
This diff is collapsed.
......@@ -32,8 +32,7 @@ typedef struct session_struct session_t;
** Structure definitions
**--------------------------------------------------------------------------*/
typedef struct
{
typedef struct {
scan_type_t type;
int x;
int y;
......@@ -41,12 +40,11 @@ typedef struct
int h;
} scan_report_t;
typedef struct
{
typedef struct {
pthread_t thread;
GAsyncQueue *queue;
session_t *session;
GMutex lock;
GMutex lock;
int current_scanline;
} scanner_t;
......
......@@ -52,7 +52,7 @@ session_t *global_session;
void free_cursor_queue_item(gpointer data)
{
QXLCursorCmd *ccmd = (QXLCursorCmd *) data;
QXLCursorCmd *ccmd = (QXLCursorCmd *) data;
spice_free_release((spice_release_t *) ccmd->release_info.id);
}
......@@ -65,10 +65,10 @@ void free_draw_queue_item(gpointer data)
void *session_pop_draw(session_t *session)
{
void *ret = NULL;
if (! session || ! session->running)
if (!session || !session->running)
return ret;
if (! g_mutex_trylock(&session->lock))
if (!g_mutex_trylock(&session->lock))
return ret;
ret = g_async_queue_try_pop(session->draw_queue);
......@@ -82,20 +82,20 @@ int session_draw_waiting(session_t *session)
{
int ret = 0;
if (! session || ! session->running)
if (!session || !session->running)
return 0;
if (! g_mutex_trylock(&session->lock))
if (!g_mutex_trylock(&session->lock))
return ret;
ret = g_async_queue_length(session->draw_queue);
g_mutex_unlock(&session->lock);
return(ret);
return (ret);
}
void *session_pop_cursor(session_t *session)
{
if (! session || ! session->running)
if (!session || !session->running)
return NULL;
return g_async_queue_try_pop(session->cursor_queue);
......@@ -103,7 +103,7 @@ void *session_pop_cursor(session_t *session)
int session_cursor_waiting(session_t *session)
{
if (! session || ! session->running)
if (!session || !session->running)
return 0;
return g_async_queue_length(session->cursor_queue);
......@@ -112,7 +112,7 @@ int session_cursor_waiting(session_t *session)
void session_handle_key(session_t *session, uint8_t keycode, int is_press)
{
xcb_test_fake_input(session->display.c, is_press ? XCB_KEY_PRESS : XCB_KEY_RELEASE,
keycode, XCB_CURRENT_TIME, XCB_NONE, 0, 0, 0);
keycode, XCB_CURRENT_TIME, XCB_NONE, 0, 0, 0);
g_debug("key 0x%x, press %d", keycode, is_press);
// FIXME - and maybe a sync too... xcb_flush(s->display.c);
xcb_flush(session->display.c);
......@@ -121,7 +121,7 @@ void session_handle_key(session_t *session, uint8_t keycode, int is_press)
void session_handle_mouse_position(session_t *session, int x, int y, uint32_t buttons_state)
{
xcb_test_fake_input(session->display.c, XCB_MOTION_NOTIFY, 0, XCB_CURRENT_TIME,
session->display.root, x, y, 0);
session->display.root, x, y, 0);
xcb_flush(session->display.c);
}
......@@ -133,7 +133,7 @@ static void session_handle_button_change(session_t *s, uint32_t buttons_state)
if ((buttons_state ^ s->spice.buttons_state) & (1 << i)) {
int action = (buttons_state & (1 << i));
xcb_test_fake_input(s->display.c, action ? XCB_BUTTON_PRESS : XCB_BUTTON_RELEASE,
i + 1, XCB_CURRENT_TIME, s->display.root, 0, 0, 0);
i + 1, XCB_CURRENT_TIME, s->display.root, 0, 0, 0);
}
}
s->spice.buttons_state = buttons_state;
......@@ -147,9 +147,9 @@ static uint32_t convert_spice_buttons(int wheel, uint32_t buttons_state)
((buttons_state & SPICE_MOUSE_BUTTON_MASK_MIDDLE) << 1) |
((buttons_state & SPICE_MOUSE_BUTTON_MASK_RIGHT) >> 1) |
(buttons_state & ~(SPICE_MOUSE_BUTTON_MASK_LEFT | SPICE_MOUSE_BUTTON_MASK_MIDDLE
|SPICE_MOUSE_BUTTON_MASK_RIGHT));
return buttons_state | (wheel > 0 ? (1<<4) : 0)
| (wheel < 0 ? (1<<3) : 0);
| SPICE_MOUSE_BUTTON_MASK_RIGHT));
return buttons_state | (wheel > 0 ? (1 << 4) : 0)
| (wheel < 0 ? (1 << 3) : 0);
}
......@@ -212,10 +212,9 @@ int session_create(session_t *s)