diff options
author | 2019-05-24 21:23:36 +0200 | |
---|---|---|
committer | 2019-05-24 22:52:07 +0300 | |
commit | 0e582f1a51fde4fc31455f57fe3b9e354d2a5109 (patch) | |
tree | 2e24beb72890bfc68eaeb87e54c779c07b245345 /sway | |
parent | Implement wlr-output-management-v1 (diff) | |
download | sway-0e582f1a51fde4fc31455f57fe3b9e354d2a5109.tar.gz sway-0e582f1a51fde4fc31455f57fe3b9e354d2a5109.tar.zst sway-0e582f1a51fde4fc31455f57fe3b9e354d2a5109.zip |
Update output manager config on all output events
The output manager config was not properly updated when output
configuration was changed through some other means (such as a command).
Diffstat (limited to 'sway')
-rw-r--r-- | sway/desktop/output.c | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index dccb2432..bc0ca470 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -520,6 +520,30 @@ static void damage_handle_destroy(struct wl_listener *listener, void *data) { | |||
520 | transaction_commit_dirty(); | 520 | transaction_commit_dirty(); |
521 | } | 521 | } |
522 | 522 | ||
523 | static void update_output_manager_config(struct sway_server *server) { | ||
524 | struct wlr_output_configuration_v1 *config = | ||
525 | wlr_output_configuration_v1_create(); | ||
526 | |||
527 | struct sway_output *output; | ||
528 | wl_list_for_each(output, &root->all_outputs, link) { | ||
529 | if (output == root->noop_output) { | ||
530 | continue; | ||
531 | } | ||
532 | struct wlr_output_configuration_head_v1 *config_head = | ||
533 | wlr_output_configuration_head_v1_create(config, output->wlr_output); | ||
534 | struct wlr_box *output_box = wlr_output_layout_get_box( | ||
535 | root->output_layout, output->wlr_output); | ||
536 | // We mark the output enabled even if it is switched off by DPMS | ||
537 | config_head->state.enabled = output->enabled; | ||
538 | if (output_box) { | ||
539 | config_head->state.x = output_box->x; | ||
540 | config_head->state.y = output_box->y; | ||
541 | } | ||
542 | } | ||
543 | |||
544 | wlr_output_manager_v1_set_configuration(server->output_manager_v1, config); | ||
545 | } | ||
546 | |||
523 | static void handle_destroy(struct wl_listener *listener, void *data) { | 547 | static void handle_destroy(struct wl_listener *listener, void *data) { |
524 | struct sway_output *output = wl_container_of(listener, output, destroy); | 548 | struct sway_output *output = wl_container_of(listener, output, destroy); |
525 | wl_signal_emit(&output->events.destroy, output); | 549 | wl_signal_emit(&output->events.destroy, output); |
@@ -538,6 +562,8 @@ static void handle_destroy(struct wl_listener *listener, void *data) { | |||
538 | wl_list_remove(&output->damage_frame.link); | 562 | wl_list_remove(&output->damage_frame.link); |
539 | 563 | ||
540 | transaction_commit_dirty(); | 564 | transaction_commit_dirty(); |
565 | |||
566 | update_output_manager_config(output->server); | ||
541 | } | 567 | } |
542 | 568 | ||
543 | static void handle_mode(struct wl_listener *listener, void *data) { | 569 | static void handle_mode(struct wl_listener *listener, void *data) { |
@@ -561,6 +587,8 @@ static void handle_mode(struct wl_listener *listener, void *data) { | |||
561 | arrange_layers(output); | 587 | arrange_layers(output); |
562 | arrange_output(output); | 588 | arrange_output(output); |
563 | transaction_commit_dirty(); | 589 | transaction_commit_dirty(); |
590 | |||
591 | update_output_manager_config(output->server); | ||
564 | } | 592 | } |
565 | 593 | ||
566 | static void handle_transform(struct wl_listener *listener, void *data) { | 594 | static void handle_transform(struct wl_listener *listener, void *data) { |
@@ -571,6 +599,8 @@ static void handle_transform(struct wl_listener *listener, void *data) { | |||
571 | arrange_layers(output); | 599 | arrange_layers(output); |
572 | arrange_output(output); | 600 | arrange_output(output); |
573 | transaction_commit_dirty(); | 601 | transaction_commit_dirty(); |
602 | |||
603 | update_output_manager_config(output->server); | ||
574 | } | 604 | } |
575 | 605 | ||
576 | static void update_textures(struct sway_container *con, void *data) { | 606 | static void update_textures(struct sway_container *con, void *data) { |
@@ -578,30 +608,6 @@ static void update_textures(struct sway_container *con, void *data) { | |||
578 | container_update_marks_textures(con); | 608 | container_update_marks_textures(con); |
579 | } | 609 | } |
580 | 610 | ||
581 | static void update_output_manager_config(struct sway_server *server) { | ||
582 | struct wlr_output_configuration_v1 *config = | ||
583 | wlr_output_configuration_v1_create(); | ||
584 | |||
585 | struct sway_output *output; | ||
586 | wl_list_for_each(output, &root->all_outputs, link) { | ||
587 | if (output == root->noop_output) { | ||
588 | continue; | ||
589 | } | ||
590 | struct wlr_output_configuration_head_v1 *config_head = | ||
591 | wlr_output_configuration_head_v1_create(config, output->wlr_output); | ||
592 | struct wlr_box *output_box = wlr_output_layout_get_box( | ||
593 | root->output_layout, output->wlr_output); | ||
594 | // We mark the output enabled even if it is switched off by DPMS | ||
595 | config_head->state.enabled = output->enabled; | ||
596 | if (output_box) { | ||
597 | config_head->state.x = output_box->x; | ||
598 | config_head->state.y = output_box->y; | ||
599 | } | ||
600 | } | ||
601 | |||
602 | wlr_output_manager_v1_set_configuration(server->output_manager_v1, config); | ||
603 | } | ||
604 | |||
605 | static void handle_scale(struct wl_listener *listener, void *data) { | 611 | static void handle_scale(struct wl_listener *listener, void *data) { |
606 | struct sway_output *output = wl_container_of(listener, output, scale); | 612 | struct sway_output *output = wl_container_of(listener, output, scale); |
607 | if (!output->enabled || !output->configured) { | 613 | if (!output->enabled || !output->configured) { |
@@ -611,6 +617,8 @@ static void handle_scale(struct wl_listener *listener, void *data) { | |||
611 | output_for_each_container(output, update_textures, NULL); | 617 | output_for_each_container(output, update_textures, NULL); |
612 | arrange_output(output); | 618 | arrange_output(output); |
613 | transaction_commit_dirty(); | 619 | transaction_commit_dirty(); |
620 | |||
621 | update_output_manager_config(output->server); | ||
614 | } | 622 | } |
615 | 623 | ||
616 | static void send_presented_iterator(struct sway_output *output, | 624 | static void send_presented_iterator(struct sway_output *output, |