Use the global handler in dnd instead of custom drag_offer hook
This commit is contained in:
parent
b46df05fa8
commit
943741cb40
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1541,13 +1534,6 @@ display_run(struct display *d)
|
||||
g_main_loop_run(d->loop);
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -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 *
|
||||
@ -224,10 +222,6 @@ void
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user