src/output.c: Always react to new output configuration

Without this fix we will never react to output configuration changes
via wlr-randr and friends.

If output_config_apply() commits the new config, handle_output_layout_change()
is called but doesn't do anything because the config is still pending.

This patch moves the code into its own function do_output_layout_change()
which additionally gets called after all output configs are committed.

The original handler is turned into a wrapper around do_output_layout_change().

Reported-by @heroin-moose
This commit is contained in:
Consolatis 2022-07-09 00:42:04 +02:00 committed by Johan Malm
parent bfff9d02c7
commit ceca6afefc

View file

@ -224,6 +224,8 @@ output_update_for_layout_change(struct server *server)
XCURSOR_DEFAULT, server->seat.cursor); XCURSOR_DEFAULT, server->seat.cursor);
} }
static void do_output_layout_change(struct server *server);
static void static void
output_config_apply(struct server *server, output_config_apply(struct server *server,
struct wlr_output_configuration_v1 *config) struct wlr_output_configuration_v1 *config)
@ -278,7 +280,7 @@ output_config_apply(struct server *server,
} }
server->pending_output_config = NULL; server->pending_output_config = NULL;
output_update_for_layout_change(server); do_output_layout_change(server);
} }
static bool static bool
@ -351,11 +353,8 @@ wlr_output_configuration_v1 *create_output_config(struct server *server)
} }
static void static void
handle_output_layout_change(struct wl_listener *listener, void *data) do_output_layout_change(struct server *server)
{ {
struct server *server =
wl_container_of(listener, server, output_layout_change);
bool done_changing = !server->pending_output_config; bool done_changing = !server->pending_output_config;
if (done_changing) { if (done_changing) {
struct wlr_output_configuration_v1 *config = struct wlr_output_configuration_v1 *config =
@ -378,6 +377,14 @@ handle_output_layout_change(struct wl_listener *listener, void *data)
} }
} }
static void
handle_output_layout_change(struct wl_listener *listener, void *data)
{
struct server *server =
wl_container_of(listener, server, output_layout_change);
do_output_layout_change(server);
}
void void
output_manager_init(struct server *server) output_manager_init(struct server *server)
{ {