diff options
author | Simon Ser <contact@emersion.fr> | 2020-04-08 11:23:48 +0200 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2020-04-08 16:36:40 +0200 |
commit | f03d50f54bfca08d58c86f5c1fa65920993255be (patch) | |
tree | ce04c5588d38b4df581087f598c6b5ab3f9c975e /sway/desktop/output.c | |
parent | Introduce test_output_config (diff) | |
download | sway-f03d50f54bfca08d58c86f5c1fa65920993255be.tar.gz sway-f03d50f54bfca08d58c86f5c1fa65920993255be.tar.zst sway-f03d50f54bfca08d58c86f5c1fa65920993255be.zip |
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.
Diffstat (limited to 'sway/desktop/output.c')
-rw-r--r-- | sway/desktop/output.c | 41 |
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, | |||
906 | update_output_manager_config(server); | 906 | update_output_manager_config(server); |
907 | } | 907 | } |
908 | 908 | ||
909 | void handle_output_manager_apply(struct wl_listener *listener, void *data) { | 909 | static void output_manager_apply(struct sway_server *server, |
910 | struct sway_server *server = | 910 | struct wlr_output_configuration_v1 *config, bool test_only) { |
911 | wl_container_of(listener, server, output_manager_apply); | 911 | // TODO: perform atomic tests on the whole backend atomically |
912 | struct wlr_output_configuration_v1 *config = data; | ||
913 | 912 | ||
914 | struct wlr_output_configuration_head_v1 *config_head; | 913 | struct wlr_output_configuration_head_v1 *config_head; |
915 | // First disable outputs we need to disable | 914 | // First disable outputs we need to disable |
@@ -923,8 +922,12 @@ void handle_output_manager_apply(struct wl_listener *listener, void *data) { | |||
923 | struct output_config *oc = new_output_config(output->wlr_output->name); | 922 | struct output_config *oc = new_output_config(output->wlr_output->name); |
924 | oc->enabled = false; | 923 | oc->enabled = false; |
925 | 924 | ||
926 | oc = store_output_config(oc); | 925 | if (test_only) { |
927 | ok &= apply_output_config(oc, output); | 926 | ok &= test_output_config(oc, output); |
927 | } else { | ||
928 | oc = store_output_config(oc); | ||
929 | ok &= apply_output_config(oc, output); | ||
930 | } | ||
928 | } | 931 | } |
929 | 932 | ||
930 | // Then enable outputs that need to | 933 | // Then enable outputs that need to |
@@ -951,8 +954,12 @@ void handle_output_manager_apply(struct wl_listener *listener, void *data) { | |||
951 | oc->transform = config_head->state.transform; | 954 | oc->transform = config_head->state.transform; |
952 | oc->scale = config_head->state.scale; | 955 | oc->scale = config_head->state.scale; |
953 | 956 | ||
954 | oc = store_output_config(oc); | 957 | if (test_only) { |
955 | ok &= apply_output_config(oc, output); | 958 | ok &= test_output_config(oc, output); |
959 | } else { | ||
960 | oc = store_output_config(oc); | ||
961 | ok &= apply_output_config(oc, output); | ||
962 | } | ||
956 | } | 963 | } |
957 | 964 | ||
958 | if (ok) { | 965 | if (ok) { |
@@ -962,15 +969,25 @@ void handle_output_manager_apply(struct wl_listener *listener, void *data) { | |||
962 | } | 969 | } |
963 | wlr_output_configuration_v1_destroy(config); | 970 | wlr_output_configuration_v1_destroy(config); |
964 | 971 | ||
965 | update_output_manager_config(server); | 972 | if (!test_only) { |
973 | update_output_manager_config(server); | ||
974 | } | ||
975 | } | ||
976 | |||
977 | void handle_output_manager_apply(struct wl_listener *listener, void *data) { | ||
978 | struct sway_server *server = | ||
979 | wl_container_of(listener, server, output_manager_apply); | ||
980 | struct wlr_output_configuration_v1 *config = data; | ||
981 | |||
982 | output_manager_apply(server, config, false); | ||
966 | } | 983 | } |
967 | 984 | ||
968 | void handle_output_manager_test(struct wl_listener *listener, void *data) { | 985 | void handle_output_manager_test(struct wl_listener *listener, void *data) { |
986 | struct sway_server *server = | ||
987 | wl_container_of(listener, server, output_manager_test); | ||
969 | struct wlr_output_configuration_v1 *config = data; | 988 | struct wlr_output_configuration_v1 *config = data; |
970 | 989 | ||
971 | // TODO: implement test-only mode | 990 | output_manager_apply(server, config, true); |
972 | wlr_output_configuration_v1_send_succeeded(config); | ||
973 | wlr_output_configuration_v1_destroy(config); | ||
974 | } | 991 | } |
975 | 992 | ||
976 | void handle_output_power_manager_set_mode(struct wl_listener *listener, | 993 | void handle_output_power_manager_set_mode(struct wl_listener *listener, |