diff options
author | 2018-07-15 06:49:29 -0700 | |
---|---|---|
committer | 2018-07-15 06:49:29 -0700 | |
commit | 8e05fb782658f0bc13cfba6c069ba39122417317 (patch) | |
tree | 87a568ff97fc94ca82b9ceb4abacb02ea86a9f71 /sway/desktop | |
parent | Merge pull request #2272 from RyanDwyer/simplify-transactions (diff) | |
parent | Make focus part of transactions (diff) | |
download | sway-8e05fb782658f0bc13cfba6c069ba39122417317.tar.gz sway-8e05fb782658f0bc13cfba6c069ba39122417317.tar.zst sway-8e05fb782658f0bc13cfba6c069ba39122417317.zip |
Merge pull request #2275 from RyanDwyer/transactionise-focus
Make focus part of transactions
Diffstat (limited to 'sway/desktop')
-rw-r--r-- | sway/desktop/render.c | 61 | ||||
-rw-r--r-- | sway/desktop/transaction.c | 18 |
2 files changed, 37 insertions, 42 deletions
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 4bfc573b..17fe823a 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -543,9 +543,6 @@ static void render_container(struct sway_output *output, | |||
543 | static void render_container_simple(struct sway_output *output, | 543 | static void render_container_simple(struct sway_output *output, |
544 | pixman_region32_t *damage, struct sway_container *con, | 544 | pixman_region32_t *damage, struct sway_container *con, |
545 | bool parent_focused) { | 545 | bool parent_focused) { |
546 | struct sway_seat *seat = input_manager_current_seat(input_manager); | ||
547 | struct sway_container *focus = seat_get_focus(seat); | ||
548 | |||
549 | for (int i = 0; i < con->current.children->length; ++i) { | 546 | for (int i = 0; i < con->current.children->length; ++i) { |
550 | struct sway_container *child = con->current.children->items[i]; | 547 | struct sway_container *child = con->current.children->items[i]; |
551 | 548 | ||
@@ -556,11 +553,11 @@ static void render_container_simple(struct sway_output *output, | |||
556 | struct wlr_texture *marks_texture; | 553 | struct wlr_texture *marks_texture; |
557 | struct sway_container_state *state = &child->current; | 554 | struct sway_container_state *state = &child->current; |
558 | 555 | ||
559 | if (focus == child || parent_focused) { | 556 | if (state->focused || parent_focused) { |
560 | colors = &config->border_colors.focused; | 557 | colors = &config->border_colors.focused; |
561 | title_texture = child->title_focused; | 558 | title_texture = child->title_focused; |
562 | marks_texture = view->marks_focused; | 559 | marks_texture = view->marks_focused; |
563 | } else if (seat_get_focus_inactive(seat, con) == child) { | 560 | } else if (con->current.focused_inactive_child == child) { |
564 | colors = &config->border_colors.focused_inactive; | 561 | colors = &config->border_colors.focused_inactive; |
565 | title_texture = child->title_focused_inactive; | 562 | title_texture = child->title_focused_inactive; |
566 | marks_texture = view->marks_focused_inactive; | 563 | marks_texture = view->marks_focused_inactive; |
@@ -580,7 +577,7 @@ static void render_container_simple(struct sway_output *output, | |||
580 | render_view(output, damage, child, colors); | 577 | render_view(output, damage, child, colors); |
581 | } else { | 578 | } else { |
582 | render_container(output, damage, child, | 579 | render_container(output, damage, child, |
583 | parent_focused || focus == child); | 580 | parent_focused || child->current.focused); |
584 | } | 581 | } |
585 | } | 582 | } |
586 | } | 583 | } |
@@ -594,11 +591,9 @@ static void render_container_tabbed(struct sway_output *output, | |||
594 | if (!con->current.children->length) { | 591 | if (!con->current.children->length) { |
595 | return; | 592 | return; |
596 | } | 593 | } |
597 | struct sway_seat *seat = input_manager_current_seat(input_manager); | ||
598 | struct sway_container *focus = seat_get_focus(seat); | ||
599 | struct sway_container *current = seat_get_active_current_child(seat, con); | ||
600 | struct border_colors *current_colors = &config->border_colors.unfocused; | ||
601 | struct sway_container_state *pstate = &con->current; | 594 | struct sway_container_state *pstate = &con->current; |
595 | struct sway_container *current = pstate->focused_inactive_child; | ||
596 | struct border_colors *current_colors = &config->border_colors.unfocused; | ||
602 | 597 | ||
603 | double width_gap_adjustment = 2 * pstate->current_gaps; | 598 | double width_gap_adjustment = 2 * pstate->current_gaps; |
604 | int tab_width = | 599 | int tab_width = |
@@ -613,11 +608,11 @@ static void render_container_tabbed(struct sway_output *output, | |||
613 | struct wlr_texture *title_texture; | 608 | struct wlr_texture *title_texture; |
614 | struct wlr_texture *marks_texture; | 609 | struct wlr_texture *marks_texture; |
615 | 610 | ||
616 | if (focus == child || parent_focused) { | 611 | if (cstate->focused || parent_focused) { |
617 | colors = &config->border_colors.focused; | 612 | colors = &config->border_colors.focused; |
618 | title_texture = child->title_focused; | 613 | title_texture = child->title_focused; |
619 | marks_texture = view ? view->marks_focused : NULL; | 614 | marks_texture = view ? view->marks_focused : NULL; |
620 | } else if (child == current) { | 615 | } else if (child == pstate->focused_inactive_child) { |
621 | colors = &config->border_colors.focused_inactive; | 616 | colors = &config->border_colors.focused_inactive; |
622 | title_texture = child->title_focused_inactive; | 617 | title_texture = child->title_focused_inactive; |
623 | marks_texture = view ? view->marks_focused_inactive : NULL; | 618 | marks_texture = view ? view->marks_focused_inactive : NULL; |
@@ -644,13 +639,11 @@ static void render_container_tabbed(struct sway_output *output, | |||
644 | } | 639 | } |
645 | 640 | ||
646 | // Render surface and left/right/bottom borders | 641 | // Render surface and left/right/bottom borders |
647 | if (current) { | 642 | if (current->type == C_VIEW) { |
648 | if (current->type == C_VIEW) { | 643 | render_view(output, damage, current, current_colors); |
649 | render_view(output, damage, current, current_colors); | 644 | } else { |
650 | } else { | 645 | render_container(output, damage, current, |
651 | render_container(output, damage, current, | 646 | parent_focused || current->current.focused); |
652 | parent_focused || current == focus); | ||
653 | } | ||
654 | } | 647 | } |
655 | } | 648 | } |
656 | 649 | ||
@@ -663,11 +656,9 @@ static void render_container_stacked(struct sway_output *output, | |||
663 | if (!con->current.children->length) { | 656 | if (!con->current.children->length) { |
664 | return; | 657 | return; |
665 | } | 658 | } |
666 | struct sway_seat *seat = input_manager_current_seat(input_manager); | ||
667 | struct sway_container *focus = seat_get_focus(seat); | ||
668 | struct sway_container *current = seat_get_active_current_child(seat, con); | ||
669 | struct border_colors *current_colors = &config->border_colors.unfocused; | ||
670 | struct sway_container_state *pstate = &con->current; | 659 | struct sway_container_state *pstate = &con->current; |
660 | struct sway_container *current = pstate->focused_inactive_child; | ||
661 | struct border_colors *current_colors = &config->border_colors.unfocused; | ||
671 | 662 | ||
672 | size_t titlebar_height = container_titlebar_height(); | 663 | size_t titlebar_height = container_titlebar_height(); |
673 | 664 | ||
@@ -680,11 +671,11 @@ static void render_container_stacked(struct sway_output *output, | |||
680 | struct wlr_texture *title_texture; | 671 | struct wlr_texture *title_texture; |
681 | struct wlr_texture *marks_texture; | 672 | struct wlr_texture *marks_texture; |
682 | 673 | ||
683 | if (focus == child || parent_focused) { | 674 | if (cstate->focused || parent_focused) { |
684 | colors = &config->border_colors.focused; | 675 | colors = &config->border_colors.focused; |
685 | title_texture = child->title_focused; | 676 | title_texture = child->title_focused; |
686 | marks_texture = view ? view->marks_focused : NULL; | 677 | marks_texture = view ? view->marks_focused : NULL; |
687 | } else if (child == current) { | 678 | } else if (child == pstate->focused_inactive_child) { |
688 | colors = &config->border_colors.focused_inactive; | 679 | colors = &config->border_colors.focused_inactive; |
689 | title_texture = child->title_focused_inactive; | 680 | title_texture = child->title_focused_inactive; |
690 | marks_texture = view ? view->marks_focused_inactive : NULL; | 681 | marks_texture = view ? view->marks_focused_inactive : NULL; |
@@ -704,13 +695,11 @@ static void render_container_stacked(struct sway_output *output, | |||
704 | } | 695 | } |
705 | 696 | ||
706 | // Render surface and left/right/bottom borders | 697 | // Render surface and left/right/bottom borders |
707 | if (current) { | 698 | if (current->type == C_VIEW) { |
708 | if (current->type == C_VIEW) { | 699 | render_view(output, damage, current, current_colors); |
709 | render_view(output, damage, current, current_colors); | 700 | } else { |
710 | } else { | 701 | render_container(output, damage, current, |
711 | render_container(output, damage, current, | 702 | parent_focused || current->current.focused); |
712 | parent_focused || current == focus); | ||
713 | } | ||
714 | } | 703 | } |
715 | } | 704 | } |
716 | 705 | ||
@@ -738,13 +727,11 @@ static void render_floating_container(struct sway_output *soutput, | |||
738 | pixman_region32_t *damage, struct sway_container *con) { | 727 | pixman_region32_t *damage, struct sway_container *con) { |
739 | if (con->type == C_VIEW) { | 728 | if (con->type == C_VIEW) { |
740 | struct sway_view *view = con->sway_view; | 729 | struct sway_view *view = con->sway_view; |
741 | struct sway_seat *seat = input_manager_current_seat(input_manager); | ||
742 | struct sway_container *focus = seat_get_focus(seat); | ||
743 | struct border_colors *colors; | 730 | struct border_colors *colors; |
744 | struct wlr_texture *title_texture; | 731 | struct wlr_texture *title_texture; |
745 | struct wlr_texture *marks_texture; | 732 | struct wlr_texture *marks_texture; |
746 | 733 | ||
747 | if (focus == con) { | 734 | if (con->current.focused) { |
748 | colors = &config->border_colors.focused; | 735 | colors = &config->border_colors.focused; |
749 | title_texture = con->title_focused; | 736 | title_texture = con->title_focused; |
750 | marks_texture = view->marks_focused; | 737 | marks_texture = view->marks_focused; |
@@ -871,9 +858,7 @@ void output_render(struct sway_output *output, struct timespec *when, | |||
871 | render_layer(output, damage, | 858 | render_layer(output, damage, |
872 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]); | 859 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]); |
873 | 860 | ||
874 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 861 | render_container(output, damage, workspace, workspace->current.focused); |
875 | struct sway_container *focus = seat_get_focus(seat); | ||
876 | render_container(output, damage, workspace, focus == workspace); | ||
877 | render_floating(output, damage); | 862 | render_floating(output, damage); |
878 | 863 | ||
879 | render_unmanaged(output, damage, | 864 | render_unmanaged(output, damage, |
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index 0ae042db..fcfb0b51 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c | |||
@@ -139,6 +139,14 @@ static void copy_pending_state(struct sway_container *container, | |||
139 | state->children = create_list(); | 139 | state->children = create_list(); |
140 | list_cat(state->children, container->children); | 140 | list_cat(state->children, container->children); |
141 | } | 141 | } |
142 | |||
143 | struct sway_seat *seat = input_manager_current_seat(input_manager); | ||
144 | state->focused = seat_get_focus(seat) == container; | ||
145 | |||
146 | if (container->type != C_VIEW) { | ||
147 | state->focused_inactive_child = | ||
148 | seat_get_active_child(seat, container); | ||
149 | } | ||
142 | } | 150 | } |
143 | 151 | ||
144 | static void transaction_add_container(struct sway_transaction *transaction, | 152 | static void transaction_add_container(struct sway_transaction *transaction, |
@@ -195,10 +203,12 @@ static void transaction_apply(struct sway_transaction *transaction) { | |||
195 | .width = instruction->state.swayc_width, | 203 | .width = instruction->state.swayc_width, |
196 | .height = instruction->state.swayc_height, | 204 | .height = instruction->state.swayc_height, |
197 | }; | 205 | }; |
198 | for (int j = 0; j < root_container.children->length; ++j) { | 206 | for (int j = 0; j < root_container.current.children->length; ++j) { |
199 | struct sway_container *output = root_container.children->items[j]; | 207 | struct sway_container *output = root_container.current.children->items[j]; |
200 | output_damage_box(output->sway_output, &old_box); | 208 | if (output->sway_output) { |
201 | output_damage_box(output->sway_output, &new_box); | 209 | output_damage_box(output->sway_output, &old_box); |
210 | output_damage_box(output->sway_output, &new_box); | ||
211 | } | ||
202 | } | 212 | } |
203 | 213 | ||
204 | // There are separate children lists for each instruction state, the | 214 | // There are separate children lists for each instruction state, the |