diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-06-14 18:53:40 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-14 18:53:40 -0400 |
commit | 298f56353ef155f6a2ccc977c96b2ff5d971e65e (patch) | |
tree | dcb3b74f1dde93bce8657b7509662ffd7db667d0 /sway | |
parent | Implement KDE's server-side decoration protocol (diff) | |
parent | Merge pull request #1234 from 4e554c4c/tray (diff) | |
download | sway-298f56353ef155f6a2ccc977c96b2ff5d971e65e.tar.gz sway-298f56353ef155f6a2ccc977c96b2ff5d971e65e.tar.zst sway-298f56353ef155f6a2ccc977c96b2ff5d971e65e.zip |
Merge branch 'master' into server-decoration
Diffstat (limited to 'sway')
-rw-r--r-- | sway/border.c | 2 | ||||
-rw-r--r-- | sway/commands.c | 8 | ||||
-rw-r--r-- | sway/commands/assign.c | 3 | ||||
-rw-r--r-- | sway/commands/bar/activate_button.c | 26 | ||||
-rw-r--r-- | sway/commands/bar/context_button.c | 26 | ||||
-rw-r--r-- | sway/commands/bar/icon_theme.c | 25 | ||||
-rw-r--r-- | sway/commands/bar/secondary_button.c | 26 | ||||
-rw-r--r-- | sway/commands/bar/tray_output.c | 26 | ||||
-rw-r--r-- | sway/commands/bar/tray_padding.c | 34 | ||||
-rw-r--r-- | sway/commands/bind.c | 8 | ||||
-rw-r--r-- | sway/commands/client.c | 24 | ||||
-rw-r--r-- | sway/commands/layout.c | 4 | ||||
-rw-r--r-- | sway/commands/set.c | 2 | ||||
-rw-r--r-- | sway/config.c | 15 | ||||
-rw-r--r-- | sway/container.c | 17 | ||||
-rw-r--r-- | sway/criteria.c | 2 | ||||
-rw-r--r-- | sway/handlers.c | 22 | ||||
-rw-r--r-- | sway/input.c | 4 | ||||
-rw-r--r-- | sway/ipc-json.c | 17 | ||||
-rw-r--r-- | sway/main.c | 43 | ||||
-rw-r--r-- | sway/security.c | 2 | ||||
-rw-r--r-- | sway/sway-bar.5.txt | 36 | ||||
-rw-r--r-- | sway/sway-input.5.txt | 2 | ||||
-rw-r--r-- | sway/sway.5.txt | 5 |
24 files changed, 325 insertions, 54 deletions
diff --git a/sway/border.c b/sway/border.c index 10ad92c2..df0022ce 100644 --- a/sway/border.c +++ b/sway/border.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _XOPEN_SOURCE 700 |
2 | #include <wlc/wlc-render.h> | 2 | #include <wlc/wlc-render.h> |
3 | #include <cairo/cairo.h> | 3 | #include <cairo/cairo.h> |
4 | #include <pango/pangocairo.h> | 4 | #include <pango/pangocairo.h> |
diff --git a/sway/commands.c b/sway/commands.c index 01e5e6b5..f83b5287 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _XOPEN_SOURCE 700 |
2 | #include <xkbcommon/xkbcommon.h> | 2 | #include <xkbcommon/xkbcommon.h> |
3 | #include <xkbcommon/xkbcommon-names.h> | 3 | #include <xkbcommon/xkbcommon-names.h> |
4 | #include <wlc/wlc.h> | 4 | #include <wlc/wlc.h> |
@@ -221,18 +221,22 @@ static struct cmd_handler handlers[] = { | |||
221 | }; | 221 | }; |
222 | 222 | ||
223 | static struct cmd_handler bar_handlers[] = { | 223 | static struct cmd_handler bar_handlers[] = { |
224 | { "activate_button", bar_cmd_activate_button }, | ||
224 | { "binding_mode_indicator", bar_cmd_binding_mode_indicator }, | 225 | { "binding_mode_indicator", bar_cmd_binding_mode_indicator }, |
225 | { "bindsym", bar_cmd_bindsym }, | 226 | { "bindsym", bar_cmd_bindsym }, |
226 | { "colors", bar_cmd_colors }, | 227 | { "colors", bar_cmd_colors }, |
228 | { "context_button", bar_cmd_context_button }, | ||
227 | { "font", bar_cmd_font }, | 229 | { "font", bar_cmd_font }, |
228 | { "height", bar_cmd_height }, | 230 | { "height", bar_cmd_height }, |
229 | { "hidden_state", bar_cmd_hidden_state }, | 231 | { "hidden_state", bar_cmd_hidden_state }, |
232 | { "icon_theme", bar_cmd_icon_theme }, | ||
230 | { "id", bar_cmd_id }, | 233 | { "id", bar_cmd_id }, |
231 | { "mode", bar_cmd_mode }, | 234 | { "mode", bar_cmd_mode }, |
232 | { "modifier", bar_cmd_modifier }, | 235 | { "modifier", bar_cmd_modifier }, |
233 | { "output", bar_cmd_output }, | 236 | { "output", bar_cmd_output }, |
234 | { "pango_markup", bar_cmd_pango_markup }, | 237 | { "pango_markup", bar_cmd_pango_markup }, |
235 | { "position", bar_cmd_position }, | 238 | { "position", bar_cmd_position }, |
239 | { "secondary_button", bar_cmd_secondary_button }, | ||
236 | { "separator_symbol", bar_cmd_separator_symbol }, | 240 | { "separator_symbol", bar_cmd_separator_symbol }, |
237 | { "status_command", bar_cmd_status_command }, | 241 | { "status_command", bar_cmd_status_command }, |
238 | { "strip_workspace_numbers", bar_cmd_strip_workspace_numbers }, | 242 | { "strip_workspace_numbers", bar_cmd_strip_workspace_numbers }, |
@@ -250,7 +254,7 @@ static struct cmd_handler bar_handlers[] = { | |||
250 | */ | 254 | */ |
251 | struct cmd_results *add_color(const char *name, char *buffer, const char *color) { | 255 | struct cmd_results *add_color(const char *name, char *buffer, const char *color) { |
252 | int len = strlen(color); | 256 | int len = strlen(color); |
253 | if (len != 7 && len != 9 ) { | 257 | if (len != 7 && len != 9) { |
254 | return cmd_results_new(CMD_INVALID, name, "Invalid color definition %s", color); | 258 | return cmd_results_new(CMD_INVALID, name, "Invalid color definition %s", color); |
255 | } | 259 | } |
256 | 260 | ||
diff --git a/sway/commands/assign.c b/sway/commands/assign.c index ec262bb8..c3b03bbc 100644 --- a/sway/commands/assign.c +++ b/sway/commands/assign.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _XOPEN_SOURCE 700 |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <string.h> | 3 | #include <string.h> |
4 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
@@ -55,4 +55,3 @@ struct cmd_results *cmd_assign(int argc, char **argv) { | |||
55 | } | 55 | } |
56 | return error ? error : cmd_results_new(CMD_SUCCESS, NULL, NULL); | 56 | return error ? error : cmd_results_new(CMD_SUCCESS, NULL, NULL); |
57 | } | 57 | } |
58 | |||
diff --git a/sway/commands/bar/activate_button.c b/sway/commands/bar/activate_button.c new file mode 100644 index 00000000..32a1d3e5 --- /dev/null +++ b/sway/commands/bar/activate_button.c | |||
@@ -0,0 +1,26 @@ | |||
1 | #include <stdlib.h> | ||
2 | #include "sway/commands.h" | ||
3 | #include "log.h" | ||
4 | |||
5 | struct cmd_results *bar_cmd_activate_button(int argc, char **argv) { | ||
6 | const char *cmd_name = "activate_button"; | ||
7 | #ifndef ENABLE_TRAY | ||
8 | return cmd_results_new(CMD_INVALID, cmd_name, "Invalid %s command " | ||
9 | "%s called, but sway was compiled without tray support", | ||
10 | cmd_name, cmd_name); | ||
11 | #else | ||
12 | struct cmd_results *error = NULL; | ||
13 | if ((error = checkarg(argc, cmd_name, EXPECTED_EQUAL_TO, 1))) { | ||
14 | return error; | ||
15 | } | ||
16 | |||
17 | if (!config->current_bar) { | ||
18 | return cmd_results_new(CMD_FAILURE, cmd_name, "No bar defined."); | ||
19 | } | ||
20 | |||
21 | // User should be able to prefix with 0x or whatever they want | ||
22 | config->current_bar->secondary_button = strtoul(argv[0], NULL, 0); | ||
23 | |||
24 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
25 | #endif | ||
26 | } | ||
diff --git a/sway/commands/bar/context_button.c b/sway/commands/bar/context_button.c new file mode 100644 index 00000000..6d7d7aec --- /dev/null +++ b/sway/commands/bar/context_button.c | |||
@@ -0,0 +1,26 @@ | |||
1 | #include <stdlib.h> | ||
2 | #include "sway/commands.h" | ||
3 | #include "log.h" | ||
4 | |||
5 | struct cmd_results *bar_cmd_context_button(int argc, char **argv) { | ||
6 | const char *cmd_name = "context_button"; | ||
7 | #ifndef ENABLE_TRAY | ||
8 | return cmd_results_new(CMD_INVALID, cmd_name, "Invalid %s command " | ||
9 | "%s called, but sway was compiled without tray support", | ||
10 | cmd_name, cmd_name); | ||
11 | #else | ||
12 | struct cmd_results *error = NULL; | ||
13 | if ((error = checkarg(argc, cmd_name, EXPECTED_EQUAL_TO, 1))) { | ||
14 | return error; | ||
15 | } | ||
16 | |||
17 | if (!config->current_bar) { | ||
18 | return cmd_results_new(CMD_FAILURE, cmd_name, "No bar defined."); | ||
19 | } | ||
20 | |||
21 | // User should be able to prefix with 0x or whatever they want | ||
22 | config->current_bar->context_button = strtoul(argv[0], NULL, 0); | ||
23 | |||
24 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
25 | #endif | ||
26 | } | ||
diff --git a/sway/commands/bar/icon_theme.c b/sway/commands/bar/icon_theme.c new file mode 100644 index 00000000..cbfc0be5 --- /dev/null +++ b/sway/commands/bar/icon_theme.c | |||
@@ -0,0 +1,25 @@ | |||
1 | #define _XOPEN_SOURCE 500 | ||
2 | #include <string.h> | ||
3 | #include "sway/commands.h" | ||
4 | |||
5 | struct cmd_results *bar_cmd_icon_theme(int argc, char **argv) { | ||
6 | const char *cmd_name = "tray_output"; | ||
7 | #ifndef ENABLE_TRAY | ||
8 | return cmd_results_new(CMD_INVALID, cmd_name, "Invalid %s command " | ||
9 | "%s called, but sway was compiled without tray support", | ||
10 | cmd_name, cmd_name); | ||
11 | #else | ||
12 | struct cmd_results *error = NULL; | ||
13 | if ((error = checkarg(argc, cmd_name, EXPECTED_EQUAL_TO, 1))) { | ||
14 | return error; | ||
15 | } | ||
16 | |||
17 | if (!config->current_bar) { | ||
18 | return cmd_results_new(CMD_FAILURE, cmd_name, "No bar defined."); | ||
19 | } | ||
20 | |||
21 | config->current_bar->icon_theme = strdup(argv[0]); | ||
22 | |||
23 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
24 | #endif | ||
25 | } | ||
diff --git a/sway/commands/bar/secondary_button.c b/sway/commands/bar/secondary_button.c new file mode 100644 index 00000000..745045c5 --- /dev/null +++ b/sway/commands/bar/secondary_button.c | |||
@@ -0,0 +1,26 @@ | |||
1 | #include <stdlib.h> | ||
2 | #include "sway/commands.h" | ||
3 | #include "log.h" | ||
4 | |||
5 | struct cmd_results *bar_cmd_secondary_button(int argc, char **argv) { | ||
6 | const char *cmd_name = "secondary_button"; | ||
7 | #ifndef ENABLE_TRAY | ||
8 | return cmd_results_new(CMD_INVALID, cmd_name, "Invalid %s command " | ||
9 | "%s called, but sway was compiled without tray support", | ||
10 | cmd_name, cmd_name); | ||
11 | #else | ||
12 | struct cmd_results *error = NULL; | ||
13 | if ((error = checkarg(argc, cmd_name, EXPECTED_EQUAL_TO, 1))) { | ||
14 | return error; | ||
15 | } | ||
16 | |||
17 | if (!config->current_bar) { | ||
18 | return cmd_results_new(CMD_FAILURE, cmd_name, "No bar defined."); | ||
19 | } | ||
20 | |||
21 | // User should be able to prefix with 0x or whatever they want | ||
22 | config->current_bar->secondary_button = strtoul(argv[0], NULL, 0); | ||
23 | |||
24 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
25 | #endif | ||
26 | } | ||
diff --git a/sway/commands/bar/tray_output.c b/sway/commands/bar/tray_output.c index 8a1b5d35..012304a9 100644 --- a/sway/commands/bar/tray_output.c +++ b/sway/commands/bar/tray_output.c | |||
@@ -1,7 +1,29 @@ | |||
1 | #define _XOPEN_SOURCE 500 | ||
2 | #include <string.h> | ||
1 | #include "sway/commands.h" | 3 | #include "sway/commands.h" |
2 | #include "log.h" | ||
3 | 4 | ||
4 | struct cmd_results *bar_cmd_tray_output(int argc, char **argv) { | 5 | struct cmd_results *bar_cmd_tray_output(int argc, char **argv) { |
5 | sway_log(L_ERROR, "Warning: tray_output is not supported on wayland"); | 6 | const char *cmd_name = "tray_output"; |
7 | #ifndef ENABLE_TRAY | ||
8 | return cmd_results_new(CMD_INVALID, cmd_name, "Invalid %s command " | ||
9 | "%s called, but sway was compiled without tray support", | ||
10 | cmd_name, cmd_name); | ||
11 | #else | ||
12 | struct cmd_results *error = NULL; | ||
13 | if ((error = checkarg(argc, cmd_name, EXPECTED_EQUAL_TO, 1))) { | ||
14 | return error; | ||
15 | } | ||
16 | |||
17 | if (!config->current_bar) { | ||
18 | return cmd_results_new(CMD_FAILURE, cmd_name, "No bar defined."); | ||
19 | } | ||
20 | |||
21 | if (strcmp(argv[0], "all") == 0) { | ||
22 | // Default behaviour | ||
23 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
24 | } | ||
25 | config->current_bar->tray_output = strdup(argv[0]); | ||
26 | |||
6 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 27 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
28 | #endif | ||
7 | } | 29 | } |
diff --git a/sway/commands/bar/tray_padding.c b/sway/commands/bar/tray_padding.c index 8c559f65..ac0572ce 100644 --- a/sway/commands/bar/tray_padding.c +++ b/sway/commands/bar/tray_padding.c | |||
@@ -1,30 +1,34 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <string.h> | ||
3 | #include <strings.h> | 2 | #include <strings.h> |
4 | #include "sway/commands.h" | 3 | #include "sway/commands.h" |
5 | #include "log.h" | 4 | #include "log.h" |
6 | 5 | ||
7 | struct cmd_results *bar_cmd_tray_padding(int argc, char **argv) { | 6 | struct cmd_results *bar_cmd_tray_padding(int argc, char **argv) { |
7 | const char *cmd_name = "tray_padding"; | ||
8 | #ifndef ENABLE_TRAY | ||
9 | return cmd_results_new(CMD_INVALID, cmd_name, "Invalid %s command" | ||
10 | "%s called, but sway was compiled without tray support", | ||
11 | cmd_name, cmd_name); | ||
12 | #else | ||
8 | struct cmd_results *error = NULL; | 13 | struct cmd_results *error = NULL; |
9 | if ((error = checkarg(argc, "tray_padding", EXPECTED_AT_LEAST, 1))) { | 14 | if ((error = checkarg(argc, cmd_name, EXPECTED_AT_LEAST, 1))) { |
10 | return error; | 15 | return error; |
11 | } | 16 | } |
12 | 17 | ||
13 | if (!config->current_bar) { | 18 | if (!config->current_bar) { |
14 | return cmd_results_new(CMD_FAILURE, "tray_padding", "No bar defined."); | 19 | return cmd_results_new(CMD_FAILURE, cmd_name, "No bar defined."); |
15 | } | 20 | } |
16 | 21 | ||
17 | int padding = atoi(argv[0]); | 22 | if (argc == 1 || (argc == 2 && strcasecmp("px", argv[1]) == 0)) { |
18 | if (padding < 0) { | 23 | char *inv; |
19 | return cmd_results_new(CMD_INVALID, "tray_padding", | 24 | uint32_t padding = strtoul(argv[0], &inv, 10); |
20 | "Invalid padding value %s, minimum is 0", argv[0]); | 25 | if (*inv == '\0' || strcasecmp(inv, "px") == 0) { |
26 | config->current_bar->tray_padding = padding; | ||
27 | sway_log(L_DEBUG, "Enabling tray padding of %d px on bar: %s", padding, config->current_bar->id); | ||
28 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
29 | } | ||
21 | } | 30 | } |
22 | 31 | return cmd_results_new(CMD_FAILURE, cmd_name, | |
23 | if (argc > 1 && strcasecmp("px", argv[1]) != 0) { | 32 | "Expected 'tray_padding <padding>[px]'"); |
24 | return cmd_results_new(CMD_INVALID, "tray_padding", | 33 | #endif |
25 | "Unknown unit %s", argv[1]); | ||
26 | } | ||
27 | config->current_bar->tray_padding = padding; | ||
28 | sway_log(L_DEBUG, "Enabling tray padding of %d px on bar: %s", padding, config->current_bar->id); | ||
29 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
30 | } | 34 | } |
diff --git a/sway/commands/bind.c b/sway/commands/bind.c index 8282277b..af5a01e5 100644 --- a/sway/commands/bind.c +++ b/sway/commands/bind.c | |||
@@ -1,7 +1,9 @@ | |||
1 | #include <xkbcommon/xkbcommon.h> | 1 | #include <xkbcommon/xkbcommon.h> |
2 | #include <xkbcommon/xkbcommon-names.h> | 2 | #include <xkbcommon/xkbcommon-names.h> |
3 | #include <strings.h> | ||
3 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
4 | #include "sway/config.h" | 5 | #include "sway/config.h" |
6 | #include "sway/input_state.h" | ||
5 | #include "list.h" | 7 | #include "list.h" |
6 | #include "log.h" | 8 | #include "log.h" |
7 | #include "stringop.h" | 9 | #include "stringop.h" |
@@ -52,6 +54,12 @@ struct cmd_results *cmd_bindsym(int argc, char **argv) { | |||
52 | // Check for xkb key | 54 | // Check for xkb key |
53 | xkb_keysym_t sym = xkb_keysym_from_name(split->items[i], | 55 | xkb_keysym_t sym = xkb_keysym_from_name(split->items[i], |
54 | XKB_KEYSYM_CASE_INSENSITIVE); | 56 | XKB_KEYSYM_CASE_INSENSITIVE); |
57 | |||
58 | // Check for mouse binding | ||
59 | if (strncasecmp(split->items[i], "button", strlen("button")) == 0 && | ||
60 | strlen(split->items[i]) == strlen("button0")) { | ||
61 | sym = ((char *)split->items[i])[strlen("button")] - '1' + M_LEFT_CLICK; | ||
62 | } | ||
55 | if (!sym) { | 63 | if (!sym) { |
56 | free_sway_binding(binding); | 64 | free_sway_binding(binding); |
57 | free_flat_list(split); | 65 | free_flat_list(split); |
diff --git a/sway/commands/client.c b/sway/commands/client.c index 7954f670..f3d879cd 100644 --- a/sway/commands/client.c +++ b/sway/commands/client.c | |||
@@ -4,26 +4,30 @@ | |||
4 | 4 | ||
5 | static struct cmd_results *parse_border_color(struct border_colors *border_colors, const char *cmd_name, int argc, char **argv) { | 5 | static struct cmd_results *parse_border_color(struct border_colors *border_colors, const char *cmd_name, int argc, char **argv) { |
6 | struct cmd_results *error = NULL; | 6 | struct cmd_results *error = NULL; |
7 | if (argc != 5) { | 7 | if (argc < 3 || argc > 5) { |
8 | return cmd_results_new(CMD_INVALID, cmd_name, "Requires exactly five color values"); | 8 | return cmd_results_new(CMD_INVALID, cmd_name, "Requires between three and five color values"); |
9 | } | 9 | } |
10 | 10 | ||
11 | uint32_t colors[5]; | 11 | uint32_t *colors[5] = { |
12 | &border_colors->border, | ||
13 | &border_colors->background, | ||
14 | &border_colors->text, | ||
15 | &border_colors->indicator, | ||
16 | &border_colors->child_border | ||
17 | }; | ||
12 | int i; | 18 | int i; |
13 | for (i = 0; i < 5; i++) { | 19 | for (i = 0; i < argc; i++) { |
14 | char buffer[10]; | 20 | char buffer[10]; |
15 | error = add_color(cmd_name, buffer, argv[i]); | 21 | error = add_color(cmd_name, buffer, argv[i]); |
16 | if (error) { | 22 | if (error) { |
17 | return error; | 23 | return error; |
18 | } | 24 | } |
19 | colors[i] = strtoul(buffer+1, NULL, 16); | 25 | *colors[i] = strtoul(buffer + 1, NULL, 16); |
20 | } | 26 | } |
21 | 27 | ||
22 | border_colors->border = colors[0]; | 28 | if (argc < 5) { |
23 | border_colors->background = colors[1]; | 29 | border_colors->child_border = border_colors->background; |
24 | border_colors->text = colors[2]; | 30 | } |
25 | border_colors->indicator = colors[3]; | ||
26 | border_colors->child_border = colors[4]; | ||
27 | 31 | ||
28 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 32 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
29 | } | 33 | } |
diff --git a/sway/commands/layout.c b/sway/commands/layout.c index 40ebd590..57a86565 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c | |||
@@ -85,6 +85,10 @@ static struct cmd_results *cmd_layout_auto(swayc_t *container, int argc, char ** | |||
85 | enum swayc_layouts old_layout = container->layout; | 85 | enum swayc_layouts old_layout = container->layout; |
86 | enum swayc_layouts layout = old_layout; | 86 | enum swayc_layouts layout = old_layout; |
87 | 87 | ||
88 | if ((error = checkarg(argc, "layout auto", EXPECTED_MORE_THAN, 1))) { | ||
89 | return error; | ||
90 | } | ||
91 | |||
88 | if (strcasecmp(argv[1], "left") == 0) { | 92 | if (strcasecmp(argv[1], "left") == 0) { |
89 | layout = L_AUTO_LEFT; | 93 | layout = L_AUTO_LEFT; |
90 | } else if (strcasecmp(argv[1], "right") == 0) { | 94 | } else if (strcasecmp(argv[1], "right") == 0) { |
diff --git a/sway/commands/set.c b/sway/commands/set.c index 1d6bce04..e3d08dd3 100644 --- a/sway/commands/set.c +++ b/sway/commands/set.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _XOPEN_SOURCE 700 |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <string.h> | 3 | #include <string.h> |
4 | #include <strings.h> | 4 | #include <strings.h> |
diff --git a/sway/config.c b/sway/config.c index 19b1882f..e0b65615 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -1,5 +1,5 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #define _XOPEN_SOURCE 500 | 2 | #define _XOPEN_SOURCE 700 |
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <stdbool.h> | 4 | #include <stdbool.h> |
5 | #include <stdlib.h> | 5 | #include <stdlib.h> |
@@ -69,6 +69,10 @@ static void free_bar(struct bar_config *bar) { | |||
69 | } | 69 | } |
70 | free(bar->mode); | 70 | free(bar->mode); |
71 | free(bar->hidden_state); | 71 | free(bar->hidden_state); |
72 | #ifdef ENABLE_TRAY | ||
73 | free(bar->tray_output); | ||
74 | free(bar->icon_theme); | ||
75 | #endif | ||
72 | free(bar->status_command); | 76 | free(bar->status_command); |
73 | free(bar->font); | 77 | free(bar->font); |
74 | free(bar->separator_symbol); | 78 | free(bar->separator_symbol); |
@@ -527,7 +531,7 @@ bool load_main_config(const char *file, bool is_active) { | |||
527 | list_add(config->config_chain, path); | 531 | list_add(config->config_chain, path); |
528 | 532 | ||
529 | config->reading = true; | 533 | config->reading = true; |
530 | 534 | ||
531 | // Read security configs | 535 | // Read security configs |
532 | bool success = true; | 536 | bool success = true; |
533 | DIR *dir = opendir(SYSCONFDIR "/sway/security.d"); | 537 | DIR *dir = opendir(SYSCONFDIR "/sway/security.d"); |
@@ -1386,7 +1390,14 @@ struct bar_config *default_bar_config(void) { | |||
1386 | bar->separator_symbol = NULL; | 1390 | bar->separator_symbol = NULL; |
1387 | bar->strip_workspace_numbers = false; | 1391 | bar->strip_workspace_numbers = false; |
1388 | bar->binding_mode_indicator = true; | 1392 | bar->binding_mode_indicator = true; |
1393 | #ifdef ENABLE_TRAY | ||
1394 | bar->tray_output = NULL; | ||
1395 | bar->icon_theme = NULL; | ||
1389 | bar->tray_padding = 2; | 1396 | bar->tray_padding = 2; |
1397 | bar->activate_button = 0x110; /* BTN_LEFT */ | ||
1398 | bar->context_button = 0x111; /* BTN_RIGHT */ | ||
1399 | bar->secondary_button = 0x112; /* BTN_MIDDLE */ | ||
1400 | #endif | ||
1390 | bar->verbose = false; | 1401 | bar->verbose = false; |
1391 | bar->pid = 0; | 1402 | bar->pid = 0; |
1392 | // set default colors | 1403 | // set default colors |
diff --git a/sway/container.c b/sway/container.c index 08aa77a8..358ba767 100644 --- a/sway/container.c +++ b/sway/container.c | |||
@@ -699,12 +699,12 @@ static bool pointer_test(swayc_t *view, void *_origin) { | |||
699 | 699 | ||
700 | swayc_t *container_under_pointer(void) { | 700 | swayc_t *container_under_pointer(void) { |
701 | // root.output->workspace | 701 | // root.output->workspace |
702 | if (!root_container.focused || !root_container.focused->focused) { | 702 | if (!root_container.focused) { |
703 | return NULL; | 703 | return NULL; |
704 | } | 704 | } |
705 | swayc_t *lookup = root_container.focused->focused; | 705 | swayc_t *lookup = root_container.focused; |
706 | // Case of empty workspace | 706 | // Case of empty workspace |
707 | if (lookup->children == 0) { | 707 | if (lookup->children && !lookup->unmanaged) { |
708 | return NULL; | 708 | return NULL; |
709 | } | 709 | } |
710 | struct wlc_point origin; | 710 | struct wlc_point origin; |
@@ -712,6 +712,17 @@ swayc_t *container_under_pointer(void) { | |||
712 | while (lookup && lookup->type != C_VIEW) { | 712 | while (lookup && lookup->type != C_VIEW) { |
713 | int i; | 713 | int i; |
714 | int len; | 714 | int len; |
715 | for (int _i = 0; lookup->unmanaged && _i < lookup->unmanaged->length; ++_i) { | ||
716 | wlc_handle *handle = lookup->unmanaged->items[_i]; | ||
717 | const struct wlc_geometry *geo = wlc_view_get_geometry(*handle); | ||
718 | if (origin.x >= geo->origin.x && origin.y >= geo->origin.y | ||
719 | && origin.x < geo->origin.x + (int)geo->size.w | ||
720 | && origin.y < geo->origin.y + (int)geo->size.h) { | ||
721 | // Hack: we force focus upon unmanaged views here | ||
722 | wlc_view_focus(*handle); | ||
723 | return NULL; | ||
724 | } | ||
725 | } | ||
715 | // if tabbed/stacked go directly to focused container, otherwise search | 726 | // if tabbed/stacked go directly to focused container, otherwise search |
716 | // children | 727 | // children |
717 | if (lookup->layout == L_TABBED || lookup->layout == L_STACKED) { | 728 | if (lookup->layout == L_TABBED || lookup->layout == L_STACKED) { |
diff --git a/sway/criteria.c b/sway/criteria.c index 1ea8311e..04683f66 100644 --- a/sway/criteria.c +++ b/sway/criteria.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _XOPEN_SOURCE 700 |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <stdbool.h> | 4 | #include <stdbool.h> |
diff --git a/sway/handlers.c b/sway/handlers.c index 0aa35c26..39261e3d 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -609,6 +609,8 @@ static void handle_view_geometry_request(wlc_handle handle, const struct wlc_geo | |||
609 | view->y = geometry->origin.y; | 609 | view->y = geometry->origin.y; |
610 | update_geometry(view); | 610 | update_geometry(view); |
611 | } | 611 | } |
612 | } else { | ||
613 | wlc_view_set_geometry(handle, 0, geometry); | ||
612 | } | 614 | } |
613 | } | 615 | } |
614 | 616 | ||
@@ -927,6 +929,26 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w | |||
927 | // Update view pointer is on | 929 | // Update view pointer is on |
928 | pointer_state.view = container_under_pointer(); | 930 | pointer_state.view = container_under_pointer(); |
929 | 931 | ||
932 | struct sway_mode *mode = config->current_mode; | ||
933 | // handle bindings | ||
934 | for (int i = 0; i < mode->bindings->length; ++i) { | ||
935 | struct sway_binding *binding = mode->bindings->items[i]; | ||
936 | if ((modifiers->mods ^ binding->modifiers) == 0) { | ||
937 | switch (state) { | ||
938 | case WLC_BUTTON_STATE_PRESSED: { | ||
939 | if (!binding->release && handle_bindsym(binding, button, 0)) { | ||
940 | return EVENT_HANDLED; | ||
941 | } | ||
942 | } | ||
943 | case WLC_BUTTON_STATE_RELEASED: | ||
944 | if (binding->release && handle_bindsym(binding, button, 0)) { | ||
945 | return EVENT_HANDLED; | ||
946 | } | ||
947 | break; | ||
948 | } | ||
949 | } | ||
950 | } | ||
951 | |||
930 | // Update pointer_state | 952 | // Update pointer_state |
931 | switch (button) { | 953 | switch (button) { |
932 | case M_LEFT_CLICK: | 954 | case M_LEFT_CLICK: |
diff --git a/sway/input.c b/sway/input.c index 4f1ef760..6263f79f 100644 --- a/sway/input.c +++ b/sway/input.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _XOPEN_SOURCE 700 |
2 | #include <ctype.h> | 2 | #include <ctype.h> |
3 | #include <float.h> | 3 | #include <float.h> |
4 | #include <limits.h> | 4 | #include <limits.h> |
@@ -60,7 +60,7 @@ char *libinput_dev_unique_id(struct libinput_device *device) { | |||
60 | } | 60 | } |
61 | 61 | ||
62 | const char *fmt = "%d:%d:%s"; | 62 | const char *fmt = "%d:%d:%s"; |
63 | snprintf(identifier, len, fmt, vendor, product, name); | 63 | snprintf(identifier, len, fmt, vendor, product, name); |
64 | free(name); | 64 | free(name); |
65 | return identifier; | 65 | return identifier; |
66 | } | 66 | } |
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 512144a4..31de53f0 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -327,7 +327,22 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) { | |||
327 | 327 | ||
328 | json_object *json = json_object_new_object(); | 328 | json_object *json = json_object_new_object(); |
329 | json_object_object_add(json, "id", json_object_new_string(bar->id)); | 329 | json_object_object_add(json, "id", json_object_new_string(bar->id)); |
330 | json_object_object_add(json, "tray_output", NULL); | 330 | #ifdef ENABLE_TRAY |
331 | if (bar->tray_output) { | ||
332 | json_object_object_add(json, "tray_output", json_object_new_string(bar->tray_output)); | ||
333 | } else { | ||
334 | json_object_object_add(json, "tray_output", NULL); | ||
335 | } | ||
336 | if (bar->icon_theme) { | ||
337 | json_object_object_add(json, "icon_theme", json_object_new_string(bar->icon_theme)); | ||
338 | } else { | ||
339 | json_object_object_add(json, "icon_theme", NULL); | ||
340 | } | ||
341 | json_object_object_add(json, "tray_padding", json_object_new_int(bar->tray_padding)); | ||
342 | json_object_object_add(json, "activate_button", json_object_new_int(bar->activate_button)); | ||
343 | json_object_object_add(json, "context_button", json_object_new_int(bar->context_button)); | ||
344 | json_object_object_add(json, "secondary_button", json_object_new_int(bar->secondary_button)); | ||
345 | #endif | ||
331 | json_object_object_add(json, "mode", json_object_new_string(bar->mode)); | 346 | json_object_object_add(json, "mode", json_object_new_string(bar->mode)); |
332 | json_object_object_add(json, "hidden_state", json_object_new_string(bar->hidden_state)); | 347 | json_object_object_add(json, "hidden_state", json_object_new_string(bar->hidden_state)); |
333 | json_object_object_add(json, "modifier", json_object_new_string(get_modifier_name_by_mask(bar->modifier))); | 348 | json_object_object_add(json, "modifier", json_object_new_string(get_modifier_name_by_mask(bar->modifier))); |
diff --git a/sway/main.c b/sway/main.c index b9549b12..82375e0b 100644 --- a/sway/main.c +++ b/sway/main.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _XOPEN_SOURCE 700 |
2 | #define _POSIX_C_SOURCE 200112L | 2 | #define _POSIX_C_SOURCE 200112L |
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
@@ -27,6 +27,7 @@ | |||
27 | #include "stringop.h" | 27 | #include "stringop.h" |
28 | #include "sway.h" | 28 | #include "sway.h" |
29 | #include "log.h" | 29 | #include "log.h" |
30 | #include "util.h" | ||
30 | 31 | ||
31 | static bool terminate_request = false; | 32 | static bool terminate_request = false; |
32 | static int exit_value = 0; | 33 | static int exit_value = 0; |
@@ -209,6 +210,27 @@ static void security_sanity_check() { | |||
209 | #endif | 210 | #endif |
210 | } | 211 | } |
211 | 212 | ||
213 | static void executable_sanity_check() { | ||
214 | #ifdef __linux__ | ||
215 | struct stat sb; | ||
216 | char *exe = realpath("/proc/self/exe", NULL); | ||
217 | stat(exe, &sb); | ||
218 | // We assume that cap_get_file returning NULL implies ENODATA | ||
219 | if (sb.st_mode & (S_ISUID|S_ISGID) && cap_get_file(exe)) { | ||
220 | sway_log(L_ERROR, | ||
221 | "sway executable has both the s(g)uid bit AND file caps set."); | ||
222 | sway_log(L_ERROR, | ||
223 | "This is strongly discouraged (and completely broken)."); | ||
224 | sway_log(L_ERROR, | ||
225 | "Please clear one of them (either the suid bit, or the file caps)."); | ||
226 | sway_log(L_ERROR, | ||
227 | "If unsure, strip the file caps."); | ||
228 | exit(EXIT_FAILURE); | ||
229 | } | ||
230 | free(exe); | ||
231 | #endif | ||
232 | } | ||
233 | |||
212 | int main(int argc, char **argv) { | 234 | int main(int argc, char **argv) { |
213 | static int verbose = 0, debug = 0, validate = 0; | 235 | static int verbose = 0, debug = 0, validate = 0; |
214 | 236 | ||
@@ -288,6 +310,15 @@ int main(int argc, char **argv) { | |||
288 | } | 310 | } |
289 | } | 311 | } |
290 | 312 | ||
313 | // we need to setup logging before wlc_init in case it fails. | ||
314 | if (debug) { | ||
315 | init_log(L_DEBUG); | ||
316 | } else if (verbose || validate) { | ||
317 | init_log(L_INFO); | ||
318 | } else { | ||
319 | init_log(L_ERROR); | ||
320 | } | ||
321 | |||
291 | if (optind < argc) { // Behave as IPC client | 322 | if (optind < argc) { // Behave as IPC client |
292 | if(optind != 1) { | 323 | if(optind != 1) { |
293 | sway_log(L_ERROR, "Don't use options with the IPC client"); | 324 | sway_log(L_ERROR, "Don't use options with the IPC client"); |
@@ -317,6 +348,7 @@ int main(int argc, char **argv) { | |||
317 | return 0; | 348 | return 0; |
318 | } | 349 | } |
319 | 350 | ||
351 | executable_sanity_check(); | ||
320 | #ifdef __linux__ | 352 | #ifdef __linux__ |
321 | bool suid = false; | 353 | bool suid = false; |
322 | if (getuid() != geteuid() || getgid() != getegid()) { | 354 | if (getuid() != geteuid() || getgid() != getegid()) { |
@@ -329,14 +361,6 @@ int main(int argc, char **argv) { | |||
329 | } | 361 | } |
330 | #endif | 362 | #endif |
331 | 363 | ||
332 | // we need to setup logging before wlc_init in case it fails. | ||
333 | if (debug) { | ||
334 | init_log(L_DEBUG); | ||
335 | } else if (verbose || validate) { | ||
336 | init_log(L_INFO); | ||
337 | } else { | ||
338 | init_log(L_ERROR); | ||
339 | } | ||
340 | wlc_log_set_handler(wlc_log_handler); | 364 | wlc_log_set_handler(wlc_log_handler); |
341 | log_kernel(); | 365 | log_kernel(); |
342 | log_distro(); | 366 | log_distro(); |
@@ -409,4 +433,3 @@ int main(int argc, char **argv) { | |||
409 | 433 | ||
410 | return exit_value; | 434 | return exit_value; |
411 | } | 435 | } |
412 | |||
diff --git a/sway/security.c b/sway/security.c index 8eab6126..92de06c1 100644 --- a/sway/security.c +++ b/sway/security.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _XOPEN_SOURCE 700 |
2 | #include <sys/types.h> | 2 | #include <sys/types.h> |
3 | #include <sys/stat.h> | 3 | #include <sys/stat.h> |
4 | #include <string.h> | 4 | #include <string.h> |
diff --git a/sway/sway-bar.5.txt b/sway/sway-bar.5.txt index 5a52e7db..29487662 100644 --- a/sway/sway-bar.5.txt +++ b/sway/sway-bar.5.txt | |||
@@ -65,6 +65,42 @@ Commands | |||
65 | **height** <height>:: | 65 | **height** <height>:: |
66 | Sets the height of the bar. Default height will match the font size. | 66 | Sets the height of the bar. Default height will match the font size. |
67 | 67 | ||
68 | Tray | ||
69 | ---- | ||
70 | |||
71 | Swaybar provides a system tray where programs such as NetworkManager, VLC, | ||
72 | Pidgin, etc. can place little icons. The following commands configure | ||
73 | interaction with the tray or individual icons. | ||
74 | The _button_ argument in all following commands is a Linux input event code as | ||
75 | defined in linux/input-event-codes.h. This is because wayland defines button | ||
76 | codes in this manner. | ||
77 | |||
78 | **activate_button** <button>:: | ||
79 | Sets the button to be used for the _activate_ (primary click) tray item | ||
80 | event. By default is BTN_LEFT (0x110). | ||
81 | |||
82 | **context_button** <button>:: | ||
83 | Sets the button to be used for the _context menu_ (right click) tray item | ||
84 | event. By default is BTN_RIGHT (0x111). | ||
85 | |||
86 | **secondary_button** <button>:: | ||
87 | Sets the button to be used for the _secondary_ (middle click) tray item | ||
88 | event. By default is BTN_MIDDLE (0x112). | ||
89 | |||
90 | **tray_output** none|all|<name>:: | ||
91 | Sets the output that the tray will appear on or none. Unlike i3bar, swaybar | ||
92 | should be able to show icons on any number of bars and outputs without | ||
93 | races. Because of this, the default value for this is _all_. | ||
94 | |||
95 | **tray_padding** <px> [px]:: | ||
96 | Sets the pixel padding of the system tray. This padding will surround the | ||
97 | tray on all sides and between each item. The default value for _px_ is 2. | ||
98 | |||
99 | **icon_theme** <name>:: | ||
100 | Sets the icon theme that sway will look for item icons in. This option has | ||
101 | no default value, because sway will always default to the fallback theme, | ||
102 | hicolor. | ||
103 | |||
68 | Colors | 104 | Colors |
69 | ------ | 105 | ------ |
70 | 106 | ||
diff --git a/sway/sway-input.5.txt b/sway/sway-input.5.txt index e92b523a..f44a3179 100644 --- a/sway/sway-input.5.txt +++ b/sway/sway-input.5.txt | |||
@@ -30,7 +30,7 @@ Commands | |||
30 | **input** <identifier> dwt <enabled|disabled>:: | 30 | **input** <identifier> dwt <enabled|disabled>:: |
31 | Enables or disables disable-while-typing for the specified input device. | 31 | Enables or disables disable-while-typing for the specified input device. |
32 | 32 | ||
33 | **input** <identifier> events <enable|disabled>:: | 33 | **input** <identifier> events <enabled|disabled|disabled_on_external_mouse>:: |
34 | Enables or disables send_events for specified input device. | 34 | Enables or disables send_events for specified input device. |
35 | (Disabling send_events disables the input device) | 35 | (Disabling send_events disables the input device) |
36 | 36 | ||
diff --git a/sway/sway.5.txt b/sway/sway.5.txt index 1fa0b856..131780e2 100644 --- a/sway/sway.5.txt +++ b/sway/sway.5.txt | |||
@@ -276,6 +276,11 @@ The default colors are: | |||
276 | **focus_follows_mouse** <yes|no>:: | 276 | **focus_follows_mouse** <yes|no>:: |
277 | If set to _yes_, moving your mouse over a window will focus that window. | 277 | If set to _yes_, moving your mouse over a window will focus that window. |
278 | 278 | ||
279 | **font** <font>:: | ||
280 | Sets font for use in title bars. Generally the format is something like "Name | ||
281 | Style Size" e.g. "Deja Vu Sans Book 12". You can also use Pango font | ||
282 | descriptions with "pango:font". | ||
283 | |||
279 | **for_window** <criteria> <command>:: | 284 | **for_window** <criteria> <command>:: |
280 | Whenever a window that matches _criteria_ appears, run list of commands. See | 285 | Whenever a window that matches _criteria_ appears, run list of commands. See |
281 | **Criteria** section below. | 286 | **Criteria** section below. |