diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-20 09:11:55 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-21 20:16:56 +1000 |
commit | efc07fb3d45e07529e3817b4a1598f2c3256d600 (patch) | |
tree | 28a76416b5d3a50fa4db1c459e19a3f42c849d35 | |
parent | Add assertion in container_at_view (diff) | |
download | sway-efc07fb3d45e07529e3817b4a1598f2c3256d600.tar.gz sway-efc07fb3d45e07529e3817b4a1598f2c3256d600.tar.zst sway-efc07fb3d45e07529e3817b4a1598f2c3256d600.zip |
Don't track damage for views on inactive tabs
-rw-r--r-- | include/sway/input/seat.h | 6 | ||||
-rw-r--r-- | include/sway/tree/view.h | 6 | ||||
-rw-r--r-- | sway/desktop/output.c | 9 | ||||
-rw-r--r-- | sway/input/seat.c | 12 | ||||
-rw-r--r-- | sway/tree/container.c | 5 | ||||
-rw-r--r-- | sway/tree/view.c | 25 |
6 files changed, 52 insertions, 11 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index ff76841e..2e4da438 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -95,6 +95,12 @@ struct sway_container *seat_get_focus_inactive_view(struct sway_seat *seat, | |||
95 | struct sway_container *container); | 95 | struct sway_container *container); |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * Return the immediate child of container which was most recently focused. | ||
99 | */ | ||
100 | struct sway_container *seat_get_active_child(struct sway_seat *seat, | ||
101 | struct sway_container *container); | ||
102 | |||
103 | /** | ||
98 | * Iterate over the focus-inactive children of the container calling the | 104 | * Iterate over the focus-inactive children of the container calling the |
99 | * function on each. | 105 | * function on each. |
100 | */ | 106 | */ |
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 951912d0..0fb8f1b3 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -274,4 +274,10 @@ bool view_has_mark(struct sway_view *view, char *mark); | |||
274 | 274 | ||
275 | void view_update_marks_textures(struct sway_view *view); | 275 | void view_update_marks_textures(struct sway_view *view); |
276 | 276 | ||
277 | /** | ||
278 | * Returns true if there's a possibility the view may be rendered on screen. | ||
279 | * Intended for damage tracking. | ||
280 | */ | ||
281 | bool view_is_visible(struct sway_view *view); | ||
282 | |||
277 | #endif | 283 | #endif |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index e39ef8db..6d5777f3 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -754,10 +754,7 @@ static void render_container_tabbed(struct sway_output *output, | |||
754 | } | 754 | } |
755 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 755 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
756 | struct sway_container *focus = seat_get_focus(seat); | 756 | struct sway_container *focus = seat_get_focus(seat); |
757 | struct sway_container *current = seat_get_focus_inactive(seat, con); | 757 | struct sway_container *current = seat_get_active_child(seat, con); |
758 | while (current->parent != con) { | ||
759 | current = current->parent; | ||
760 | } | ||
761 | struct border_colors *current_colors = NULL; | 758 | struct border_colors *current_colors = NULL; |
762 | 759 | ||
763 | // Render tabs | 760 | // Render tabs |
@@ -1082,9 +1079,7 @@ static void output_damage_view(struct sway_output *output, | |||
1082 | return; | 1079 | return; |
1083 | } | 1080 | } |
1084 | 1081 | ||
1085 | struct sway_container *workspace = container_parent(view->swayc, | 1082 | if (!view_is_visible(view)) { |
1086 | C_WORKSPACE); | ||
1087 | if (workspace->sway_workspace->fullscreen && !view->is_fullscreen) { | ||
1088 | return; | 1083 | return; |
1089 | } | 1084 | } |
1090 | 1085 | ||
diff --git a/sway/input/seat.c b/sway/input/seat.c index 7d541f6e..7a3e928a 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -718,6 +718,18 @@ struct sway_container *seat_get_focus_inactive(struct sway_seat *seat, | |||
718 | return seat_get_focus_by_type(seat, container, C_TYPES); | 718 | return seat_get_focus_by_type(seat, container, C_TYPES); |
719 | } | 719 | } |
720 | 720 | ||
721 | struct sway_container *seat_get_active_child(struct sway_seat *seat, | ||
722 | struct sway_container *container) { | ||
723 | struct sway_container *focus = seat_get_focus_inactive(seat, container); | ||
724 | if (!focus) { | ||
725 | return NULL; | ||
726 | } | ||
727 | while (focus->parent != container) { | ||
728 | focus = focus->parent; | ||
729 | } | ||
730 | return focus; | ||
731 | } | ||
732 | |||
721 | struct sway_container *sway_seat_get_focus(struct sway_seat *seat) { | 733 | struct sway_container *sway_seat_get_focus(struct sway_seat *seat) { |
722 | if (!seat->has_focus) { | 734 | if (!seat->has_focus) { |
723 | return NULL; | 735 | return NULL; |
diff --git a/sway/tree/container.c b/sway/tree/container.c index 62dca487..5c1f42c2 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -522,10 +522,7 @@ static struct sway_container *container_at_tabbed(struct sway_container *parent, | |||
522 | } | 522 | } |
523 | 523 | ||
524 | // Surfaces | 524 | // Surfaces |
525 | struct sway_container *current = seat_get_focus_inactive(seat, parent); | 525 | struct sway_container *current = seat_get_active_child(seat, parent); |
526 | while (current->parent != parent) { | ||
527 | current = current->parent; | ||
528 | } | ||
529 | 526 | ||
530 | return container_at(current, ox, oy, surface, sx, sy); | 527 | return container_at(current, ox, oy, surface, sx, sy); |
531 | } | 528 | } |
diff --git a/sway/tree/view.c b/sway/tree/view.c index 636abb25..51316507 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -865,3 +865,28 @@ void view_update_marks_textures(struct sway_view *view) { | |||
865 | &config->border_colors.urgent); | 865 | &config->border_colors.urgent); |
866 | container_damage_whole(view->swayc); | 866 | container_damage_whole(view->swayc); |
867 | } | 867 | } |
868 | |||
869 | bool view_is_visible(struct sway_view *view) { | ||
870 | if (!view->swayc) { | ||
871 | return false; | ||
872 | } | ||
873 | // Check view isn't in a tabbed or stacked container on an inactive tab | ||
874 | struct sway_seat *seat = input_manager_current_seat(input_manager); | ||
875 | struct sway_container *container = view->swayc; | ||
876 | while (container->type != C_WORKSPACE) { | ||
877 | if (container->parent->layout == L_TABBED || | ||
878 | container->parent->layout == L_STACKED) { | ||
879 | if (seat_get_active_child(seat, container->parent) != container) { | ||
880 | return false; | ||
881 | } | ||
882 | } | ||
883 | container = container->parent; | ||
884 | } | ||
885 | // Check view isn't hidden by another fullscreen view | ||
886 | struct sway_container *workspace = container; | ||
887 | if (workspace->sway_workspace->fullscreen && !view->is_fullscreen) { | ||
888 | return false; | ||
889 | } | ||
890 | // Check the workspace is visible | ||
891 | return workspace_is_visible(workspace); | ||
892 | } | ||