[PATCH 1/2] server: Rename wl_grab_interface.

Scott Moreau oreaus at gmail.com
Sat Feb 18 03:25:36 PST 2012


In order to separate pointer and keyboard grabs, we need to
introduce a keyboard grab interface but first we must rename
some generic types to denote which device is holding the grab.

Type renames:

wl_grab_interface -> wl_pointer_grab_interface
wl_grab -> wl_pointer_grab
wl_input_device_start_grab -> wl_input_device_start_pointer_grab
wl_input_device_end_grab -> wl_input_device_end_pointer_grab
---
 src/data-device.c    |   14 +++++++++-----
 src/wayland-server.c |   39 ++++++++++++++++++++-------------------
 src/wayland-server.h |   26 +++++++++++++-------------
 3 files changed, 42 insertions(+), 37 deletions(-)

diff --git a/src/data-device.c b/src/data-device.c
index 6c254c7..334375b 100644
--- a/src/data-device.c
+++ b/src/data-device.c
@@ -179,7 +179,7 @@ destroy_drag_focus(struct wl_listener *listener,
 }
 
 static void
-drag_grab_focus(struct wl_grab *grab, uint32_t time,
+drag_grab_focus(struct wl_pointer_grab *grab, uint32_t time,
 		struct wl_surface *surface, int32_t x, int32_t y)
 {
 	struct wl_input_device *device =
@@ -215,7 +215,7 @@ drag_grab_focus(struct wl_grab *grab, uint32_t time,
 }
 
 static void
-drag_grab_motion(struct wl_grab *grab,
+drag_grab_motion(struct wl_pointer_grab *grab,
 		 uint32_t time, int32_t x, int32_t y)
 {
 	struct wl_input_device *device =
@@ -227,7 +227,7 @@ drag_grab_motion(struct wl_grab *grab,
 }
 
 static void
-drag_grab_button(struct wl_grab *grab,
+drag_grab_button(struct wl_pointer_grab *grab,
 		 uint32_t time, int32_t button, int32_t state)
 {
 	struct wl_input_device *device =
@@ -239,6 +239,7 @@ drag_grab_button(struct wl_grab *grab,
 				       WL_DATA_DEVICE_DROP);
 
 	if (device->button_count == 0 && state == 0) {
+<<<<<<< HEAD
 		wl_input_device_end_grab(device, time);
 
 		if (device->drag_surface) {
@@ -252,12 +253,15 @@ drag_grab_button(struct wl_grab *grab,
 					       surface_resource, NULL, 0, 0);
 		}
 
+=======
+		wl_input_device_end_pointer_grab(device, time);
+>>>>>>> server: Rename wl_grab_interface.
 		device->drag_data_source = NULL;
 		device->drag_surface = NULL;
 	}
 }
 
-static const struct wl_grab_interface drag_grab_interface = {
+static const struct wl_pointer_grab_interface drag_grab_interface = {
 	drag_grab_focus,
 	drag_grab_motion,
 	drag_grab_button,
@@ -282,7 +286,7 @@ data_device_start_drag(struct wl_client *client, struct wl_resource *resource,
 	if (icon_resource)
 		device->drag_surface = icon_resource->data;
 
-	wl_input_device_start_grab(device, &device->drag_grab, time);
+	wl_input_device_start_pointer_grab(device, &device->drag_grab, time);
 }
 
 static void
diff --git a/src/wayland-server.c b/src/wayland-server.c
index 8239291..7fd66f1 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -413,7 +413,7 @@ lose_keyboard_focus(struct wl_listener *listener,
 }
 
 static void
-default_grab_focus(struct wl_grab *grab, uint32_t time,
+default_grab_focus(struct wl_pointer_grab *grab, uint32_t time,
 		   struct wl_surface *surface, int32_t x, int32_t y)
 {
 	struct wl_input_device *device = grab->input_device;
@@ -425,7 +425,7 @@ default_grab_focus(struct wl_grab *grab, uint32_t time,
 }
 
 static void
-default_grab_motion(struct wl_grab *grab,
+default_grab_motion(struct wl_pointer_grab *grab,
 		    uint32_t time, int32_t x, int32_t y)
 {
 	struct wl_resource *resource;
@@ -437,7 +437,7 @@ default_grab_motion(struct wl_grab *grab,
 }
 
 static void
-default_grab_button(struct wl_grab *grab,
+default_grab_button(struct wl_pointer_grab *grab,
 		    uint32_t time, int32_t button, int32_t state)
 {
 	struct wl_input_device *device = grab->input_device;
@@ -455,7 +455,8 @@ default_grab_button(struct wl_grab *grab,
 						  device->current_y);
 }
 
-static const struct wl_grab_interface default_grab_interface = {
+static const struct wl_pointer_grab_interface
+				default_pointer_grab_interface = {
 	default_grab_focus,
 	default_grab_motion,
 	default_grab_button
@@ -470,9 +471,9 @@ wl_input_device_init(struct wl_input_device *device)
 	device->pointer_focus_listener.func = lose_pointer_focus;
 	device->keyboard_focus_listener.func = lose_keyboard_focus;
 
-	device->default_grab.interface = &default_grab_interface;
-	device->default_grab.input_device = device;
-	device->grab = &device->default_grab;
+	device->default_pointer_grab.interface = &default_pointer_grab_interface;
+	device->default_pointer_grab.input_device = device;
+	device->pointer_grab = &device->default_pointer_grab;
 
 	wl_list_init(&device->drag_resource_list);
 	device->selection_data_source = NULL;
@@ -544,7 +545,7 @@ wl_input_device_set_pointer_focus(struct wl_input_device *device,
 	device->pointer_focus_resource = resource;
 	device->pointer_focus = surface;
 	device->pointer_focus_time = time;
-	device->default_grab.focus = surface;
+	device->default_pointer_grab.focus = surface;
 }
 
 WL_EXPORT void
@@ -581,28 +582,28 @@ wl_input_device_set_keyboard_focus(struct wl_input_device *device,
 }
 
 WL_EXPORT void
-wl_input_device_start_grab(struct wl_input_device *device,
-			   struct wl_grab *grab, uint32_t time)
+wl_input_device_start_pointer_grab(struct wl_input_device *device,
+			   struct wl_pointer_grab *grab, uint32_t time)
 {
-	const struct wl_grab_interface *interface;
+	const struct wl_pointer_grab_interface *interface;
 
-	device->grab = grab;
-	interface = device->grab->interface;
+	device->pointer_grab = grab;
+	interface = device->pointer_grab->interface;
 	grab->input_device = device;
 
 	if (device->current)
-		interface->focus(device->grab, time, device->current,
+		interface->focus(device->pointer_grab, time, device->current,
 				 device->current_x, device->current_y);
 }
 
 WL_EXPORT void
-wl_input_device_end_grab(struct wl_input_device *device, uint32_t time)
+wl_input_device_end_pointer_grab(struct wl_input_device *device, uint32_t time)
 {
-	const struct wl_grab_interface *interface;
+	const struct wl_pointer_grab_interface *interface;
 
-	device->grab = &device->default_grab;
-	interface = device->grab->interface;
-	interface->focus(device->grab, time, device->current,
+	device->pointer_grab = &device->default_pointer_grab;
+	interface = device->pointer_grab->interface;
+	interface->focus(device->pointer_grab, time, device->current,
 			 device->current_x, device->current_y);
 }
 
diff --git a/src/wayland-server.h b/src/wayland-server.h
index 616df3b..45778ee 100644
--- a/src/wayland-server.h
+++ b/src/wayland-server.h
@@ -145,18 +145,18 @@ struct wl_surface {
 	struct wl_resource resource;
 };
 
-struct wl_grab;
-struct wl_grab_interface {
-	void (*focus)(struct wl_grab *grab, uint32_t time,
+struct wl_pointer_grab;
+struct wl_pointer_grab_interface {
+	void (*focus)(struct wl_pointer_grab *grab, uint32_t time,
 		      struct wl_surface *surface, int32_t x, int32_t y);
-	void (*motion)(struct wl_grab *grab,
+	void (*motion)(struct wl_pointer_grab *grab,
 		       uint32_t time, int32_t x, int32_t y);
-	void (*button)(struct wl_grab *grab,
+	void (*button)(struct wl_pointer_grab *grab,
 		       uint32_t time, int32_t button, int32_t state);
 };
 
-struct wl_grab {
-	const struct wl_grab_interface *interface;
+struct wl_pointer_grab {
+	const struct wl_pointer_grab_interface *interface;
 	struct wl_input_device *input_device;
 	struct wl_surface *focus;
 	int32_t x, y;
@@ -198,8 +198,8 @@ struct wl_input_device {
 	struct wl_surface *current;
 	int32_t current_x, current_y;
 
-	struct wl_grab *grab;
-	struct wl_grab default_grab;
+	struct wl_pointer_grab *pointer_grab;
+	struct wl_pointer_grab default_pointer_grab;
 	uint32_t button_count;
 	uint32_t grab_time;
 	int32_t grab_x, grab_y;
@@ -211,7 +211,7 @@ struct wl_input_device {
 	struct wl_surface *drag_focus;
 	struct wl_resource *drag_focus_resource;
 	struct wl_listener drag_focus_listener;
-	struct wl_grab drag_grab;
+	struct wl_pointer_grab drag_grab;
 	struct wl_surface *drag_surface;
 
 	struct wl_data_source *selection_data_source;
@@ -281,10 +281,10 @@ int
 wl_data_device_manager_init(struct wl_display *display);
 
 void
-wl_input_device_end_grab(struct wl_input_device *device, uint32_t time);
+wl_input_device_start_pointer_grab(struct wl_input_device *device,
+			   struct wl_pointer_grab *grab, uint32_t time);
 void
-wl_input_device_start_grab(struct wl_input_device *device,
-			   struct wl_grab *grab, uint32_t time);
+wl_input_device_end_pointer_grab(struct wl_input_device *device, uint32_t time);
 
 void
 wl_input_device_set_selection(struct wl_input_device *device,
-- 
1.7.4.1



More information about the wayland-devel mailing list