summaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <RyanDwyer@users.noreply.github.com>2018-09-21 20:05:39 +1000
committerLibravatar GitHub <noreply@github.com>2018-09-21 20:05:39 +1000
commit0798fadff2f2f74a7efd7c14c55737bac19de954 (patch)
tree86e1ab4983fec3586a8bbb0044216216e22cc1cb /sway
parentFix segfault in output_render (diff)
parentMerge pull request #2671 from emersion/output-execute-no-focus (diff)
downloadsway-0798fadff2f2f74a7efd7c14c55737bac19de954.tar.gz
sway-0798fadff2f2f74a7efd7c14c55737bac19de954.tar.zst
sway-0798fadff2f2f74a7efd7c14c55737bac19de954.zip
Merge branch 'master' into render-output-segfault
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[] = {
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 },
@@ -215,18 +216,23 @@ struct cmd_handler *find_handler(char *line, struct cmd_handler *cmd_handlers,
215 216
216static void set_config_node(struct sway_node *node) { 217static void set_config_node(struct sway_node *node) {
217 config->handler_context.node = node; 218 config->handler_context.node = node;
219 config->handler_context.container = NULL;
220 config->handler_context.workspace = NULL;
221
222 if (node == NULL) {
223 return;
224 }
225
218 switch (node->type) { 226 switch (node->type) {
219 case N_CONTAINER: 227 case N_CONTAINER:
220 config->handler_context.container = node->sway_container; 228 config->handler_context.container = node->sway_container;
221 config->handler_context.workspace = node->sway_container->workspace; 229 config->handler_context.workspace = node->sway_container->workspace;
222 break; 230 break;
223 case N_WORKSPACE: 231 case N_WORKSPACE:
224 config->handler_context.container = NULL;
225 config->handler_context.workspace = node->sway_workspace; 232 config->handler_context.workspace = node->sway_workspace;
226 break; 233 break;
227 default: 234 case N_ROOT:
228 config->handler_context.container = NULL; 235 case N_OUTPUT:
229 config->handler_context.workspace = NULL;
230 break; 236 break;
231 } 237 }
232} 238}
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/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) {
140 return; 140 return;
141 } 141 }
142 free(ic->identifier); 142 free(ic->identifier);
143 free(ic->xkb_layout);
144 free(ic->xkb_model);
145 free(ic->xkb_options);
146 free(ic->xkb_rules);
147 free(ic->xkb_variant);
148 free(ic->mapped_from_region);
149 free(ic->mapped_to_output);
143 free(ic); 150 free(ic);
144} 151}
145 152
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;