aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/commands.h1
-rw-r--r--include/sway/tree/view.h2
-rw-r--r--sway/commands.c1
-rw-r--r--sway/commands/create_output.c39
-rw-r--r--sway/ipc-json.c2
-rw-r--r--sway/meson.build1
-rw-r--r--sway/tree/view.c1
7 files changed, 47 insertions, 0 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h
index e51b12fd..226cf932 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -103,6 +103,7 @@ sway_cmd cmd_client_urgent;
103sway_cmd cmd_client_placeholder; 103sway_cmd cmd_client_placeholder;
104sway_cmd cmd_client_background; 104sway_cmd cmd_client_background;
105sway_cmd cmd_commands; 105sway_cmd cmd_commands;
106sway_cmd cmd_create_output;
106sway_cmd cmd_debuglog; 107sway_cmd cmd_debuglog;
107sway_cmd cmd_default_border; 108sway_cmd cmd_default_border;
108sway_cmd cmd_default_floating_border; 109sway_cmd cmd_default_floating_border;
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 439dc1bf..d10251dd 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -61,6 +61,8 @@ struct sway_view {
61 struct sway_container *container; // NULL if unmapped and transactions finished 61 struct sway_container *container; // NULL if unmapped and transactions finished
62 struct wlr_surface *surface; // NULL for unmapped views 62 struct wlr_surface *surface; // NULL for unmapped views
63 63
64 pid_t pid;
65
64 // Geometry of the view itself (excludes borders) in layout coordinates 66 // Geometry of the view itself (excludes borders) in layout coordinates
65 double x, y; 67 double x, y;
66 int width, height; 68 int width, height;
diff --git a/sway/commands.c b/sway/commands.c
index 32079492..07169f1e 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -143,6 +143,7 @@ static struct cmd_handler config_handlers[] = {
143/* Runtime-only commands. Keep alphabetized */ 143/* Runtime-only commands. Keep alphabetized */
144static struct cmd_handler command_handlers[] = { 144static struct cmd_handler command_handlers[] = {
145 { "border", cmd_border }, 145 { "border", cmd_border },
146 { "create_output", cmd_create_output },
146 { "exit", cmd_exit }, 147 { "exit", cmd_exit },
147 { "floating", cmd_floating }, 148 { "floating", cmd_floating },
148 { "fullscreen", cmd_fullscreen }, 149 { "fullscreen", cmd_fullscreen },
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 @@
1#include <wlr/backend/multi.h>
2#include <wlr/backend/wayland.h>
3#include <wlr/backend/x11.h>
4#include "sway/commands.h"
5#include "sway/server.h"
6#include "log.h"
7
8static void create_output(struct wlr_backend *backend, void *data) {
9 bool *done = data;
10 if (*done) {
11 return;
12 }
13
14 if (wlr_backend_is_wl(backend)) {
15 wlr_wl_output_create(backend);
16 *done = true;
17 } else if (wlr_backend_is_x11(backend)) {
18 wlr_x11_output_create(backend);
19 *done = true;
20 }
21}
22
23/**
24 * This command is intended for developer use only.
25 */
26struct cmd_results *cmd_create_output(int argc, char **argv) {
27 sway_assert(wlr_backend_is_multi(server.backend),
28 "Expected a multi backend");
29
30 bool done = false;
31 wlr_multi_for_each_backend(server.backend, create_output, &done);
32
33 if (!done) {
34 return cmd_results_new(CMD_INVALID, "create_output",
35 "Can only create outputs for Wayland or X11 backends");
36 }
37
38 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
39}
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)
221} 221}
222 222
223static void ipc_json_describe_view(struct sway_container *c, json_object *object) { 223static void ipc_json_describe_view(struct sway_container *c, json_object *object) {
224 json_object_object_add(object, "pid", json_object_new_int(c->view->pid));
225
224 const char *app_id = view_get_app_id(c->view); 226 const char *app_id = view_get_app_id(c->view);
225 json_object_object_add(object, "app_id", 227 json_object_object_add(object, "app_id",
226 app_id ? json_object_new_string(app_id) : NULL); 228 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(
35 'commands/bind.c', 35 'commands/bind.c',
36 'commands/border.c', 36 'commands/border.c',
37 'commands/client.c', 37 'commands/client.c',
38 'commands/create_output.c',
38 'commands/default_border.c', 39 'commands/default_border.c',
39 'commands/default_floating_border.c', 40 'commands/default_floating_border.c',
40 'commands/default_orientation.c', 41 '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) {
470 wl_resource_get_client(view->surface->resource); 470 wl_resource_get_client(view->surface->resource);
471 wl_client_get_credentials(client, &pid, NULL, NULL); 471 wl_client_get_credentials(client, &pid, NULL, NULL);
472#endif 472#endif
473 view->pid = pid;
473 ws = root_workspace_for_pid(pid); 474 ws = root_workspace_for_pid(pid);
474 if (ws) { 475 if (ws) {
475 return ws; 476 return ws;