aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Primak <vyivel@eclair.cafe>2023-03-04 22:14:50 +0300
committerIsaac Freund <mail@isaacfreund.com>2023-06-02 17:26:18 +0000
commitb0437fc416e2938f49449c3d9cb1a8107544c335 (patch)
tree4cdf8d042e06d19be6f387f552863c019549fecc
parentc590bb600f9caf60a48263b0559c75f1515b1769 (diff)
xdg-shell: use unified map logic
-rw-r--r--include/types/wlr_xdg_shell.h3
-rw-r--r--include/wlr/types/wlr_xdg_shell.h18
-rw-r--r--tinywl/tinywl.c4
-rw-r--r--types/scene/xdg_shell.c9
-rw-r--r--types/wlr_layer_shell_v1.c6
-rw-r--r--types/wlr_xdg_foreign_v1.c2
-rw-r--r--types/wlr_xdg_foreign_v2.c2
-rw-r--r--types/xdg_shell/wlr_xdg_popup.c2
-rw-r--r--types/xdg_shell/wlr_xdg_surface.c36
-rw-r--r--types/xdg_shell/wlr_xdg_toplevel.c6
10 files changed, 28 insertions, 60 deletions
diff --git a/include/types/wlr_xdg_shell.h b/include/types/wlr_xdg_shell.h
index eb619fba..0386388b 100644
--- a/include/types/wlr_xdg_shell.h
+++ b/include/types/wlr_xdg_shell.h
@@ -14,8 +14,7 @@ struct wlr_xdg_surface *create_xdg_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);
+void xdg_surface_role_unmap(struct wlr_surface *wlr_surface);
void xdg_surface_role_destroy(struct wlr_surface *wlr_surface);
void create_xdg_positioner(struct wlr_xdg_client *client, uint32_t id);
diff --git a/include/wlr/types/wlr_xdg_shell.h b/include/wlr/types/wlr_xdg_shell.h
index d1072d0d..7678a168 100644
--- a/include/wlr/types/wlr_xdg_shell.h
+++ b/include/wlr/types/wlr_xdg_shell.h
@@ -251,7 +251,7 @@ struct wlr_xdg_surface {
struct wl_list popups; // wlr_xdg_popup.link
- bool added, configured, mapped;
+ bool added, configured;
struct wl_event_source *configure_idle;
uint32_t scheduled_serial;
struct wl_list configure_list;
@@ -264,22 +264,6 @@ struct wlr_xdg_surface {
struct wl_signal destroy;
struct wl_signal ping_timeout;
struct wl_signal new_popup;
- /**
- * The `map` event signals that the shell surface is ready to be
- * managed by the compositor and rendered on the screen. At this point,
- * the surface has configured its properties, has had the opportunity
- * to bind to the seat to receive input events, and has a buffer that
- * is ready to be rendered. You can now safely add this surface to a
- * list of views.
- */
- struct wl_signal map;
- /**
- * The `unmap` event signals that the surface is no longer in a state
- * where it should be shown on the screen. This might happen if the
- * surface no longer has a displayable buffer because either the
- * surface has been hidden or is about to be destroyed.
- */
- struct wl_signal unmap;
// for protocol extensions
struct wl_signal configure; // struct wlr_xdg_surface_configure
diff --git a/tinywl/tinywl.c b/tinywl/tinywl.c
index 835be217..77502b3f 100644
--- a/tinywl/tinywl.c
+++ b/tinywl/tinywl.c
@@ -795,9 +795,9 @@ static void server_new_xdg_surface(struct wl_listener *listener, void *data) {
/* Listen to the various events it can emit */
view->map.notify = xdg_toplevel_map;
- wl_signal_add(&xdg_surface->events.map, &view->map);
+ wl_signal_add(&xdg_surface->surface->events.map, &view->map);
view->unmap.notify = xdg_toplevel_unmap;
- wl_signal_add(&xdg_surface->events.unmap, &view->unmap);
+ wl_signal_add(&xdg_surface->surface->events.unmap, &view->unmap);
view->destroy.notify = xdg_toplevel_destroy;
wl_signal_add(&xdg_surface->events.destroy, &view->destroy);
diff --git a/types/scene/xdg_shell.c b/types/scene/xdg_shell.c
index 16883488..eba33c86 100644
--- a/types/scene/xdg_shell.c
+++ b/types/scene/xdg_shell.c
@@ -106,18 +106,21 @@ struct wlr_scene_tree *wlr_scene_xdg_surface_create(
scene_xdg_surface->xdg_surface_map.notify =
scene_xdg_surface_handle_xdg_surface_map;
- wl_signal_add(&xdg_surface->events.map, &scene_xdg_surface->xdg_surface_map);
+ wl_signal_add(&xdg_surface->surface->events.map,
+ &scene_xdg_surface->xdg_surface_map);
scene_xdg_surface->xdg_surface_unmap.notify =
scene_xdg_surface_handle_xdg_surface_unmap;
- wl_signal_add(&xdg_surface->events.unmap, &scene_xdg_surface->xdg_surface_unmap);
+ wl_signal_add(&xdg_surface->surface->events.unmap,
+ &scene_xdg_surface->xdg_surface_unmap);
scene_xdg_surface->xdg_surface_commit.notify =
scene_xdg_surface_handle_xdg_surface_commit;
wl_signal_add(&xdg_surface->surface->events.commit,
&scene_xdg_surface->xdg_surface_commit);
- wlr_scene_node_set_enabled(&scene_xdg_surface->tree->node, xdg_surface->mapped);
+ wlr_scene_node_set_enabled(&scene_xdg_surface->tree->node,
+ xdg_surface->surface->mapped);
scene_xdg_surface_update_position(scene_xdg_surface);
return scene_xdg_surface->tree;
diff --git a/types/wlr_layer_shell_v1.c b/types/wlr_layer_shell_v1.c
index cc1ea8fe..359bcc6a 100644
--- a/types/wlr_layer_shell_v1.c
+++ b/types/wlr_layer_shell_v1.c
@@ -544,10 +544,10 @@ void wlr_layer_surface_v1_for_each_surface(struct wlr_layer_surface_v1 *surface,
}
void wlr_layer_surface_v1_for_each_popup_surface(struct wlr_layer_surface_v1 *surface,
- wlr_surface_iterator_func_t iterator, void *user_data){
+ wlr_surface_iterator_func_t iterator, void *user_data) {
struct wlr_xdg_popup *popup;
wl_list_for_each(popup, &surface->popups, link) {
- if (!popup->base->configured || !popup->base->mapped) {
+ if (!popup->base->surface->mapped) {
continue;
}
@@ -582,7 +582,7 @@ struct wlr_surface *wlr_layer_surface_v1_popup_surface_at(
double *sub_x, double *sub_y) {
struct wlr_xdg_popup *popup;
wl_list_for_each(popup, &surface->popups, link) {
- if (!popup->base->mapped) {
+ if (!popup->base->surface->mapped) {
continue;
}
diff --git a/types/wlr_xdg_foreign_v1.c b/types/wlr_xdg_foreign_v1.c
index a2d5c792..0e898d07 100644
--- a/types/wlr_xdg_foreign_v1.c
+++ b/types/wlr_xdg_foreign_v1.c
@@ -80,7 +80,7 @@ static void xdg_imported_handle_set_parent_of(struct wl_client *client,
struct wlr_xdg_surface *surface =
wlr_xdg_surface_try_from_wlr_surface(wlr_surface);
- if (!surface->mapped) {
+ if (!surface->surface->mapped) {
wlr_xdg_toplevel_set_parent(child_toplevel, NULL);
return;
}
diff --git a/types/wlr_xdg_foreign_v2.c b/types/wlr_xdg_foreign_v2.c
index 11cc03f7..d9c15eb7 100644
--- a/types/wlr_xdg_foreign_v2.c
+++ b/types/wlr_xdg_foreign_v2.c
@@ -83,7 +83,7 @@ static void xdg_imported_handle_set_parent_of(struct wl_client *client,
return;
}
- if (!surface->mapped) {
+ if (!surface->surface->mapped) {
wlr_xdg_toplevel_set_parent(child_toplevel, NULL);
return;
}
diff --git a/types/xdg_shell/wlr_xdg_popup.c b/types/xdg_shell/wlr_xdg_popup.c
index 14c5c505..f3e64110 100644
--- a/types/xdg_shell/wlr_xdg_popup.c
+++ b/types/xdg_shell/wlr_xdg_popup.c
@@ -360,7 +360,7 @@ static void xdg_popup_handle_resource_destroy(struct wl_resource *resource) {
const struct wlr_surface_role xdg_popup_surface_role = {
.name = "xdg_popup",
.commit = xdg_surface_role_commit,
- .precommit = xdg_surface_role_precommit,
+ .unmap = xdg_surface_role_unmap,
.destroy = xdg_surface_role_destroy,
};
diff --git a/types/xdg_shell/wlr_xdg_surface.c b/types/xdg_shell/wlr_xdg_surface.c
index 14fc92d3..ebe8dcd5 100644
--- a/types/xdg_shell/wlr_xdg_surface.c
+++ b/types/xdg_shell/wlr_xdg_surface.c
@@ -54,15 +54,6 @@ static void reset_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);
@@ -306,24 +297,17 @@ void xdg_surface_role_commit(struct wlr_surface *wlr_surface) {
wl_signal_emit_mutable(&surface->client->shell->events.new_surface,
surface);
}
- if (surface->configured && wlr_surface_has_buffer(surface->surface) &&
- !surface->mapped) {
- surface->mapped = true;
- wl_signal_emit_mutable(&surface->events.map, NULL);
+
+ if (surface->configured && wlr_surface_has_buffer(wlr_surface)) {
+ wlr_surface_map(wlr_surface);
}
}
-void xdg_surface_role_precommit(struct wlr_surface *wlr_surface,
- const struct wlr_surface_state *state) {
+void xdg_surface_role_unmap(struct wlr_surface *wlr_surface) {
struct wlr_xdg_surface *surface = wlr_xdg_surface_try_from_wlr_surface(wlr_surface);
assert(surface != NULL);
- if (state->committed & WLR_SURFACE_STATE_BUFFER && state->buffer == NULL) {
- // This is a NULL commit
- if (surface->configured && surface->mapped) {
- unmap_xdg_surface(surface);
- }
- }
+ reset_xdg_surface(surface);
}
void xdg_surface_role_destroy(struct wlr_surface *wlr_surface) {
@@ -376,8 +360,6 @@ struct wlr_xdg_surface *create_xdg_surface(
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_init(&surface->events.configure);
wl_signal_init(&surface->events.ack_configure);
@@ -396,8 +378,8 @@ struct wlr_xdg_surface *create_xdg_surface(
}
void destroy_xdg_surface_role_object(struct wlr_xdg_surface *surface) {
- if (surface->configured && surface->mapped) {
- unmap_xdg_surface(surface);
+ if (surface->surface->mapped) {
+ wlr_surface_unmap(surface->surface);
} else {
reset_xdg_surface(surface);
}
@@ -473,7 +455,7 @@ struct wlr_surface *wlr_xdg_surface_popup_surface_at(
double *sub_x, double *sub_y) {
struct wlr_xdg_popup *popup;
wl_list_for_each(popup, &surface->popups, link) {
- if (!popup->base->mapped) {
+ if (!popup->base->surface->mapped) {
continue;
}
@@ -508,7 +490,7 @@ static void xdg_surface_for_each_popup_surface(struct wlr_xdg_surface *surface,
int x, int y, wlr_surface_iterator_func_t iterator, void *user_data) {
struct wlr_xdg_popup *popup;
wl_list_for_each(popup, &surface->popups, link) {
- if (!popup->base->configured || !popup->base->mapped) {
+ if (!popup->base->surface->mapped) {
continue;
}
diff --git a/types/xdg_shell/wlr_xdg_toplevel.c b/types/xdg_shell/wlr_xdg_toplevel.c
index 112cbdd6..7e6ff606 100644
--- a/types/xdg_shell/wlr_xdg_toplevel.c
+++ b/types/xdg_shell/wlr_xdg_toplevel.c
@@ -182,10 +182,10 @@ bool wlr_xdg_toplevel_set_parent(struct wlr_xdg_toplevel *toplevel,
wl_list_remove(&toplevel->parent_unmap.link);
}
- if (parent != NULL && parent->base->mapped) {
+ if (parent != NULL && parent->base->surface->mapped) {
toplevel->parent = parent;
toplevel->parent_unmap.notify = handle_parent_unmap;
- wl_signal_add(&toplevel->parent->base->events.unmap,
+ wl_signal_add(&toplevel->parent->base->surface->events.unmap,
&toplevel->parent_unmap);
} else {
toplevel->parent = NULL;
@@ -475,7 +475,7 @@ static void xdg_toplevel_handle_resource_destroy(struct wl_resource *resource) {
const struct wlr_surface_role xdg_toplevel_surface_role = {
.name = "xdg_toplevel",
.commit = xdg_surface_role_commit,
- .precommit = xdg_surface_role_precommit,
+ .unmap = xdg_surface_role_unmap,
.destroy = xdg_surface_role_destroy,
};