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

Giulio Camuffo giuliocamuffo at gmail.com
Mon Sep 30 03:40:28 PDT 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 0fa6613..62a3558 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3077,6 +3077,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;
@@ -3515,6 +3530,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 a19d966..92c7f4d 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -348,7 +348,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_end_grab(struct weston_pointer *pointer);
 void
 weston_pointer_clamp(struct weston_pointer *pointer,
 			    wl_fixed_t *fx, wl_fixed_t *fy);
+void
+weston_pointer_set_default_grab(struct weston_pointer *pointer,
+		const struct weston_pointer_grab_interface *interface);
 
 struct weston_keyboard *
 weston_keyboard_create(void);
@@ -582,6 +585,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 */
@@ -1023,6 +1028,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 1313b52..15c2b5f 100644
--- a/src/input.c
+++ b/src/input.c
@@ -350,7 +350,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;
 
@@ -360,7 +360,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);
@@ -385,6 +386,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)
 {
@@ -1676,7 +1688,7 @@ weston_seat_init_pointer(struct weston_seat *seat)
 	if (seat->pointer)
 		return;
 
-	pointer = weston_pointer_create();
+	pointer = weston_pointer_create(seat);
 	if (pointer == NULL)
 		return;
 
-- 
1.8.4



More information about the wayland-devel mailing list