diff options
author | 2020-08-27 21:46:20 +0200 | |
---|---|---|
committer | 2020-08-27 13:57:10 -0600 | |
commit | 2c76923282b12c77e6cb30e3bf233e5878ac86fe (patch) | |
tree | 838842a6513072931bde27f852c935382df78ac7 | |
parent | exec: fix validation during config reload (diff) | |
download | sway-2c76923282b12c77e6cb30e3bf233e5878ac86fe.tar.gz sway-2c76923282b12c77e6cb30e3bf233e5878ac86fe.tar.zst sway-2c76923282b12c77e6cb30e3bf233e5878ac86fe.zip |
Use wlr_output_event_commit
Instead of listening to both transform and scale events, we can listen
to the commit event and use the new wlr_output_event_commit struct to
decide what to do.
This de-duplicates some of the work we were doing twice when an output
was re-configured.
Depends on [1].
[1]: https://github.com/swaywm/wlroots/pull/2315
-rw-r--r-- | include/sway/output.h | 3 | ||||
-rw-r--r-- | sway/desktop/output.c | 43 |
2 files changed, 19 insertions, 27 deletions
diff --git a/include/sway/output.h b/include/sway/output.h index f27f6344..16451d81 100644 --- a/include/sway/output.h +++ b/include/sway/output.h | |||
@@ -42,9 +42,8 @@ struct sway_output { | |||
42 | struct sway_output_state current; | 42 | struct sway_output_state current; |
43 | 43 | ||
44 | struct wl_listener destroy; | 44 | struct wl_listener destroy; |
45 | struct wl_listener commit; | ||
45 | struct wl_listener mode; | 46 | struct wl_listener mode; |
46 | struct wl_listener transform; | ||
47 | struct wl_listener scale; | ||
48 | struct wl_listener present; | 47 | struct wl_listener present; |
49 | struct wl_listener damage_destroy; | 48 | struct wl_listener damage_destroy; |
50 | struct wl_listener damage_frame; | 49 | struct wl_listener damage_frame; |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 90653fa1..cf2456ef 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -832,9 +832,8 @@ static void handle_destroy(struct wl_listener *listener, void *data) { | |||
832 | output_begin_destroy(output); | 832 | output_begin_destroy(output); |
833 | 833 | ||
834 | wl_list_remove(&output->destroy.link); | 834 | wl_list_remove(&output->destroy.link); |
835 | wl_list_remove(&output->commit.link); | ||
835 | wl_list_remove(&output->mode.link); | 836 | wl_list_remove(&output->mode.link); |
836 | wl_list_remove(&output->transform.link); | ||
837 | wl_list_remove(&output->scale.link); | ||
838 | wl_list_remove(&output->present.link); | 837 | wl_list_remove(&output->present.link); |
839 | 838 | ||
840 | transaction_commit_dirty(); | 839 | transaction_commit_dirty(); |
@@ -867,34 +866,30 @@ static void handle_mode(struct wl_listener *listener, void *data) { | |||
867 | update_output_manager_config(output->server); | 866 | update_output_manager_config(output->server); |
868 | } | 867 | } |
869 | 868 | ||
870 | static void handle_transform(struct wl_listener *listener, void *data) { | ||
871 | struct sway_output *output = wl_container_of(listener, output, transform); | ||
872 | if (!output->enabled) { | ||
873 | return; | ||
874 | } | ||
875 | arrange_layers(output); | ||
876 | arrange_output(output); | ||
877 | transaction_commit_dirty(); | ||
878 | |||
879 | update_output_manager_config(output->server); | ||
880 | } | ||
881 | |||
882 | static void update_textures(struct sway_container *con, void *data) { | 869 | static void update_textures(struct sway_container *con, void *data) { |
883 | container_update_title_textures(con); | 870 | container_update_title_textures(con); |
884 | container_update_marks_textures(con); | 871 | container_update_marks_textures(con); |
885 | } | 872 | } |
886 | 873 | ||
887 | static void handle_scale(struct wl_listener *listener, void *data) { | 874 | static void handle_commit(struct wl_listener *listener, void *data) { |
888 | struct sway_output *output = wl_container_of(listener, output, scale); | 875 | struct sway_output *output = wl_container_of(listener, output, commit); |
876 | struct wlr_output_event_commit *event = data; | ||
877 | |||
889 | if (!output->enabled) { | 878 | if (!output->enabled) { |
890 | return; | 879 | return; |
891 | } | 880 | } |
892 | arrange_layers(output); | ||
893 | output_for_each_container(output, update_textures, NULL); | ||
894 | arrange_output(output); | ||
895 | transaction_commit_dirty(); | ||
896 | 881 | ||
897 | update_output_manager_config(output->server); | 882 | if (event->committed & WLR_OUTPUT_STATE_SCALE) { |
883 | output_for_each_container(output, update_textures, NULL); | ||
884 | } | ||
885 | |||
886 | if (event->committed & (WLR_OUTPUT_STATE_TRANSFORM | WLR_OUTPUT_STATE_SCALE)) { | ||
887 | arrange_layers(output); | ||
888 | arrange_output(output); | ||
889 | transaction_commit_dirty(); | ||
890 | |||
891 | update_output_manager_config(output->server); | ||
892 | } | ||
898 | } | 893 | } |
899 | 894 | ||
900 | static void handle_present(struct wl_listener *listener, void *data) { | 895 | static void handle_present(struct wl_listener *listener, void *data) { |
@@ -923,12 +918,10 @@ void handle_new_output(struct wl_listener *listener, void *data) { | |||
923 | 918 | ||
924 | wl_signal_add(&wlr_output->events.destroy, &output->destroy); | 919 | wl_signal_add(&wlr_output->events.destroy, &output->destroy); |
925 | output->destroy.notify = handle_destroy; | 920 | output->destroy.notify = handle_destroy; |
921 | wl_signal_add(&wlr_output->events.commit, &output->commit); | ||
922 | output->commit.notify = handle_commit; | ||
926 | wl_signal_add(&wlr_output->events.mode, &output->mode); | 923 | wl_signal_add(&wlr_output->events.mode, &output->mode); |
927 | output->mode.notify = handle_mode; | 924 | output->mode.notify = handle_mode; |
928 | wl_signal_add(&wlr_output->events.transform, &output->transform); | ||
929 | output->transform.notify = handle_transform; | ||
930 | wl_signal_add(&wlr_output->events.scale, &output->scale); | ||
931 | output->scale.notify = handle_scale; | ||
932 | wl_signal_add(&wlr_output->events.present, &output->present); | 925 | wl_signal_add(&wlr_output->events.present, &output->present); |
933 | output->present.notify = handle_present; | 926 | output->present.notify = handle_present; |
934 | wl_signal_add(&output->damage->events.frame, &output->damage_frame); | 927 | wl_signal_add(&output->damage->events.frame, &output->damage_frame); |