diff options
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/border.c | 8 | ||||
-rw-r--r-- | sway/commands/floating.c | 40 | ||||
-rw-r--r-- | sway/commands/layout.c | 10 | ||||
-rw-r--r-- | sway/commands/move.c | 6 | ||||
-rw-r--r-- | sway/commands/split.c | 15 | ||||
-rw-r--r-- | sway/commands/sticky.c | 40 |
6 files changed, 101 insertions, 18 deletions
diff --git a/sway/commands/border.c b/sway/commands/border.c index 4ba361da..0b059562 100644 --- a/sway/commands/border.c +++ b/sway/commands/border.c @@ -37,7 +37,13 @@ struct cmd_results *cmd_border(int argc, char **argv) { "or 'border pixel <px>'"); } - view_autoconfigure(view); + if (container_is_floating(view->swayc)) { + container_damage_whole(view->swayc); + container_set_geometry_from_floating_view(view->swayc); + container_damage_whole(view->swayc); + } else { + view_autoconfigure(view); + } struct sway_seat *seat = input_manager_current_seat(input_manager); if (seat->cursor) { diff --git a/sway/commands/floating.c b/sway/commands/floating.c new file mode 100644 index 00000000..46b761da --- /dev/null +++ b/sway/commands/floating.c @@ -0,0 +1,40 @@ +#include <string.h> +#include <strings.h> +#include "sway/commands.h" +#include "sway/input/seat.h" +#include "sway/ipc-server.h" +#include "sway/output.h" +#include "sway/tree/arrange.h" +#include "sway/tree/container.h" +#include "sway/tree/layout.h" +#include "sway/tree/view.h" +#include "list.h" + +struct cmd_results *cmd_floating(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "floating", EXPECTED_EQUAL_TO, 1))) { + return error; + } + struct sway_container *container = + config->handler_context.current_container; + if (container->type != C_VIEW) { + // TODO: This doesn't strictly speaking have to be true + return cmd_results_new(CMD_INVALID, "float", "Only views can float"); + } + + bool wants_floating; + if (strcasecmp(argv[0], "enable") == 0) { + wants_floating = true; + } else if (strcasecmp(argv[0], "disable") == 0) { + wants_floating = false; + } else if (strcasecmp(argv[0], "toggle") == 0) { + wants_floating = !container_is_floating(container); + } else { + return cmd_results_new(CMD_FAILURE, "floating", + "Expected 'floating <enable|disable|toggle>'"); + } + + container_set_floating(container, wants_floating); + + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} diff --git a/sway/commands/layout.c b/sway/commands/layout.c index 6b44b001..a009e38f 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c @@ -12,19 +12,15 @@ struct cmd_results *cmd_layout(int argc, char **argv) { } struct sway_container *parent = config->handler_context.current_container; - // TODO: floating - /* - if (parent->is_floating) { - return cmd_results_new(CMD_FAILURE, "layout", "Unable to change layout of floating windows"); + if (container_is_floating(parent)) { + return cmd_results_new(CMD_FAILURE, "layout", + "Unable to change layout of floating windows"); } - */ while (parent->type == C_VIEW) { parent = parent->parent; } - // TODO: stacks and tabs - if (strcasecmp(argv[0], "default") == 0) { parent->layout = parent->prev_layout; if (parent->layout == L_NONE) { diff --git a/sway/commands/move.c b/sway/commands/move.c index 890b1a8c..dc9a6f6f 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c @@ -13,16 +13,14 @@ #include "stringop.h" #include "list.h" -static const char* expected_syntax = +static const char* expected_syntax = "Expected 'move <left|right|up|down> <[px] px>' or " "'move <container|window> to workspace <name>' or " "'move <container|window|workspace> to output <name|direction>' or " "'move position mouse'"; static struct sway_container *output_in_direction(const char *direction, - struct wlr_output *reference, int ref_ox, int ref_oy) { - int ref_lx = ref_ox + reference->lx, - ref_ly = ref_oy + reference->ly; + struct wlr_output *reference, int ref_lx, int ref_ly) { struct { char *name; enum wlr_direction direction; diff --git a/sway/commands/split.c b/sway/commands/split.c index 0a61ac8d..57e42a5a 100644 --- a/sway/commands/split.c +++ b/sway/commands/split.c @@ -10,6 +10,10 @@ static struct cmd_results *do_split(int layout) { struct sway_container *con = config->handler_context.current_container; + if (container_is_floating(con)) { + return cmd_results_new(CMD_FAILURE, "split", + "Can't split a floating view"); + } struct sway_container *parent = container_split(con, layout); container_create_notify(parent); arrange_children_of(parent); @@ -23,24 +27,23 @@ struct cmd_results *cmd_split(int argc, char **argv) { return error; } if (strcasecmp(argv[0], "v") == 0 || strcasecmp(argv[0], "vertical") == 0) { - do_split(L_VERT); + return do_split(L_VERT); } else if (strcasecmp(argv[0], "h") == 0 || strcasecmp(argv[0], "horizontal") == 0) { - do_split(L_HORIZ); + return do_split(L_HORIZ); } else if (strcasecmp(argv[0], "t") == 0 || strcasecmp(argv[0], "toggle") == 0) { struct sway_container *focused = config->handler_context.current_container; if (focused->parent->layout == L_VERT) { - do_split(L_HORIZ); + return do_split(L_HORIZ); } else { - do_split(L_VERT); + return do_split(L_VERT); } } else { - error = cmd_results_new(CMD_FAILURE, "split", + return cmd_results_new(CMD_FAILURE, "split", "Invalid split command (expected either horizontal or vertical)."); - return error; } return cmd_results_new(CMD_SUCCESS, NULL, NULL); } diff --git a/sway/commands/sticky.c b/sway/commands/sticky.c new file mode 100644 index 00000000..732ccb98 --- /dev/null +++ b/sway/commands/sticky.c @@ -0,0 +1,40 @@ +#include <string.h> +#include <strings.h> +#include "sway/commands.h" +#include "sway/input/seat.h" +#include "sway/ipc-server.h" +#include "sway/output.h" +#include "sway/tree/arrange.h" +#include "sway/tree/container.h" +#include "sway/tree/layout.h" +#include "sway/tree/view.h" +#include "list.h" + +struct cmd_results *cmd_sticky(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "sticky", EXPECTED_EQUAL_TO, 1))) { + return error; + } + struct sway_container *container = + config->handler_context.current_container; + if (!container_is_floating(container)) { + return cmd_results_new(CMD_FAILURE, "sticky", + "Can't set sticky on a tiled container"); + } + + bool wants_sticky; + if (strcasecmp(argv[0], "enable") == 0) { + wants_sticky = true; + } else if (strcasecmp(argv[0], "disable") == 0) { + wants_sticky = false; + } else if (strcasecmp(argv[0], "toggle") == 0) { + wants_sticky = !container->is_sticky; + } else { + return cmd_results_new(CMD_FAILURE, "sticky", + "Expected 'sticky <enable|disable|toggle>'"); + } + + container->is_sticky = wants_sticky; + + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} |