Add test-only support to wlr-output-management-unstable-v1

Use the new test_output_config function to implement
wlr-output-management-unstable-v1's test request.
This commit is contained in:
Simon Ser 2020-04-08 11:23:48 +02:00 committed by Drew DeVault
parent 0cdcf66bbc
commit f03d50f54b

View file

@ -906,10 +906,9 @@ void handle_output_layout_change(struct wl_listener *listener,
update_output_manager_config(server); update_output_manager_config(server);
} }
void handle_output_manager_apply(struct wl_listener *listener, void *data) { static void output_manager_apply(struct sway_server *server,
struct sway_server *server = struct wlr_output_configuration_v1 *config, bool test_only) {
wl_container_of(listener, server, output_manager_apply); // TODO: perform atomic tests on the whole backend atomically
struct wlr_output_configuration_v1 *config = data;
struct wlr_output_configuration_head_v1 *config_head; struct wlr_output_configuration_head_v1 *config_head;
// First disable outputs we need to disable // First disable outputs we need to disable
@ -923,9 +922,13 @@ void handle_output_manager_apply(struct wl_listener *listener, void *data) {
struct output_config *oc = new_output_config(output->wlr_output->name); struct output_config *oc = new_output_config(output->wlr_output->name);
oc->enabled = false; oc->enabled = false;
if (test_only) {
ok &= test_output_config(oc, output);
} else {
oc = store_output_config(oc); oc = store_output_config(oc);
ok &= apply_output_config(oc, output); ok &= apply_output_config(oc, output);
} }
}
// Then enable outputs that need to // Then enable outputs that need to
wl_list_for_each(config_head, &config->heads, link) { wl_list_for_each(config_head, &config->heads, link) {
@ -951,9 +954,13 @@ void handle_output_manager_apply(struct wl_listener *listener, void *data) {
oc->transform = config_head->state.transform; oc->transform = config_head->state.transform;
oc->scale = config_head->state.scale; oc->scale = config_head->state.scale;
if (test_only) {
ok &= test_output_config(oc, output);
} else {
oc = store_output_config(oc); oc = store_output_config(oc);
ok &= apply_output_config(oc, output); ok &= apply_output_config(oc, output);
} }
}
if (ok) { if (ok) {
wlr_output_configuration_v1_send_succeeded(config); wlr_output_configuration_v1_send_succeeded(config);
@ -962,15 +969,25 @@ void handle_output_manager_apply(struct wl_listener *listener, void *data) {
} }
wlr_output_configuration_v1_destroy(config); wlr_output_configuration_v1_destroy(config);
if (!test_only) {
update_output_manager_config(server); update_output_manager_config(server);
}
}
void handle_output_manager_apply(struct wl_listener *listener, void *data) {
struct sway_server *server =
wl_container_of(listener, server, output_manager_apply);
struct wlr_output_configuration_v1 *config = data;
output_manager_apply(server, config, false);
} }
void handle_output_manager_test(struct wl_listener *listener, void *data) { void handle_output_manager_test(struct wl_listener *listener, void *data) {
struct sway_server *server =
wl_container_of(listener, server, output_manager_test);
struct wlr_output_configuration_v1 *config = data; struct wlr_output_configuration_v1 *config = data;
// TODO: implement test-only mode output_manager_apply(server, config, true);
wlr_output_configuration_v1_send_succeeded(config);
wlr_output_configuration_v1_destroy(config);
} }
void handle_output_power_manager_set_mode(struct wl_listener *listener, void handle_output_power_manager_set_mode(struct wl_listener *listener,