diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 14 | ||||
-rw-r--r-- | sway/commands/create_output.c | 45 | ||||
-rw-r--r-- | sway/config/bar.c | 26 | ||||
-rw-r--r-- | sway/config/input.c | 7 | ||||
-rw-r--r-- | sway/desktop/render.c | 11 | ||||
-rw-r--r-- | sway/desktop/transaction.c | 11 | ||||
-rw-r--r-- | sway/ipc-json.c | 2 | ||||
-rw-r--r-- | sway/main.c | 1 | ||||
-rw-r--r-- | sway/meson.build | 1 | ||||
-rw-r--r-- | sway/tree/output.c | 2 | ||||
-rw-r--r-- | sway/tree/view.c | 10 |
11 files changed, 93 insertions, 37 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..1c2464ea --- /dev/null +++ b/sway/commands/create_output.c @@ -0,0 +1,45 @@ +#include <wlr/config.h> +#include <wlr/backend/multi.h> +#include <wlr/backend/wayland.h> +#ifdef WLR_HAS_X11_BACKEND +#include <wlr/backend/x11.h> +#endif +#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; + } +#ifdef WLR_HAS_X11_BACKEND + else if (wlr_backend_is_x11(backend)) { + wlr_x11_output_create(backend); + *done = true; + } +#endif +} + +/** + * 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/bar.c b/sway/config/bar.c index f83b37d1..48a632fb 100644 --- a/sway/config/bar.c +++ b/sway/config/bar.c @@ -165,7 +165,7 @@ cleanup: return NULL; } -void invoke_swaybar(struct bar_config *bar) { +static void invoke_swaybar(struct bar_config *bar) { // Pipe to communicate errors int filedes[2]; if (pipe(filedes) == -1) { @@ -219,27 +219,13 @@ void invoke_swaybar(struct bar_config *bar) { close(filedes[1]); } -void load_swaybars() { +void load_swaybars(void) { for (int i = 0; i < config->bars->length; ++i) { struct bar_config *bar = config->bars->items[i]; - bool apply = false; - if (bar->outputs) { - for (int j = 0; j < bar->outputs->length; ++j) { - char *o = bar->outputs->items[j]; - if (!strcmp(o, "*") || output_by_name(o)) { - apply = true; - break; - } - } - } else { - apply = true; - } - if (apply) { - if (bar->pid != 0) { - terminate_swaybar(bar->pid); - } - wlr_log(WLR_DEBUG, "Invoking swaybar for bar id '%s'", bar->id); - invoke_swaybar(bar); + if (bar->pid != 0) { + terminate_swaybar(bar->pid); } + wlr_log(WLR_DEBUG, "Invoking swaybar for bar id '%s'", bar->id); + invoke_swaybar(bar); } } 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/desktop/render.c b/sway/desktop/render.c index 1d2f445d..af4e2905 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -914,12 +914,17 @@ void output_render(struct sway_output *output, struct timespec *when, struct wlr_output *wlr_output = output->wlr_output; struct wlr_renderer *renderer = - wlr_backend_get_renderer(wlr_output->backend); + wlr_backend_get_renderer(wlr_output->backend); if (!sway_assert(renderer != NULL, "expected the output backend to have a renderer")) { return; } + struct sway_workspace *workspace = output->current.active_workspace; + if (workspace == NULL) { + return; + } + wlr_renderer_begin(renderer, wlr_output->width, wlr_output->height); if (!pixman_region32_not_empty(damage)) { @@ -935,13 +940,11 @@ void output_render(struct sway_output *output, struct timespec *when, pixman_region32_union_rect(damage, damage, 0, 0, width, height); } - struct sway_workspace *workspace = output->current.active_workspace; - struct sway_container *fullscreen_con = workspace->current.fullscreen; - if (output_has_opaque_overlay_layer_surface(output)) { goto render_overlay; } + struct sway_container *fullscreen_con = workspace->current.fullscreen; if (fullscreen_con) { float clear_color[] = {0.0f, 0.0f, 0.0f, 1.0f}; diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index d747e279..797f6b4c 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c @@ -6,6 +6,7 @@ #include <string.h> #include <time.h> #include <wlr/types/wlr_buffer.h> +#include "sway/config.h" #include "sway/debug.h" #include "sway/desktop.h" #include "sway/desktop/idle_inhibit_v1.h" @@ -390,6 +391,16 @@ static bool should_configure(struct sway_node *node, } struct sway_container_state *cstate = &node->sway_container->current; struct sway_container_state *istate = instruction->container_state; +#ifdef HAVE_XWAYLAND + // Xwayland views are position-aware and need to be reconfigured + // when their position changes. + if (node->sway_container->view->type == SWAY_VIEW_XWAYLAND) { + if (cstate->view_x != istate->view_x || + cstate->view_y != istate->view_y) { + return true; + } + } +#endif if (cstate->view_width == istate->view_width && cstate->view_height == istate->view_height) { return false; 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/main.c b/sway/main.c index fb4f0d8c..3d7cd158 100644 --- a/sway/main.c +++ b/sway/main.c @@ -424,6 +424,7 @@ int main(int argc, char **argv) { } config->active = true; + load_swaybars(); // Execute commands until there are none left wlr_log(WLR_DEBUG, "Running deferred commands"); while (config->cmd_queue->length) { 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/output.c b/sway/tree/output.c index 1976ad51..06933dc4 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c @@ -109,8 +109,6 @@ void output_enable(struct sway_output *output, struct output_config *oc) { wl_signal_emit(&root->events.new_node, &output->node); - load_swaybars(); - arrange_layers(output); arrange_root(); } diff --git a/sway/tree/view.c b/sway/tree/view.c index e4e1c161..f61f5c84 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; @@ -784,14 +785,9 @@ static size_t parse_title_format(struct sway_view *view, char *buffer) { } static char *escape_title(char *buffer) { - int length = escape_markup_text(buffer, NULL, 0); + size_t length = escape_markup_text(buffer, NULL); char *escaped_title = calloc(length + 1, sizeof(char)); - int result = escape_markup_text(buffer, escaped_title, length); - if (result != length) { - wlr_log(WLR_ERROR, "Could not escape title: %s", buffer); - free(escaped_title); - return buffer; - } + escape_markup_text(buffer, escaped_title); free(buffer); return escaped_title; } |