diff options
-rw-r--r-- | include/stringop.h | 7 | ||||
-rw-r--r-- | meson.build | 16 | ||||
-rw-r--r-- | sway/commands.c | 61 | ||||
-rw-r--r-- | sway/commands/create_output.c | 4 | ||||
-rw-r--r-- | sway/desktop/output.c | 9 | ||||
-rw-r--r-- | sway/desktop/render.c | 1 | ||||
-rw-r--r-- | sway/ipc-json.c | 22 | ||||
-rw-r--r-- | swaymsg/main.c | 11 |
8 files changed, 92 insertions, 39 deletions
diff --git a/include/stringop.h b/include/stringop.h index 01bbdaa9..919e605c 100644 --- a/include/stringop.h +++ b/include/stringop.h | |||
@@ -1,12 +1,7 @@ | |||
1 | #ifndef _SWAY_STRINGOP_H | 1 | #ifndef _SWAY_STRINGOP_H |
2 | #define _SWAY_STRINGOP_H | 2 | #define _SWAY_STRINGOP_H |
3 | #include <stdlib.h> | ||
4 | #include "list.h" | ||
5 | 3 | ||
6 | #if !HAVE_DECL_SETENV | 4 | #include "list.h" |
7 | // Not sure why we need to provide this | ||
8 | extern int setenv(const char *, const char *, int); | ||
9 | #endif | ||
10 | 5 | ||
11 | // array of whitespace characters to use for delims | 6 | // array of whitespace characters to use for delims |
12 | extern const char whitespace[]; | 7 | extern const char whitespace[]; |
diff --git a/meson.build b/meson.build index 6b23b4e3..8327b763 100644 --- a/meson.build +++ b/meson.build | |||
@@ -9,11 +9,17 @@ project( | |||
9 | ], | 9 | ], |
10 | ) | 10 | ) |
11 | 11 | ||
12 | add_project_arguments('-Wno-unused-parameter', language: 'c') | 12 | add_project_arguments( |
13 | add_project_arguments('-Wno-unused-function', language: 'c') | 13 | [ |
14 | add_project_arguments('-Wno-unused-result', language: 'c') | 14 | '-DWL_HIDE_DEPRECATED', |
15 | add_project_arguments('-DWL_HIDE_DEPRECATED', language: 'c') | 15 | '-DWLR_USE_UNSTABLE', |
16 | add_project_arguments('-DWLR_USE_UNSTABLE', language: 'c') | 16 | |
17 | '-Wno-unused-parameter', | ||
18 | '-Wno-unused-result', | ||
19 | '-Wundef', | ||
20 | ], | ||
21 | language: 'c', | ||
22 | ) | ||
17 | 23 | ||
18 | cc = meson.get_compiler('c') | 24 | cc = meson.get_compiler('c') |
19 | 25 | ||
diff --git a/sway/commands.c b/sway/commands.c index 37c7169a..4b86c2fa 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -353,12 +353,14 @@ struct cmd_results *config_command(char *exec) { | |||
353 | struct cmd_results *results = NULL; | 353 | struct cmd_results *results = NULL; |
354 | int argc; | 354 | int argc; |
355 | char **argv = split_args(exec, &argc); | 355 | char **argv = split_args(exec, &argc); |
356 | |||
357 | // Check for empty lines | ||
356 | if (!argc) { | 358 | if (!argc) { |
357 | results = cmd_results_new(CMD_SUCCESS, NULL, NULL); | 359 | results = cmd_results_new(CMD_SUCCESS, NULL, NULL); |
358 | goto cleanup; | 360 | goto cleanup; |
359 | } | 361 | } |
360 | 362 | ||
361 | // Start block | 363 | // Check for the start of a block |
362 | if (argc > 1 && strcmp(argv[argc - 1], "{") == 0) { | 364 | if (argc > 1 && strcmp(argv[argc - 1], "{") == 0) { |
363 | char *block = join_args(argv, argc - 1); | 365 | char *block = join_args(argv, argc - 1); |
364 | results = cmd_results_new(CMD_BLOCK, block, NULL); | 366 | results = cmd_results_new(CMD_BLOCK, block, NULL); |
@@ -366,22 +368,54 @@ struct cmd_results *config_command(char *exec) { | |||
366 | goto cleanup; | 368 | goto cleanup; |
367 | } | 369 | } |
368 | 370 | ||
369 | // Endblock | 371 | // Check for the end of a block |
370 | if (strcmp(argv[argc - 1], "}") == 0) { | 372 | if (strcmp(argv[argc - 1], "}") == 0) { |
371 | results = cmd_results_new(CMD_BLOCK_END, NULL, NULL); | 373 | results = cmd_results_new(CMD_BLOCK_END, NULL, NULL); |
372 | goto cleanup; | 374 | goto cleanup; |
373 | } | 375 | } |
374 | wlr_log(WLR_INFO, "handling config command '%s'", exec); | 376 | |
377 | // Make sure the command is not stored in a variable | ||
378 | if (*argv[0] == '$') { | ||
379 | argv[0] = do_var_replacement(argv[0]); | ||
380 | char *temp = join_args(argv, argc); | ||
381 | free_argv(argc, argv); | ||
382 | argv = split_args(temp, &argc); | ||
383 | free(temp); | ||
384 | if (!argc) { | ||
385 | results = cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
386 | goto cleanup; | ||
387 | } | ||
388 | } | ||
389 | |||
390 | // Determine the command handler | ||
391 | wlr_log(WLR_INFO, "Config command: %s", exec); | ||
375 | struct cmd_handler *handler = find_handler(argv[0], NULL, 0); | 392 | struct cmd_handler *handler = find_handler(argv[0], NULL, 0); |
376 | if (!handler) { | 393 | if (!handler || !handler->handle) { |
377 | char *input = argv[0] ? argv[0] : "(empty)"; | 394 | char *input = argv[0] ? argv[0] : "(empty)"; |
378 | results = cmd_results_new(CMD_INVALID, input, "Unknown/invalid command"); | 395 | char *error = handler |
396 | ? "This command is shimmed, but unimplemented" | ||
397 | : "Unknown/invalid command"; | ||
398 | results = cmd_results_new(CMD_INVALID, input, error); | ||
379 | goto cleanup; | 399 | goto cleanup; |
380 | } | 400 | } |
381 | int i; | 401 | |
382 | // Var replacement, for all but first argument of set | 402 | // Do variable replacement |
383 | // TODO commands | 403 | if (handler->handle == cmd_set && argc > 1 && *argv[1] == '$') { |
384 | for (i = handler->handle == cmd_set ? 2 : 1; i < argc; ++i) { | 404 | // Escape the variable name so it does not get replaced by one shorter |
405 | char *temp = calloc(1, strlen(argv[1]) + 2); | ||
406 | temp[0] = '$'; | ||
407 | strcpy(&temp[1], argv[1]); | ||
408 | free(argv[1]); | ||
409 | argv[1] = temp; | ||
410 | } | ||
411 | char *command = do_var_replacement(join_args(argv, argc)); | ||
412 | wlr_log(WLR_INFO, "After replacement: %s", command); | ||
413 | free_argv(argc, argv); | ||
414 | argv = split_args(command, &argc); | ||
415 | free(command); | ||
416 | |||
417 | // Strip quotes and unescape the string | ||
418 | for (int i = handler->handle == cmd_set ? 2 : 1; i < argc; ++i) { | ||
385 | if (handler->handle != cmd_exec && handler->handle != cmd_exec_always | 419 | if (handler->handle != cmd_exec && handler->handle != cmd_exec_always |
386 | && handler->handle != cmd_bindsym | 420 | && handler->handle != cmd_bindsym |
387 | && handler->handle != cmd_bindcode | 421 | && handler->handle != cmd_bindcode |
@@ -389,14 +423,11 @@ struct cmd_results *config_command(char *exec) { | |||
389 | && (*argv[i] == '\"' || *argv[i] == '\'')) { | 423 | && (*argv[i] == '\"' || *argv[i] == '\'')) { |
390 | strip_quotes(argv[i]); | 424 | strip_quotes(argv[i]); |
391 | } | 425 | } |
392 | argv[i] = do_var_replacement(argv[i]); | ||
393 | unescape_string(argv[i]); | 426 | unescape_string(argv[i]); |
394 | } | 427 | } |
395 | if (handler->handle) { | 428 | |
396 | results = handler->handle(argc-1, argv+1); | 429 | // Run command |
397 | } else { | 430 | results = handler->handle(argc - 1, argv + 1); |
398 | results = cmd_results_new(CMD_INVALID, argv[0], "This command is shimmed, but unimplemented"); | ||
399 | } | ||
400 | 431 | ||
401 | cleanup: | 432 | cleanup: |
402 | free_argv(argc, argv); | 433 | free_argv(argc, argv); |
diff --git a/sway/commands/create_output.c b/sway/commands/create_output.c index 1c2464ea..3f870acb 100644 --- a/sway/commands/create_output.c +++ b/sway/commands/create_output.c | |||
@@ -1,7 +1,7 @@ | |||
1 | #include <wlr/config.h> | 1 | #include <wlr/config.h> |
2 | #include <wlr/backend/multi.h> | 2 | #include <wlr/backend/multi.h> |
3 | #include <wlr/backend/wayland.h> | 3 | #include <wlr/backend/wayland.h> |
4 | #ifdef WLR_HAS_X11_BACKEND | 4 | #if WLR_HAS_X11_BACKEND |
5 | #include <wlr/backend/x11.h> | 5 | #include <wlr/backend/x11.h> |
6 | #endif | 6 | #endif |
7 | #include "sway/commands.h" | 7 | #include "sway/commands.h" |
@@ -18,7 +18,7 @@ static void create_output(struct wlr_backend *backend, void *data) { | |||
18 | wlr_wl_output_create(backend); | 18 | wlr_wl_output_create(backend); |
19 | *done = true; | 19 | *done = true; |
20 | } | 20 | } |
21 | #ifdef WLR_HAS_X11_BACKEND | 21 | #if WLR_HAS_X11_BACKEND |
22 | else if (wlr_backend_is_x11(backend)) { | 22 | else if (wlr_backend_is_x11(backend)) { |
23 | wlr_x11_output_create(backend); | 23 | wlr_x11_output_create(backend); |
24 | *done = true; | 24 | *done = true; |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index d48ddef3..c53a9c73 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -469,15 +469,6 @@ void output_damage_box(struct sway_output *output, struct wlr_box *_box) { | |||
469 | wlr_output_damage_add_box(output->damage, &box); | 469 | wlr_output_damage_add_box(output->damage, &box); |
470 | } | 470 | } |
471 | 471 | ||
472 | static void output_damage_whole_container_iterator(struct sway_container *con, | ||
473 | void *data) { | ||
474 | if (!sway_assert(con->view, "expected a view")) { | ||
475 | return; | ||
476 | } | ||
477 | struct sway_output *output = data; | ||
478 | output_damage_view(output, con->view, true); | ||
479 | } | ||
480 | |||
481 | void output_damage_whole_container(struct sway_output *output, | 472 | void output_damage_whole_container(struct sway_output *output, |
482 | struct sway_container *con) { | 473 | struct sway_container *con) { |
483 | // Pad the box by 1px, because the width is a double and might be a fraction | 474 | // Pad the box by 1px, because the width is a double and might be a fraction |
diff --git a/sway/desktop/render.c b/sway/desktop/render.c index cf6da682..1b3b29e7 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c | |||
@@ -1019,6 +1019,7 @@ renderer_end: | |||
1019 | } | 1019 | } |
1020 | 1020 | ||
1021 | wlr_renderer_scissor(renderer, NULL); | 1021 | wlr_renderer_scissor(renderer, NULL); |
1022 | wlr_output_render_software_cursors(wlr_output, damage); | ||
1022 | wlr_renderer_end(renderer); | 1023 | wlr_renderer_end(renderer); |
1023 | if (!wlr_output_damage_swap_buffers(output->damage, when, damage)) { | 1024 | if (!wlr_output_damage_swap_buffers(output->damage, when, damage)) { |
1024 | return; | 1025 | return; |
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 4583558c..4d9a87d8 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include "sway/input/seat.h" | 12 | #include "sway/input/seat.h" |
13 | #include <wlr/types/wlr_box.h> | 13 | #include <wlr/types/wlr_box.h> |
14 | #include <wlr/types/wlr_output.h> | 14 | #include <wlr/types/wlr_output.h> |
15 | #include <xkbcommon/xkbcommon.h> | ||
15 | #include "wlr-layer-shell-unstable-v1-protocol.h" | 16 | #include "wlr-layer-shell-unstable-v1-protocol.h" |
16 | 17 | ||
17 | static const char *ipc_json_layout_description(enum sway_container_layout l) { | 18 | static const char *ipc_json_layout_description(enum sway_container_layout l) { |
@@ -503,6 +504,27 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) { | |||
503 | json_object_object_add(object, "type", | 504 | json_object_object_add(object, "type", |
504 | json_object_new_string(describe_device_type(device))); | 505 | json_object_new_string(describe_device_type(device))); |
505 | 506 | ||
507 | if (device->wlr_device->type == WLR_INPUT_DEVICE_KEYBOARD) { | ||
508 | struct wlr_keyboard *keyboard = device->wlr_device->keyboard; | ||
509 | struct xkb_keymap *keymap = keyboard->keymap; | ||
510 | struct xkb_state *state = keyboard->xkb_state; | ||
511 | xkb_layout_index_t num_layouts = xkb_keymap_num_layouts(keymap); | ||
512 | xkb_layout_index_t layout_idx; | ||
513 | for (layout_idx = 0; layout_idx < num_layouts; layout_idx++) { | ||
514 | bool is_active = | ||
515 | xkb_state_layout_index_is_active(state, | ||
516 | layout_idx, | ||
517 | XKB_STATE_LAYOUT_EFFECTIVE); | ||
518 | if (is_active) { | ||
519 | const char *layout = | ||
520 | xkb_keymap_layout_get_name(keymap, layout_idx); | ||
521 | json_object_object_add(object, "xkb_active_layout_name", | ||
522 | json_object_new_string(layout)); | ||
523 | break; | ||
524 | } | ||
525 | } | ||
526 | } | ||
527 | |||
506 | return object; | 528 | return object; |
507 | } | 529 | } |
508 | 530 | ||
diff --git a/swaymsg/main.c b/swaymsg/main.c index 663518f6..243b5fdc 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c | |||
@@ -111,7 +111,7 @@ static const char *pretty_type_name(const char *name) { | |||
111 | } | 111 | } |
112 | 112 | ||
113 | static void pretty_print_input(json_object *i) { | 113 | static void pretty_print_input(json_object *i) { |
114 | json_object *id, *name, *type, *product, *vendor; | 114 | json_object *id, *name, *type, *product, *vendor, *kbdlayout; |
115 | json_object_object_get_ex(i, "identifier", &id); | 115 | json_object_object_get_ex(i, "identifier", &id); |
116 | json_object_object_get_ex(i, "name", &name); | 116 | json_object_object_get_ex(i, "name", &name); |
117 | json_object_object_get_ex(i, "type", &type); | 117 | json_object_object_get_ex(i, "type", &type); |
@@ -123,7 +123,7 @@ static void pretty_print_input(json_object *i) { | |||
123 | " Type: %s\n" | 123 | " Type: %s\n" |
124 | " Identifier: %s\n" | 124 | " Identifier: %s\n" |
125 | " Product ID: %d\n" | 125 | " Product ID: %d\n" |
126 | " Vendor ID: %d\n\n"; | 126 | " Vendor ID: %d\n"; |
127 | 127 | ||
128 | 128 | ||
129 | printf(fmt, json_object_get_string(name), | 129 | printf(fmt, json_object_get_string(name), |
@@ -131,6 +131,13 @@ static void pretty_print_input(json_object *i) { | |||
131 | json_object_get_string(id), | 131 | json_object_get_string(id), |
132 | json_object_get_int(product), | 132 | json_object_get_int(product), |
133 | json_object_get_int(vendor)); | 133 | json_object_get_int(vendor)); |
134 | |||
135 | if (json_object_object_get_ex(i, "xkb_active_layout_name", &kbdlayout)) { | ||
136 | printf(" Active Keyboard Layout: %s\n", | ||
137 | json_object_get_string(kbdlayout)); | ||
138 | } | ||
139 | |||
140 | printf("\n"); | ||
134 | } | 141 | } |
135 | 142 | ||
136 | static void pretty_print_seat(json_object *i) { | 143 | static void pretty_print_seat(json_object *i) { |