mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-03-24 09:06:21 -04:00
Send wl_registry.global_remove to global's offer list
Since the globals track the registries that received global announcements, we can use that instead of going through all present registries and duplicate some filtering logic. Signed-off-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
This commit is contained in:
parent
268e8373ae
commit
17915041fb
1 changed files with 19 additions and 21 deletions
|
|
@ -130,7 +130,7 @@ struct wl_global {
|
||||||
wl_global_bind_func_t bind;
|
wl_global_bind_func_t bind;
|
||||||
wl_global_withdrawn_func_t withdrawn;
|
wl_global_withdrawn_func_t withdrawn;
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
bool removed;
|
bool unpublished;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wl_global_offer {
|
struct wl_global_offer {
|
||||||
|
|
@ -1115,8 +1115,8 @@ display_sync(struct wl_client *client,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wl_global_announce(struct wl_global *global,
|
wl_global_publish(struct wl_global *global,
|
||||||
struct wl_resource *registry_resource)
|
struct wl_resource *registry_resource)
|
||||||
{
|
{
|
||||||
struct wl_global_offer *offer;
|
struct wl_global_offer *offer;
|
||||||
struct wl_registry *registry = registry_resource->data;
|
struct wl_registry *registry = registry_resource->data;
|
||||||
|
|
@ -1154,7 +1154,7 @@ wl_global_offer_done(struct wl_global_offer *offer)
|
||||||
|
|
||||||
wl_global_offer_destroy(offer);
|
wl_global_offer_destroy(offer);
|
||||||
|
|
||||||
if (global->removed && global->withdrawn && wl_list_empty(&global->offer_list))
|
if (global->unpublished && global->withdrawn && wl_list_empty(&global->offer_list))
|
||||||
global->withdrawn(global);
|
global->withdrawn(global);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1220,8 +1220,8 @@ display_get_registry(struct wl_client *client,
|
||||||
®istry_resource->link);
|
®istry_resource->link);
|
||||||
|
|
||||||
wl_list_for_each(global, &display->global_list, link)
|
wl_list_for_each(global, &display->global_list, link)
|
||||||
if (wl_global_is_visible(client, global) && !global->removed)
|
if (wl_global_is_visible(client, global) && !global->unpublished)
|
||||||
wl_global_announce(global, registry_resource);
|
wl_global_publish(global, registry_resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wl_display_interface display_interface = {
|
static const struct wl_display_interface display_interface = {
|
||||||
|
|
@ -1488,29 +1488,27 @@ wl_global_create(struct wl_display *display,
|
||||||
global->data = data;
|
global->data = data;
|
||||||
global->bind = bind;
|
global->bind = bind;
|
||||||
global->withdrawn = NULL;
|
global->withdrawn = NULL;
|
||||||
global->removed = false;
|
global->unpublished = false;
|
||||||
wl_list_insert(display->global_list.prev, &global->link);
|
wl_list_insert(display->global_list.prev, &global->link);
|
||||||
wl_list_init(&global->offer_list);
|
wl_list_init(&global->offer_list);
|
||||||
|
|
||||||
wl_list_for_each(resource, &display->registry_resource_list, link)
|
wl_list_for_each(resource, &display->registry_resource_list, link)
|
||||||
if (wl_global_is_visible(resource->client, global))
|
if (wl_global_is_visible(resource->client, global))
|
||||||
wl_global_announce(global, resource);
|
wl_global_publish(global, resource);
|
||||||
|
|
||||||
return global;
|
return global;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wl_global_send_removed(struct wl_global *global)
|
wl_global_unpublish(struct wl_global *global)
|
||||||
{
|
{
|
||||||
struct wl_display *display = global->display;
|
struct wl_global_offer *offer;
|
||||||
struct wl_resource *resource;
|
|
||||||
|
|
||||||
wl_list_for_each(resource, &display->registry_resource_list, link)
|
wl_list_for_each(offer, &global->offer_list, global_link)
|
||||||
if (wl_global_is_visible(resource->client, global))
|
wl_resource_post_event(offer->registry_resource,
|
||||||
wl_resource_post_event(resource, WL_REGISTRY_GLOBAL_REMOVE,
|
WL_REGISTRY_GLOBAL_REMOVE, global->name);
|
||||||
global->name);
|
|
||||||
|
|
||||||
global->removed = true;
|
global->unpublished = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Remove the global
|
/** Remove the global
|
||||||
|
|
@ -1554,12 +1552,12 @@ wl_global_send_removed(struct wl_global *global)
|
||||||
WL_EXPORT void
|
WL_EXPORT void
|
||||||
wl_global_remove(struct wl_global *global)
|
wl_global_remove(struct wl_global *global)
|
||||||
{
|
{
|
||||||
if (global->removed)
|
if (global->unpublished)
|
||||||
wl_abort("wl_global_remove: called twice on the same "
|
wl_abort("wl_global_remove: called twice on the same "
|
||||||
"global '%s#%"PRIu32"'", global->interface->name,
|
"global '%s#%"PRIu32"'", global->interface->name,
|
||||||
global->name);
|
global->name);
|
||||||
|
|
||||||
wl_global_send_removed(global);
|
wl_global_unpublish(global);
|
||||||
|
|
||||||
if (global->withdrawn && wl_list_empty(&global->offer_list))
|
if (global->withdrawn && wl_list_empty(&global->offer_list))
|
||||||
global->withdrawn(global);
|
global->withdrawn(global);
|
||||||
|
|
@ -1597,8 +1595,8 @@ wl_global_destroy(struct wl_global *global)
|
||||||
{
|
{
|
||||||
struct wl_global_offer *offer;
|
struct wl_global_offer *offer;
|
||||||
|
|
||||||
if (!global->removed)
|
if (!global->unpublished)
|
||||||
wl_global_send_removed(global);
|
wl_global_unpublish(global);
|
||||||
|
|
||||||
wl_list_remove(&global->link);
|
wl_list_remove(&global->link);
|
||||||
|
|
||||||
|
|
@ -2889,7 +2887,7 @@ wl_fixes_handle_ack_global_remove(struct wl_resource *fixes_resource,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!offer->global->removed) {
|
if (!offer->global->unpublished) {
|
||||||
wl_resource_post_error(fixes_resource, WL_FIXES_ERROR_INVALID_ACK_REMOVE,
|
wl_resource_post_error(fixes_resource, WL_FIXES_ERROR_INVALID_ACK_REMOVE,
|
||||||
"global %u is not removed", global_name);
|
"global %u is not removed", global_name);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue