Chase wlroots: Unified mapping

Need to handle new unified mapping, where mapping is attached to the
wlr_surface objects instead of their parents. Also, most of them require
a new associate event for xsurface objects, their surface member will be
NULL before this event is received.

Refactored by jlindgren:
- add struct mappable
- unify map/unmap logic
This commit is contained in:
Christopher Snowhill 2023-06-15 02:35:43 -07:00 committed by Johan Malm
parent bf576e97de
commit d7dc6e01b4
10 changed files with 142 additions and 52 deletions

View file

@ -1605,6 +1605,55 @@ view_toggle_keybinds(struct view *view)
}
}
void
mappable_connect(struct mappable *mappable, struct wlr_surface *surface,
wl_notify_func_t notify_map, wl_notify_func_t notify_unmap)
{
assert(mappable);
assert(!mappable->connected);
mappable->map.notify = notify_map;
wl_signal_add(&surface->events.map, &mappable->map);
mappable->unmap.notify = notify_unmap;
wl_signal_add(&surface->events.unmap, &mappable->unmap);
mappable->connected = true;
}
void
mappable_disconnect(struct mappable *mappable)
{
assert(mappable);
assert(mappable->connected);
wl_list_remove(&mappable->map.link);
wl_list_remove(&mappable->unmap.link);
mappable->connected = false;
}
static void
handle_map(struct wl_listener *listener, void *data)
{
struct view *view = wl_container_of(listener, view, mappable.map);
view->impl->map(view);
}
static void
handle_unmap(struct wl_listener *listener, void *data)
{
struct view *view = wl_container_of(listener, view, mappable.unmap);
view->impl->unmap(view, /* client_request */ true);
}
/*
* TODO: after the release of wlroots 0.17, consider incorporating this
* function into a more general view_set_surface() function, which could
* connect other surface event handlers (like commit) as well.
*/
void
view_connect_map(struct view *view, struct wlr_surface *surface)
{
assert(view);
mappable_connect(&view->mappable, surface, handle_map, handle_unmap);
}
void
view_destroy(struct view *view)
{
@ -1612,8 +1661,10 @@ view_destroy(struct view *view)
struct server *server = view->server;
bool need_cursor_update = false;
wl_list_remove(&view->map.link);
wl_list_remove(&view->unmap.link);
if (view->mappable.connected) {
mappable_disconnect(&view->mappable);
}
wl_list_remove(&view->request_move.link);
wl_list_remove(&view->request_resize.link);
wl_list_remove(&view->request_minimize.link);