From 9aa36d8d0dad30c490b7807951e806fd105c7bca Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 20 Dec 2012 13:40:31 +0100 Subject: [PATCH] broadway: Add enum for even types --- gdk/broadway/broadway-protocol.h | 16 ++++++++++ gdk/broadway/gdkbroadway-server.c | 52 +++++++++++++++---------------- gdk/broadway/gdkeventsource.c | 26 ++++++++-------- 3 files changed, 55 insertions(+), 39 deletions(-) diff --git a/gdk/broadway/broadway-protocol.h b/gdk/broadway/broadway-protocol.h index 8fd13699c8..9104a8a2e0 100644 --- a/gdk/broadway/broadway-protocol.h +++ b/gdk/broadway/broadway-protocol.h @@ -3,6 +3,22 @@ #include +typedef enum { + BROADWAY_EVENT_ENTER = 'e', + BROADWAY_EVENT_LEAVE = 'l', + BROADWAY_EVENT_POINTER_MOVE = 'm', + BROADWAY_EVENT_BUTTON_PRESS = 'b', + BROADWAY_EVENT_BUTTON_RELEASE = 'B', + BROADWAY_EVENT_SCROLL = 's', + BROADWAY_EVENT_KEY_PRESS = 'k', + BROADWAY_EVENT_KEY_RELEASE = 'K', + BROADWAY_EVENT_GRAB_NOTIFY = 'g', + BROADWAY_EVENT_UNGRAB_NOTIFY = 'u', + BROADWAY_EVENT_CONFIGURE_NOTIFY = 'w', + BROADWAY_EVENT_DELETE_NOTIFY = 'W', + BROADWAY_EVENT_SCREEN_SIZE_CHANGED = 'd' +} BroadwayEventType; + typedef struct { guint8 type; guint32 serial; diff --git a/gdk/broadway/gdkbroadway-server.c b/gdk/broadway/gdkbroadway-server.c index 597a34e767..3a14c4cc55 100644 --- a/gdk/broadway/gdkbroadway-server.c +++ b/gdk/broadway/gdkbroadway-server.c @@ -152,7 +152,7 @@ update_event_state (GdkBroadwayServer *server, BroadwayInputMsg *message) { switch (message->base.type) { - case 'e': /* Enter */ + case BROADWAY_EVENT_ENTER: server->last_x = message->pointer.root_x; server->last_y = message->pointer.root_y; server->last_state = message->pointer.state; @@ -161,7 +161,7 @@ update_event_state (GdkBroadwayServer *server, /* TODO: Unset when it dies */ server->mouse_in_toplevel_id = message->pointer.event_window_id; break; - case 'l': /* Leave */ + case BROADWAY_EVENT_LEAVE: server->last_x = message->pointer.root_x; server->last_y = message->pointer.root_y; server->last_state = message->pointer.state; @@ -169,37 +169,37 @@ update_event_state (GdkBroadwayServer *server, server->mouse_in_toplevel_id = 0; break; - case 'm': /* Mouse move */ + case BROADWAY_EVENT_POINTER_MOVE: server->last_x = message->pointer.root_x; server->last_y = message->pointer.root_y; server->last_state = message->pointer.state; server->real_mouse_in_toplevel_id = message->pointer.mouse_window_id; break; - case 'b': - case 'B': + case BROADWAY_EVENT_BUTTON_PRESS: + case BROADWAY_EVENT_BUTTON_RELEASE: server->last_x = message->pointer.root_x; server->last_y = message->pointer.root_y; server->last_state = message->pointer.state; server->real_mouse_in_toplevel_id = message->pointer.mouse_window_id; break; - case 's': + case BROADWAY_EVENT_SCROLL: server->last_x = message->pointer.root_x; server->last_y = message->pointer.root_y; server->last_state = message->pointer.state; server->real_mouse_in_toplevel_id = message->pointer.mouse_window_id; break; - case 'k': - case 'K': + case BROADWAY_EVENT_KEY_PRESS: + case BROADWAY_EVENT_KEY_RELEASE: server->last_state = message->key.state; break; - case 'g': - case 'u': + case BROADWAY_EVENT_GRAB_NOTIFY: + case BROADWAY_EVENT_UNGRAB_NOTIFY: break; - case 'w': + case BROADWAY_EVENT_CONFIGURE_NOTIFY: break; - case 'W': + case BROADWAY_EVENT_DELETE_NOTIFY: break; - case 'd': + case BROADWAY_EVENT_SCREEN_SIZE_CHANGED: break; default: @@ -306,36 +306,36 @@ parse_input_message (BroadwayInput *input, const char *message) msg.base.time = time_; switch (msg.base.type) { - case 'e': /* Enter */ - case 'l': /* Leave */ + case BROADWAY_EVENT_ENTER: + case BROADWAY_EVENT_LEAVE: p = parse_pointer_data (p, &msg.pointer); update_future_pointer_info (server, &msg.pointer); p++; /* Skip , */ msg.crossing.mode = strtol(p, &p, 10); break; - case 'm': /* Mouse move */ + case BROADWAY_EVENT_POINTER_MOVE: /* Mouse move */ p = parse_pointer_data (p, &msg.pointer); update_future_pointer_info (server, &msg.pointer); break; - case 'b': - case 'B': + case BROADWAY_EVENT_BUTTON_PRESS: + case BROADWAY_EVENT_BUTTON_RELEASE: p = parse_pointer_data (p, &msg.pointer); update_future_pointer_info (server, &msg.pointer); p++; /* Skip , */ msg.button.button = strtol(p, &p, 10); break; - case 's': + case BROADWAY_EVENT_SCROLL: p = parse_pointer_data (p, &msg.pointer); update_future_pointer_info (server, &msg.pointer); p++; /* Skip , */ msg.scroll.dir = strtol(p, &p, 10); break; - case 'k': - case 'K': + case BROADWAY_EVENT_KEY_PRESS: + case BROADWAY_EVENT_KEY_RELEASE: msg.key.mouse_window_id = strtol(p, &p, 10); p++; /* Skip , */ msg.key.key = strtol(p, &p, 10); @@ -343,12 +343,12 @@ parse_input_message (BroadwayInput *input, const char *message) msg.key.state = strtol(p, &p, 10); break; - case 'g': - case 'u': + case BROADWAY_EVENT_GRAB_NOTIFY: + case BROADWAY_EVENT_UNGRAB_NOTIFY: msg.grab_reply.res = strtol(p, &p, 10); break; - case 'w': + case BROADWAY_EVENT_CONFIGURE_NOTIFY: msg.configure_notify.id = strtol(p, &p, 10); p++; /* Skip , */ msg.configure_notify.x = strtol (p, &p, 10); @@ -360,11 +360,11 @@ parse_input_message (BroadwayInput *input, const char *message) msg.configure_notify.height = strtol (p, &p, 10); break; - case 'W': + case BROADWAY_EVENT_DELETE_NOTIFY: msg.delete_notify.id = strtol(p, &p, 10); break; - case 'd': + case BROADWAY_EVENT_SCREEN_SIZE_CHANGED: msg.screen_resize_notify.width = strtol (p, &p, 10); p++; /* Skip , */ msg.screen_resize_notify.height = strtol (p, &p, 10); diff --git a/gdk/broadway/gdkeventsource.c b/gdk/broadway/gdkeventsource.c index ff8430dbc0..e9aa2c86b3 100644 --- a/gdk/broadway/gdkeventsource.c +++ b/gdk/broadway/gdkeventsource.c @@ -97,7 +97,7 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message) GList *node; switch (message->base.type) { - case 'e': /* Enter */ + case BROADWAY_EVENT_ENTER: window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_window_id)); if (window) { @@ -125,7 +125,7 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message) _gdk_windowing_got_event (display, node, event, message->base.serial); } break; - case 'l': /* Leave */ + case BROADWAY_EVENT_LEAVE: window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_window_id)); if (window) { @@ -153,7 +153,7 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message) _gdk_windowing_got_event (display, node, event, message->base.serial); } break; - case 'm': /* Mouse move */ + case BROADWAY_EVENT_POINTER_MOVE: if (_gdk_broadway_moveresize_handle_event (display, message)) break; @@ -175,8 +175,8 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message) } break; - case 'b': - case 'B': + case BROADWAY_EVENT_BUTTON_PRESS: + case BROADWAY_EVENT_BUTTON_RELEASE: if (message->base.type != 'b' && _gdk_broadway_moveresize_handle_event (display, message)) break; @@ -200,7 +200,7 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message) } break; - case 's': + case BROADWAY_EVENT_SCROLL: window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->pointer.event_window_id)); if (window) { @@ -219,8 +219,8 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message) } break; - case 'k': - case 'K': + case BROADWAY_EVENT_KEY_PRESS: + case BROADWAY_EVENT_KEY_RELEASE: window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->key.mouse_window_id)); if (window) @@ -239,12 +239,12 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message) } break; - case 'g': - case 'u': + case BROADWAY_EVENT_GRAB_NOTIFY: + case BROADWAY_EVENT_UNGRAB_NOTIFY: _gdk_display_device_grab_update (display, display->core_pointer, NULL, message->base.serial); break; - case 'w': + case BROADWAY_EVENT_CONFIGURE_NOTIFY: window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->configure_notify.id)); if (window) { @@ -275,7 +275,7 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message) } break; - case 'W': + case BROADWAY_EVENT_DELETE_NOTIFY: window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (message->delete_notify.id)); if (window) { @@ -287,7 +287,7 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message) } break; - case 'd': + case BROADWAY_EVENT_SCREEN_SIZE_CHANGED: screen = gdk_display_get_default_screen (display); window = gdk_screen_get_root_window (screen); window->width = message->screen_resize_notify.width;