aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/transaction.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-15 15:20:21 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-15 22:08:26 +1000
commita120d4c79f9406a2f7cc38c60069d3183c98ea87 (patch)
tree87a568ff97fc94ca82b9ceb4abacb02ea86a9f71 /sway/desktop/transaction.c
parentMerge pull request #2272 from RyanDwyer/simplify-transactions (diff)
downloadsway-a120d4c79f9406a2f7cc38c60069d3183c98ea87.tar.gz
sway-a120d4c79f9406a2f7cc38c60069d3183c98ea87.tar.zst
sway-a120d4c79f9406a2f7cc38c60069d3183c98ea87.zip
Make focus part of transactions
Rather than maintain copies of the entire focus stack, this PR transactionises the focus by introducing two new properties to the container state and using those when rendering. * `bool focused` means this container has actual focus. Only one container should have this equalling true in its current state. * `struct sway_container *focus_inactive_child` points to the immediate child that was most recently focused (eg. for tabbed and stacked containers).
Diffstat (limited to 'sway/desktop/transaction.c')
-rw-r--r--sway/desktop/transaction.c18
1 files changed, 14 insertions, 4 deletions
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
144static void transaction_add_container(struct sway_transaction *transaction, 152static 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