diff options
author | Simon Ser <contact@emersion.fr> | 2020-08-27 21:46:20 +0200 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2020-08-27 13:57:10 -0600 |
commit | 2c76923282b12c77e6cb30e3bf233e5878ac86fe (patch) | |
tree | 838842a6513072931bde27f852c935382df78ac7 /sway/desktop/output.c | |
parent | fd216b3a81129f15036755bc6f383c7c261291a5 (diff) |
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
Diffstat (limited to 'sway/desktop/output.c')
-rw-r--r-- | sway/desktop/output.c | 43 |
1 files changed, 18 insertions, 25 deletions
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) { output_begin_destroy(output); wl_list_remove(&output->destroy.link); + wl_list_remove(&output->commit.link); wl_list_remove(&output->mode.link); - wl_list_remove(&output->transform.link); - wl_list_remove(&output->scale.link); wl_list_remove(&output->present.link); transaction_commit_dirty(); @@ -867,34 +866,30 @@ static void handle_mode(struct wl_listener *listener, void *data) { update_output_manager_config(output->server); } -static void handle_transform(struct wl_listener *listener, void *data) { - struct sway_output *output = wl_container_of(listener, output, transform); - if (!output->enabled) { - return; - } - arrange_layers(output); - arrange_output(output); - transaction_commit_dirty(); - - update_output_manager_config(output->server); -} - static void update_textures(struct sway_container *con, void *data) { container_update_title_textures(con); container_update_marks_textures(con); } -static void handle_scale(struct wl_listener *listener, void *data) { - struct sway_output *output = wl_container_of(listener, output, scale); +static void handle_commit(struct wl_listener *listener, void *data) { + struct sway_output *output = wl_container_of(listener, output, commit); + struct wlr_output_event_commit *event = data; + if (!output->enabled) { return; } - arrange_layers(output); - output_for_each_container(output, update_textures, NULL); - arrange_output(output); - transaction_commit_dirty(); - update_output_manager_config(output->server); + if (event->committed & WLR_OUTPUT_STATE_SCALE) { + output_for_each_container(output, update_textures, NULL); + } + + if (event->committed & (WLR_OUTPUT_STATE_TRANSFORM | WLR_OUTPUT_STATE_SCALE)) { + arrange_layers(output); + arrange_output(output); + transaction_commit_dirty(); + + update_output_manager_config(output->server); + } } static void handle_present(struct wl_listener *listener, void *data) { @@ -923,12 +918,10 @@ void handle_new_output(struct wl_listener *listener, void *data) { wl_signal_add(&wlr_output->events.destroy, &output->destroy); output->destroy.notify = handle_destroy; + wl_signal_add(&wlr_output->events.commit, &output->commit); + output->commit.notify = handle_commit; wl_signal_add(&wlr_output->events.mode, &output->mode); output->mode.notify = handle_mode; - wl_signal_add(&wlr_output->events.transform, &output->transform); - output->transform.notify = handle_transform; - wl_signal_add(&wlr_output->events.scale, &output->scale); - output->scale.notify = handle_scale; wl_signal_add(&wlr_output->events.present, &output->present); output->present.notify = handle_present; wl_signal_add(&output->damage->events.frame, &output->damage_frame); |