aboutsummaryrefslogtreecommitdiff
path: root/sway/commands/border.c
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2018-04-30 21:24:13 +1000
committerDrew DeVault <sir@cmpwn.com>2018-05-01 07:46:57 -0400
commit630ba30e3c60cfe3f1018b4a1701f0c2a0f6da9a (patch)
treeda0aa984dd39f3501c4d9facd5c6a2f340ab2da4 /sway/commands/border.c
parentbf0603cd2d905554cc57d121b56b6708bb1d382b (diff)
Implement borders
Implements rendering of borders. Title text is still to do. Implements the following configuration directives: * client.focused * client.focused_inactive * client.unfocused * client.urgent * border * default_border
Diffstat (limited to 'sway/commands/border.c')
-rw-r--r--sway/commands/border.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/sway/commands/border.c b/sway/commands/border.c
new file mode 100644
index 00000000..873abb68
--- /dev/null
+++ b/sway/commands/border.c
@@ -0,0 +1,41 @@
+#include "log.h"
+#include "sway/commands.h"
+#include "sway/config.h"
+#include "sway/tree/container.h"
+#include "sway/tree/view.h"
+
+struct cmd_results *cmd_border(int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "border", EXPECTED_AT_LEAST, 1))) {
+ return error;
+ }
+
+ struct sway_container *container =
+ config->handler_context.current_container;
+ if (container->type != C_VIEW) {
+ return cmd_results_new(CMD_INVALID, "border",
+ "Only views can have borders");
+ }
+ struct sway_view *view = container->sway_view;
+
+ if (strcmp(argv[0], "none") == 0) {
+ view->border = B_NONE;
+ } else if (strcmp(argv[0], "normal") == 0) {
+ view->border = B_NORMAL;
+ } else if (strcmp(argv[0], "pixel") == 0) {
+ view->border = B_PIXEL;
+ if (argc == 2) {
+ view->border_thickness = atoi(argv[1]);
+ }
+ } else if (strcmp(argv[0], "toggle") == 0) {
+ view->border = (view->border + 1) % 3;
+ } else {
+ return cmd_results_new(CMD_INVALID, "border",
+ "Expected 'border <none|normal|pixel|toggle>' "
+ "or 'border pixel <px>'");
+ }
+
+ view_autoconfigure(view);
+
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}