[PATCH weston 04/31] Convert Weston modifier #defines to an enum

Daniel Stone daniel at fooishbar.org
Wed May 30 08:31:42 PDT 2012


To avoid any possible collision between the disparate XKB and Weston
modifier namespaces.

Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
 src/compositor.c |    2 +-
 src/compositor.h |   14 ++++++++------
 src/shell.c      |    2 +-
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 6baa554..108a41f 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1734,7 +1734,7 @@ static int
 update_modifier_state(struct weston_seat *seat, uint32_t key, uint32_t state)
 {
 	struct weston_compositor *compositor = seat->compositor;
-	uint32_t modifier;
+	enum weston_keyboard_modifier modifier;
 	uint32_t mods_depressed, mods_latched, mods_locked, group;
 	int ret = 0;
 
diff --git a/src/compositor.h b/src/compositor.h
index c9fe510..d292c7a 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -48,6 +48,12 @@ struct shell_surface;
 struct weston_seat;
 struct weston_output;
 
+enum weston_keyboard_modifier {
+	MODIFIER_CTRL = (1 << 0),
+	MODIFIER_ALT = (1 << 1),
+	MODIFIER_SUPER = (1 << 2),
+};
+
 struct weston_mode {
 	uint32_t flags;
 	int32_t width, height;
@@ -156,7 +162,7 @@ struct weston_seat {
 	struct wl_listener drag_surface_destroy_listener;
 	int32_t hotspot_x, hotspot_y;
 	struct wl_list link;
-	uint32_t modifier_state;
+	enum weston_keyboard_modifier modifier_state;
 	int hw_cursor;
 	struct wl_surface *saved_kbd_focus;
 	struct wl_listener saved_kbd_focus_listener;
@@ -294,10 +300,6 @@ struct weston_compositor {
 	} xkb_info;
 };
 
-#define MODIFIER_CTRL	(1 << 8)
-#define MODIFIER_ALT	(1 << 9)
-#define MODIFIER_SUPER	(1 << 10)
-
 enum weston_output_flags {
 	WL_OUTPUT_FLIPPED = 0x01
 };
@@ -508,7 +510,7 @@ typedef void (*weston_binding_handler_t)(struct wl_seat *seat,
 struct weston_binding *
 weston_compositor_add_binding(struct weston_compositor *compositor,
 			      uint32_t key, uint32_t button, uint32_t axis,
-			      uint32_t modifier,
+			      enum weston_keyboard_modifier modifier,
 			      weston_binding_handler_t binding, void *data);
 void
 weston_binding_destroy(struct weston_binding *binding);
diff --git a/src/shell.c b/src/shell.c
index f818b4c..87b0738 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -242,7 +242,7 @@ static void
 center_on_output(struct weston_surface *surface,
 		 struct weston_output *output);
 
-static uint32_t
+static enum weston_keyboard_modifier
 get_modifier(char *modifier)
 {
 	if (!modifier)
-- 
1.7.10



More information about the wayland-devel mailing list