aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/types/wlr_xdg_shell.h7
-rw-r--r--types/xdg_shell/wlr_xdg_popup.c4
-rw-r--r--types/xdg_shell/wlr_xdg_surface.c32
-rw-r--r--types/xdg_shell/wlr_xdg_toplevel.c4
4 files changed, 25 insertions, 22 deletions
diff --git a/include/types/wlr_xdg_shell.h b/include/types/wlr_xdg_shell.h
index ddff7b6f..eb619fba 100644
--- a/include/types/wlr_xdg_shell.h
+++ b/include/types/wlr_xdg_shell.h
@@ -11,9 +11,8 @@ extern const struct wlr_surface_role xdg_popup_surface_role;
struct wlr_xdg_surface *create_xdg_surface(
struct wlr_xdg_client *client, struct wlr_surface *wlr_surface,
uint32_t id);
-void unmap_xdg_surface(struct wlr_xdg_surface *surface);
-void reset_xdg_surface(struct wlr_xdg_surface *surface);
void destroy_xdg_surface(struct wlr_xdg_surface *surface);
+void destroy_xdg_surface_role_object(struct wlr_xdg_surface *surface);
void xdg_surface_role_commit(struct wlr_surface *wlr_surface);
void xdg_surface_role_precommit(struct wlr_surface *wlr_surface,
const struct wlr_surface_state *state);
@@ -24,7 +23,7 @@ void create_xdg_positioner(struct wlr_xdg_client *client, uint32_t id);
void create_xdg_popup(struct wlr_xdg_surface *surface,
struct wlr_xdg_surface *parent,
struct wlr_xdg_positioner *positioner, uint32_t id);
-void unmap_xdg_popup(struct wlr_xdg_popup *popup);
+void reset_xdg_popup(struct wlr_xdg_popup *popup);
void destroy_xdg_popup(struct wlr_xdg_popup *popup);
void handle_xdg_popup_committed(struct wlr_xdg_popup *popup);
struct wlr_xdg_popup_configure *send_xdg_popup_configure(
@@ -34,7 +33,7 @@ void handle_xdg_popup_ack_configure(struct wlr_xdg_popup *popup,
void create_xdg_toplevel(struct wlr_xdg_surface *surface,
uint32_t id);
-void unmap_xdg_toplevel(struct wlr_xdg_toplevel *toplevel);
+void reset_xdg_toplevel(struct wlr_xdg_toplevel *toplevel);
void destroy_xdg_toplevel(struct wlr_xdg_toplevel *toplevel);
void handle_xdg_toplevel_committed(struct wlr_xdg_toplevel *toplevel);
struct wlr_xdg_toplevel_configure *send_xdg_toplevel_configure(
diff --git a/types/xdg_shell/wlr_xdg_popup.c b/types/xdg_shell/wlr_xdg_popup.c
index 33eba859..14c5c505 100644
--- a/types/xdg_shell/wlr_xdg_popup.c
+++ b/types/xdg_shell/wlr_xdg_popup.c
@@ -425,7 +425,7 @@ void create_xdg_popup(struct wlr_xdg_surface *surface,
}
}
-void unmap_xdg_popup(struct wlr_xdg_popup *popup) {
+void reset_xdg_popup(struct wlr_xdg_popup *popup) {
if (popup->seat != NULL) {
struct wlr_xdg_popup_grab *grab =
get_xdg_shell_popup_grab_from_seat(
@@ -471,7 +471,7 @@ void wlr_xdg_popup_destroy(struct wlr_xdg_popup *popup) {
xdg_popup_send_popup_done(popup->resource);
wl_resource_set_user_data(popup->resource, NULL);
- reset_xdg_surface(popup->base);
+ destroy_xdg_surface_role_object(popup->base);
}
void wlr_xdg_popup_get_toplevel_coords(struct wlr_xdg_popup *popup,
diff --git a/types/xdg_shell/wlr_xdg_surface.c b/types/xdg_shell/wlr_xdg_surface.c
index 9f696868..14fc92d3 100644
--- a/types/xdg_shell/wlr_xdg_surface.c
+++ b/types/xdg_shell/wlr_xdg_surface.c
@@ -24,16 +24,9 @@ static void xdg_surface_configure_destroy(
free(configure);
}
-void unmap_xdg_surface(struct wlr_xdg_surface *surface) {
- assert(surface->role != WLR_XDG_SURFACE_ROLE_NONE);
+static void reset_xdg_surface(struct wlr_xdg_surface *surface) {
surface->configured = false;
- // TODO: probably need to ungrab before this event
- if (surface->mapped) {
- surface->mapped = false;
- wl_signal_emit_mutable(&surface->events.unmap, NULL);
- }
-
struct wlr_xdg_popup *popup, *popup_tmp;
wl_list_for_each_safe(popup, popup_tmp, &surface->popups, link) {
wlr_xdg_popup_destroy(popup);
@@ -41,13 +34,13 @@ void unmap_xdg_surface(struct wlr_xdg_surface *surface) {
switch (surface->role) {
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
- unmap_xdg_toplevel(surface->toplevel);
+ reset_xdg_toplevel(surface->toplevel);
break;
case WLR_XDG_SURFACE_ROLE_POPUP:
- unmap_xdg_popup(surface->popup);
+ reset_xdg_popup(surface->popup);
break;
case WLR_XDG_SURFACE_ROLE_NONE:
- assert(false && "not reached");
+ break;
}
struct wlr_xdg_surface_configure *configure, *tmp;
@@ -61,6 +54,15 @@ void unmap_xdg_surface(struct wlr_xdg_surface *surface) {
}
}
+static void unmap_xdg_surface(struct wlr_xdg_surface *surface) {
+ surface->mapped = false;
+
+ // TODO: probably need to ungrab before this event
+ wl_signal_emit_mutable(&surface->events.unmap, NULL);
+
+ reset_xdg_surface(surface);
+}
+
static void xdg_surface_handle_ack_configure(struct wl_client *client,
struct wl_resource *resource, uint32_t serial) {
struct wlr_xdg_surface *surface = wlr_xdg_surface_from_resource(resource);
@@ -328,7 +330,7 @@ void xdg_surface_role_destroy(struct wlr_surface *wlr_surface) {
struct wlr_xdg_surface *surface = wlr_xdg_surface_try_from_wlr_surface(wlr_surface);
assert(surface != NULL);
- reset_xdg_surface(surface);
+ destroy_xdg_surface_role_object(surface);
wl_list_remove(&surface->link);
wl_list_remove(&surface->surface_commit.link);
@@ -393,9 +395,11 @@ struct wlr_xdg_surface *create_xdg_surface(
return surface;
}
-void reset_xdg_surface(struct wlr_xdg_surface *surface) {
- if (surface->role != WLR_XDG_SURFACE_ROLE_NONE) {
+void destroy_xdg_surface_role_object(struct wlr_xdg_surface *surface) {
+ if (surface->configured && surface->mapped) {
unmap_xdg_surface(surface);
+ } else {
+ reset_xdg_surface(surface);
}
if (surface->added) {
diff --git a/types/xdg_shell/wlr_xdg_toplevel.c b/types/xdg_shell/wlr_xdg_toplevel.c
index 526f4833..112cbdd6 100644
--- a/types/xdg_shell/wlr_xdg_toplevel.c
+++ b/types/xdg_shell/wlr_xdg_toplevel.c
@@ -469,7 +469,7 @@ static void xdg_toplevel_handle_resource_destroy(struct wl_resource *resource) {
if (toplevel == NULL) {
return;
}
- reset_xdg_surface(toplevel->base);
+ destroy_xdg_surface_role_object(toplevel->base);
}
const struct wlr_surface_role xdg_toplevel_surface_role = {
@@ -527,7 +527,7 @@ void create_xdg_toplevel(struct wlr_xdg_surface *surface,
surface->role = WLR_XDG_SURFACE_ROLE_TOPLEVEL;
}
-void unmap_xdg_toplevel(struct wlr_xdg_toplevel *toplevel) {
+void reset_xdg_toplevel(struct wlr_xdg_toplevel *toplevel) {
if (toplevel->parent) {
wl_list_remove(&toplevel->parent_unmap.link);
toplevel->parent = NULL;