aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/stringop.h7
-rw-r--r--meson.build16
-rw-r--r--sway/commands.c61
-rw-r--r--sway/commands/create_output.c4
-rw-r--r--sway/desktop/output.c9
-rw-r--r--sway/desktop/render.c1
-rw-r--r--sway/ipc-json.c22
-rw-r--r--swaymsg/main.c11
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 @@
#ifndef _SWAY_STRINGOP_H
#define _SWAY_STRINGOP_H
-#include <stdlib.h>
-#include "list.h"
-#if !HAVE_DECL_SETENV
-// Not sure why we need to provide this
-extern int setenv(const char *, const char *, int);
-#endif
+#include "list.h"
// array of whitespace characters to use for delims
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(
],
)
-add_project_arguments('-Wno-unused-parameter', language: 'c')
-add_project_arguments('-Wno-unused-function', language: 'c')
-add_project_arguments('-Wno-unused-result', language: 'c')
-add_project_arguments('-DWL_HIDE_DEPRECATED', language: 'c')
-add_project_arguments('-DWLR_USE_UNSTABLE', language: 'c')
+add_project_arguments(
+ [
+ '-DWL_HIDE_DEPRECATED',
+ '-DWLR_USE_UNSTABLE',
+
+ '-Wno-unused-parameter',
+ '-Wno-unused-result',
+ '-Wundef',
+ ],
+ language: 'c',
+)
cc = meson.get_compiler('c')
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) {
struct cmd_results *results = NULL;
int argc;
char **argv = split_args(exec, &argc);
+
+ // Check for empty lines
if (!argc) {
results = cmd_results_new(CMD_SUCCESS, NULL, NULL);
goto cleanup;
}
- // Start block
+ // Check for the start of a block
if (argc > 1 && strcmp(argv[argc - 1], "{") == 0) {
char *block = join_args(argv, argc - 1);
results = cmd_results_new(CMD_BLOCK, block, NULL);
@@ -366,22 +368,54 @@ struct cmd_results *config_command(char *exec) {
goto cleanup;
}
- // Endblock
+ // Check for the end of a block
if (strcmp(argv[argc - 1], "}") == 0) {
results = cmd_results_new(CMD_BLOCK_END, NULL, NULL);
goto cleanup;
}
- wlr_log(WLR_INFO, "handling config command '%s'", exec);
+
+ // Make sure the command is not stored in a variable
+ if (*argv[0] == '$') {
+ argv[0] = do_var_replacement(argv[0]);
+ char *temp = join_args(argv, argc);
+ free_argv(argc, argv);
+ argv = split_args(temp, &argc);
+ free(temp);
+ if (!argc) {
+ results = cmd_results_new(CMD_SUCCESS, NULL, NULL);
+ goto cleanup;
+ }
+ }
+
+ // Determine the command handler
+ wlr_log(WLR_INFO, "Config command: %s", exec);
struct cmd_handler *handler = find_handler(argv[0], NULL, 0);
- if (!handler) {
+ if (!handler || !handler->handle) {
char *input = argv[0] ? argv[0] : "(empty)";
- results = cmd_results_new(CMD_INVALID, input, "Unknown/invalid command");
+ char *error = handler
+ ? "This command is shimmed, but unimplemented"
+ : "Unknown/invalid command";
+ results = cmd_results_new(CMD_INVALID, input, error);
goto cleanup;
}
- int i;
- // Var replacement, for all but first argument of set
- // TODO commands
- for (i = handler->handle == cmd_set ? 2 : 1; i < argc; ++i) {
+
+ // Do variable replacement
+ if (handler->handle == cmd_set && argc > 1 && *argv[1] == '$') {
+ // Escape the variable name so it does not get replaced by one shorter
+ char *temp = calloc(1, strlen(argv[1]) + 2);
+ temp[0] = '$';
+ strcpy(&temp[1], argv[1]);
+ free(argv[1]);
+ argv[1] = temp;
+ }
+ char *command = do_var_replacement(join_args(argv, argc));
+ wlr_log(WLR_INFO, "After replacement: %s", command);
+ free_argv(argc, argv);
+ argv = split_args(command, &argc);
+ free(command);
+
+ // Strip quotes and unescape the string
+ for (int i = handler->handle == cmd_set ? 2 : 1; i < argc; ++i) {
if (handler->handle != cmd_exec && handler->handle != cmd_exec_always
&& handler->handle != cmd_bindsym
&& handler->handle != cmd_bindcode
@@ -389,14 +423,11 @@ struct cmd_results *config_command(char *exec) {
&& (*argv[i] == '\"' || *argv[i] == '\'')) {
strip_quotes(argv[i]);
}
- argv[i] = do_var_replacement(argv[i]);
unescape_string(argv[i]);
}
- if (handler->handle) {
- results = handler->handle(argc-1, argv+1);
- } else {
- results = cmd_results_new(CMD_INVALID, argv[0], "This command is shimmed, but unimplemented");
- }
+
+ // Run command
+ results = handler->handle(argc - 1, argv + 1);
cleanup:
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 @@
#include <wlr/config.h>
#include <wlr/backend/multi.h>
#include <wlr/backend/wayland.h>
-#ifdef WLR_HAS_X11_BACKEND
+#if WLR_HAS_X11_BACKEND
#include <wlr/backend/x11.h>
#endif
#include "sway/commands.h"
@@ -18,7 +18,7 @@ static void create_output(struct wlr_backend *backend, void *data) {
wlr_wl_output_create(backend);
*done = true;
}
-#ifdef WLR_HAS_X11_BACKEND
+#if WLR_HAS_X11_BACKEND
else if (wlr_backend_is_x11(backend)) {
wlr_x11_output_create(backend);
*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) {
wlr_output_damage_add_box(output->damage, &box);
}
-static void output_damage_whole_container_iterator(struct sway_container *con,
- void *data) {
- if (!sway_assert(con->view, "expected a view")) {
- return;
- }
- struct sway_output *output = data;
- output_damage_view(output, con->view, true);
-}
-
void output_damage_whole_container(struct sway_output *output,
struct sway_container *con) {
// 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:
}
wlr_renderer_scissor(renderer, NULL);
+ wlr_output_render_software_cursors(wlr_output, damage);
wlr_renderer_end(renderer);
if (!wlr_output_damage_swap_buffers(output->damage, when, damage)) {
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 @@
#include "sway/input/seat.h"
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output.h>
+#include <xkbcommon/xkbcommon.h>
#include "wlr-layer-shell-unstable-v1-protocol.h"
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) {
json_object_object_add(object, "type",
json_object_new_string(describe_device_type(device)));
+ if (device->wlr_device->type == WLR_INPUT_DEVICE_KEYBOARD) {
+ struct wlr_keyboard *keyboard = device->wlr_device->keyboard;
+ struct xkb_keymap *keymap = keyboard->keymap;
+ struct xkb_state *state = keyboard->xkb_state;
+ xkb_layout_index_t num_layouts = xkb_keymap_num_layouts(keymap);
+ xkb_layout_index_t layout_idx;
+ for (layout_idx = 0; layout_idx < num_layouts; layout_idx++) {
+ bool is_active =
+ xkb_state_layout_index_is_active(state,
+ layout_idx,
+ XKB_STATE_LAYOUT_EFFECTIVE);
+ if (is_active) {
+ const char *layout =
+ xkb_keymap_layout_get_name(keymap, layout_idx);
+ json_object_object_add(object, "xkb_active_layout_name",
+ json_object_new_string(layout));
+ break;
+ }
+ }
+ }
+
return object;
}
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) {
}
static void pretty_print_input(json_object *i) {
- json_object *id, *name, *type, *product, *vendor;
+ json_object *id, *name, *type, *product, *vendor, *kbdlayout;
json_object_object_get_ex(i, "identifier", &id);
json_object_object_get_ex(i, "name", &name);
json_object_object_get_ex(i, "type", &type);
@@ -123,7 +123,7 @@ static void pretty_print_input(json_object *i) {
" Type: %s\n"
" Identifier: %s\n"
" Product ID: %d\n"
- " Vendor ID: %d\n\n";
+ " Vendor ID: %d\n";
printf(fmt, json_object_get_string(name),
@@ -131,6 +131,13 @@ static void pretty_print_input(json_object *i) {
json_object_get_string(id),
json_object_get_int(product),
json_object_get_int(vendor));
+
+ if (json_object_object_get_ex(i, "xkb_active_layout_name", &kbdlayout)) {
+ printf(" Active Keyboard Layout: %s\n",
+ json_object_get_string(kbdlayout));
+ }
+
+ printf("\n");
}
static void pretty_print_seat(json_object *i) {