From 4c688cba4e3528921656d63a09f7015cae13cd0c Mon Sep 17 00:00:00 2001 From: KoffeinFlummi Date: Tue, 18 Aug 2015 23:53:57 +0200 Subject: Add support for gaps option --- sway/commands.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index 51de7a50..f716efa3 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -281,6 +282,44 @@ static bool cmd_focus_follows_mouse(struct sway_config *config, int argc, char * return true; } +static bool cmd_gaps(struct sway_config *config, int argc, char **argv) { + if (!checkarg(argc, "gaps", EXPECTED_AT_LEAST, 1)) { + return false; + } + + if (argc == 1) { + char *end; + int amount = (int)strtol(argv[0], &end, 10); + if (errno == ERANGE || amount == 0) { + errno = 0; + return false; + } + if (config->gaps_inner == 0) { + config->gaps_inner = amount; + } + if (config->gaps_outer == 0) { + config->gaps_outer = amount; + } + } else if (argc == 2) { + char *end; + int amount = (int)strtol(argv[1], &end, 10); + if (errno == ERANGE || amount == 0) { + errno = 0; + return false; + } + if (strcmp(argv[0], "inner") == 0) { + config->gaps_inner = amount; + } else if (strcmp(argv[0], "outer") == 0) { + config->gaps_outer = amount; + } else { + return false; + } + } else { + return false; + } + return true; +} + static bool cmd_kill(struct sway_config *config, int argc, char **argv) { swayc_t *view = get_focused_container(&root_container); wlc_view_close(view->handle); @@ -484,6 +523,7 @@ static struct cmd_handler handlers[] = { { "focus", cmd_focus }, { "focus_follows_mouse", cmd_focus_follows_mouse }, { "fullscreen", cmd_fullscreen }, + { "gaps", cmd_gaps }, { "kill", cmd_kill }, { "layout", cmd_layout }, { "log_colors", cmd_log_colors }, -- cgit v1.2.3 From cf916bbf6fbdf75abc55d4c1abe26ed6b8153687 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 18 Aug 2015 18:44:50 -0400 Subject: Improvements to gaps --- sway/commands.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index 54839322..42d6b173 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -307,9 +307,9 @@ static bool cmd_gaps(struct sway_config *config, int argc, char **argv) { errno = 0; return false; } - if (strcmp(argv[0], "inner") == 0) { + if (strcasecmp(argv[0], "inner") == 0) { config->gaps_inner = amount; - } else if (strcmp(argv[0], "outer") == 0) { + } else if (strcasecmp(argv[0], "outer") == 0) { config->gaps_outer = amount; } else { return false; -- cgit v1.2.3 From e16a4015ff216594eeb237ef81534bfaea7533d6 Mon Sep 17 00:00:00 2001 From: taiyu Date: Wed, 19 Aug 2015 00:28:53 -0700 Subject: fixed focus key handler --- sway/commands.c | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index 42d6b173..6e1f1848 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -185,40 +185,23 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { int i; // Change from nonfloating to floating if (!view->is_floating) { - view->is_floating = true; - for (i = 0; i < view->parent->children->length; i++) { - if (view->parent->children->items[i] == view) { - // Try to use desired geometry to set w/h - if (view->desired_width != -1) { - view->width = view->desired_width; - } - if (view->desired_height != -1) { - view->height = view->desired_height; - } - - // Swap from the list of whatever container the view was in - // to the workspace->floating list - list_del(view->parent->children, i); - list_add(active_workspace->floating, view); - destroy_container(view->parent); - - // Set the new position of the container and arrange windows - view->x = (active_workspace->width - view->width)/2; - view->y = (active_workspace->height - view->height)/2; - sway_log(L_INFO, "Setting container %p to floating at coordinates X:%d Y:%d, W:%d, H:%d", view, view->x, view->y, view->width, view->height); - // Change parent to active_workspace - view->parent = active_workspace; - arrange_windows(active_workspace, -1, -1); - return true; - } + remove_child(view); + add_floating(active_workspace,view); + view->x = (active_workspace->width - view->width)/2; + view->y = (active_workspace->height - view->height)/2; + arrange_windows(active_workspace, -1, -1); + if (view->desired_width != -1) { + view->width = view->desired_width; + } + if (view->desired_height != -1) { + view->height = view->desired_height; } } else { // Delete the view from the floating list and unset its is_floating flag // Using length-1 as the index is safe because the view must be the currently // focused floating output - list_del(active_workspace->floating, active_workspace->floating->length - 1); + remove_child(view); view->is_floating = false; - active_workspace->focused = NULL; // Get the properly focused container, and add in the view there swayc_t *focused = container_under_pointer(); // If focused is null, it's because the currently focused container is a workspace -- cgit v1.2.3 From c5a69828934bf07db9062bd5f24bb2ff94b45b4a Mon Sep 17 00:00:00 2001 From: taiyu Date: Wed, 19 Aug 2015 01:06:15 -0700 Subject: fixed some more bugs, moved layout_log into log.ch, restored focus_parent --- sway/commands.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index 6e1f1848..7dde78bd 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -182,20 +182,22 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { if (view->type != C_VIEW) { return true; } - int i; // Change from nonfloating to floating if (!view->is_floating) { - remove_child(view); + //Remove view from its current location + destroy_container(remove_child(view)); + + //and move it into workspace floating add_floating(active_workspace,view); view->x = (active_workspace->width - view->width)/2; view->y = (active_workspace->height - view->height)/2; - arrange_windows(active_workspace, -1, -1); if (view->desired_width != -1) { view->width = view->desired_width; } if (view->desired_height != -1) { view->height = view->desired_height; } + arrange_windows(active_workspace, -1, -1); } else { // Delete the view from the floating list and unset its is_floating flag // Using length-1 as the index is safe because the view must be the currently @@ -221,10 +223,10 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { add_sibling(focused, view); } // Refocus on the view once its been put back into the layout - set_focused_container(view); arrange_windows(active_workspace, -1, -1); return true; } + set_focused_container(view); } return true; -- cgit v1.2.3 From 95517ac77ebedb6e07011affd9520159acf38376 Mon Sep 17 00:00:00 2001 From: Syed Amer Gilani Date: Wed, 19 Aug 2015 11:27:48 +0200 Subject: fix a few possible memory leaks --- sway/commands.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index 42d6b173..ab24f6ae 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -105,6 +105,10 @@ static bool cmd_bindsym(struct sway_config *config, int argc, char **argv) { xkb_keysym_t sym = xkb_keysym_from_name(split->items[i], XKB_KEYSYM_CASE_INSENSITIVE); if (!sym) { sway_log(L_ERROR, "bindsym - unknown key %s", (char *)split->items[i]); + list_free(binding->keys); + free(binding->command); + free(binding); + list_free(split); return false; } xkb_keysym_t *key = malloc(sizeof(xkb_keysym_t)); -- cgit v1.2.3 From 8205a6fd3bb544b11c9d56abc93da02b03543297 Mon Sep 17 00:00:00 2001 From: taiyu Date: Wed, 19 Aug 2015 09:09:35 -0700 Subject: floating_modifier uses mod_keys instead of anykey --- sway/commands.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index cc51717b..37bd9b00 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -240,7 +240,24 @@ static bool cmd_floating_mod(struct sway_config *config, int argc, char **argv) if (!checkarg(argc, "floating_modifier", EXPECTED_EQUAL_TO, 1)) { return false; } - config->floating_mod = xkb_keysym_from_name(argv[0], XKB_KEYSYM_CASE_INSENSITIVE); + int i, j; + list_t *split = split_string(argv[0], "+"); + fprintf(stderr,"%s, %d,%d\n",argv[0], split->length,split->items); + config->floating_mod = 0; + + //set modifer keys + for (i = 0; i < split->length; ++i) { + for (j = 0; j < sizeof(modifiers) / sizeof(struct modifier_key); ++j) { + if (strcasecmp(modifiers[j].name, split->items[i]) == 0) { + config->floating_mod |= modifiers[j].mod; + } + } + } + list_free(split); + if (!config->floating_mod) { + sway_log(L_ERROR, "bindsym - unknown keys %s", argv[0]); + return false; + } return true; } -- cgit v1.2.3 From 289aab9f0adf856e1dc9c8bbe2108171d67c9043 Mon Sep 17 00:00:00 2001 From: taiyu Date: Wed, 19 Aug 2015 09:21:44 -0700 Subject: removed debug which shouldnt be there --- sway/commands.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index 37bd9b00..aafa51f3 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -242,7 +242,6 @@ static bool cmd_floating_mod(struct sway_config *config, int argc, char **argv) } int i, j; list_t *split = split_string(argv[0], "+"); - fprintf(stderr,"%s, %d,%d\n",argv[0], split->length,split->items); config->floating_mod = 0; //set modifer keys -- cgit v1.2.3 From 48a983316c01d9ccd9fdd7aab56ee4e779654915 Mon Sep 17 00:00:00 2001 From: taiyu Date: Wed, 19 Aug 2015 13:02:29 -0700 Subject: floating mode_toggle --- sway/commands.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index aafa51f3..f87ab0e5 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -231,6 +231,17 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { return true; } set_focused_container(view); + } else if (strcasecmp(argv[0], "mode_toggle") == 0) { + if (get_focused_view(active_workspace)->is_floating) { + if (active_workspace->children->length > 0) { + set_focused_container(get_focused_view(active_workspace->children->items[0])); + } + } else { + if (active_workspace->floating->length > 0) { + swayc_t *floating = active_workspace->floating->items[active_workspace->floating->length-1]; + set_focused_container(get_focused_view(floating)); + } + } } return true; -- cgit v1.2.3 From 29b6b2f37b3a3ec05c48c00103360b2297912e69 Mon Sep 17 00:00:00 2001 From: Luminarys Date: Wed, 19 Aug 2015 19:57:24 -0500 Subject: Fixed mode_toggle --- sway/commands.c | 51 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index f87ab0e5..f3553b03 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -231,19 +231,7 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { return true; } set_focused_container(view); - } else if (strcasecmp(argv[0], "mode_toggle") == 0) { - if (get_focused_view(active_workspace)->is_floating) { - if (active_workspace->children->length > 0) { - set_focused_container(get_focused_view(active_workspace->children->items[0])); - } - } else { - if (active_workspace->floating->length > 0) { - swayc_t *floating = active_workspace->floating->items[active_workspace->floating->length-1]; - set_focused_container(get_focused_view(floating)); - } - } } - return true; } @@ -272,6 +260,8 @@ static bool cmd_floating_mod(struct sway_config *config, int argc, char **argv) } static bool cmd_focus(struct sway_config *config, int argc, char **argv) { + static int floating_toggled_index = 0; + static int tiled_toggled_index = 0; if (!checkarg(argc, "focus", EXPECTED_EQUAL_TO, 1)) { return false; } @@ -285,7 +275,44 @@ static bool cmd_focus(struct sway_config *config, int argc, char **argv) { return move_focus(MOVE_DOWN); } else if (strcasecmp(argv[0], "parent") == 0) { return move_focus(MOVE_PARENT); + } else if (strcasecmp(argv[0], "mode_toggle") == 0) { + int i; + swayc_t *focused = get_focused_view(active_workspace); + if (focused->is_floating) { + if (active_workspace->children->length > 0) { + for (i = 0;i < active_workspace->floating->length; i++) { + if (active_workspace->floating->items[i] == focused) { + floating_toggled_index = i; + break; + } + } + if (active_workspace->children->length > tiled_toggled_index) { + set_focused_container(get_focused_view(active_workspace->children->items[tiled_toggled_index])); + } else { + set_focused_container(get_focused_view(active_workspace->children->items[0])); + tiled_toggled_index = 0; + } + } + } else { + if (active_workspace->floating->length > 0) { + for (i = 0;i < active_workspace->children->length; i++) { + if (active_workspace->children->items[i] == focused) { + tiled_toggled_index = i; + break; + } + } + if (active_workspace->floating->length > floating_toggled_index) { + swayc_t *floating = active_workspace->floating->items[floating_toggled_index]; + set_focused_container(get_focused_view(floating)); + } else { + swayc_t *floating = active_workspace->floating->items[active_workspace->floating->length - 1]; + set_focused_container(get_focused_view(floating)); + tiled_toggled_index = active_workspace->floating->length - 1; + } + } + } } + return true; } -- cgit v1.2.3 From 470b4dfbae146d83c0061b39534c16b5aad90f1c Mon Sep 17 00:00:00 2001 From: taiyu Date: Wed, 19 Aug 2015 18:59:27 -0700 Subject: key_state.ch, and command conflicts resolved --- sway/commands.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index f3553b03..66c05a0c 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -76,6 +76,18 @@ static bool checkarg(int argc, char *name, enum expected_args type, int val) { return false; } +static int bindsym_sort(const void *_lbind, const void *_rbind) { + const struct sway_binding *lbind = *(void **)_lbind; + const struct sway_binding *rbind = *(void **)_rbind; + unsigned int lmod = 0, rmod = 0, i; + + //Count how any modifiers are pressed + for (i = 0; i < 8 * sizeof(lbind->modifiers); ++i) { + lmod += lbind->modifiers & 1 << i; + rmod += rbind->modifiers & 1 << i; + } + return (rbind->keys->length + rmod) - (lbind->keys->length + lmod); +} static bool cmd_bindsym(struct sway_config *config, int argc, char **argv) { if (!checkarg(argc, "bindsym", EXPECTED_MORE_THAN, 1)) { @@ -118,7 +130,10 @@ static bool cmd_bindsym(struct sway_config *config, int argc, char **argv) { list_free(split); // TODO: Check if there are other commands with this key binding - list_add(config->current_mode->bindings, binding); + struct sway_mode *mode = config->current_mode; + list_add(mode->bindings, binding); + qsort(mode->bindings->items, mode->bindings->length, + sizeof(mode->bindings->items[0]), bindsym_sort); sway_log(L_DEBUG, "bindsym - Bound %s to command %s", argv[0], binding->command); return true; -- cgit v1.2.3 From 5ff0619ca1cab044004df044c253c9170b8316c3 Mon Sep 17 00:00:00 2001 From: taiyu Date: Wed, 19 Aug 2015 20:22:15 -0700 Subject: input state, find_container_in_direction --- sway/commands.c | 1 - 1 file changed, 1 deletion(-) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index 66c05a0c..c4cf96a2 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -243,7 +243,6 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { } // Refocus on the view once its been put back into the layout arrange_windows(active_workspace, -1, -1); - return true; } set_focused_container(view); } -- cgit v1.2.3 From fbaa9111a8525daeef8a5534784da2f793917a36 Mon Sep 17 00:00:00 2001 From: taiyu Date: Thu, 20 Aug 2015 04:47:36 -0700 Subject: setup for resizable windows, drop weight --- sway/commands.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index c4cf96a2..babefd02 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -242,6 +242,7 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { add_sibling(focused, view); } // Refocus on the view once its been put back into the layout + view->width = view->height = 0; arrange_windows(active_workspace, -1, -1); } set_focused_container(view); -- cgit v1.2.3 From f5fde7c45c04b02406eabc34cbb4248189c6a26e Mon Sep 17 00:00:00 2001 From: taiyu Date: Thu, 20 Aug 2015 05:06:22 -0700 Subject: style --- sway/commands.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index babefd02..a3f74747 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -81,7 +81,7 @@ static int bindsym_sort(const void *_lbind, const void *_rbind) { const struct sway_binding *rbind = *(void **)_rbind; unsigned int lmod = 0, rmod = 0, i; - //Count how any modifiers are pressed + // Count how any modifiers are pressed for (i = 0; i < 8 * sizeof(lbind->modifiers); ++i) { lmod += lbind->modifiers & 1 << i; rmod += rbind->modifiers & 1 << i; @@ -203,10 +203,10 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { } // Change from nonfloating to floating if (!view->is_floating) { - //Remove view from its current location + // Remove view from its current location destroy_container(remove_child(view)); - //and move it into workspace floating + // and move it into workspace floating add_floating(active_workspace,view); view->x = (active_workspace->width - view->width)/2; view->y = (active_workspace->height - view->height)/2; @@ -233,11 +233,11 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) { sway_log(L_DEBUG, "Non-floating focused container is %p", focused); - //Case of focused workspace, just create as child of it + // Case of focused workspace, just create as child of it if (focused->type == C_WORKSPACE) { add_child(focused, view); } - //Regular case, create as sibling of current container + // Regular case, create as sibling of current container else { add_sibling(focused, view); } @@ -258,7 +258,7 @@ static bool cmd_floating_mod(struct sway_config *config, int argc, char **argv) list_t *split = split_string(argv[0], "+"); config->floating_mod = 0; - //set modifer keys + // set modifer keys for (i = 0; i < split->length; ++i) { for (j = 0; j < sizeof(modifiers) / sizeof(struct modifier_key); ++j) { if (strcasecmp(modifiers[j].name, split->items[i]) == 0) { @@ -508,14 +508,14 @@ static bool cmd_fullscreen(struct sway_config *config, int argc, char **argv) { swayc_t *container = get_focused_view(&root_container); bool current = (wlc_view_get_state(container->handle) & WLC_BIT_FULLSCREEN) > 0; wlc_view_set_state(container->handle, WLC_BIT_FULLSCREEN, !current); - //Resize workspace if going from fullscreen -> notfullscreen - //otherwise just resize container + // Resize workspace if going from fullscreen -> notfullscreen + // otherwise just resize container if (current) { while (container->type != C_WORKSPACE) { container = container->parent; } } - //Only resize container when going into fullscreen + // Only resize container when going into fullscreen arrange_windows(container, -1, -1); return true; @@ -679,7 +679,7 @@ bool handle_command(struct sway_config *config, char *exec) { char **argv = split_directive(exec + strlen(handler->command), &argc); int i; - //Perform var subs on all parts of the command + // Perform var subs on all parts of the command for (i = 0; i < argc; ++i) { argv[i] = do_var_replacement(config, argv[i]); } -- cgit v1.2.3 From 579fe70ed92ce65d5a761ebdbb6c458b5f919687 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 20 Aug 2015 08:37:09 -0400 Subject: Add command line parsing Closes #6 --- sway/commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index a3f74747..803d9a21 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -414,7 +414,7 @@ static bool cmd_reload(struct sway_config *config, int argc, char **argv) { if (!checkarg(argc, "reload", EXPECTED_EQUAL_TO, 0)) { return false; } - if (!load_config()) { + if (!load_config(NULL)) { // TODO: Use config given from -c return false; } arrange_windows(&root_container, -1, -1); -- cgit v1.2.3 From 91c08772645e2162015c3acf8a8ae7187502adb4 Mon Sep 17 00:00:00 2001 From: minus Date: Wed, 19 Aug 2015 01:52:46 +0200 Subject: properly exit sway - wlc_terminate() instead of exit(0) - unlink IPC socket --- sway/commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index 803d9a21..38557b62 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -186,7 +186,7 @@ static bool cmd_exit(struct sway_config *config, int argc, char **argv) { } // Close all views container_map(&root_container, kill_views, NULL); - exit(0); + wlc_terminate(); return true; } -- cgit v1.2.3 From f26ed32e460f3007e623c529d28562f4a0b261cd Mon Sep 17 00:00:00 2001 From: minus Date: Thu, 20 Aug 2015 15:12:34 +0200 Subject: added sway_terminate to exit cleanly --- sway/commands.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index 38557b62..644b8005 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -15,6 +15,7 @@ #include "commands.h" #include "container.h" #include "handlers.h" +#include "sway.h" struct modifier_key { char *name; @@ -186,7 +187,7 @@ static bool cmd_exit(struct sway_config *config, int argc, char **argv) { } // Close all views container_map(&root_container, kill_views, NULL); - wlc_terminate(); + sway_terminate(); return true; } -- cgit v1.2.3 From 36e07e9ebc55b3fc8a8b8cd76ee743202691ad56 Mon Sep 17 00:00:00 2001 From: taiyu Date: Thu, 20 Aug 2015 09:52:54 -0700 Subject: find_parent_by_type --- sway/commands.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'sway/commands.c') diff --git a/sway/commands.c b/sway/commands.c index 644b8005..3ac7f4dd 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -390,7 +390,6 @@ static bool cmd_layout(struct sway_config *config, int argc, char **argv) { return false; } swayc_t *parent = get_focused_container(&root_container); - while (parent->type == C_VIEW) { parent = parent->parent; } @@ -512,9 +511,7 @@ static bool cmd_fullscreen(struct sway_config *config, int argc, char **argv) { // Resize workspace if going from fullscreen -> notfullscreen // otherwise just resize container if (current) { - while (container->type != C_WORKSPACE) { - container = container->parent; - } + container = swayc_parent_by_type(container, C_WORKSPACE); } // Only resize container when going into fullscreen arrange_windows(container, -1, -1); -- cgit v1.2.3