aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-rw-r--r--sway/commands.c14
-rw-r--r--sway/commands/create_output.c39
-rw-r--r--sway/config/input.c7
-rw-r--r--sway/ipc-json.c2
-rw-r--r--sway/meson.build1
-rw-r--r--sway/tree/view.c1
6 files changed, 60 insertions, 4 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 41e1c653..07169f1e 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -143,6 +143,7 @@ static struct cmd_handler config_handlers[] = {
/* Runtime-only commands. Keep alphabetized */
static struct cmd_handler command_handlers[] = {
{ "border", cmd_border },
+ { "create_output", cmd_create_output },
{ "exit", cmd_exit },
{ "floating", cmd_floating },
{ "fullscreen", cmd_fullscreen },
@@ -215,18 +216,23 @@ struct cmd_handler *find_handler(char *line, struct cmd_handler *cmd_handlers,
static void set_config_node(struct sway_node *node) {
config->handler_context.node = node;
+ config->handler_context.container = NULL;
+ config->handler_context.workspace = NULL;
+
+ if (node == NULL) {
+ return;
+ }
+
switch (node->type) {
case N_CONTAINER:
config->handler_context.container = node->sway_container;
config->handler_context.workspace = node->sway_container->workspace;
break;
case N_WORKSPACE:
- config->handler_context.container = NULL;
config->handler_context.workspace = node->sway_workspace;
break;
- default:
- config->handler_context.container = NULL;
- config->handler_context.workspace = NULL;
+ case N_ROOT:
+ case N_OUTPUT:
break;
}
}
diff --git a/sway/commands/create_output.c b/sway/commands/create_output.c
new file mode 100644
index 00000000..a852c2a0
--- /dev/null
+++ b/sway/commands/create_output.c
@@ -0,0 +1,39 @@
+#include <wlr/backend/multi.h>
+#include <wlr/backend/wayland.h>
+#include <wlr/backend/x11.h>
+#include "sway/commands.h"
+#include "sway/server.h"
+#include "log.h"
+
+static void create_output(struct wlr_backend *backend, void *data) {
+ bool *done = data;
+ if (*done) {
+ return;
+ }
+
+ if (wlr_backend_is_wl(backend)) {
+ wlr_wl_output_create(backend);
+ *done = true;
+ } else if (wlr_backend_is_x11(backend)) {
+ wlr_x11_output_create(backend);
+ *done = true;
+ }
+}
+
+/**
+ * This command is intended for developer use only.
+ */
+struct cmd_results *cmd_create_output(int argc, char **argv) {
+ sway_assert(wlr_backend_is_multi(server.backend),
+ "Expected a multi backend");
+
+ bool done = false;
+ wlr_multi_for_each_backend(server.backend, create_output, &done);
+
+ if (!done) {
+ return cmd_results_new(CMD_INVALID, "create_output",
+ "Can only create outputs for Wayland or X11 backends");
+ }
+
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}
diff --git a/sway/config/input.c b/sway/config/input.c
index 9885e85c..ad5b96c8 100644
--- a/sway/config/input.c
+++ b/sway/config/input.c
@@ -140,6 +140,13 @@ void free_input_config(struct input_config *ic) {
return;
}
free(ic->identifier);
+ free(ic->xkb_layout);
+ free(ic->xkb_model);
+ free(ic->xkb_options);
+ free(ic->xkb_rules);
+ free(ic->xkb_variant);
+ free(ic->mapped_from_region);
+ free(ic->mapped_to_output);
free(ic);
}
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 52278be2..f054ac9f 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -221,6 +221,8 @@ static const char *describe_container_border(enum sway_container_border border)
}
static void ipc_json_describe_view(struct sway_container *c, json_object *object) {
+ json_object_object_add(object, "pid", json_object_new_int(c->view->pid));
+
const char *app_id = view_get_app_id(c->view);
json_object_object_add(object, "app_id",
app_id ? json_object_new_string(app_id) : NULL);
diff --git a/sway/meson.build b/sway/meson.build
index 01c83a33..d67a4c64 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -35,6 +35,7 @@ sway_sources = files(
'commands/bind.c',
'commands/border.c',
'commands/client.c',
+ 'commands/create_output.c',
'commands/default_border.c',
'commands/default_floating_border.c',
'commands/default_orientation.c',
diff --git a/sway/tree/view.c b/sway/tree/view.c
index e4e1c161..4398f518 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -470,6 +470,7 @@ static struct sway_workspace *select_workspace(struct sway_view *view) {
wl_resource_get_client(view->surface->resource);
wl_client_get_credentials(client, &pid, NULL, NULL);
#endif
+ view->pid = pid;
ws = root_workspace_for_pid(pid);
if (ws) {
return ws;