diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/desktop/output.c | 50 | ||||
-rw-r--r-- | sway/tree/output.c | 18 |
2 files changed, 39 insertions, 29 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 04c9b4f6..3f6c3d87 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -359,8 +359,7 @@ static void send_frame_done(struct sway_output *output, struct timespec *when) { static void damage_handle_frame(struct wl_listener *listener, void *data) { struct sway_output *output = wl_container_of(listener, output, damage_frame); - - if (!output->wlr_output->enabled) { + if (!output->enabled || !output->wlr_output->enabled) { return; } @@ -475,6 +474,9 @@ void output_damage_whole_container(struct sway_output *output, static void damage_handle_destroy(struct wl_listener *listener, void *data) { struct sway_output *output = wl_container_of(listener, output, damage_destroy); + if (!output->enabled) { + return; + } output_disable(output); transaction_commit_dirty(); } @@ -488,11 +490,22 @@ static void handle_destroy(struct wl_listener *listener, void *data) { } output_begin_destroy(output); + wl_list_remove(&output->destroy.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); + wl_list_remove(&output->damage_destroy.link); + wl_list_remove(&output->damage_frame.link); + transaction_commit_dirty(); } static void handle_mode(struct wl_listener *listener, void *data) { struct sway_output *output = wl_container_of(listener, output, mode); + if (!output->enabled) { + return; + } arrange_layers(output); arrange_output(output); transaction_commit_dirty(); @@ -500,6 +513,9 @@ static void handle_mode(struct wl_listener *listener, void *data) { 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(); @@ -512,6 +528,9 @@ static void update_textures(struct sway_container *con, void *data) { static void handle_scale(struct wl_listener *listener, void *data) { struct sway_output *output = wl_container_of(listener, output, scale); + if (!output->enabled) { + return; + } arrange_layers(output); output_for_each_container(output, update_textures, NULL); arrange_output(output); @@ -530,6 +549,10 @@ static void handle_present(struct wl_listener *listener, void *data) { struct sway_output *output = wl_container_of(listener, output, present); struct wlr_output_event_present *output_event = data; + if (!output->enabled) { + return; + } + struct wlr_presentation_event event = { .output = output->wlr_output, .tv_sec = (uint64_t)output_event->when->tv_sec, @@ -552,7 +575,21 @@ void handle_new_output(struct wl_listener *listener, void *data) { } output->server = server; output->damage = wlr_output_damage_create(wlr_output); + + wl_signal_add(&wlr_output->events.destroy, &output->destroy); output->destroy.notify = handle_destroy; + 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); + output->damage_frame.notify = damage_handle_frame; + wl_signal_add(&output->damage->events.destroy, &output->damage_destroy); + output->damage_destroy.notify = damage_handle_destroy; struct output_config *oc = output_find_config(output); @@ -564,12 +601,3 @@ void handle_new_output(struct wl_listener *listener, void *data) { transaction_commit_dirty(); } - -void output_add_listeners(struct sway_output *output) { - output->mode.notify = handle_mode; - output->transform.notify = handle_transform; - output->scale.notify = handle_scale; - output->present.notify = handle_present; - output->damage_frame.notify = damage_handle_frame; - output->damage_destroy.notify = damage_handle_destroy; -} diff --git a/sway/tree/output.c b/sway/tree/output.c index f24be010..3c376c6b 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c @@ -57,7 +57,6 @@ struct sway_output *output_create(struct wlr_output *wlr_output) { output->wlr_output = wlr_output; wlr_output->data = output; - wl_signal_add(&wlr_output->events.destroy, &output->destroy); wl_signal_init(&output->events.destroy); wl_list_insert(&root->all_outputs, &output->link); @@ -116,15 +115,6 @@ void output_enable(struct sway_output *output, struct output_config *oc) { input_manager_configure_xcursor(); - wl_signal_add(&wlr_output->events.mode, &output->mode); - wl_signal_add(&wlr_output->events.transform, &output->transform); - wl_signal_add(&wlr_output->events.scale, &output->scale); - wl_signal_add(&wlr_output->events.present, &output->present); - wl_signal_add(&output->damage->events.frame, &output->damage_frame); - wl_signal_add(&output->damage->events.destroy, &output->damage_destroy); - - output_add_listeners(output); - wl_signal_emit(&root->events.new_node, &output->node); arrange_layers(output); @@ -233,13 +223,6 @@ void output_disable(struct sway_output *output) { int index = list_find(root->outputs, output); list_del(root->outputs, index); - wl_list_remove(&output->mode.link); - wl_list_remove(&output->transform.link); - wl_list_remove(&output->scale.link); - wl_list_remove(&output->present.link); - wl_list_remove(&output->damage_destroy.link); - wl_list_remove(&output->damage_frame.link); - output->enabled = false; arrange_root(); @@ -255,7 +238,6 @@ void output_begin_destroy(struct sway_output *output) { node_set_dirty(&output->node); wl_list_remove(&output->link); - wl_list_remove(&output->destroy.link); output->wlr_output->data = NULL; output->wlr_output = NULL; } |