diff options
-rw-r--r-- | include/sway/output.h | 2 | ||||
-rw-r--r-- | sway/desktop/output.c | 50 | ||||
-rw-r--r-- | sway/tree/output.c | 18 |
3 files changed, 39 insertions, 31 deletions
diff --git a/include/sway/output.h b/include/sway/output.h index bdf9614d..7279187d 100644 --- a/include/sway/output.h +++ b/include/sway/output.h | |||
@@ -144,8 +144,6 @@ void output_get_box(struct sway_output *output, struct wlr_box *box); | |||
144 | enum sway_container_layout output_get_default_layout( | 144 | enum sway_container_layout output_get_default_layout( |
145 | struct sway_output *output); | 145 | struct sway_output *output); |
146 | 146 | ||
147 | void output_add_listeners(struct sway_output *output); | ||
148 | |||
149 | void render_rect(struct wlr_output *wlr_output, | 147 | void render_rect(struct wlr_output *wlr_output, |
150 | pixman_region32_t *output_damage, const struct wlr_box *_box, | 148 | pixman_region32_t *output_damage, const struct wlr_box *_box, |
151 | float color[static 4]); | 149 | float color[static 4]); |
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) { | |||
359 | static void damage_handle_frame(struct wl_listener *listener, void *data) { | 359 | static void damage_handle_frame(struct wl_listener *listener, void *data) { |
360 | struct sway_output *output = | 360 | struct sway_output *output = |
361 | wl_container_of(listener, output, damage_frame); | 361 | wl_container_of(listener, output, damage_frame); |
362 | 362 | if (!output->enabled || !output->wlr_output->enabled) { | |
363 | if (!output->wlr_output->enabled) { | ||
364 | return; | 363 | return; |
365 | } | 364 | } |
366 | 365 | ||
@@ -475,6 +474,9 @@ void output_damage_whole_container(struct sway_output *output, | |||
475 | static void damage_handle_destroy(struct wl_listener *listener, void *data) { | 474 | static void damage_handle_destroy(struct wl_listener *listener, void *data) { |
476 | struct sway_output *output = | 475 | struct sway_output *output = |
477 | wl_container_of(listener, output, damage_destroy); | 476 | wl_container_of(listener, output, damage_destroy); |
477 | if (!output->enabled) { | ||
478 | return; | ||
479 | } | ||
478 | output_disable(output); | 480 | output_disable(output); |
479 | transaction_commit_dirty(); | 481 | transaction_commit_dirty(); |
480 | } | 482 | } |
@@ -488,11 +490,22 @@ static void handle_destroy(struct wl_listener *listener, void *data) { | |||
488 | } | 490 | } |
489 | output_begin_destroy(output); | 491 | output_begin_destroy(output); |
490 | 492 | ||
493 | wl_list_remove(&output->destroy.link); | ||
494 | wl_list_remove(&output->mode.link); | ||
495 | wl_list_remove(&output->transform.link); | ||
496 | wl_list_remove(&output->scale.link); | ||
497 | wl_list_remove(&output->present.link); | ||
498 | wl_list_remove(&output->damage_destroy.link); | ||
499 | wl_list_remove(&output->damage_frame.link); | ||
500 | |||
491 | transaction_commit_dirty(); | 501 | transaction_commit_dirty(); |
492 | } | 502 | } |
493 | 503 | ||
494 | static void handle_mode(struct wl_listener *listener, void *data) { | 504 | static void handle_mode(struct wl_listener *listener, void *data) { |
495 | struct sway_output *output = wl_container_of(listener, output, mode); | 505 | struct sway_output *output = wl_container_of(listener, output, mode); |
506 | if (!output->enabled) { | ||
507 | return; | ||
508 | } | ||
496 | arrange_layers(output); | 509 | arrange_layers(output); |
497 | arrange_output(output); | 510 | arrange_output(output); |
498 | transaction_commit_dirty(); | 511 | transaction_commit_dirty(); |
@@ -500,6 +513,9 @@ static void handle_mode(struct wl_listener *listener, void *data) { | |||
500 | 513 | ||
501 | static void handle_transform(struct wl_listener *listener, void *data) { | 514 | static void handle_transform(struct wl_listener *listener, void *data) { |
502 | struct sway_output *output = wl_container_of(listener, output, transform); | 515 | struct sway_output *output = wl_container_of(listener, output, transform); |
516 | if (!output->enabled) { | ||
517 | return; | ||
518 | } | ||
503 | arrange_layers(output); | 519 | arrange_layers(output); |
504 | arrange_output(output); | 520 | arrange_output(output); |
505 | transaction_commit_dirty(); | 521 | transaction_commit_dirty(); |
@@ -512,6 +528,9 @@ static void update_textures(struct sway_container *con, void *data) { | |||
512 | 528 | ||
513 | static void handle_scale(struct wl_listener *listener, void *data) { | 529 | static void handle_scale(struct wl_listener *listener, void *data) { |
514 | struct sway_output *output = wl_container_of(listener, output, scale); | 530 | struct sway_output *output = wl_container_of(listener, output, scale); |
531 | if (!output->enabled) { | ||
532 | return; | ||
533 | } | ||
515 | arrange_layers(output); | 534 | arrange_layers(output); |
516 | output_for_each_container(output, update_textures, NULL); | 535 | output_for_each_container(output, update_textures, NULL); |
517 | arrange_output(output); | 536 | arrange_output(output); |
@@ -530,6 +549,10 @@ static void handle_present(struct wl_listener *listener, void *data) { | |||
530 | struct sway_output *output = wl_container_of(listener, output, present); | 549 | struct sway_output *output = wl_container_of(listener, output, present); |
531 | struct wlr_output_event_present *output_event = data; | 550 | struct wlr_output_event_present *output_event = data; |
532 | 551 | ||
552 | if (!output->enabled) { | ||
553 | return; | ||
554 | } | ||
555 | |||
533 | struct wlr_presentation_event event = { | 556 | struct wlr_presentation_event event = { |
534 | .output = output->wlr_output, | 557 | .output = output->wlr_output, |
535 | .tv_sec = (uint64_t)output_event->when->tv_sec, | 558 | .tv_sec = (uint64_t)output_event->when->tv_sec, |
@@ -552,7 +575,21 @@ void handle_new_output(struct wl_listener *listener, void *data) { | |||
552 | } | 575 | } |
553 | output->server = server; | 576 | output->server = server; |
554 | output->damage = wlr_output_damage_create(wlr_output); | 577 | output->damage = wlr_output_damage_create(wlr_output); |
578 | |||
579 | wl_signal_add(&wlr_output->events.destroy, &output->destroy); | ||
555 | output->destroy.notify = handle_destroy; | 580 | output->destroy.notify = handle_destroy; |
581 | wl_signal_add(&wlr_output->events.mode, &output->mode); | ||
582 | output->mode.notify = handle_mode; | ||
583 | wl_signal_add(&wlr_output->events.transform, &output->transform); | ||
584 | output->transform.notify = handle_transform; | ||
585 | wl_signal_add(&wlr_output->events.scale, &output->scale); | ||
586 | output->scale.notify = handle_scale; | ||
587 | wl_signal_add(&wlr_output->events.present, &output->present); | ||
588 | output->present.notify = handle_present; | ||
589 | wl_signal_add(&output->damage->events.frame, &output->damage_frame); | ||
590 | output->damage_frame.notify = damage_handle_frame; | ||
591 | wl_signal_add(&output->damage->events.destroy, &output->damage_destroy); | ||
592 | output->damage_destroy.notify = damage_handle_destroy; | ||
556 | 593 | ||
557 | struct output_config *oc = output_find_config(output); | 594 | struct output_config *oc = output_find_config(output); |
558 | 595 | ||
@@ -564,12 +601,3 @@ void handle_new_output(struct wl_listener *listener, void *data) { | |||
564 | 601 | ||
565 | transaction_commit_dirty(); | 602 | transaction_commit_dirty(); |
566 | } | 603 | } |
567 | |||
568 | void output_add_listeners(struct sway_output *output) { | ||
569 | output->mode.notify = handle_mode; | ||
570 | output->transform.notify = handle_transform; | ||
571 | output->scale.notify = handle_scale; | ||
572 | output->present.notify = handle_present; | ||
573 | output->damage_frame.notify = damage_handle_frame; | ||
574 | output->damage_destroy.notify = damage_handle_destroy; | ||
575 | } | ||
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) { | |||
57 | output->wlr_output = wlr_output; | 57 | output->wlr_output = wlr_output; |
58 | wlr_output->data = output; | 58 | wlr_output->data = output; |
59 | 59 | ||
60 | wl_signal_add(&wlr_output->events.destroy, &output->destroy); | ||
61 | wl_signal_init(&output->events.destroy); | 60 | wl_signal_init(&output->events.destroy); |
62 | 61 | ||
63 | wl_list_insert(&root->all_outputs, &output->link); | 62 | wl_list_insert(&root->all_outputs, &output->link); |
@@ -116,15 +115,6 @@ void output_enable(struct sway_output *output, struct output_config *oc) { | |||
116 | 115 | ||
117 | input_manager_configure_xcursor(); | 116 | input_manager_configure_xcursor(); |
118 | 117 | ||
119 | wl_signal_add(&wlr_output->events.mode, &output->mode); | ||
120 | wl_signal_add(&wlr_output->events.transform, &output->transform); | ||
121 | wl_signal_add(&wlr_output->events.scale, &output->scale); | ||
122 | wl_signal_add(&wlr_output->events.present, &output->present); | ||
123 | wl_signal_add(&output->damage->events.frame, &output->damage_frame); | ||
124 | wl_signal_add(&output->damage->events.destroy, &output->damage_destroy); | ||
125 | |||
126 | output_add_listeners(output); | ||
127 | |||
128 | wl_signal_emit(&root->events.new_node, &output->node); | 118 | wl_signal_emit(&root->events.new_node, &output->node); |
129 | 119 | ||
130 | arrange_layers(output); | 120 | arrange_layers(output); |
@@ -233,13 +223,6 @@ void output_disable(struct sway_output *output) { | |||
233 | int index = list_find(root->outputs, output); | 223 | int index = list_find(root->outputs, output); |
234 | list_del(root->outputs, index); | 224 | list_del(root->outputs, index); |
235 | 225 | ||
236 | wl_list_remove(&output->mode.link); | ||
237 | wl_list_remove(&output->transform.link); | ||
238 | wl_list_remove(&output->scale.link); | ||
239 | wl_list_remove(&output->present.link); | ||
240 | wl_list_remove(&output->damage_destroy.link); | ||
241 | wl_list_remove(&output->damage_frame.link); | ||
242 | |||
243 | output->enabled = false; | 226 | output->enabled = false; |
244 | 227 | ||
245 | arrange_root(); | 228 | arrange_root(); |
@@ -255,7 +238,6 @@ void output_begin_destroy(struct sway_output *output) { | |||
255 | node_set_dirty(&output->node); | 238 | node_set_dirty(&output->node); |
256 | 239 | ||
257 | wl_list_remove(&output->link); | 240 | wl_list_remove(&output->link); |
258 | wl_list_remove(&output->destroy.link); | ||
259 | output->wlr_output->data = NULL; | 241 | output->wlr_output->data = NULL; |
260 | output->wlr_output = NULL; | 242 | output->wlr_output = NULL; |
261 | } | 243 | } |