summaryrefslogtreecommitdiffstats
path: root/sway/layout.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/layout.c')
-rw-r--r--sway/layout.c66
1 files changed, 1 insertions, 65 deletions
diff --git a/sway/layout.c b/sway/layout.c
index f4079d4b..de7ef370 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -31,9 +31,6 @@ void add_child(swayc_t *parent, swayc_t *child) {
31 child->width, child->height, parent, parent->type, parent->width, parent->height); 31 child->width, child->height, parent, parent->type, parent->width, parent->height);
32 list_add(parent->children, child); 32 list_add(parent->children, child);
33 child->parent = parent; 33 child->parent = parent;
34 if (parent->focused == NULL) {
35 parent->focused = child;
36 }
37} 34}
38 35
39swayc_t *add_sibling(swayc_t *sibling, swayc_t *child) { 36swayc_t *add_sibling(swayc_t *sibling, swayc_t *child) {
@@ -206,7 +203,7 @@ void arrange_windows(swayc_t *container, int width, int height) {
206 // Arrage floating layouts for workspaces last 203 // Arrage floating layouts for workspaces last
207 if (container->type == C_WORKSPACE) { 204 if (container->type == C_WORKSPACE) {
208 for (i = 0; i < container->floating->length; ++i) { 205 for (i = 0; i < container->floating->length; ++i) {
209 swayc_t *view = ((swayc_t *)container->floating->items[i]); 206 swayc_t *view = container->floating->items[i];
210 // Set the geometry 207 // Set the geometry
211 struct wlc_geometry geometry = { 208 struct wlc_geometry geometry = {
212 .origin = { 209 .origin = {
@@ -262,64 +259,3 @@ swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent) {
262 return NULL; 259 return NULL;
263} 260}
264 261
265swayc_t *get_focused_container(swayc_t *parent) {
266 if (parent->focused == NULL) {
267 return parent;
268 }
269 return get_focused_container(parent->focused);
270}
271
272void unfocus_all(swayc_t *container) {
273 if (container->children == NULL) {
274 return;
275 }
276 int i;
277 for (i = 0; i < container->children->length; ++i) {
278 swayc_t *view = container->children->items[i];
279 if (view->type == C_VIEW) {
280 wlc_view_set_state(view->handle, WLC_BIT_ACTIVATED, false);
281 } else {
282 unfocus_all(view);
283 }
284 }
285}
286
287void focus_view(swayc_t *view) {
288 if (!view) {
289 return;
290 }
291 sway_log(L_DEBUG, "Setting focus for %p:%ld", view, view->handle);
292 swayc_t *c = view;
293 //Set focus from root to view
294 while (c != &root_container) {
295 c->parent->focused = c;
296 c = c->parent;
297 }
298 //Set output
299 wlc_output_focus(c->focused->handle);
300 //get focus for views focused window
301 while (view && view->type != C_VIEW) {
302 view = view->focused;
303 }
304 if (view) {
305 wlc_view_set_state(view->handle, WLC_BIT_ACTIVATED, true);
306 wlc_view_focus(view->handle);
307 }
308}
309
310void focus_view_for(swayc_t *top, swayc_t *view) {
311 swayc_t *find = view;
312 //Make sure top is a ancestor of view
313 while (find != top) {
314 if (find == &root_container) {
315 return;
316 }
317 find = find->parent;
318 }
319 //Set focus for top to go to view
320 while (view != top) {
321 view->parent->focused = view;
322 view = view->parent;
323 }
324}
325