aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Primak <vyivel@posteo.net>2021-09-20 17:09:38 +0300
committerSimon Ser <contact@emersion.fr>2021-09-21 10:09:09 +0200
commit0e2d36910612b849ca9c4868910b308c4bf49213 (patch)
tree6dcf5970c2f5ea16e19fb9f67a6822896cbf0107
parentb72a217fcc9f8bb47788c2068093579ac893301c (diff)
xdg-surface: simplify configure mechanism
This commit removes any checks whether a configure will change anything and makes configures be sent unconditionally. Additionally, configures are scheduled on xdg_toplevel.{un,}set_{maximized,fullscreen} events.
-rw-r--r--include/types/wlr_xdg_shell.h2
-rw-r--r--types/xdg_shell/wlr_xdg_popup.c2
-rw-r--r--types/xdg_shell/wlr_xdg_surface.c43
-rw-r--r--types/xdg_shell/wlr_xdg_toplevel.c71
4 files changed, 15 insertions, 103 deletions
diff --git a/include/types/wlr_xdg_shell.h b/include/types/wlr_xdg_shell.h
index 2afd564e..509b1d2c 100644
--- a/include/types/wlr_xdg_shell.h
+++ b/include/types/wlr_xdg_shell.h
@@ -13,7 +13,6 @@ struct wlr_xdg_positioner_resource {
extern const struct wlr_surface_role xdg_toplevel_surface_role;
extern const struct wlr_surface_role xdg_popup_surface_role;
-uint32_t schedule_xdg_surface_configure(struct wlr_xdg_surface *surface);
struct wlr_xdg_surface *create_xdg_surface(
struct wlr_xdg_client *client, struct wlr_surface *surface,
uint32_t id);
@@ -41,7 +40,6 @@ void send_xdg_toplevel_configure(struct wlr_xdg_surface *surface,
struct wlr_xdg_surface_configure *configure);
void handle_xdg_toplevel_ack_configure(struct wlr_xdg_surface *surface,
struct wlr_xdg_surface_configure *configure);
-bool compare_xdg_surface_toplevel_state(struct wlr_xdg_toplevel *state);
void destroy_xdg_toplevel(struct wlr_xdg_surface *surface);
#endif
diff --git a/types/xdg_shell/wlr_xdg_popup.c b/types/xdg_shell/wlr_xdg_popup.c
index 33f1c20f..9e5c2ced 100644
--- a/types/xdg_shell/wlr_xdg_popup.c
+++ b/types/xdg_shell/wlr_xdg_popup.c
@@ -207,7 +207,7 @@ void handle_xdg_surface_popup_committed(struct wlr_xdg_surface *surface) {
}
if (!surface->popup->committed) {
- schedule_xdg_surface_configure(surface);
+ wlr_xdg_surface_schedule_configure(surface);
surface->popup->committed = true;
}
}
diff --git a/types/xdg_shell/wlr_xdg_surface.c b/types/xdg_shell/wlr_xdg_surface.c
index 8819fd15..bd59a549 100644
--- a/types/xdg_shell/wlr_xdg_surface.c
+++ b/types/xdg_shell/wlr_xdg_surface.c
@@ -187,53 +187,16 @@ static void surface_send_configure(void *user_data) {
xdg_surface_send_configure(surface->resource, configure->serial);
}
-static uint32_t schedule_configure(struct wlr_xdg_surface *surface,
- bool pending_same) {
+uint32_t wlr_xdg_surface_schedule_configure(struct wlr_xdg_surface *surface) {
struct wl_display *display = wl_client_get_display(surface->client->client);
struct wl_event_loop *loop = wl_display_get_event_loop(display);
- if (surface->configure_idle != NULL) {
- if (!pending_same) {
- // configure request already scheduled
- return surface->configure_next_serial;
- }
-
- // configure request not necessary anymore
- wl_event_source_remove(surface->configure_idle);
- surface->configure_idle = NULL;
- return 0;
- } else {
- if (pending_same) {
- // configure request not necessary
- return 0;
- }
-
+ if (surface->configure_idle == NULL) {
surface->configure_next_serial = wl_display_next_serial(display);
surface->configure_idle = wl_event_loop_add_idle(loop,
surface_send_configure, surface);
- return surface->configure_next_serial;
}
-}
-
-uint32_t schedule_xdg_surface_configure(struct wlr_xdg_surface *surface) {
- bool pending_same = false;
-
- switch (surface->role) {
- case WLR_XDG_SURFACE_ROLE_NONE:
- assert(0 && "not reached");
- break;
- case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
- pending_same = compare_xdg_surface_toplevel_state(surface->toplevel);
- break;
- case WLR_XDG_SURFACE_ROLE_POPUP:
- break;
- }
-
- return schedule_configure(surface, pending_same);
-}
-
-uint32_t wlr_xdg_surface_schedule_configure(struct wlr_xdg_surface *surface) {
- return schedule_configure(surface, false);
+ return surface->configure_next_serial;
}
static void xdg_surface_handle_get_popup(struct wl_client *client,
diff --git a/types/xdg_shell/wlr_xdg_toplevel.c b/types/xdg_shell/wlr_xdg_toplevel.c
index d94b92e5..b5a7239b 100644
--- a/types/xdg_shell/wlr_xdg_toplevel.c
+++ b/types/xdg_shell/wlr_xdg_toplevel.c
@@ -25,59 +25,6 @@ void handle_xdg_toplevel_ack_configure(
surface->toplevel->pending.height = acked->height;
}
-bool compare_xdg_surface_toplevel_state(struct wlr_xdg_toplevel *toplevel) {
- // Is the scheduled configure different from the last sent one?
- if (!toplevel->base->configured) {
- return false;
- }
-
- struct wlr_xdg_toplevel_configure last_acked;
- struct wlr_xdg_toplevel_configure *configure = NULL;
- if (wl_list_empty(&toplevel->base->configure_list)) {
- // There are currently no pending configures, so check against the last
- // state acked by the client.
- last_acked.maximized = toplevel->pending.maximized;
- last_acked.fullscreen = toplevel->pending.fullscreen;
- last_acked.resizing = toplevel->pending.resizing;
- last_acked.activated = toplevel->pending.activated;
- last_acked.tiled = toplevel->pending.tiled;
- last_acked.width = toplevel->pending.width;
- last_acked.height = toplevel->pending.height;
- configure = &last_acked;
- } else {
- struct wlr_xdg_surface_configure *surface_configure =
- wl_container_of(toplevel->base->configure_list.prev, surface_configure, link);
- configure = surface_configure->toplevel_configure;
- }
-
- if (toplevel->scheduled.activated != configure->activated) {
- return false;
- }
- if (toplevel->scheduled.fullscreen != configure->fullscreen) {
- return false;
- }
- if (toplevel->scheduled.maximized != configure->maximized) {
- return false;
- }
- if (toplevel->scheduled.resizing != configure->resizing) {
- return false;
- }
- if (toplevel->scheduled.tiled != configure->tiled) {
- return false;
- }
-
- if (toplevel->scheduled.width == configure->width &&
- toplevel->scheduled.height == configure->height) {
- return true;
- }
-
- if (toplevel->scheduled.width == 0 && toplevel->scheduled.height == 0) {
- return true;
- }
-
- return false;
-}
-
void send_xdg_toplevel_configure(struct wlr_xdg_surface *surface,
struct wlr_xdg_surface_configure *configure) {
assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL);
@@ -183,7 +130,7 @@ void handle_xdg_surface_toplevel_committed(struct wlr_xdg_surface *surface) {
if (!surface->toplevel->added) {
// on the first commit, send a configure request to tell the client it
// is added
- schedule_xdg_surface_configure(surface);
+ wlr_xdg_surface_schedule_configure(surface);
surface->toplevel->added = true;
return;
}
@@ -383,6 +330,7 @@ static void xdg_toplevel_handle_set_maximized(struct wl_client *client,
wlr_xdg_surface_from_toplevel_resource(resource);
surface->toplevel->requested.maximized = true;
wlr_signal_emit_safe(&surface->toplevel->events.request_maximize, surface);
+ wlr_xdg_surface_schedule_configure(surface);
}
static void xdg_toplevel_handle_unset_maximized(struct wl_client *client,
@@ -391,6 +339,7 @@ static void xdg_toplevel_handle_unset_maximized(struct wl_client *client,
wlr_xdg_surface_from_toplevel_resource(resource);
surface->toplevel->requested.maximized = false;
wlr_signal_emit_safe(&surface->toplevel->events.request_maximize, surface);
+ wlr_xdg_surface_schedule_configure(surface);
}
static void handle_fullscreen_output_destroy(struct wl_listener *listener,
@@ -436,6 +385,7 @@ static void xdg_toplevel_handle_set_fullscreen(struct wl_client *client,
};
wlr_signal_emit_safe(&surface->toplevel->events.request_fullscreen, &event);
+ wlr_xdg_surface_schedule_configure(surface);
}
static void xdg_toplevel_handle_unset_fullscreen(struct wl_client *client,
@@ -452,6 +402,7 @@ static void xdg_toplevel_handle_unset_fullscreen(struct wl_client *client,
};
wlr_signal_emit_safe(&surface->toplevel->events.request_fullscreen, &event);
+ wlr_xdg_surface_schedule_configure(surface);
}
static void xdg_toplevel_handle_set_minimized(struct wl_client *client,
@@ -557,7 +508,7 @@ uint32_t wlr_xdg_toplevel_set_size(struct wlr_xdg_surface *surface,
surface->toplevel->scheduled.width = width;
surface->toplevel->scheduled.height = height;
- return schedule_xdg_surface_configure(surface);
+ return wlr_xdg_surface_schedule_configure(surface);
}
uint32_t wlr_xdg_toplevel_set_activated(struct wlr_xdg_surface *surface,
@@ -565,7 +516,7 @@ uint32_t wlr_xdg_toplevel_set_activated(struct wlr_xdg_surface *surface,
assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL);
surface->toplevel->scheduled.activated = activated;
- return schedule_xdg_surface_configure(surface);
+ return wlr_xdg_surface_schedule_configure(surface);
}
uint32_t wlr_xdg_toplevel_set_maximized(struct wlr_xdg_surface *surface,
@@ -573,7 +524,7 @@ uint32_t wlr_xdg_toplevel_set_maximized(struct wlr_xdg_surface *surface,
assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL);
surface->toplevel->scheduled.maximized = maximized;
- return schedule_xdg_surface_configure(surface);
+ return wlr_xdg_surface_schedule_configure(surface);
}
uint32_t wlr_xdg_toplevel_set_fullscreen(struct wlr_xdg_surface *surface,
@@ -581,7 +532,7 @@ uint32_t wlr_xdg_toplevel_set_fullscreen(struct wlr_xdg_surface *surface,
assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL);
surface->toplevel->scheduled.fullscreen = fullscreen;
- return schedule_xdg_surface_configure(surface);
+ return wlr_xdg_surface_schedule_configure(surface);
}
uint32_t wlr_xdg_toplevel_set_resizing(struct wlr_xdg_surface *surface,
@@ -589,7 +540,7 @@ uint32_t wlr_xdg_toplevel_set_resizing(struct wlr_xdg_surface *surface,
assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL);
surface->toplevel->scheduled.resizing = resizing;
- return schedule_xdg_surface_configure(surface);
+ return wlr_xdg_surface_schedule_configure(surface);
}
uint32_t wlr_xdg_toplevel_set_tiled(struct wlr_xdg_surface *surface,
@@ -597,5 +548,5 @@ uint32_t wlr_xdg_toplevel_set_tiled(struct wlr_xdg_surface *surface,
assert(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL);
surface->toplevel->scheduled.tiled = tiled;
- return schedule_xdg_surface_configure(surface);
+ return wlr_xdg_surface_schedule_configure(surface);
}