aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-04-08 11:23:48 +0200
committerDrew DeVault <sir@cmpwn.com>2020-04-08 16:36:40 +0200
commitf03d50f54bfca08d58c86f5c1fa65920993255be (patch)
treece04c5588d38b4df581087f598c6b5ab3f9c975e
parent0cdcf66bbccfeb1e3a8191cedd5f824bb27776a6 (diff)
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.
-rw-r--r--sway/desktop/output.c41
1 files changed, 29 insertions, 12 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index be424cde..03868b73 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -906,10 +906,9 @@ void handle_output_layout_change(struct wl_listener *listener,
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;
+static void output_manager_apply(struct sway_server *server,
+ struct wlr_output_configuration_v1 *config, bool test_only) {
+ // TODO: perform atomic tests on the whole backend atomically
struct wlr_output_configuration_head_v1 *config_head;
// First disable outputs we need to disable
@@ -923,8 +922,12 @@ void handle_output_manager_apply(struct wl_listener *listener, void *data) {
struct output_config *oc = new_output_config(output->wlr_output->name);
oc->enabled = false;
- oc = store_output_config(oc);
- ok &= apply_output_config(oc, output);
+ if (test_only) {
+ ok &= test_output_config(oc, output);
+ } else {
+ oc = store_output_config(oc);
+ ok &= apply_output_config(oc, output);
+ }
}
// Then enable outputs that need to
@@ -951,8 +954,12 @@ void handle_output_manager_apply(struct wl_listener *listener, void *data) {
oc->transform = config_head->state.transform;
oc->scale = config_head->state.scale;
- oc = store_output_config(oc);
- ok &= apply_output_config(oc, output);
+ if (test_only) {
+ ok &= test_output_config(oc, output);
+ } else {
+ oc = store_output_config(oc);
+ ok &= apply_output_config(oc, output);
+ }
}
if (ok) {
@@ -962,15 +969,25 @@ void handle_output_manager_apply(struct wl_listener *listener, void *data) {
}
wlr_output_configuration_v1_destroy(config);
- update_output_manager_config(server);
+ if (!test_only) {
+ 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) {
+ struct sway_server *server =
+ wl_container_of(listener, server, output_manager_test);
struct wlr_output_configuration_v1 *config = data;
- // TODO: implement test-only mode
- wlr_output_configuration_v1_send_succeeded(config);
- wlr_output_configuration_v1_destroy(config);
+ output_manager_apply(server, config, true);
}
void handle_output_power_manager_set_mode(struct wl_listener *listener,