From c27fd1e1ee9826ea0668d2bb5aa8644daec29a7f Mon Sep 17 00:00:00 2001 From: emersion Date: Fri, 9 Mar 2018 10:29:22 +0100 Subject: rootston: add view_map and view_unmap --- rootston/xdg_shell_v6.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'rootston/xdg_shell_v6.c') diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index eda349cb..c49bd911 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -287,9 +287,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) { wl_list_remove(&roots_xdg_surface->request_resize.link); wl_list_remove(&roots_xdg_surface->request_maximize.link); wl_list_remove(&roots_xdg_surface->request_fullscreen.link); - wl_list_remove(&roots_xdg_surface->view->link); - view_finish(roots_xdg_surface->view); - free(roots_xdg_surface->view); + view_destroy(roots_xdg_surface->view); free(roots_xdg_surface); } @@ -333,7 +331,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { roots_surface->new_popup.notify = handle_new_popup; wl_signal_add(&surface->events.new_popup, &roots_surface->new_popup); - struct roots_view *view = view_create(); + struct roots_view *view = view_create(desktop); if (!view) { free(roots_surface); return; @@ -342,7 +340,6 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { view->xdg_surface_v6 = surface; view->roots_xdg_surface_v6 = roots_surface; - view->wlr_surface = surface->surface; view->activate = activate; view->resize = resize; view->move_resize = move_resize; @@ -356,8 +353,6 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { view->width = box.width; view->height = box.height; - view_init(view, desktop); - wl_list_insert(&desktop->views, &view->link); - + view_map(view, surface->surface); view_setup(view); } -- cgit v1.2.3 From 3f072bedd98969974ec1d3e8ffd9bae4150e52d4 Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 10 Mar 2018 11:18:50 +0100 Subject: xdg-shell-v6: add map signal --- include/rootston/view.h | 2 ++ include/wlr/types/wlr_xdg_shell_v6.h | 5 +++-- rootston/desktop.c | 16 ++++++++++++--- rootston/output.c | 7 ++++++- rootston/xdg_shell_v6.c | 38 ++++++++++++++++++++++++++++-------- types/wlr_xdg_shell_v6.c | 18 +++++++++++++++-- 6 files changed, 70 insertions(+), 16 deletions(-) (limited to 'rootston/xdg_shell_v6.c') diff --git a/include/rootston/view.h b/include/rootston/view.h index 66a0cb3d..0844a6da 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -27,6 +27,8 @@ struct roots_xdg_surface_v6 { struct wl_listener destroy; struct wl_listener new_popup; + struct wl_listener map; + struct wl_listener unmap; struct wl_listener request_move; struct wl_listener request_resize; struct wl_listener request_maximize; diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index 7dc746ce..959d420f 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -107,8 +107,7 @@ struct wlr_xdg_surface_v6 { struct wl_list popups; // wlr_xdg_popup_v6::link - bool configured; - bool added; + bool added, configured, mapped; uint32_t configure_serial; struct wl_event_source *configure_idle; uint32_t configure_next_serial; @@ -127,6 +126,8 @@ struct wlr_xdg_surface_v6 { struct wl_signal destroy; struct wl_signal ping_timeout; struct wl_signal new_popup; + struct wl_signal map; + struct wl_signal unmap; struct wl_signal request_maximize; struct wl_signal request_fullscreen; diff --git a/rootston/desktop.c b/rootston/desktop.c index 66c7ac2b..278f4fea 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -54,7 +54,8 @@ void view_get_deco_box(const struct roots_view *view, struct wlr_box *box) { box->height += (view->border_width * 2 + view->titlebar_height); } -enum roots_deco_part view_get_deco_part(struct roots_view *view, double sx, double sy) { +enum roots_deco_part view_get_deco_part(struct roots_view *view, double sx, + double sy) { if (!view->decorated) { return ROOTS_DECO_PART_NONE; } @@ -94,9 +95,15 @@ enum roots_deco_part view_get_deco_part(struct roots_view *view, double sx, doub static void view_update_output(const struct roots_view *view, const struct wlr_box *before) { struct roots_desktop *desktop = view->desktop; - struct roots_output *output; + + if (view->wlr_surface == NULL) { + return; + } + struct wlr_box box; view_get_box(view, &box); + + struct roots_output *output; wl_list_for_each(output, &desktop->outputs, link) { bool intersected = before != NULL && wlr_output_layout_intersects( desktop->layout, output->wlr_output, before); @@ -479,7 +486,10 @@ void view_initial_focus(struct roots_view *view) { void view_setup(struct roots_view *view) { view_initial_focus(view); - view_center(view); + if (view->fullscreen_output == NULL) { + view_center(view); + } + view_update_output(view, NULL); } diff --git a/rootston/output.c b/rootston/output.c index 4d0a9c05..adcbb961 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -501,7 +501,9 @@ static void render_output(struct roots_output *output) { goto renderer_end; } - view_for_each_surface(view, render_surface, &data); + if (view->wlr_surface != NULL) { + view_for_each_surface(view, render_surface, &data); + } // During normal rendering the xwayland window tree isn't traversed // because all windows are rendered. Here we only want to render @@ -570,6 +572,9 @@ void output_damage_whole(struct roots_output *output) { static bool view_accept_damage(struct roots_output *output, struct roots_view *view) { + if (view->wlr_surface == NULL) { + return false; + } if (output->fullscreen_view == NULL) { return true; } diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index c49bd911..4591f642 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -243,6 +243,10 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) { struct roots_view *view = roots_surface->view; struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; + if (!surface->mapped) { + return; + } + view_apply_damage(view); struct wlr_box size; @@ -277,6 +281,28 @@ static void handle_new_popup(struct wl_listener *listener, void *data) { popup_create(roots_xdg_surface->view, wlr_popup); } +static void handle_map(struct wl_listener *listener, void *data) { + struct roots_xdg_surface_v6 *roots_xdg_surface = + wl_container_of(listener, roots_xdg_surface, map); + struct roots_view *view = roots_xdg_surface->view; + + struct wlr_box box; + get_size(view, &box); + view->width = box.width; + view->height = box.height; + + view_map(view, view->xdg_surface_v6->surface); + view_setup(view); +} + +static void handle_unmap(struct wl_listener *listener, void *data) { + struct roots_xdg_surface_v6 *roots_xdg_surface = + wl_container_of(listener, roots_xdg_surface, unmap); + struct roots_view *view = roots_xdg_surface->view; + + view_unmap(view); +} + static void handle_destroy(struct wl_listener *listener, void *data) { struct roots_xdg_surface_v6 *roots_xdg_surface = wl_container_of(listener, roots_xdg_surface, destroy); @@ -317,6 +343,10 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { &roots_surface->surface_commit); roots_surface->destroy.notify = handle_destroy; wl_signal_add(&surface->events.destroy, &roots_surface->destroy); + roots_surface->map.notify = handle_map; + wl_signal_add(&surface->events.map, &roots_surface->map); + roots_surface->unmap.notify = handle_unmap; + wl_signal_add(&surface->events.unmap, &roots_surface->unmap); roots_surface->request_move.notify = handle_request_move; wl_signal_add(&surface->events.request_move, &roots_surface->request_move); roots_surface->request_resize.notify = handle_request_resize; @@ -347,12 +377,4 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { view->set_fullscreen = set_fullscreen; view->close = close; roots_surface->view = view; - - struct wlr_box box; - get_size(view, &box); - view->width = box.width; - view->height = box.height; - - view_map(view, surface->surface); - view_setup(view); } diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index e07d78a1..18f7393d 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -481,6 +481,7 @@ static void xdg_popup_resource_destroy(struct wl_resource *resource) { struct wlr_xdg_surface_v6 *surface = xdg_surface_from_xdg_popup_resource(resource); if (surface != NULL) { + // TODO: don't destroy the surface, unmap it xdg_surface_destroy(surface); } } @@ -792,6 +793,7 @@ static void xdg_toplevel_resource_destroy(struct wl_resource *resource) { struct wlr_xdg_surface_v6 *surface = xdg_surface_from_xdg_toplevel_resource(resource); if (surface != NULL) { + // TODO: don't destroy the surface, unmap it xdg_surface_destroy(surface); } } @@ -1172,9 +1174,19 @@ static void handle_wlr_surface_committed(struct wlr_surface *wlr_surface, break; } - if (surface->configured && !surface->added) { + if (!surface->added) { surface->added = true; - wlr_signal_emit_safe(&surface->client->shell->events.new_surface, surface); + wlr_signal_emit_safe(&surface->client->shell->events.new_surface, + surface); + } + if (surface->configured && wlr_surface_has_buffer(surface->surface) && + !surface->mapped) { + surface->mapped = true; + wlr_signal_emit_safe(&surface->events.map, surface); + } + if (surface->configured && !wlr_surface_has_buffer(surface->surface) && + surface->mapped) { + // TODO: unmap the surface } } @@ -1249,6 +1261,8 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client, wl_signal_init(&surface->events.destroy); wl_signal_init(&surface->events.ping_timeout); wl_signal_init(&surface->events.new_popup); + wl_signal_init(&surface->events.map); + wl_signal_init(&surface->events.unmap); wl_signal_add(&surface->surface->events.destroy, &surface->surface_destroy_listener); -- cgit v1.2.3 From 1f8854f2172b124572f53976b9067fc4ef33a8a1 Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 12 Mar 2018 09:00:59 +0100 Subject: rootston: remove xdg-shell-v6 map/unmap listeners on destroy --- rootston/xdg_shell_v6.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'rootston/xdg_shell_v6.c') diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index 4591f642..12e22afb 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -309,6 +309,8 @@ static void handle_destroy(struct wl_listener *listener, void *data) { wl_list_remove(&roots_xdg_surface->surface_commit.link); wl_list_remove(&roots_xdg_surface->destroy.link); wl_list_remove(&roots_xdg_surface->new_popup.link); + wl_list_remove(&roots_xdg_surface->map.link); + wl_list_remove(&roots_xdg_surface->unmap.link); wl_list_remove(&roots_xdg_surface->request_move.link); wl_list_remove(&roots_xdg_surface->request_resize.link); wl_list_remove(&roots_xdg_surface->request_maximize.link); -- cgit v1.2.3 From 6ac3534df6ce1ac35932fb71584675d32507fed7 Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 12 Mar 2018 09:17:06 +0100 Subject: rootston: add destroy to view interface --- include/rootston/view.h | 1 + rootston/desktop.c | 4 ++++ rootston/wl_shell.c | 22 ++++++++++++++-------- rootston/xdg_shell.c | 21 +++++++++++++-------- rootston/xdg_shell_v6.c | 30 +++++++++++++++++------------- rootston/xwayland.c | 14 ++++++++++---- 6 files changed, 59 insertions(+), 33 deletions(-) (limited to 'rootston/xdg_shell_v6.c') diff --git a/include/rootston/view.h b/include/rootston/view.h index 0844a6da..1e5c0933 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -142,6 +142,7 @@ struct roots_view { void (*maximize)(struct roots_view *view, bool maximized); void (*set_fullscreen)(struct roots_view *view, bool fullscreen); void (*close)(struct roots_view *view); + void (*destroy)(struct roots_view *view); }; struct roots_view_child { diff --git a/rootston/desktop.c b/rootston/desktop.c index 278f4fea..19b7768c 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -422,6 +422,10 @@ void view_destroy(struct roots_view *view) { wl_signal_emit(&view->events.destroy, view); + if (view->destroy) { + view->destroy(view); + } + free(view); } diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c index 6326d9d7..d58f030a 100644 --- a/rootston/wl_shell.c +++ b/rootston/wl_shell.c @@ -78,6 +78,19 @@ static void close(struct roots_view *view) { wl_client_destroy(surf->client); } +static void destroy(struct roots_view *view) { + assert(view->type == ROOTS_WL_SHELL_VIEW); + struct roots_wl_shell_surface *roots_surface = view->roots_wl_shell_surface; + wl_list_remove(&roots_surface->destroy.link); + wl_list_remove(&roots_surface->request_move.link); + wl_list_remove(&roots_surface->request_resize.link); + wl_list_remove(&roots_surface->request_maximize.link); + wl_list_remove(&roots_surface->request_fullscreen.link); + wl_list_remove(&roots_surface->set_state.link); + wl_list_remove(&roots_surface->surface_commit.link); + free(roots_surface); +} + static void handle_request_move(struct wl_listener *listener, void *data) { struct roots_wl_shell_surface *roots_surface = wl_container_of(listener, roots_surface, request_move); @@ -174,15 +187,7 @@ static void handle_new_popup(struct wl_listener *listener, void *data) { static void handle_destroy(struct wl_listener *listener, void *data) { struct roots_wl_shell_surface *roots_surface = wl_container_of(listener, roots_surface, destroy); - wl_list_remove(&roots_surface->destroy.link); - wl_list_remove(&roots_surface->request_move.link); - wl_list_remove(&roots_surface->request_resize.link); - wl_list_remove(&roots_surface->request_maximize.link); - wl_list_remove(&roots_surface->request_fullscreen.link); - wl_list_remove(&roots_surface->set_state.link); - wl_list_remove(&roots_surface->surface_commit.link); view_destroy(roots_surface->view); - free(roots_surface); } void handle_wl_shell_surface(struct wl_listener *listener, void *data) { @@ -238,6 +243,7 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { view->roots_wl_shell_surface = roots_surface; view->resize = resize; view->close = close; + view->destroy = destroy; roots_surface->view = view; view_map(view, surface->surface); diff --git a/rootston/xdg_shell.c b/rootston/xdg_shell.c index 1733eb4e..24c57bd5 100644 --- a/rootston/xdg_shell.c +++ b/rootston/xdg_shell.c @@ -180,6 +180,18 @@ static void close(struct roots_view *view) { } } +static void destroy(struct roots_view *view) { + struct roots_xdg_surface *roots_xdg_surface = view->roots_xdg_surface; + wl_list_remove(&roots_xdg_surface->surface_commit.link); + wl_list_remove(&roots_xdg_surface->destroy.link); + wl_list_remove(&roots_xdg_surface->new_popup.link); + wl_list_remove(&roots_xdg_surface->request_move.link); + wl_list_remove(&roots_xdg_surface->request_resize.link); + wl_list_remove(&roots_xdg_surface->request_maximize.link); + wl_list_remove(&roots_xdg_surface->request_fullscreen.link); + free(roots_xdg_surface); +} + static void handle_request_move(struct wl_listener *listener, void *data) { struct roots_xdg_surface *roots_xdg_surface = wl_container_of(listener, roots_xdg_surface, request_move); @@ -280,15 +292,7 @@ static void handle_new_popup(struct wl_listener *listener, void *data) { static void handle_destroy(struct wl_listener *listener, void *data) { struct roots_xdg_surface *roots_xdg_surface = wl_container_of(listener, roots_xdg_surface, destroy); - wl_list_remove(&roots_xdg_surface->surface_commit.link); - wl_list_remove(&roots_xdg_surface->destroy.link); - wl_list_remove(&roots_xdg_surface->new_popup.link); - wl_list_remove(&roots_xdg_surface->request_move.link); - wl_list_remove(&roots_xdg_surface->request_resize.link); - wl_list_remove(&roots_xdg_surface->request_maximize.link); - wl_list_remove(&roots_xdg_surface->request_fullscreen.link); view_destroy(roots_xdg_surface->view); - free(roots_xdg_surface); } void handle_xdg_shell_surface(struct wl_listener *listener, void *data) { @@ -346,6 +350,7 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) { view->maximize = maximize; view->set_fullscreen = set_fullscreen; view->close = close; + view->destroy = destroy; roots_surface->view = view; struct wlr_box box; diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index 12e22afb..1f6f25eb 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -180,6 +180,21 @@ static void close(struct roots_view *view) { } } +static void destroy(struct roots_view *view) { + assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); + struct roots_xdg_surface_v6 *roots_xdg_surface = view->roots_xdg_surface_v6; + wl_list_remove(&roots_xdg_surface->surface_commit.link); + wl_list_remove(&roots_xdg_surface->destroy.link); + wl_list_remove(&roots_xdg_surface->new_popup.link); + wl_list_remove(&roots_xdg_surface->map.link); + wl_list_remove(&roots_xdg_surface->unmap.link); + wl_list_remove(&roots_xdg_surface->request_move.link); + wl_list_remove(&roots_xdg_surface->request_resize.link); + wl_list_remove(&roots_xdg_surface->request_maximize.link); + wl_list_remove(&roots_xdg_surface->request_fullscreen.link); + free(roots_xdg_surface); +} + static void handle_request_move(struct wl_listener *listener, void *data) { struct roots_xdg_surface_v6 *roots_xdg_surface = wl_container_of(listener, roots_xdg_surface, request_move); @@ -298,25 +313,13 @@ static void handle_map(struct wl_listener *listener, void *data) { static void handle_unmap(struct wl_listener *listener, void *data) { struct roots_xdg_surface_v6 *roots_xdg_surface = wl_container_of(listener, roots_xdg_surface, unmap); - struct roots_view *view = roots_xdg_surface->view; - - view_unmap(view); + view_unmap(roots_xdg_surface->view); } static void handle_destroy(struct wl_listener *listener, void *data) { struct roots_xdg_surface_v6 *roots_xdg_surface = wl_container_of(listener, roots_xdg_surface, destroy); - wl_list_remove(&roots_xdg_surface->surface_commit.link); - wl_list_remove(&roots_xdg_surface->destroy.link); - wl_list_remove(&roots_xdg_surface->new_popup.link); - wl_list_remove(&roots_xdg_surface->map.link); - wl_list_remove(&roots_xdg_surface->unmap.link); - wl_list_remove(&roots_xdg_surface->request_move.link); - wl_list_remove(&roots_xdg_surface->request_resize.link); - wl_list_remove(&roots_xdg_surface->request_maximize.link); - wl_list_remove(&roots_xdg_surface->request_fullscreen.link); view_destroy(roots_xdg_surface->view); - free(roots_xdg_surface); } void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { @@ -378,5 +381,6 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { view->maximize = maximize; view->set_fullscreen = set_fullscreen; view->close = close; + view->destroy = destroy; roots_surface->view = view; } diff --git a/rootston/xwayland.c b/rootston/xwayland.c index f95e5f81..53331b1f 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -106,9 +106,9 @@ static void set_fullscreen(struct roots_view *view, bool fullscreen) { wlr_xwayland_surface_set_fullscreen(view->xwayland_surface, fullscreen); } -static void handle_destroy(struct wl_listener *listener, void *data) { - struct roots_xwayland_surface *roots_surface = - wl_container_of(listener, roots_surface, destroy); +static void destroy(struct roots_view *view) { + assert(view->type == ROOTS_XWAYLAND_VIEW); + struct roots_xwayland_surface *roots_surface = view->roots_xwayland_surface; wl_list_remove(&roots_surface->destroy.link); wl_list_remove(&roots_surface->request_configure.link); wl_list_remove(&roots_surface->request_move.link); @@ -116,10 +116,15 @@ static void handle_destroy(struct wl_listener *listener, void *data) { wl_list_remove(&roots_surface->request_maximize.link); wl_list_remove(&roots_surface->map_notify.link); wl_list_remove(&roots_surface->unmap_notify.link); - view_destroy(roots_surface->view); free(roots_surface); } +static void handle_destroy(struct wl_listener *listener, void *data) { + struct roots_xwayland_surface *roots_surface = + wl_container_of(listener, roots_surface, destroy); + view_destroy(roots_surface->view); +} + static void handle_request_configure(struct wl_listener *listener, void *data) { struct roots_xwayland_surface *roots_surface = wl_container_of(listener, roots_surface, request_configure); @@ -307,6 +312,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { view->maximize = maximize; view->set_fullscreen = set_fullscreen; view->close = close; + view->destroy = destroy; roots_surface->view = view; view_map(view, surface->surface); -- cgit v1.2.3 From 42637a52cf2779ec05f0fdb97df416e21438a77b Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 12 Mar 2018 10:42:41 +0100 Subject: rootston: don't segfault when getting size of an unmapped xdg-shell view --- rootston/xdg_shell_v6.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'rootston/xdg_shell_v6.c') diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index 1f6f25eb..c81cd16a 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -63,9 +63,11 @@ static void get_size(const struct roots_view *view, struct wlr_box *box) { if (surface->geometry->width > 0 && surface->geometry->height > 0) { box->width = surface->geometry->width; box->height = surface->geometry->height; - } else { + } else if (view->wlr_surface != NULL) { box->width = view->wlr_surface->current->width; box->height = view->wlr_surface->current->height; + } else { + box->width = box->height = 0; } } -- cgit v1.2.3 From e74ddaaf10f1c8078cf078f55428b9e86776ca93 Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 13 Mar 2018 19:57:21 +0100 Subject: xdg-shell-v6: redesign the configure/ack_configure workflow --- include/wlr/types/wlr_xdg_shell_v6.h | 23 ++++++++-------------- rootston/output.c | 3 ++- rootston/xdg_shell_v6.c | 7 +++++++ types/wlr_xdg_shell_v6.c | 38 +++++++++++++++++++++++------------- 4 files changed, 41 insertions(+), 30 deletions(-) (limited to 'rootston/xdg_shell_v6.c') diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index 959d420f..86a42181 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -62,19 +62,10 @@ enum wlr_xdg_surface_v6_role { }; struct wlr_xdg_toplevel_v6_state { - bool maximized; - bool fullscreen; - bool resizing; - bool activated; - - uint32_t width; - uint32_t height; - - uint32_t max_width; - uint32_t max_height; - - uint32_t min_width; - uint32_t min_height; + bool maximized, fullscreen, resizing, activated; + uint32_t width, height; + uint32_t max_width, max_height; + uint32_t min_width, min_height; }; struct wlr_xdg_toplevel_v6 { @@ -90,7 +81,8 @@ struct wlr_xdg_toplevel_v6 { struct wlr_xdg_surface_v6_configure { struct wl_list link; // wlr_xdg_surface_v6::configure_list uint32_t serial; - struct wlr_xdg_toplevel_v6_state state; + + struct wlr_xdg_toplevel_v6_state toplevel_state; // TODO: should be null-able }; struct wlr_xdg_surface_v6 { @@ -100,6 +92,7 @@ struct wlr_xdg_surface_v6 { struct wl_list link; // wlr_xdg_client_v6::surfaces enum wlr_xdg_surface_v6_role role; + // TODO: the _state prefix should be dropped union { struct wlr_xdg_toplevel_v6 *toplevel_state; struct wlr_xdg_popup_v6 *popup_state; @@ -118,7 +111,7 @@ struct wlr_xdg_surface_v6 { bool has_next_geometry; struct wlr_box *next_geometry; - struct wlr_box *geometry; + struct wlr_box *geometry; // TODO: should not be a pointer struct wl_listener surface_destroy_listener; diff --git a/rootston/output.c b/rootston/output.c index adcbb961..f772ea24 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -433,7 +433,8 @@ static void render_output(struct roots_output *output) { float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f}; // Check if we can delegate the fullscreen surface to the output - if (output->fullscreen_view != NULL) { + if (output->fullscreen_view != NULL && + output->fullscreen_view->wlr_surface != NULL) { struct roots_view *view = output->fullscreen_view; // Make sure the view is centered on screen diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index c81cd16a..84c76d16 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -385,4 +385,11 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { view->close = close; view->destroy = destroy; roots_surface->view = view; + + if (surface->toplevel_state->next.maximized) { + view_maximize(view, true); + } + if (surface->toplevel_state->next.fullscreen) { + view_set_fullscreen(view, true, NULL); + } } diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index 5da25f62..8c2e9d58 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -868,9 +868,15 @@ static void wlr_xdg_toplevel_v6_ack_configure( struct wlr_xdg_surface_v6 *surface, struct wlr_xdg_surface_v6_configure *configure) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); - surface->toplevel_state->next = configure->state; - surface->toplevel_state->pending.width = 0; - surface->toplevel_state->pending.height = 0; + + surface->toplevel_state->current.maximized = + configure->toplevel_state.maximized; + surface->toplevel_state->current.fullscreen = + configure->toplevel_state.fullscreen; + surface->toplevel_state->current.resizing = + configure->toplevel_state.resizing; + surface->toplevel_state->current.activated = + configure->toplevel_state.activated; } static void xdg_surface_handle_ack_configure(struct wl_client *client, @@ -982,9 +988,9 @@ static bool wlr_xdg_surface_v6_toplevel_state_compare( } else { struct wlr_xdg_surface_v6_configure *configure = wl_container_of(state->base->configure_list.prev, configure, link); - configured.state = configure->state; - configured.width = configure->state.width; - configured.height = configure->state.height; + configured.state = configure->toplevel_state; + configured.width = configure->toplevel_state.width; + configured.height = configure->toplevel_state.height; } if (state->pending.activated != configured.state.activated) { @@ -1019,7 +1025,7 @@ static void wlr_xdg_toplevel_v6_send_configure( uint32_t *s; struct wl_array states; - configure->state = surface->toplevel_state->pending; + configure->toplevel_state = surface->toplevel_state->pending; wl_array_init(&states); if (surface->toplevel_state->pending.maximized) { @@ -1160,8 +1166,7 @@ static void wlr_xdg_surface_v6_toplevel_committed( struct wlr_xdg_surface_v6 *surface) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); - if (!wlr_surface_has_buffer(surface->surface) - && !surface->toplevel_state->added) { + if (!surface->toplevel_state->added) { // on the first commit, send a configure request to tell the client it // is added wlr_xdg_surface_v6_schedule_configure(surface); @@ -1169,11 +1174,15 @@ static void wlr_xdg_surface_v6_toplevel_committed( return; } - if (!wlr_surface_has_buffer(surface->surface)) { - return; - } - - surface->toplevel_state->current = surface->toplevel_state->next; + // update state that doesn't need compositor approval + surface->toplevel_state->current.max_width = + surface->toplevel_state->next.max_width; + surface->toplevel_state->current.min_width = + surface->toplevel_state->next.min_width; + surface->toplevel_state->current.max_height = + surface->toplevel_state->next.max_height; + surface->toplevel_state->current.min_height = + surface->toplevel_state->next.min_height; } static void wlr_xdg_surface_v6_popup_committed( @@ -1482,6 +1491,7 @@ uint32_t wlr_xdg_toplevel_v6_set_size(struct wlr_xdg_surface_v6 *surface, assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); surface->toplevel_state->pending.width = width; surface->toplevel_state->pending.height = height; + wlr_log(L_DEBUG, "wlr_xdg_toplevel_v6_set_size %d", width); return wlr_xdg_surface_v6_schedule_configure(surface); } -- cgit v1.2.3 From 149209b72ed069f3c6026e6bf7ffb4ffff0de190 Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 13 Mar 2018 22:09:44 +0100 Subject: xdg-shell-v6: rename toplevel and popup fields in wlr_xdg_surface_v6 for consistency --- include/wlr/types/wlr_xdg_shell_v6.h | 5 +- rootston/xdg_shell_v6.c | 8 +- types/wlr_xdg_shell_v6.c | 172 +++++++++++++++++------------------ 3 files changed, 92 insertions(+), 93 deletions(-) (limited to 'rootston/xdg_shell_v6.c') diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index 9140fa64..2358feec 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -92,10 +92,9 @@ struct wlr_xdg_surface_v6 { struct wl_list link; // wlr_xdg_client_v6::surfaces enum wlr_xdg_surface_v6_role role; - // TODO: the _state prefix should be dropped union { - struct wlr_xdg_toplevel_v6 *toplevel_state; - struct wlr_xdg_popup_v6 *popup_state; + struct wlr_xdg_toplevel_v6 *toplevel; + struct wlr_xdg_popup_v6 *popup; }; struct wl_list popups; // wlr_xdg_popup_v6::link diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index 84c76d16..59637105 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -85,7 +85,7 @@ static void apply_size_constraints(struct wlr_xdg_surface_v6 *surface, *dest_width = width; *dest_height = height; - struct wlr_xdg_toplevel_v6_state *state = &surface->toplevel_state->current; + struct wlr_xdg_toplevel_v6_state *state = &surface->toplevel->current; if (width < state->min_width) { *dest_width = state->min_width; } else if (state->max_width > 0 && @@ -236,7 +236,7 @@ static void handle_request_maximize(struct wl_listener *listener, void *data) { return; } - view_maximize(view, surface->toplevel_state->next.maximized); + view_maximize(view, surface->toplevel->next.maximized); } static void handle_request_fullscreen(struct wl_listener *listener, @@ -386,10 +386,10 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { view->destroy = destroy; roots_surface->view = view; - if (surface->toplevel_state->next.maximized) { + if (surface->toplevel->next.maximized) { view_maximize(view, true); } - if (surface->toplevel_state->next.fullscreen) { + if (surface->toplevel->next.fullscreen) { view_set_fullscreen(view, true, NULL); } } diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index 5ea1fb8b..214f818c 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -166,20 +166,20 @@ static void xdg_surface_unmap(struct wlr_xdg_surface_v6 *surface) { wlr_signal_emit_safe(&surface->events.unmap, surface); if (surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { - wl_resource_set_user_data(surface->toplevel_state->resource, NULL); - free(surface->toplevel_state); - surface->toplevel_state = NULL; + wl_resource_set_user_data(surface->toplevel->resource, NULL); + free(surface->toplevel); + surface->toplevel = NULL; } if (surface->role == WLR_XDG_SURFACE_V6_ROLE_POPUP) { - wl_resource_set_user_data(surface->popup_state->resource, NULL); + wl_resource_set_user_data(surface->popup->resource, NULL); - if (surface->popup_state->seat) { + if (surface->popup->seat) { struct wlr_xdg_popup_grab_v6 *grab = xdg_shell_popup_grab_from_seat(surface->client->shell, - surface->popup_state->seat); + surface->popup->seat); - wl_list_remove(&surface->popup_state->grab_link); + wl_list_remove(&surface->popup->grab_link); if (wl_list_empty(&grab->popups)) { if (grab->seat->pointer_state.grab == &grab->pointer_grab) { @@ -191,9 +191,9 @@ static void xdg_surface_unmap(struct wlr_xdg_surface_v6 *surface) { } } - wl_list_remove(&surface->popup_state->link); - free(surface->popup_state); - surface->popup_state = NULL; + wl_list_remove(&surface->popup->link); + free(surface->popup); + surface->popup = NULL; } surface->role = WLR_XDG_SURFACE_V6_ROLE_NONE; @@ -452,8 +452,8 @@ static void xdg_popup_handle_grab(struct wl_client *client, struct wlr_seat_client *seat_client = wlr_seat_client_from_resource(seat_resource); - if (surface->popup_state->committed) { - wl_resource_post_error(surface->popup_state->resource, + if (surface->popup->committed) { + wl_resource_post_error(surface->popup->resource, ZXDG_POPUP_V6_ERROR_INVALID_GRAB, "xdg_popup is already mapped"); return; @@ -465,10 +465,10 @@ static void xdg_popup_handle_grab(struct wl_client *client, struct wlr_xdg_surface_v6 *topmost = xdg_popup_grab_get_topmost(popup_grab); bool parent_is_toplevel = - surface->popup_state->parent->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL; + surface->popup->parent->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL; if ((topmost == NULL && !parent_is_toplevel) || - (topmost != NULL && topmost != surface->popup_state->parent)) { + (topmost != NULL && topmost != surface->popup->parent)) { wl_resource_post_error(surface->client->resource, ZXDG_SHELL_V6_ERROR_NOT_THE_TOPMOST_POPUP, "xdg_popup was not created on the topmost popup"); @@ -476,9 +476,9 @@ static void xdg_popup_handle_grab(struct wl_client *client, } popup_grab->client = surface->client->client; - surface->popup_state->seat = seat_client->seat; + surface->popup->seat = seat_client->seat; - wl_list_insert(&popup_grab->popups, &surface->popup_state->grab_link); + wl_list_insert(&popup_grab->popups, &surface->popup->grab_link); wlr_seat_pointer_start_grab(seat_client->seat, &popup_grab->pointer_grab); @@ -492,7 +492,7 @@ static void xdg_popup_handle_destroy(struct wl_client *client, xdg_surface_from_xdg_popup_resource(resource); struct wlr_xdg_popup_grab_v6 *grab = xdg_shell_popup_grab_from_seat(surface->client->shell, - surface->popup_state->seat); + surface->popup->seat); struct wlr_xdg_surface_v6 *topmost = xdg_popup_grab_get_topmost(grab); @@ -552,33 +552,33 @@ static void xdg_surface_handle_get_popup(struct wl_client *client, return; } - surface->popup_state = calloc(1, sizeof(struct wlr_xdg_popup_v6)); - if (!surface->popup_state) { + surface->popup = calloc(1, sizeof(struct wlr_xdg_popup_v6)); + if (!surface->popup) { wl_resource_post_no_memory(resource); return; } - surface->popup_state->resource = + surface->popup->resource = wl_resource_create(client, &zxdg_popup_v6_interface, wl_resource_get_version(resource), id); - if (surface->popup_state->resource == NULL) { - free(surface->popup_state); + if (surface->popup->resource == NULL) { + free(surface->popup); wl_resource_post_no_memory(resource); return; } surface->role = WLR_XDG_SURFACE_V6_ROLE_POPUP; - surface->popup_state->base = surface; - surface->popup_state->parent = parent; - surface->popup_state->geometry = + surface->popup->base = surface; + surface->popup->parent = parent; + surface->popup->geometry = xdg_positioner_get_geometry(positioner, surface, parent); - wl_list_insert(&parent->popups, &surface->popup_state->link); + wl_list_insert(&parent->popups, &surface->popup->link); - wl_resource_set_implementation(surface->popup_state->resource, + wl_resource_set_implementation(surface->popup->resource, &zxdg_popup_v6_implementation, surface, xdg_popup_resource_destroy); - wlr_signal_emit_safe(&parent->events.new_popup, surface->popup_state); + wlr_signal_emit_safe(&parent->events.new_popup, surface->popup); } @@ -601,7 +601,7 @@ static void xdg_toplevel_handle_set_parent(struct wl_client *client, parent = xdg_surface_from_xdg_toplevel_resource(parent_resource); } - surface->toplevel_state->parent = parent; + surface->toplevel->parent = parent; } static void xdg_toplevel_handle_set_title(struct wl_client *client, @@ -641,7 +641,7 @@ static void xdg_toplevel_handle_show_window_menu(struct wl_client *client, wlr_seat_client_from_resource(seat_resource); if (!surface->configured) { - wl_resource_post_error(surface->toplevel_state->resource, + wl_resource_post_error(surface->toplevel->resource, ZXDG_SURFACE_V6_ERROR_NOT_CONSTRUCTED, "surface has not been configured yet"); return; @@ -672,7 +672,7 @@ static void xdg_toplevel_handle_move(struct wl_client *client, wlr_seat_client_from_resource(seat_resource); if (!surface->configured) { - wl_resource_post_error(surface->toplevel_state->resource, + wl_resource_post_error(surface->toplevel->resource, ZXDG_SURFACE_V6_ERROR_NOT_CONSTRUCTED, "surface has not been configured yet"); return; @@ -701,7 +701,7 @@ static void xdg_toplevel_handle_resize(struct wl_client *client, wlr_seat_client_from_resource(seat_resource); if (!surface->configured) { - wl_resource_post_error(surface->toplevel_state->resource, + wl_resource_post_error(surface->toplevel->resource, ZXDG_SURFACE_V6_ERROR_NOT_CONSTRUCTED, "surface has not been configured yet"); return; @@ -726,23 +726,23 @@ static void xdg_toplevel_handle_set_max_size(struct wl_client *client, struct wl_resource *resource, int32_t width, int32_t height) { struct wlr_xdg_surface_v6 *surface = xdg_surface_from_xdg_toplevel_resource(resource); - surface->toplevel_state->next.max_width = width; - surface->toplevel_state->next.max_height = height; + surface->toplevel->next.max_width = width; + surface->toplevel->next.max_height = height; } static void xdg_toplevel_handle_set_min_size(struct wl_client *client, struct wl_resource *resource, int32_t width, int32_t height) { struct wlr_xdg_surface_v6 *surface = xdg_surface_from_xdg_toplevel_resource(resource); - surface->toplevel_state->next.min_width = width; - surface->toplevel_state->next.min_height = height; + surface->toplevel->next.min_width = width; + surface->toplevel->next.min_height = height; } static void xdg_toplevel_handle_set_maximized(struct wl_client *client, struct wl_resource *resource) { struct wlr_xdg_surface_v6 *surface = xdg_surface_from_xdg_toplevel_resource(resource); - surface->toplevel_state->next.maximized = true; + surface->toplevel->next.maximized = true; wlr_signal_emit_safe(&surface->events.request_maximize, surface); } @@ -750,7 +750,7 @@ static void xdg_toplevel_handle_unset_maximized(struct wl_client *client, struct wl_resource *resource) { struct wlr_xdg_surface_v6 *surface = xdg_surface_from_xdg_toplevel_resource(resource); - surface->toplevel_state->next.maximized = false; + surface->toplevel->next.maximized = false; wlr_signal_emit_safe(&surface->events.request_maximize, surface); } @@ -764,7 +764,7 @@ static void xdg_toplevel_handle_set_fullscreen(struct wl_client *client, output = wlr_output_from_resource(output_resource); } - surface->toplevel_state->next.fullscreen = true; + surface->toplevel->next.fullscreen = true; struct wlr_xdg_toplevel_v6_set_fullscreen_event event = { .surface = surface, @@ -780,7 +780,7 @@ static void xdg_toplevel_handle_unset_fullscreen(struct wl_client *client, struct wlr_xdg_surface_v6 *surface = xdg_surface_from_xdg_toplevel_resource(resource); - surface->toplevel_state->next.fullscreen = false; + surface->toplevel->next.fullscreen = false; struct wlr_xdg_toplevel_v6_set_fullscreen_event event = { .surface = surface, @@ -840,24 +840,24 @@ static void xdg_surface_handle_get_toplevel(struct wl_client *client, return; } - surface->toplevel_state = calloc(1, sizeof(struct wlr_xdg_toplevel_v6)); - if (surface->toplevel_state == NULL) { + surface->toplevel = calloc(1, sizeof(struct wlr_xdg_toplevel_v6)); + if (surface->toplevel == NULL) { wl_resource_post_no_memory(resource); return; } surface->role = WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL; - surface->toplevel_state->base = surface; + surface->toplevel->base = surface; struct wl_resource *toplevel_resource = wl_resource_create(client, &zxdg_toplevel_v6_interface, wl_resource_get_version(resource), id); if (toplevel_resource == NULL) { - free(surface->toplevel_state); + free(surface->toplevel); wl_resource_post_no_memory(resource); return; } - surface->toplevel_state->resource = toplevel_resource; + surface->toplevel->resource = toplevel_resource; wl_resource_set_implementation(toplevel_resource, &zxdg_toplevel_v6_implementation, surface, @@ -870,13 +870,13 @@ static void wlr_xdg_toplevel_v6_ack_configure( assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); assert(configure->toplevel_state != NULL); - surface->toplevel_state->current.maximized = + surface->toplevel->current.maximized = configure->toplevel_state->maximized; - surface->toplevel_state->current.fullscreen = + surface->toplevel->current.fullscreen = configure->toplevel_state->fullscreen; - surface->toplevel_state->current.resizing = + surface->toplevel->current.resizing = configure->toplevel_state->resizing; - surface->toplevel_state->current.activated = + surface->toplevel->current.activated = configure->toplevel_state->activated; free(configure->toplevel_state); @@ -1034,10 +1034,10 @@ static void wlr_xdg_toplevel_v6_send_configure( wlr_log(L_ERROR, "Allocation failed"); return; } - *configure->toplevel_state = surface->toplevel_state->pending; + *configure->toplevel_state = surface->toplevel->pending; wl_array_init(&states); - if (surface->toplevel_state->pending.maximized) { + if (surface->toplevel->pending.maximized) { s = wl_array_add(&states, sizeof(uint32_t)); if (!s) { wlr_log(L_ERROR, "Could not allocate state for maximized xdg_toplevel"); @@ -1045,7 +1045,7 @@ static void wlr_xdg_toplevel_v6_send_configure( } *s = ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED; } - if (surface->toplevel_state->pending.fullscreen) { + if (surface->toplevel->pending.fullscreen) { s = wl_array_add(&states, sizeof(uint32_t)); if (!s) { wlr_log(L_ERROR, "Could not allocate state for fullscreen xdg_toplevel"); @@ -1053,7 +1053,7 @@ static void wlr_xdg_toplevel_v6_send_configure( } *s = ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN; } - if (surface->toplevel_state->pending.resizing) { + if (surface->toplevel->pending.resizing) { s = wl_array_add(&states, sizeof(uint32_t)); if (!s) { wlr_log(L_ERROR, "Could not allocate state for resizing xdg_toplevel"); @@ -1061,7 +1061,7 @@ static void wlr_xdg_toplevel_v6_send_configure( } *s = ZXDG_TOPLEVEL_V6_STATE_RESIZING; } - if (surface->toplevel_state->pending.activated) { + if (surface->toplevel->pending.activated) { s = wl_array_add(&states, sizeof(uint32_t)); if (!s) { wlr_log(L_ERROR, "Could not allocate state for activated xdg_toplevel"); @@ -1070,15 +1070,15 @@ static void wlr_xdg_toplevel_v6_send_configure( *s = ZXDG_TOPLEVEL_V6_STATE_ACTIVATED; } - uint32_t width = surface->toplevel_state->pending.width; - uint32_t height = surface->toplevel_state->pending.height; + uint32_t width = surface->toplevel->pending.width; + uint32_t height = surface->toplevel->pending.height; if (width == 0 || height == 0) { width = surface->geometry->width; height = surface->geometry->height; } - zxdg_toplevel_v6_send_configure(surface->toplevel_state->resource, width, + zxdg_toplevel_v6_send_configure(surface->toplevel->resource, width, height, &states); wl_array_release(&states); @@ -1086,7 +1086,7 @@ static void wlr_xdg_toplevel_v6_send_configure( error_out: wl_array_release(&states); - wl_resource_post_no_memory(surface->toplevel_state->resource); + wl_resource_post_no_memory(surface->toplevel->resource); } static void wlr_xdg_surface_send_configure(void *user_data) { @@ -1112,11 +1112,11 @@ static void wlr_xdg_surface_send_configure(void *user_data) { wlr_xdg_toplevel_v6_send_configure(surface, configure); break; case WLR_XDG_SURFACE_V6_ROLE_POPUP: - zxdg_popup_v6_send_configure(surface->popup_state->resource, - surface->popup_state->geometry.x, - surface->popup_state->geometry.y, - surface->popup_state->geometry.width, - surface->popup_state->geometry.height); + zxdg_popup_v6_send_configure(surface->popup->resource, + surface->popup->geometry.x, + surface->popup->geometry.y, + surface->popup->geometry.width, + surface->popup->geometry.height); break; } @@ -1135,7 +1135,7 @@ static uint32_t wlr_xdg_surface_v6_schedule_configure( break; case WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL: pending_same = - wlr_xdg_surface_v6_toplevel_state_compare(surface->toplevel_state); + wlr_xdg_surface_v6_toplevel_state_compare(surface->toplevel); break; case WLR_XDG_SURFACE_V6_ROLE_POPUP: break; @@ -1175,32 +1175,32 @@ static void wlr_xdg_surface_v6_toplevel_committed( struct wlr_xdg_surface_v6 *surface) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); - if (!surface->toplevel_state->added) { + if (!surface->toplevel->added) { // on the first commit, send a configure request to tell the client it // is added wlr_xdg_surface_v6_schedule_configure(surface); - surface->toplevel_state->added = true; + surface->toplevel->added = true; return; } // update state that doesn't need compositor approval - surface->toplevel_state->current.max_width = - surface->toplevel_state->next.max_width; - surface->toplevel_state->current.min_width = - surface->toplevel_state->next.min_width; - surface->toplevel_state->current.max_height = - surface->toplevel_state->next.max_height; - surface->toplevel_state->current.min_height = - surface->toplevel_state->next.min_height; + surface->toplevel->current.max_width = + surface->toplevel->next.max_width; + surface->toplevel->current.min_width = + surface->toplevel->next.min_width; + surface->toplevel->current.max_height = + surface->toplevel->next.max_height; + surface->toplevel->current.min_height = + surface->toplevel->next.min_height; } static void wlr_xdg_surface_v6_popup_committed( struct wlr_xdg_surface_v6 *surface) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_POPUP); - if (!surface->popup_state->committed) { + if (!surface->popup->committed) { wlr_xdg_surface_v6_schedule_configure(surface); - surface->popup_state->committed = true; + surface->popup->committed = true; } } @@ -1498,8 +1498,8 @@ void wlr_xdg_surface_v6_ping(struct wlr_xdg_surface_v6 *surface) { uint32_t wlr_xdg_toplevel_v6_set_size(struct wlr_xdg_surface_v6 *surface, uint32_t width, uint32_t height) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); - surface->toplevel_state->pending.width = width; - surface->toplevel_state->pending.height = height; + surface->toplevel->pending.width = width; + surface->toplevel->pending.height = height; wlr_log(L_DEBUG, "wlr_xdg_toplevel_v6_set_size %d", width); return wlr_xdg_surface_v6_schedule_configure(surface); @@ -1508,7 +1508,7 @@ uint32_t wlr_xdg_toplevel_v6_set_size(struct wlr_xdg_surface_v6 *surface, uint32_t wlr_xdg_toplevel_v6_set_activated(struct wlr_xdg_surface_v6 *surface, bool activated) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); - surface->toplevel_state->pending.activated = activated; + surface->toplevel->pending.activated = activated; return wlr_xdg_surface_v6_schedule_configure(surface); } @@ -1516,7 +1516,7 @@ uint32_t wlr_xdg_toplevel_v6_set_activated(struct wlr_xdg_surface_v6 *surface, uint32_t wlr_xdg_toplevel_v6_set_maximized(struct wlr_xdg_surface_v6 *surface, bool maximized) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); - surface->toplevel_state->pending.maximized = maximized; + surface->toplevel->pending.maximized = maximized; return wlr_xdg_surface_v6_schedule_configure(surface); } @@ -1524,7 +1524,7 @@ uint32_t wlr_xdg_toplevel_v6_set_maximized(struct wlr_xdg_surface_v6 *surface, uint32_t wlr_xdg_toplevel_v6_set_fullscreen(struct wlr_xdg_surface_v6 *surface, bool fullscreen) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); - surface->toplevel_state->pending.fullscreen = fullscreen; + surface->toplevel->pending.fullscreen = fullscreen; return wlr_xdg_surface_v6_schedule_configure(surface); } @@ -1532,23 +1532,23 @@ uint32_t wlr_xdg_toplevel_v6_set_fullscreen(struct wlr_xdg_surface_v6 *surface, uint32_t wlr_xdg_toplevel_v6_set_resizing(struct wlr_xdg_surface_v6 *surface, bool resizing) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); - surface->toplevel_state->pending.resizing = resizing; + surface->toplevel->pending.resizing = resizing; return wlr_xdg_surface_v6_schedule_configure(surface); } void wlr_xdg_toplevel_v6_send_close(struct wlr_xdg_surface_v6 *surface) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); - zxdg_toplevel_v6_send_close(surface->toplevel_state->resource); + zxdg_toplevel_v6_send_close(surface->toplevel->resource); } void wlr_xdg_surface_v6_popup_get_position(struct wlr_xdg_surface_v6 *surface, double *popup_sx, double *popup_sy) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_POPUP); - struct wlr_xdg_surface_v6 *parent = surface->popup_state->parent; - *popup_sx = parent->geometry->x + surface->popup_state->geometry.x - + struct wlr_xdg_surface_v6 *parent = surface->popup->parent; + *popup_sx = parent->geometry->x + surface->popup->geometry.x - surface->geometry->x; - *popup_sy = parent->geometry->y + surface->popup_state->geometry.y - + *popup_sy = parent->geometry->y + surface->popup->geometry.y - surface->geometry->y; } -- cgit v1.2.3 From ace738dbca9cadb9b9bc5e15aeac19131bab3998 Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 13 Mar 2018 22:17:25 +0100 Subject: xdg-shell-v6: next_geometry and geometry fields are not longer pointers in wlr_xdg_surface_v6 --- include/wlr/types/wlr_xdg_shell_v6.h | 4 +- rootston/xdg_shell_v6.c | 6 +-- types/wlr_xdg_shell_v6.c | 78 +++++++++++++----------------------- 3 files changed, 32 insertions(+), 56 deletions(-) (limited to 'rootston/xdg_shell_v6.c') diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index 2358feec..d8503d28 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -109,8 +109,8 @@ struct wlr_xdg_surface_v6 { char *app_id; bool has_next_geometry; - struct wlr_box *next_geometry; - struct wlr_box *geometry; // TODO: should not be a pointer + struct wlr_box next_geometry; + struct wlr_box geometry; struct wl_listener surface_destroy_listener; diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index 59637105..13d25331 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -60,9 +60,9 @@ static void get_size(const struct roots_view *view, struct wlr_box *box) { assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; - if (surface->geometry->width > 0 && surface->geometry->height > 0) { - box->width = surface->geometry->width; - box->height = surface->geometry->height; + if (surface->geometry.width > 0 && surface->geometry.height > 0) { + box->width = surface->geometry.width; + box->height = surface->geometry.height; } else if (view->wlr_surface != NULL) { box->width = view->wlr_surface->current->width; box->height = view->wlr_surface->current->height; diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index 214f818c..aabd9f2b 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -217,8 +217,8 @@ static void xdg_surface_unmap(struct wlr_xdg_surface_v6 *surface) { } surface->has_next_geometry = false; - memset(surface->geometry, 0, sizeof(struct wlr_box)); - memset(surface->next_geometry, 0, sizeof(struct wlr_box)); + memset(&surface->geometry, 0, sizeof(struct wlr_box)); + memset(&surface->next_geometry, 0, sizeof(struct wlr_box)); } static void xdg_surface_destroy(struct wlr_xdg_surface_v6 *surface) { @@ -232,8 +232,6 @@ static void xdg_surface_destroy(struct wlr_xdg_surface_v6 *surface) { wl_list_remove(&surface->link); wl_list_remove(&surface->surface_destroy_listener.link); wlr_surface_set_role_committed(surface->surface, NULL, NULL); - free(surface->geometry); - free(surface->next_geometry); free(surface); } @@ -945,10 +943,10 @@ static void xdg_surface_handle_set_window_geometry(struct wl_client *client, } surface->has_next_geometry = true; - surface->next_geometry->height = height; - surface->next_geometry->width = width; - surface->next_geometry->x = x; - surface->next_geometry->y = y; + surface->next_geometry.height = height; + surface->next_geometry.width = width; + surface->next_geometry.x = x; + surface->next_geometry.y = y; } static void xdg_surface_handle_destroy(struct wl_client *client, @@ -1073,11 +1071,6 @@ static void wlr_xdg_toplevel_v6_send_configure( uint32_t width = surface->toplevel->pending.width; uint32_t height = surface->toplevel->pending.height; - if (width == 0 || height == 0) { - width = surface->geometry->width; - height = surface->geometry->height; - } - zxdg_toplevel_v6_send_configure(surface->toplevel->resource, width, height, &states); @@ -1217,10 +1210,10 @@ static void handle_wlr_surface_committed(struct wlr_surface *wlr_surface, if (surface->has_next_geometry) { surface->has_next_geometry = false; - surface->geometry->x = surface->next_geometry->x; - surface->geometry->y = surface->next_geometry->y; - surface->geometry->width = surface->next_geometry->width; - surface->geometry->height = surface->next_geometry->height; + surface->geometry.x = surface->next_geometry.x; + surface->geometry.y = surface->next_geometry.y; + surface->geometry.width = surface->next_geometry.width; + surface->geometry.height = surface->next_geometry.height; } switch (surface->role) { @@ -1268,21 +1261,9 @@ static void xdg_shell_handle_get_xdg_surface(struct wl_client *wl_client, struct wlr_xdg_client_v6 *client = xdg_client_from_resource(client_resource); - struct wlr_xdg_surface_v6 *surface; - if (!(surface = calloc(1, sizeof(struct wlr_xdg_surface_v6)))) { - wl_client_post_no_memory(wl_client); - return; - } - - if (!(surface->geometry = calloc(1, sizeof(struct wlr_box)))) { - free(surface); - wl_client_post_no_memory(wl_client); - return; - } - - if (!(surface->next_geometry = calloc(1, sizeof(struct wlr_box)))) { - free(surface->geometry); - free(surface); + struct wlr_xdg_surface_v6 *surface = + calloc(1, sizeof(struct wlr_xdg_surface_v6)); + if (surface == NULL) { wl_client_post_no_memory(wl_client); return; } @@ -1294,8 +1275,6 @@ static void xdg_shell_handle_get_xdg_surface(struct wl_client *wl_client, &zxdg_surface_v6_interface, wl_resource_get_version(client_resource), id); if (surface->resource == NULL) { - free(surface->next_geometry); - free(surface->geometry); free(surface); wl_client_post_no_memory(wl_client); return; @@ -1303,8 +1282,6 @@ static void xdg_shell_handle_get_xdg_surface(struct wl_client *wl_client, if (wlr_surface_has_buffer(surface->surface)) { wl_resource_destroy(surface->resource); - free(surface->next_geometry); - free(surface->geometry); free(surface); wl_resource_post_error(surface_resource, ZXDG_SURFACE_V6_ERROR_UNCONFIGURED_BUFFER, @@ -1500,7 +1477,6 @@ uint32_t wlr_xdg_toplevel_v6_set_size(struct wlr_xdg_surface_v6 *surface, assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); surface->toplevel->pending.width = width; surface->toplevel->pending.height = height; - wlr_log(L_DEBUG, "wlr_xdg_toplevel_v6_set_size %d", width); return wlr_xdg_surface_v6_schedule_configure(surface); } @@ -1546,10 +1522,10 @@ void wlr_xdg_surface_v6_popup_get_position(struct wlr_xdg_surface_v6 *surface, double *popup_sx, double *popup_sy) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_POPUP); struct wlr_xdg_surface_v6 *parent = surface->popup->parent; - *popup_sx = parent->geometry->x + surface->popup->geometry.x - - surface->geometry->x; - *popup_sy = parent->geometry->y + surface->popup->geometry.y - - surface->geometry->y; + *popup_sx = parent->geometry.x + surface->popup->geometry.x - + surface->geometry.x; + *popup_sy = parent->geometry.y + surface->popup->geometry.y - + surface->geometry.y; } struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6_popup_at( @@ -1563,30 +1539,30 @@ struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6_popup_at( struct wlr_xdg_surface_v6 *popup = popup_state->base; double _popup_sx = - surface->geometry->x + popup_state->geometry.x; + surface->geometry.x + popup_state->geometry.x; double _popup_sy = - surface->geometry->y + popup_state->geometry.y; + surface->geometry.y + popup_state->geometry.y; int popup_width = popup_state->geometry.width; int popup_height = popup_state->geometry.height; struct wlr_xdg_surface_v6 *_popup = wlr_xdg_surface_v6_popup_at(popup, - sx - _popup_sx + popup->geometry->x, - sy - _popup_sy + popup->geometry->y, + sx - _popup_sx + popup->geometry.x, + sy - _popup_sy + popup->geometry.y, popup_sx, popup_sy); if (_popup) { - *popup_sx = *popup_sx + _popup_sx - popup->geometry->x; - *popup_sy = *popup_sy + _popup_sy - popup->geometry->y; + *popup_sx = *popup_sx + _popup_sx - popup->geometry.x; + *popup_sy = *popup_sy + _popup_sy - popup->geometry.y; return _popup; } if ((sx > _popup_sx && sx < _popup_sx + popup_width) && (sy > _popup_sy && sy < _popup_sy + popup_height)) { if (pixman_region32_contains_point(&popup->surface->current->input, - sx - _popup_sx + popup->geometry->x, - sy - _popup_sy + popup->geometry->y, NULL)) { - *popup_sx = _popup_sx - popup->geometry->x; - *popup_sy = _popup_sy - popup->geometry->y; + sx - _popup_sx + popup->geometry.x, + sy - _popup_sy + popup->geometry.y, NULL)) { + *popup_sx = _popup_sx - popup->geometry.x; + *popup_sy = _popup_sy - popup->geometry.y; return popup; } } -- cgit v1.2.3