diff options
author | Tony Crisci <tony@dubstepdish.com> | 2018-04-02 14:06:04 -0400 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2018-04-02 14:06:04 -0400 |
commit | 2187684bd09928748f8b3a82c2e25e5ae82f5ae6 (patch) | |
tree | e70e2862280a410f8f0d617abc3539d6f0ae056e /sway/tree/layout.c | |
parent | remove default from kill switch (diff) | |
parent | Merge pull request #1697 from RedSoxFan/back-and-forth (diff) | |
download | sway-2187684bd09928748f8b3a82c2e25e5ae82f5ae6.tar.gz sway-2187684bd09928748f8b3a82c2e25e5ae82f5ae6.tar.zst sway-2187684bd09928748f8b3a82c2e25e5ae82f5ae6.zip |
Merge branch 'wlroots' into split-containers
Diffstat (limited to 'sway/tree/layout.c')
-rw-r--r-- | sway/tree/layout.c | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 5098c8d1..83e4fe37 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -109,8 +109,10 @@ struct sway_container *container_reap_empty(struct sway_container *container) { | |||
109 | if (container == NULL) { | 109 | if (container == NULL) { |
110 | return NULL; | 110 | return NULL; |
111 | } | 111 | } |
112 | wlr_log(L_DEBUG, "reaping %p %s", container, container->name); | 112 | wlr_log(L_DEBUG, "Reaping %p %s '%s'", container, |
113 | while (container->type != C_VIEW && container != &root_container && container->children->length == 0) { | 113 | container_type_to_str(container->type), container->name); |
114 | while (container->type != C_ROOT && container->type != C_OUTPUT | ||
115 | && container->children->length == 0) { | ||
114 | if (container->type == C_WORKSPACE) { | 116 | if (container->type == C_WORKSPACE) { |
115 | if (!workspace_is_visible(container)) { | 117 | if (!workspace_is_visible(container)) { |
116 | struct sway_container *parent = container->parent; | 118 | struct sway_container *parent = container->parent; |
@@ -141,22 +143,46 @@ struct sway_container *container_remove_child(struct sway_container *child) { | |||
141 | return parent; | 143 | return parent; |
142 | } | 144 | } |
143 | 145 | ||
144 | void container_move_to(struct sway_container* container, | 146 | void container_move_to(struct sway_container *container, |
145 | struct sway_container* destination) { | 147 | struct sway_container *destination) { |
146 | if (container == destination | 148 | if (container == destination |
147 | || container_has_anscestor(container, destination)) { | 149 | || container_has_anscestor(container, destination)) { |
148 | return; | 150 | return; |
149 | } | 151 | } |
150 | struct sway_container *old_parent = container_remove_child(container); | 152 | struct sway_container *old_parent = container_remove_child(container); |
151 | container->width = container->height = 0; | 153 | container->width = container->height = 0; |
152 | struct sway_container *new_parent = | 154 | struct sway_container *new_parent; |
153 | container_add_sibling(destination, container); | 155 | if (destination->type == C_VIEW) { |
156 | new_parent = container_add_sibling(destination, container); | ||
157 | } else { | ||
158 | new_parent = destination; | ||
159 | container_add_child(destination, container); | ||
160 | } | ||
161 | wl_signal_emit(&container->events.reparent, old_parent); | ||
162 | if (container->type == C_WORKSPACE) { | ||
163 | struct sway_seat *seat = sway_input_manager_get_default_seat( | ||
164 | input_manager); | ||
165 | if (old_parent->children->length == 0) { | ||
166 | char *ws_name = workspace_next_name(old_parent->name); | ||
167 | struct sway_container *ws = | ||
168 | container_workspace_create(old_parent, ws_name); | ||
169 | free(ws_name); | ||
170 | sway_seat_set_focus(seat, ws); | ||
171 | } | ||
172 | container_sort_workspaces(new_parent); | ||
173 | sway_seat_set_focus(seat, new_parent); | ||
174 | } | ||
154 | if (old_parent) { | 175 | if (old_parent) { |
155 | arrange_windows(old_parent, -1, -1); | 176 | arrange_windows(old_parent, -1, -1); |
156 | } | 177 | } |
157 | arrange_windows(new_parent, -1, -1); | 178 | arrange_windows(new_parent, -1, -1); |
158 | } | 179 | } |
159 | 180 | ||
181 | void container_move(struct sway_container *container, | ||
182 | enum movement_direction dir, int move_amt) { | ||
183 | // TODO | ||
184 | } | ||
185 | |||
160 | enum sway_container_layout container_get_default_layout( | 186 | enum sway_container_layout container_get_default_layout( |
161 | struct sway_container *output) { | 187 | struct sway_container *output) { |
162 | if (config->default_layout != L_NONE) { | 188 | if (config->default_layout != L_NONE) { |
@@ -529,26 +555,6 @@ struct sway_container *container_get_in_direction( | |||
529 | } | 555 | } |
530 | } | 556 | } |
531 | 557 | ||
532 | if (dir == MOVE_PREV || dir == MOVE_NEXT) { | ||
533 | int focused_idx = index_child(container); | ||
534 | if (focused_idx == -1) { | ||
535 | return NULL; | ||
536 | } else { | ||
537 | int desired = (focused_idx + (dir == MOVE_NEXT ? 1 : -1)) % | ||
538 | parent->children->length; | ||
539 | if (desired < 0) { | ||
540 | desired += parent->children->length; | ||
541 | } | ||
542 | return parent->children->items[desired]; | ||
543 | } | ||
544 | } | ||
545 | |||
546 | // If moving to an adjacent output we need a starting position (since this | ||
547 | // output might border to multiple outputs). | ||
548 | //struct wlc_point abs_pos; | ||
549 | //get_layout_center_position(container, &abs_pos); | ||
550 | |||
551 | |||
552 | // TODO WLR fullscreen | 558 | // TODO WLR fullscreen |
553 | /* | 559 | /* |
554 | if (container->type == C_VIEW && swayc_is_fullscreen(container)) { | 560 | if (container->type == C_VIEW && swayc_is_fullscreen(container)) { |