aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/client.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-04-30 21:24:13 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-04-30 21:24:13 +1000
commite67f3543332349e63b5099a241fdd85ce28ea54b (patch)
tree54bede11d48f561693d1288e0980660c644b4dc3 /sway/commands/client.c
parentMerge pull request #1873 from RyanDwyer/remove-arrange-windows (diff)
downloadsway-e67f3543332349e63b5099a241fdd85ce28ea54b.tar.gz
sway-e67f3543332349e63b5099a241fdd85ce28ea54b.tar.zst
sway-e67f3543332349e63b5099a241fdd85ce28ea54b.zip
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/client.c')
-rw-r--r--sway/commands/client.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/sway/commands/client.c b/sway/commands/client.c
new file mode 100644
index 00000000..ce519381
--- /dev/null
+++ b/sway/commands/client.c
@@ -0,0 +1,79 @@
1#include "log.h"
2#include "sway/commands.h"
3#include "sway/config.h"
4#include "sway/tree/container.h"
5
6static bool parse_color(char *hexstring, float (*dest)[4]) {
7 if (hexstring[0] != '#') {
8 return false;
9 }
10
11 if (strlen(hexstring) != 7) {
12 return false;
13 }
14
15 ++hexstring;
16 char *end;
17 uint32_t decimal = strtol(hexstring, &end, 16);
18
19 if (*end != '\0') {
20 return false;
21 }
22
23 (*dest)[0] = ((decimal >> 16) & 0xff) / 255.0;
24 (*dest)[1] = ((decimal >> 8) & 0xff) / 255.0;
25 (*dest)[2] = (decimal & 0xff) / 255.0;
26 (*dest)[3] = 1.0;
27 return true;
28}
29
30static struct cmd_results *handle_command(int argc, char **argv,
31 struct border_colors *class, char *cmd_name) {
32 struct cmd_results *error = NULL;
33 if ((error = checkarg(argc, cmd_name, EXPECTED_EQUAL_TO, 5))) {
34 return error;
35 }
36
37 if (!parse_color(argv[0], &class->border)) {
38 return cmd_results_new(CMD_INVALID, cmd_name,
39 "Unable to parse border color");
40 }
41
42 if (!parse_color(argv[1], &class->background)) {
43 return cmd_results_new(CMD_INVALID, cmd_name,
44 "Unable to parse background color");
45 }
46
47 if (!parse_color(argv[2], &class->text)) {
48 return cmd_results_new(CMD_INVALID, cmd_name,
49 "Unable to parse text color");
50 }
51
52 if (!parse_color(argv[3], &class->indicator)) {
53 return cmd_results_new(CMD_INVALID, cmd_name,
54 "Unable to parse indicator color");
55 }
56
57 if (!parse_color(argv[4], &class->child_border)) {
58 return cmd_results_new(CMD_INVALID, cmd_name,
59 "Unable to parse child border color");
60 }
61
62 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
63}
64
65struct cmd_results *cmd_client_focused(int argc, char **argv) {
66 return handle_command(argc, argv, &config->border_colors.focused, "client.focused");
67}
68
69struct cmd_results *cmd_client_focused_inactive(int argc, char **argv) {
70 return handle_command(argc, argv, &config->border_colors.focused_inactive, "client.focused_inactive");
71}
72
73struct cmd_results *cmd_client_unfocused(int argc, char **argv) {
74 return handle_command(argc, argv, &config->border_colors.unfocused, "client.unfocused");
75}
76
77struct cmd_results *cmd_client_urgent(int argc, char **argv) {
78 return handle_command(argc, argv, &config->border_colors.urgent, "client.urgent");
79}