[PATCH 2/2] Define global handler on display creation

Tim Wiederhake twied at gmx.net
Fri Jan 28 16:30:26 PST 2011


Otherwise the initial announcement of interfaces gets lost.
---
 clients/dnd.c       |    4 +---
 clients/eventdemo.c |    2 +-
 clients/flower.c    |    2 +-
 clients/gears.c     |    2 +-
 clients/image.c     |    2 +-
 clients/resizor.c   |    2 +-
 clients/smoke.c     |    2 +-
 clients/terminal.c  |    2 +-
 clients/view.c      |    2 +-
 clients/window.c    |   12 ++++--------
 clients/window.h    |   18 ++++++++----------
 11 files changed, 21 insertions(+), 29 deletions(-)

diff --git a/clients/dnd.c b/clients/dnd.c
index 1625ffd..3dcd40d 100644
--- a/clients/dnd.c
+++ b/clients/dnd.c
@@ -679,14 +679,12 @@ main(int argc, char *argv[])
 {
 	struct display *d;
 
-	d = display_create(&argc, &argv, option_entries);
+	d = display_create(&argc, &argv, option_entries, global_handler);
 	if (d == NULL) {
 		fprintf(stderr, "failed to create display: %m\n");
 		return -1;
 	}
 
-	display_set_global_handler(d, global_handler);
-
 	dnd_create(d);
 
 	display_run(d);
diff --git a/clients/eventdemo.c b/clients/eventdemo.c
index 8de620a..3a0fd0d 100644
--- a/clients/eventdemo.c
+++ b/clients/eventdemo.c
@@ -377,7 +377,7 @@ main(int argc, char *argv[])
 	struct eventdemo *e;
 
 	/* Connect to the display and have the arguments parsed */
-	d = display_create(&argc, &argv, option_entries);
+	d = display_create(&argc, &argv, option_entries, NULL);
 	if (d == NULL) {
 		fprintf(stderr, "failed to create display: %m\n");
 		return -1;
diff --git a/clients/flower.c b/clients/flower.c
index b5caa32..5081ba2 100644
--- a/clients/flower.c
+++ b/clients/flower.c
@@ -129,7 +129,7 @@ int main(int argc, char *argv[])
 	struct display *d;
 	struct timeval tv;
 
-	d = display_create(&argc, &argv, NULL);
+	d = display_create(&argc, &argv, NULL, NULL);
 	if (d == NULL) {
 		fprintf(stderr, "failed to create display: %m\n");
 		return -1;
diff --git a/clients/gears.c b/clients/gears.c
index 5ae2a95..260801b 100644
--- a/clients/gears.c
+++ b/clients/gears.c
@@ -422,7 +422,7 @@ int main(int argc, char *argv[])
 {
 	struct display *d;
 
-	d = display_create(&argc, &argv, NULL);
+	d = display_create(&argc, &argv, NULL, NULL);
 	if (d == NULL) {
 		fprintf(stderr, "failed to create display: %m\n");
 		return -1;
diff --git a/clients/image.c b/clients/image.c
index 3eada1e..f7d040f 100644
--- a/clients/image.c
+++ b/clients/image.c
@@ -244,7 +244,7 @@ main(int argc, char *argv[])
 	struct display *d;
 	int i;
 
-	d = display_create(&argc, &argv, option_entries);
+	d = display_create(&argc, &argv, option_entries, NULL);
 	if (d == NULL) {
 		fprintf(stderr, "failed to create display: %m\n");
 		return -1;
diff --git a/clients/resizor.c b/clients/resizor.c
index 0ac02f6..9788d25 100644
--- a/clients/resizor.c
+++ b/clients/resizor.c
@@ -220,7 +220,7 @@ main(int argc, char *argv[])
 {
 	struct display *d;
 
-	d = display_create(&argc, &argv, NULL);
+	d = display_create(&argc, &argv, NULL, NULL);
 	if (d == NULL) {
 		fprintf(stderr, "failed to create display: %m\n");
 		return -1;
diff --git a/clients/smoke.c b/clients/smoke.c
index 0710b3a..e132229 100644
--- a/clients/smoke.c
+++ b/clients/smoke.c
@@ -249,7 +249,7 @@ int main(int argc, char *argv[])
 	struct display *d;
 	int size;
 
-	d = display_create(&argc, &argv, NULL);
+	d = display_create(&argc, &argv, NULL, NULL);
 	if (d == NULL) {
 		fprintf(stderr, "failed to create display: %m\n");
 		return -1;
diff --git a/clients/terminal.c b/clients/terminal.c
index 3573382..0d41226 100644
--- a/clients/terminal.c
+++ b/clients/terminal.c
@@ -2382,7 +2382,7 @@ int main(int argc, char *argv[])
 	struct display *d;
 	struct terminal *terminal;
 
-	d = display_create(&argc, &argv, option_entries);
+	d = display_create(&argc, &argv, option_entries, NULL);
 	if (d == NULL) {
 		fprintf(stderr, "failed to create display: %m\n");
 		return -1;
diff --git a/clients/view.c b/clients/view.c
index 05edf3f..40614c0 100644
--- a/clients/view.c
+++ b/clients/view.c
@@ -253,7 +253,7 @@ main(int argc, char *argv[])
 	struct display *d;
 	int i;
 
-	d = display_create(&argc, &argv, option_entries);
+	d = display_create(&argc, &argv, option_entries, NULL);
 	if (d == NULL) {
 		fprintf(stderr, "failed to create display: %m\n");
 		return -1;
diff --git a/clients/window.c b/clients/window.c
index 955db66..1f21a60 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -1636,7 +1636,8 @@ init_drm(struct display *d)
 }
 
 struct display *
-display_create(int *argc, char **argv[], const GOptionEntry *option_entries)
+display_create(int *argc, char **argv[], const GOptionEntry *option_entries,
+               display_global_handler_t global_handler)
 {
 	struct display *d;
 	GOptionContext *context;
@@ -1675,6 +1676,8 @@ display_create(int *argc, char **argv[], const GOptionEntry *option_entries)
 		return NULL;
 	}
 
+	d->global_handler = global_handler;
+
 	wl_list_init(&d->input_list);
 
 	/* Set up listener so we'll catch all events. */
@@ -1731,10 +1734,3 @@ display_run(struct display *d)
 {
 	g_main_loop_run(d->loop);
 }
-
-void
-display_set_global_handler(struct display *display,
-			   display_global_handler_t handler)
-{
-	display->global_handler = handler;
-}
diff --git a/clients/window.h b/clients/window.h
index 5f41ba5..d6d49e8 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -39,8 +39,15 @@ struct rectangle {
 struct display;
 struct input;
 
+
+typedef void (*display_global_handler_t)(struct display *display,
+                                         const char *interface,
+                                         uint32_t id,
+                                         uint32_t version);
+
 struct display *
-display_create(int *argc, char **argv[], const GOptionEntry *option_entries);
+display_create(int *argc, char **argv[], const GOptionEntry *option_entries,
+               display_global_handler_t global_handler);
 
 struct wl_display *
 display_get_display(struct display *display);
@@ -122,11 +129,6 @@ typedef int (*window_motion_handler_t)(struct window *window,
 				       int32_t x, int32_t y,
 				       int32_t sx, int32_t sy, void *data);
 
-typedef void (*display_global_handler_t)(struct display *display,
-					 const char *interface,
-					 uint32_t id,
-					 uint32_t version);
-
 struct window *
 window_create(struct display *display, int32_t width, int32_t height);
 struct window *
@@ -216,10 +218,6 @@ window_set_title(struct window *window, const char *title);
 const char *
 window_get_title(struct window *window);
 
-void
-display_set_global_handler(struct display *display,
-			   display_global_handler_t handler);
-
 struct wl_drag *
 window_create_drag(struct window *window);
 
-- 
1.7.2.3



More information about the wayland-devel mailing list