[PATCH weston 1/6] input: For serial generation get the display from the compositor

Rob Bradford robert.bradford at intel.com
Mon Jul 22 09:31:38 PDT 2013


From: Rob Bradford <rob at linux.intel.com>

This removes the use of wl_client_get_display() where the client is
derived from the focussed resource. This starts the removal of the
assumption of a single resource on a client that would be notified about
events on the focussed surface.
---
 src/bindings.c    |  5 +----
 src/data-device.c |  3 +--
 src/input.c       | 20 ++++++--------------
 src/shell.c       |  9 +++------
 4 files changed, 11 insertions(+), 26 deletions(-)

diff --git a/src/bindings.c b/src/bindings.c
index 3194414..a871c26 100644
--- a/src/bindings.c
+++ b/src/bindings.c
@@ -155,11 +155,10 @@ binding_key(struct weston_keyboard_grab *grab,
 	struct binding_keyboard_grab *b =
 		container_of(grab, struct binding_keyboard_grab, grab);
 	struct wl_resource *resource;
-	struct wl_client *client;
-	struct wl_display *display;
 	enum wl_keyboard_key_state state = state_w;
 	uint32_t serial;
 	struct weston_keyboard *keyboard = grab->keyboard;
+	struct wl_display *display = keyboard->seat->compositor->wl_display;
 
 	resource = grab->keyboard->focus_resource;
 	if (key == b->key) {
@@ -170,8 +169,6 @@ binding_key(struct weston_keyboard_grab *grab,
 			free(b);
 		}
 	} else if (resource) {
-		client = wl_resource_get_client(resource);
-		display = wl_client_get_display(client);
 		serial = wl_display_next_serial(display);
 		wl_keyboard_send_key(resource, serial, time, key, state);
 	}
diff --git a/src/data-device.c b/src/data-device.c
index c89379c..f6f90b5 100644
--- a/src/data-device.c
+++ b/src/data-device.c
@@ -204,7 +204,7 @@ weston_drag_set_focus(struct weston_drag *drag, struct weston_surface *surface,
 {
 	struct weston_pointer *pointer = drag->grab.pointer;
 	struct wl_resource *resource, *offer = NULL;
-	struct wl_display *display;
+	struct wl_display *display = pointer->seat->compositor->wl_display;
 	uint32_t serial;
 
 	if (drag->focus_resource) {
@@ -226,7 +226,6 @@ weston_drag_set_focus(struct weston_drag *drag, struct weston_surface *surface,
 	if (!resource)
 		return;
 
-	display = wl_client_get_display(wl_resource_get_client(resource));
 	serial = wl_display_next_serial(display);
 
 	if (drag->data_source)
diff --git a/src/input.c b/src/input.c
index 1887e7f..8757097 100644
--- a/src/input.c
+++ b/src/input.c
@@ -137,12 +137,11 @@ default_grab_button(struct weston_pointer_grab *grab,
 	struct wl_resource *resource;
 	uint32_t serial;
 	enum wl_pointer_button_state state = state_w;
-	struct wl_display *display;
+	struct wl_display *display = compositor->wl_display;
 	wl_fixed_t sx, sy;
 
 	resource = pointer->focus_resource;
 	if (resource) {
-		display = wl_client_get_display(wl_resource_get_client(resource));
 		serial = wl_display_next_serial(display);
 		wl_pointer_send_button(resource, serial, time, button, state_w);
 	}
@@ -170,11 +169,10 @@ default_grab_touch_down(struct weston_touch_grab *grab, uint32_t time,
 			int touch_id, wl_fixed_t sx, wl_fixed_t sy)
 {
 	struct weston_touch *touch = grab->touch;
-	struct wl_display *display;
+	struct wl_display *display = touch->seat->compositor->wl_display;
 	uint32_t serial;
 
 	if (touch->focus_resource && touch->focus) {
-		display = wl_client_get_display(wl_resource_get_client(touch->focus_resource));
 		serial = wl_display_next_serial(display);
 		wl_touch_send_down(touch->focus_resource, serial, time,
 				   touch->focus->resource,
@@ -187,11 +185,10 @@ default_grab_touch_up(struct weston_touch_grab *grab,
 		      uint32_t time, int touch_id)
 {
 	struct weston_touch *touch = grab->touch;
-	struct wl_display *display;
+	struct wl_display *display = touch->seat->compositor->wl_display;
 	uint32_t serial;
 
 	if (touch->focus_resource) {
-		display = wl_client_get_display(wl_resource_get_client(touch->focus_resource));
 		serial = wl_display_next_serial(display);
 		wl_touch_send_up(touch->focus_resource, serial, time, touch_id);
 	}
@@ -221,12 +218,11 @@ default_grab_key(struct weston_keyboard_grab *grab,
 {
 	struct weston_keyboard *keyboard = grab->keyboard;
 	struct wl_resource *resource;
-	struct wl_display *display;
+	struct wl_display *display = keyboard->seat->compositor->wl_display;
 	uint32_t serial;
 
 	resource = keyboard->focus_resource;
 	if (resource) {
-		display = wl_client_get_display(wl_resource_get_client(resource));
 		serial = wl_display_next_serial(display);
 		wl_keyboard_send_key(resource, serial, time, key, state);
 	}
@@ -426,12 +422,11 @@ weston_pointer_set_focus(struct weston_pointer *pointer,
 {
 	struct weston_keyboard *kbd = pointer->seat->keyboard;
 	struct wl_resource *resource, *kr;
-	struct wl_display *display;
+	struct wl_display *display = pointer->seat->compositor->wl_display;
 	uint32_t serial;
 
 	resource = pointer->focus_resource;
 	if (resource && pointer->focus != surface) {
-		display = wl_client_get_display(wl_resource_get_client(resource));
 		serial = wl_display_next_serial(display);
 		wl_pointer_send_leave(resource, serial,
 				      pointer->focus->resource);
@@ -443,7 +438,6 @@ weston_pointer_set_focus(struct weston_pointer *pointer,
 	if (resource &&
 	    (pointer->focus != surface ||
 	     pointer->focus_resource != resource)) {
-		display = wl_client_get_display(wl_resource_get_client(resource));
 		serial = wl_display_next_serial(display);
 		if (kbd) {
 			kr = find_resource_for_surface(&kbd->resource_list,
@@ -474,12 +468,11 @@ weston_keyboard_set_focus(struct weston_keyboard *keyboard,
 			  struct weston_surface *surface)
 {
 	struct wl_resource *resource;
-	struct wl_display *display;
+	struct wl_display *display = keyboard->seat->compositor->wl_display;
 	uint32_t serial;
 
 	if (keyboard->focus_resource && keyboard->focus != surface) {
 		resource = keyboard->focus_resource;
-		display = wl_client_get_display(wl_resource_get_client(resource));
 		serial = wl_display_next_serial(display);
 		wl_keyboard_send_leave(resource, serial,
 				       keyboard->focus->resource);
@@ -491,7 +484,6 @@ weston_keyboard_set_focus(struct weston_keyboard *keyboard,
 	if (resource &&
 	    (keyboard->focus != surface ||
 	     keyboard->focus_resource != resource)) {
-		display = wl_client_get_display(wl_resource_get_client(resource));
 		serial = wl_display_next_serial(display);
 		wl_keyboard_send_modifiers(resource, serial,
 					   keyboard->modifiers.mods_depressed,
diff --git a/src/shell.c b/src/shell.c
index 7e98831..e4d5a5e 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -2060,13 +2060,12 @@ popup_grab_button(struct weston_pointer_grab *grab,
 	struct wl_resource *resource;
 	struct shell_seat *shseat =
 	    container_of(grab, struct shell_seat, popup_grab.grab);
-	struct wl_display *display;
+	struct wl_display *display = shseat->seat->compositor->wl_display;
 	enum wl_pointer_button_state state = state_w;
 	uint32_t serial;
 
 	resource = grab->pointer->focus_resource;
 	if (resource) {
-		display = wl_client_get_display(wl_resource_get_client(resource));
 		serial = wl_display_get_serial(display);
 		wl_pointer_send_button(resource, serial, time, button, state);
 	} else if (state == WL_POINTER_BUTTON_STATE_RELEASED &&
@@ -4129,8 +4128,9 @@ debug_binding_key(struct weston_keyboard_grab *grab, uint32_t time,
 		  uint32_t key, uint32_t state)
 {
 	struct debug_binding_grab *db = (struct debug_binding_grab *) grab;
+	struct weston_compositor *ec = db->seat->compositor;
+	struct wl_display *display = ec->wl_display;
 	struct wl_resource *resource;
-	struct wl_display *display;
 	uint32_t serial;
 	int send = 0, terminate = 0;
 	int check_binding = 1;
@@ -4165,8 +4165,6 @@ debug_binding_key(struct weston_keyboard_grab *grab, uint32_t time,
 	}
 
 	if (check_binding) {
-		struct weston_compositor *ec = db->seat->compositor;
-
 		if (weston_compositor_run_debug_binding(ec, db->seat, time,
 							key, state)) {
 			/* We ran a binding so swallow the press and keep the
@@ -4186,7 +4184,6 @@ debug_binding_key(struct weston_keyboard_grab *grab, uint32_t time,
 		resource = grab->keyboard->focus_resource;
 
 		if (resource) {
-			display = wl_client_get_display(wl_resource_get_client(resource));
 			serial = wl_display_next_serial(display);
 			wl_keyboard_send_key(resource, serial, time, key, state);
 		}
-- 
1.8.3.1



More information about the wayland-devel mailing list