xdg-shell: chase events update

This commit is contained in:
Kirill Primak 2023-07-11 15:09:14 +03:00 committed by Simon Ser
parent 128b6253a9
commit 47e6a1164c
7 changed files with 133 additions and 109 deletions

View file

@ -23,6 +23,45 @@ static void xdg_decoration_handle_request_mode(struct wl_listener *listener,
void *data) {
struct sway_xdg_decoration *deco =
wl_container_of(listener, deco, request_mode);
set_xdg_decoration_mode(deco);
}
void handle_xdg_decoration(struct wl_listener *listener, void *data) {
struct wlr_xdg_toplevel_decoration_v1 *wlr_deco = data;
struct sway_xdg_shell_view *xdg_shell_view = wlr_deco->toplevel->base->data;
struct sway_xdg_decoration *deco = calloc(1, sizeof(*deco));
if (deco == NULL) {
return;
}
deco->view = &xdg_shell_view->view;
deco->view->xdg_decoration = deco;
deco->wlr_xdg_decoration = wlr_deco;
wl_signal_add(&wlr_deco->events.destroy, &deco->destroy);
deco->destroy.notify = xdg_decoration_handle_destroy;
wl_signal_add(&wlr_deco->events.request_mode, &deco->request_mode);
deco->request_mode.notify = xdg_decoration_handle_request_mode;
wl_list_insert(&server.xdg_decorations, &deco->link);
set_xdg_decoration_mode(deco);
}
struct sway_xdg_decoration *xdg_decoration_from_surface(
struct wlr_surface *surface) {
struct sway_xdg_decoration *deco;
wl_list_for_each(deco, &server.xdg_decorations, link) {
if (deco->wlr_xdg_decoration->toplevel->base->surface == surface) {
return deco;
}
}
return NULL;
}
void set_xdg_decoration_mode(struct sway_xdg_decoration *deco) {
struct sway_view *view = deco->view;
enum wlr_xdg_toplevel_decoration_v1_mode mode =
WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
@ -47,41 +86,7 @@ static void xdg_decoration_handle_request_mode(struct wl_listener *listener,
mode = client_mode;
}
wlr_xdg_toplevel_decoration_v1_set_mode(deco->wlr_xdg_decoration,
mode);
}
void handle_xdg_decoration(struct wl_listener *listener, void *data) {
struct wlr_xdg_toplevel_decoration_v1 *wlr_deco = data;
struct sway_xdg_shell_view *xdg_shell_view = wlr_deco->toplevel->base->data;
struct sway_xdg_decoration *deco = calloc(1, sizeof(*deco));
if (deco == NULL) {
return;
if (view->wlr_xdg_toplevel->base->initialized) {
wlr_xdg_toplevel_decoration_v1_set_mode(deco->wlr_xdg_decoration, mode);
}
deco->view = &xdg_shell_view->view;
deco->view->xdg_decoration = deco;
deco->wlr_xdg_decoration = wlr_deco;
wl_signal_add(&wlr_deco->events.destroy, &deco->destroy);
deco->destroy.notify = xdg_decoration_handle_destroy;
wl_signal_add(&wlr_deco->events.request_mode, &deco->request_mode);
deco->request_mode.notify = xdg_decoration_handle_request_mode;
wl_list_insert(&server.xdg_decorations, &deco->link);
xdg_decoration_handle_request_mode(&deco->request_mode, wlr_deco);
}
struct sway_xdg_decoration *xdg_decoration_from_surface(
struct wlr_surface *surface) {
struct sway_xdg_decoration *deco;
wl_list_for_each(deco, &server.xdg_decorations, link) {
if (deco->wlr_xdg_decoration->toplevel->base->surface == surface) {
return deco;
}
}
return NULL;
}