aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/wlr/types/wlr_xdg_decoration_v1.h12
-rw-r--r--types/wlr_xdg_decoration_v1.c29
2 files changed, 21 insertions, 20 deletions
diff --git a/include/wlr/types/wlr_xdg_decoration_v1.h b/include/wlr/types/wlr_xdg_decoration_v1.h
index eafa05cc..b3651559 100644
--- a/include/wlr/types/wlr_xdg_decoration_v1.h
+++ b/include/wlr/types/wlr_xdg_decoration_v1.h
@@ -30,16 +30,22 @@ struct wlr_xdg_toplevel_decoration_v1_configure {
enum wlr_xdg_toplevel_decoration_v1_mode mode;
};
+struct wlr_xdg_toplevel_decoration_v1_state {
+ enum wlr_xdg_toplevel_decoration_v1_mode mode;
+};
+
struct wlr_xdg_toplevel_decoration_v1 {
struct wl_resource *resource;
struct wlr_xdg_surface *surface;
struct wlr_xdg_decoration_manager_v1 *manager;
struct wl_list link; // wlr_xdg_decoration_manager_v1::link
+ struct wlr_xdg_toplevel_decoration_v1_state current, pending;
+
+ enum wlr_xdg_toplevel_decoration_v1_mode scheduled_mode;
+ enum wlr_xdg_toplevel_decoration_v1_mode requested_mode;
+
bool added;
- enum wlr_xdg_toplevel_decoration_v1_mode current_mode;
- enum wlr_xdg_toplevel_decoration_v1_mode client_pending_mode;
- enum wlr_xdg_toplevel_decoration_v1_mode server_pending_mode;
struct wl_list configure_list; // wlr_xdg_toplevel_decoration_v1_configure::link
diff --git a/types/wlr_xdg_decoration_v1.c b/types/wlr_xdg_decoration_v1.c
index 544035b7..b6dd003e 100644
--- a/types/wlr_xdg_decoration_v1.c
+++ b/types/wlr_xdg_decoration_v1.c
@@ -29,7 +29,7 @@ static void toplevel_decoration_handle_set_mode(struct wl_client *client,
struct wlr_xdg_toplevel_decoration_v1 *decoration =
toplevel_decoration_from_resource(resource);
- decoration->client_pending_mode =
+ decoration->requested_mode =
(enum wlr_xdg_toplevel_decoration_v1_mode)mode;
wlr_signal_emit_safe(&decoration->events.request_mode, decoration);
}
@@ -39,7 +39,7 @@ static void toplevel_decoration_handle_unset_mode(struct wl_client *client,
struct wlr_xdg_toplevel_decoration_v1 *decoration =
toplevel_decoration_from_resource(resource);
- decoration->client_pending_mode = WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_NONE;
+ decoration->requested_mode = WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_NONE;
wlr_signal_emit_safe(&decoration->events.request_mode, decoration);
}
@@ -54,7 +54,7 @@ uint32_t wlr_xdg_toplevel_decoration_v1_set_mode(
struct wlr_xdg_toplevel_decoration_v1 *decoration,
enum wlr_xdg_toplevel_decoration_v1_mode mode) {
assert(mode != WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_NONE);
- decoration->server_pending_mode = mode;
+ decoration->scheduled_mode = mode;
return wlr_xdg_surface_schedule_configure(decoration->surface);
}
@@ -88,7 +88,7 @@ static void toplevel_decoration_handle_surface_configure(
wl_container_of(listener, decoration, surface_configure);
struct wlr_xdg_surface_configure *surface_configure = data;
- if (decoration->current_mode == decoration->server_pending_mode) {
+ if (decoration->pending.mode == decoration->scheduled_mode) {
return;
}
@@ -98,7 +98,7 @@ static void toplevel_decoration_handle_surface_configure(
return;
}
configure->surface_configure = surface_configure;
- configure->mode = decoration->server_pending_mode;
+ configure->mode = decoration->scheduled_mode;
wl_list_insert(decoration->configure_list.prev, &configure->link);
zxdg_toplevel_decoration_v1_send_configure(decoration->resource,
@@ -132,7 +132,7 @@ static void toplevel_decoration_handle_surface_ack_configure(
free(configure);
}
- decoration->current_mode = configure->mode;
+ decoration->pending.mode = configure->mode;
wl_list_remove(&configure->link);
free(configure);
@@ -144,17 +144,15 @@ static void toplevel_decoration_handle_surface_commit(
wl_container_of(listener, decoration, surface_commit);
struct wlr_xdg_decoration_manager_v1 *manager = decoration->manager;
- if (decoration->surface->added) {
- wl_list_remove(&decoration->surface_commit.link);
- wl_list_init(&decoration->surface_commit.link);
+ decoration->current = decoration->pending;
+ if (decoration->surface->added && !decoration->added) {
decoration->added = true;
wlr_signal_emit_safe(&manager->events.new_toplevel_decoration,
decoration);
}
}
-
static const struct zxdg_decoration_manager_v1_interface decoration_manager_impl;
static struct wlr_xdg_decoration_manager_v1 *
@@ -224,7 +222,10 @@ static void decoration_manager_handle_get_toplevel_decoration(
&decoration->surface_ack_configure);
decoration->surface_ack_configure.notify =
toplevel_decoration_handle_surface_ack_configure;
- wl_list_init(&decoration->surface_commit.link);
+ wl_signal_add(&surface->surface->events.commit,
+ &decoration->surface_commit);
+ decoration->surface_commit.notify =
+ toplevel_decoration_handle_surface_commit;
wl_list_insert(&manager->decorations, &decoration->link);
@@ -232,12 +233,6 @@ static void decoration_manager_handle_get_toplevel_decoration(
decoration->added = true;
wlr_signal_emit_safe(&manager->events.new_toplevel_decoration,
decoration);
- } else {
- wl_list_remove(&decoration->surface_commit.link);
- wl_signal_add(&surface->surface->events.commit,
- &decoration->surface_commit);
- decoration->surface_commit.notify =
- toplevel_decoration_handle_surface_commit;
}
}