From: Kristian Høgsberg Date: Tue, 18 Jan 2011 14:23:13 +0000 (-0500) Subject: Use the global handler in dnd instead of custom drag_offer hook X-Git-Tag: 0.85.0~265 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=943741cb40a5e2691c5a95a8c253dee69f0c86b0;p=profile%2Fivi%2Fwayland.git Use the global handler in dnd instead of custom drag_offer hook --- diff --git a/clients/dnd.c b/clients/dnd.c index feea336..33562bc 100644 --- a/clients/dnd.c +++ b/clients/dnd.c @@ -487,14 +487,21 @@ static const struct wl_drag_offer_listener drag_offer_listener = { }; static void -drag_offer_handler(struct wl_drag_offer *offer, struct display *display) +global_handler(struct display *display, + const char *interface, uint32_t id, uint32_t version) { + struct wl_drag_offer *offer; struct dnd_offer *dnd_offer; + if (strcmp(interface, "drag_offer") != 0) + return; + + offer = wl_drag_offer_create(display_get_display(display), id); + dnd_offer = malloc(sizeof *dnd_offer); if (dnd_offer == NULL) return; - + dnd_offer->refcount = 1; wl_drag_offer_add_listener(offer, &drag_offer_listener, dnd_offer); @@ -681,7 +688,7 @@ main(int argc, char *argv[]) return -1; } - display_set_drag_offer_handler(d, drag_offer_handler); + display_set_global_handler(d, global_handler); dnd = dnd_create (d); diff --git a/clients/window.c b/clients/window.c index 9d5c9d1..13d7ece 100644 --- a/clients/window.c +++ b/clients/window.c @@ -79,7 +79,6 @@ struct display { struct xkb_desc *xkb; cairo_surface_t **pointer_surfaces; - display_drag_offer_handler_t drag_offer_handler; display_global_handler_t global_handler; }; @@ -1317,7 +1316,6 @@ display_handle_global(struct wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data) { struct display *d = data; - struct wl_drag_offer *offer; if (strcmp(interface, "compositor") == 0) { d->compositor = wl_compositor_create(display, id); @@ -1334,13 +1332,8 @@ display_handle_global(struct wl_display *display, uint32_t id, wl_drm_add_listener(d->drm, &drm_listener, d); } else if (strcmp(interface, "shm") == 0) { d->shm = wl_shm_create(display, id); - } else if (strcmp(interface, "drag_offer") == 0) { - if (d->drag_offer_handler) { - offer = wl_drag_offer_create(display, id); - d->drag_offer_handler(offer, d); - } } else if (d->global_handler) { - d->global_handler(d, interface, version); + d->global_handler(d, interface, id, version); } } @@ -1542,13 +1535,6 @@ display_run(struct display *d) } void -display_set_drag_offer_handler(struct display *display, - display_drag_offer_handler_t handler) -{ - display->drag_offer_handler = handler; -} - -void display_set_global_handler(struct display *display, display_global_handler_t handler) { diff --git a/clients/window.h b/clients/window.h index f84ae92..b4457bc 100644 --- a/clients/window.h +++ b/clients/window.h @@ -124,11 +124,9 @@ 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_drag_offer_handler_t)(struct wl_drag_offer *offer, - struct display *display); - typedef void (*display_global_handler_t)(struct display *display, const char *interface, + uint32_t id, uint32_t version); struct window * @@ -225,10 +223,6 @@ window_set_frame_handler(struct window *window, window_frame_handler_t handler); void -display_set_drag_offer_handler(struct display *display, - display_drag_offer_handler_t handler); - -void display_set_global_handler(struct display *display, display_global_handler_t handler);