diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 43 | ||||
-rw-r--r-- | sway/commands/bar/bindsym.c | 2 | ||||
-rw-r--r-- | sway/commands/bar/hidden_state.c | 2 | ||||
-rw-r--r-- | sway/commands/bar/mode.c | 2 | ||||
-rw-r--r-- | sway/commands/bind.c | 2 | ||||
-rw-r--r-- | sway/commands/exec_always.c | 8 | ||||
-rw-r--r-- | sway/commands/fullscreen.c | 2 | ||||
-rw-r--r-- | sway/commands/layout.c | 2 | ||||
-rw-r--r-- | sway/commands/move.c | 2 | ||||
-rw-r--r-- | sway/commands/opacity.c | 2 | ||||
-rw-r--r-- | sway/commands/reload.c | 11 | ||||
-rw-r--r-- | sway/commands/resize.c | 4 | ||||
-rw-r--r-- | sway/commands/swaynag_command.c | 2 | ||||
-rw-r--r-- | sway/config.c | 3 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 2 | ||||
-rw-r--r-- | sway/input/cursor.c | 3 | ||||
-rw-r--r-- | sway/input/seat.c | 7 | ||||
-rw-r--r-- | sway/sway.5.scd | 10 | ||||
-rw-r--r-- | sway/tree/container.c | 10 | ||||
-rw-r--r-- | sway/tree/view.c | 11 |
20 files changed, 66 insertions, 64 deletions
diff --git a/sway/commands.c b/sway/commands.c index 3f416afc..37c7169a 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -18,41 +18,28 @@ // Returns error object, or NULL if check succeeds. struct cmd_results *checkarg(int argc, const char *name, enum expected_args type, int val) { - struct cmd_results *error = NULL; + const char *error_name = NULL; switch (type) { - case EXPECTED_MORE_THAN: - if (argc > val) { - return NULL; - } - error = cmd_results_new(CMD_INVALID, name, "Invalid %s command " - "(expected more than %d argument%s, got %d)", - name, val, (char*[2]){"s", ""}[argc==1], argc); - break; case EXPECTED_AT_LEAST: - if (argc >= val) { - return NULL; + if (argc < val) { + error_name = "at least "; } - error = cmd_results_new(CMD_INVALID, name, "Invalid %s command " - "(expected at least %d argument%s, got %d)", - name, val, (char*[2]){"s", ""}[argc==1], argc); break; - case EXPECTED_LESS_THAN: - if (argc < val) { - return NULL; - }; - error = cmd_results_new(CMD_INVALID, name, "Invalid %s command " - "(expected less than %d argument%s, got %d)", - name, val, (char*[2]){"s", ""}[argc==1], argc); + case EXPECTED_AT_MOST: + if (argc > val) { + error_name = "at most "; + } break; case EXPECTED_EQUAL_TO: - if (argc == val) { - return NULL; - }; - error = cmd_results_new(CMD_INVALID, name, "Invalid %s command " - "(expected %d arguments, got %d)", name, val, argc); - break; + if (argc != val) { + error_name = ""; + } } - return error; + return error_name ? + cmd_results_new(CMD_INVALID, name, "Invalid %s command " + "(expected %s%d argument%s, got %d)", + name, error_name, val, val != 1 ? "s" : "", argc) + : NULL; } void apply_seat_config(struct seat_config *seat_config) { diff --git a/sway/commands/bar/bindsym.c b/sway/commands/bar/bindsym.c index 4eea3e6a..965c8903 100644 --- a/sway/commands/bar/bindsym.c +++ b/sway/commands/bar/bindsym.c @@ -10,7 +10,7 @@ struct cmd_results *bar_cmd_bindsym(int argc, char **argv) { struct cmd_results *error = NULL; - if ((error = checkarg(argc, "bar bindsym", EXPECTED_MORE_THAN, 1))) { + if ((error = checkarg(argc, "bar bindsym", EXPECTED_AT_LEAST, 2))) { return error; } if (!config->current_bar) { diff --git a/sway/commands/bar/hidden_state.c b/sway/commands/bar/hidden_state.c index 28adf6c7..5be6c2dc 100644 --- a/sway/commands/bar/hidden_state.c +++ b/sway/commands/bar/hidden_state.c @@ -40,7 +40,7 @@ struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) { if ((error = checkarg(argc, "hidden_state", EXPECTED_AT_LEAST, 1))) { return error; } - if ((error = checkarg(argc, "hidden_state", EXPECTED_LESS_THAN, 3))) { + if ((error = checkarg(argc, "hidden_state", EXPECTED_AT_MOST, 2))) { return error; } if (config->reading && argc > 1) { diff --git a/sway/commands/bar/mode.c b/sway/commands/bar/mode.c index dbdd3897..2cba785e 100644 --- a/sway/commands/bar/mode.c +++ b/sway/commands/bar/mode.c @@ -41,7 +41,7 @@ struct cmd_results *bar_cmd_mode(int argc, char **argv) { if ((error = checkarg(argc, "mode", EXPECTED_AT_LEAST, 1))) { return error; } - if ((error = checkarg(argc, "mode", EXPECTED_LESS_THAN, 3))) { + if ((error = checkarg(argc, "mode", EXPECTED_AT_MOST, 2))) { return error; } if (config->reading && argc > 1) { diff --git a/sway/commands/bind.c b/sway/commands/bind.c index 5832d01e..a9de227f 100644 --- a/sway/commands/bind.c +++ b/sway/commands/bind.c @@ -145,7 +145,7 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv, const char *bindtype = bindcode ? "bindcode" : "bindsym"; struct cmd_results *error = NULL; - if ((error = checkarg(argc, bindtype, EXPECTED_MORE_THAN, 1))) { + if ((error = checkarg(argc, bindtype, EXPECTED_AT_LEAST, 2))) { return error; } diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c index de78dd83..8bdeceeb 100644 --- a/sway/commands/exec_always.c +++ b/sway/commands/exec_always.c @@ -16,7 +16,7 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) { struct cmd_results *error = NULL; if (!config->active) return cmd_results_new(CMD_DEFER, NULL, NULL); - if ((error = checkarg(argc, "exec_always", EXPECTED_MORE_THAN, 0))) { + if ((error = checkarg(argc, argv[-1], EXPECTED_AT_LEAST, 1))) { return error; } @@ -24,7 +24,7 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) { if (strcmp(argv[0], "--no-startup-id") == 0) { wlr_log(WLR_INFO, "exec switch '--no-startup-id' not supported, ignored."); --argc; ++argv; - if ((error = checkarg(argc, "exec_always", EXPECTED_MORE_THAN, 0))) { + if ((error = checkarg(argc, argv[-1], EXPECTED_AT_LEAST, 1))) { return error; } } @@ -71,7 +71,7 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) { } else if (pid < 0) { close(fd[0]); close(fd[1]); - return cmd_results_new(CMD_FAILURE, "exec_always", "fork() failed"); + return cmd_results_new(CMD_FAILURE, argv[-1], "fork() failed"); } close(fd[1]); // close write ssize_t s = 0; @@ -85,7 +85,7 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) { wlr_log(WLR_DEBUG, "Child process created with pid %d", child); root_record_workspace_pid(child); } else { - return cmd_results_new(CMD_FAILURE, "exec_always", + return cmd_results_new(CMD_FAILURE, argv[-1], "Second fork() failed"); } diff --git a/sway/commands/fullscreen.c b/sway/commands/fullscreen.c index 22d747b9..0204a73c 100644 --- a/sway/commands/fullscreen.c +++ b/sway/commands/fullscreen.c @@ -9,7 +9,7 @@ struct cmd_results *cmd_fullscreen(int argc, char **argv) { struct cmd_results *error = NULL; - if ((error = checkarg(argc, "fullscreen", EXPECTED_LESS_THAN, 2))) { + if ((error = checkarg(argc, "fullscreen", EXPECTED_AT_MOST, 1))) { return error; } struct sway_node *node = config->handler_context.node; diff --git a/sway/commands/layout.c b/sway/commands/layout.c index c2ce2e78..65f67af8 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c @@ -96,7 +96,7 @@ static enum sway_container_layout get_layout(int argc, char **argv, struct cmd_results *cmd_layout(int argc, char **argv) { struct cmd_results *error = NULL; - if ((error = checkarg(argc, "layout", EXPECTED_MORE_THAN, 0))) { + if ((error = checkarg(argc, "layout", EXPECTED_AT_LEAST, 1))) { return error; } struct sway_container *container = config->handler_context.container; diff --git a/sway/commands/move.c b/sway/commands/move.c index a5b7f661..e0a958bf 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c @@ -108,7 +108,7 @@ static void workspace_focus_fullscreen(struct sway_workspace *workspace) { if (focus_ws == workspace) { struct sway_node *new_focus = seat_get_focus_inactive(seat, &workspace->fullscreen->node); - seat_set_focus(seat, new_focus); + seat_set_raw_focus(seat, new_focus); } } } diff --git a/sway/commands/opacity.c b/sway/commands/opacity.c index 4e4fc994..8c45b528 100644 --- a/sway/commands/opacity.c +++ b/sway/commands/opacity.c @@ -15,7 +15,7 @@ static bool parse_opacity(const char *opacity, float *val) { struct cmd_results *cmd_opacity(int argc, char **argv) { struct cmd_results *error = NULL; - if ((error = checkarg(argc, "layout", EXPECTED_EQUAL_TO, 1))) { + if ((error = checkarg(argc, "opacity", EXPECTED_EQUAL_TO, 1))) { return error; } diff --git a/sway/commands/reload.c b/sway/commands/reload.c index 9e136d48..791081a8 100644 --- a/sway/commands/reload.c +++ b/sway/commands/reload.c @@ -5,9 +5,17 @@ #include "sway/ipc-server.h" #include "sway/server.h" #include "sway/tree/arrange.h" +#include "sway/tree/view.h" #include "list.h" #include "log.h" +static void rebuild_textures_iterator(struct sway_container *con, void *data) { + if (con->view) { + view_update_marks_textures(con->view); + } + container_update_title_textures(con); +} + static void do_reload(void *data) { // store bar ids to check against new bars for barconfig_update events list_t *bar_ids = create_list(); @@ -40,6 +48,9 @@ static void do_reload(void *data) { list_foreach(bar_ids, free); list_free(bar_ids); + config_update_font_height(true); + root_for_each_container(rebuild_textures_iterator, NULL); + arrange_root(); } diff --git a/sway/commands/resize.c b/sway/commands/resize.c index 6de14ca3..8666f40b 100644 --- a/sway/commands/resize.c +++ b/sway/commands/resize.c @@ -94,7 +94,7 @@ static void calculate_constraints(int *min_width, int *max_width, *min_height = config->floating_minimum_height; } - if (config->floating_maximum_width == -1) { // no maximum + if (config->floating_maximum_width == -1 || !con->workspace) { // no max *max_width = INT_MAX; } else if (config->floating_maximum_width == 0) { // automatic *max_width = con->workspace->width; @@ -102,7 +102,7 @@ static void calculate_constraints(int *min_width, int *max_width, *max_width = config->floating_maximum_width; } - if (config->floating_maximum_height == -1) { // no maximum + if (config->floating_maximum_height == -1 || !con->workspace) { // no max *max_height = INT_MAX; } else if (config->floating_maximum_height == 0) { // automatic *max_height = con->workspace->height; diff --git a/sway/commands/swaynag_command.c b/sway/commands/swaynag_command.c index 6c86f1a7..5e54504c 100644 --- a/sway/commands/swaynag_command.c +++ b/sway/commands/swaynag_command.c @@ -14,7 +14,7 @@ struct cmd_results *cmd_swaynag_command(int argc, char **argv) { char *new_command = join_args(argv, argc); if (strcmp(new_command, "-") != 0) { - config->swaybg_command = new_command; + config->swaynag_command = new_command; wlr_log(WLR_DEBUG, "Using custom swaynag command: %s", config->swaynag_command); } else { diff --git a/sway/config.c b/sway/config.c index b9cb0a1c..9ec40367 100644 --- a/sway/config.c +++ b/sway/config.c @@ -584,13 +584,11 @@ static int detect_brace_on_following_line(FILE *file, char *line, char *peeked = NULL; long position = 0; do { - wlr_log(WLR_DEBUG, "Peeking line %d", line_number + lines + 1); free(peeked); peeked = peek_line(file, lines, &position); if (peeked) { peeked = strip_whitespace(peeked); } - wlr_log(WLR_DEBUG, "Peeked line: `%s`", peeked); lines++; } while (peeked && strlen(peeked) == 0); @@ -695,7 +693,6 @@ bool read_config(FILE *file, struct sway_config *config, free(line); return false; } - wlr_log(WLR_DEBUG, "Expanded line: %s", expanded); struct cmd_results *res; if (block && strcmp(block, "<commands>") == 0) { // Special case diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index a8fbd574..d1aec084 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -244,7 +244,7 @@ static bool wants_floating(struct sway_view *view) { struct wlr_xwayland_surface_size_hints *size_hints = surface->size_hints; if (size_hints != NULL && - size_hints->min_width != 0 && size_hints->min_height != 0 && + size_hints->min_width > 0 && size_hints->min_height > 0 && (size_hints->max_width == size_hints->min_width || size_hints->max_height == size_hints->min_height)) { return true; diff --git a/sway/input/cursor.c b/sway/input/cursor.c index a07bc53b..60d4bf5d 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -1220,6 +1220,9 @@ static void handle_request_set_cursor(struct wl_listener *listener, void cursor_set_image(struct sway_cursor *cursor, const char *image, struct wl_client *client) { + if (!(cursor->seat->wlr_seat->capabilities & WL_SEAT_CAPABILITY_POINTER)) { + return; + } if (!image) { wlr_cursor_set_image(cursor->cursor, NULL, 0, 0, 0, 0, 0, 0); } else if (!cursor->image || strcmp(cursor->image, image) != 0) { diff --git a/sway/input/seat.c b/sway/input/seat.c index 16acc8a5..89d841bb 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -389,12 +389,15 @@ static void seat_update_capabilities(struct sway_seat *seat) { break; } } - wlr_seat_set_capabilities(seat->wlr_seat, caps); - // Hide cursor if seat doesn't have pointer capability + // Hide cursor if seat doesn't have pointer capability. + // We must call cursor_set_image while the wlr_seat has the capabilities + // otherwise it's a no op. if ((caps & WL_SEAT_CAPABILITY_POINTER) == 0) { cursor_set_image(seat->cursor, NULL, NULL); + wlr_seat_set_capabilities(seat->wlr_seat, caps); } else { + wlr_seat_set_capabilities(seat->wlr_seat, caps); cursor_set_image(seat->cursor, "left_ptr", NULL); } } diff --git a/sway/sway.5.scd b/sway/sway.5.scd index 51fd260b..1999a6c8 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd @@ -69,7 +69,7 @@ The following commands may only be used in the configuration file. *swaybg\_command* <command> Executes custom background _command_. Default is _swaybg_. Refer to - *output* below for more information. + *sway-output*(5) for more information. It can be disabled by setting the command to a single dash: _swaybg\_command -_ @@ -495,6 +495,12 @@ The default colors are: Prevents windows matching <criteria> from being focused automatically when they're created. This has no effect on the first window in a workspace. +*output* <output\_name> <output-subcommands...> + For details on output subcommands, see *sway-output*(5). + + \* may be used in lieu of a specific output name to configure all outputs. + A list of output names may be obtained via *swaymsg -t get\_outputs*. + *popup\_during\_fullscreen* smart|ignore|leave\_fullscreen Determines what to do when a fullscreen view opens a dialog. If _smart_ (the default), the dialog will be displayed. If _ignore_, the @@ -669,4 +675,4 @@ The following attributes may be matched with: # SEE ALSO -*sway*(1) *sway-input*(5) *sway-bar*(5) +*sway*(1) *sway-input*(5) *sway-output*(5) *sway-bar*(5) diff --git a/sway/tree/container.c b/sway/tree/container.c index b41e8dd4..58d3df34 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -727,8 +727,14 @@ void container_set_geometry_from_floating_view(struct sway_container *con) { } bool container_is_floating(struct sway_container *container) { - return !container->parent && container->workspace && - list_find(container->workspace->floating, container) != -1; + if (!container->parent && container->workspace && + list_find(container->workspace->floating, container) != -1) { + return true; + } + if (container->scratchpad) { + return true; + } + return false; } void container_get_box(struct sway_container *container, struct wlr_box *box) { diff --git a/sway/tree/view.c b/sway/tree/view.c index 3698d7d5..20babf7b 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -738,13 +738,6 @@ static void view_child_handle_surface_destroy(struct wl_listener *listener, view_child_destroy(child); } -static void view_child_handle_view_unmap(struct wl_listener *listener, - void *data) { - struct sway_view_child *child = - wl_container_of(listener, child, view_unmap); - view_child_destroy(child); -} - static void view_init_subsurfaces(struct sway_view *view, struct wlr_surface *surface) { struct wlr_subsurface *subsurface; @@ -786,9 +779,6 @@ void view_child_init(struct sway_view_child *child, child->surface_map.notify = view_child_handle_surface_map; child->surface_unmap.notify = view_child_handle_surface_unmap; - wl_signal_add(&view->events.unmap, &child->view_unmap); - child->view_unmap.notify = view_child_handle_view_unmap; - struct sway_output *output = child->view->container->workspace->output; wlr_surface_send_enter(child->surface, output->wlr_output); @@ -798,7 +788,6 @@ void view_child_init(struct sway_view_child *child, void view_child_destroy(struct sway_view_child *child) { wl_list_remove(&child->surface_commit.link); wl_list_remove(&child->surface_destroy.link); - wl_list_remove(&child->view_unmap.link); if (child->impl && child->impl->destroy) { child->impl->destroy(child); |