[PATCH weston 4/5] compositor: add a way to override the default pointer grab

Giulio Camuffo giuliocamuffo at gmail.com
Thu Nov 14 14:42:53 PST 2013


---
 src/compositor.c | 16 ++++++++++++++++
 src/compositor.h | 11 ++++++++++-
 src/input.c      | 18 +++++++++++++++---
 3 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index c6cf682..4c37eb6 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3405,6 +3405,21 @@ weston_compositor_shutdown(struct weston_compositor *ec)
 }
 
 WL_EXPORT void
+weston_compositor_set_default_pointer_grab(struct weston_compositor *ec,
+			const struct weston_pointer_grab_interface *interface)
+{
+	struct weston_seat *seat;
+
+	ec->default_pointer_grab = interface;
+	wl_list_for_each(seat, &ec->seat_list, link) {
+		if (seat->pointer) {
+			weston_pointer_set_default_grab(seat->pointer,
+							interface);
+		}
+	}
+}
+
+WL_EXPORT void
 weston_version(int *major, int *minor, int *micro)
 {
 	*major = WESTON_VERSION_MAJOR;
@@ -3847,6 +3862,7 @@ int main(int argc, char *argv[])
 	segv_compositor = ec;
 
 	ec->idle_time = idle_time;
+	ec->default_pointer_grab = NULL;
 
 	setenv("WAYLAND_DISPLAY", socket_name, 1);
 
diff --git a/src/compositor.h b/src/compositor.h
index e7ffa4f..80fe961 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -345,7 +345,7 @@ struct weston_touch {
 };
 
 struct weston_pointer *
-weston_pointer_create(void);
+weston_pointer_create(struct weston_seat *seat);
 void
 weston_pointer_destroy(struct weston_pointer *pointer);
 void
@@ -363,6 +363,9 @@ weston_pointer_clamp(struct weston_pointer *pointer,
 void
 weston_pointer_move(struct weston_pointer *pointer,
 		    wl_fixed_t x, wl_fixed_t y);
+void
+weston_pointer_set_default_grab(struct weston_pointer *pointer,
+		const struct weston_pointer_grab_interface *interface);
 
 struct weston_keyboard *
 weston_keyboard_create(void);
@@ -586,6 +589,8 @@ struct weston_compositor {
 	uint32_t idle_inhibit;
 	int idle_time;			/* timeout, s */
 
+	const struct weston_pointer_grab_interface *default_pointer_grab;
+
 	/* Repaint state. */
 	struct weston_plane primary_plane;
 	uint32_t capabilities; /* combination of enum weston_capability */
@@ -1073,6 +1078,10 @@ weston_compositor_run_debug_binding(struct weston_compositor *compositor,
 				    uint32_t key,
 				    enum wl_keyboard_key_state state);
 
+void
+weston_compositor_set_default_pointer_grab(struct weston_compositor *compositor,
+			const struct weston_pointer_grab_interface *interface);
+
 int
 weston_environment_get_fd(const char *env);
 
diff --git a/src/input.c b/src/input.c
index d7b4b13..159049e 100644
--- a/src/input.c
+++ b/src/input.c
@@ -381,7 +381,7 @@ pointer_handle_sprite_destroy(struct wl_listener *listener, void *data)
 }
 
 WL_EXPORT struct weston_pointer *
-weston_pointer_create(void)
+weston_pointer_create(struct weston_seat *seat)
 {
 	struct weston_pointer *pointer;
 
@@ -391,7 +391,8 @@ weston_pointer_create(void)
 
 	wl_list_init(&pointer->resource_list);
 	wl_list_init(&pointer->focus_resource_list);
-	pointer->default_grab.interface = &default_pointer_grab_interface;
+	weston_pointer_set_default_grab(pointer,
+					seat->compositor->default_pointer_grab);
 	pointer->default_grab.pointer = pointer;
 	pointer->grab = &pointer->default_grab;
 	wl_signal_init(&pointer->focus_signal);
@@ -417,6 +418,17 @@ weston_pointer_destroy(struct weston_pointer *pointer)
 	free(pointer);
 }
 
+void
+weston_pointer_set_default_grab(struct weston_pointer *pointer,
+		const struct weston_pointer_grab_interface *interface)
+{
+	if (interface)
+		pointer->default_grab.interface = interface;
+	else
+		pointer->default_grab.interface =
+			&default_pointer_grab_interface;
+}
+
 WL_EXPORT struct weston_keyboard *
 weston_keyboard_create(void)
 {
@@ -1839,7 +1851,7 @@ weston_seat_init_pointer(struct weston_seat *seat)
 		return;
 	}
 
-	pointer = weston_pointer_create();
+	pointer = weston_pointer_create(seat);
 	if (pointer == NULL)
 		return;
 
-- 
1.8.4.2



More information about the wayland-devel mailing list