diff options
33 files changed, 113 insertions, 109 deletions
diff --git a/README.bg.md b/README.bg.md index 9d91dfa4..efc99f15 100644 --- a/README.bg.md +++ b/README.bg.md @@ -47,6 +47,7 @@ Sway съществува в репотата (хранилищата) на мн * pam ** * dbus >= 1.10 *** * [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (Нужен за man страници) +* git _\*Нужен само за swaybar, swaybg и swaylock_ diff --git a/README.de.md b/README.de.md index 9e591022..2c2e14e8 100644 --- a/README.de.md +++ b/README.de.md @@ -57,6 +57,7 @@ Abhängigkeiten: * gdk-pixbuf2 * * pam ** * [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (erforderlich für man pages) +* git _\*Nur erforderlich für swaybar, swaybg, und swaylock_ diff --git a/README.el.md b/README.el.md index d56728a0..3c9d65c9 100644 --- a/README.el.md +++ b/README.el.md @@ -50,6 +50,7 @@ To username μου στο Freenode είναι kon14 και θα με βρείτ� * gdk-pixbuf2 * * pam ** * [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (required for man pages) +* git _\*Απαιτείται μόνο για swaybar, swaybg, and swaylock_ diff --git a/README.fr.md b/README.fr.md index 629aef95..935d288f 100644 --- a/README.fr.md +++ b/README.fr.md @@ -52,6 +52,7 @@ Installez les dépendances : * gdk-pixbuf2 * * pam ** * [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (requis pour les pages man) +* git _\*Uniquement requis pour swaybar, swaybg, and swaylock_ diff --git a/README.it.md b/README.it.md index a7e175c1..af986844 100644 --- a/README.it.md +++ b/README.it.md @@ -53,6 +53,7 @@ Installa queste dipendenze: * gdk-pixbuf2 * * pam ** * [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (rrichiesto per man pages) +* git _\*Richiesto solo per swaybar, swaybg, e swaylock_ diff --git a/README.ja.md b/README.ja.md index 396e0a72..ae2301fb 100644 --- a/README.ja.md +++ b/README.ja.md @@ -42,6 +42,7 @@ Swayは沢山のディストリビューションで提供されています。" * gdk-pixbuf2 * * pam ** * [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (manで必要です) +* git _\*swaybar,swaybg,swaylockでのみ必要です_ @@ -46,6 +46,7 @@ Install dependencies: * pam ** * dbus >= 1.10 *** * [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (required for man pages) +* git _\*Only required for swaybar, swaybg, and swaylock_ diff --git a/README.pt.md b/README.pt.md index 57220fae..91e709c1 100644 --- a/README.pt.md +++ b/README.pt.md @@ -59,6 +59,7 @@ Antes de iniciar a compilação, instale as dependências: * gdk-pixbuf2 * * pam ** * [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (man pages) +* git _\*Dependência apenas de swaybar, swaybg, e swaylock_ diff --git a/README.ru.md b/README.ru.md index 25b80a23..4b34dc2d 100644 --- a/README.ru.md +++ b/README.ru.md @@ -53,6 +53,7 @@ Sway доступен во многих дистрибутивах и наход * pam ** * dbus >= 1.10 *** * [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (required for man pages) +* git _\*Требуется только для swaybar, swaybg и swaylock_ diff --git a/README.uk.md b/README.uk.md index 8c8b2eed..9ae7425a 100644 --- a/README.uk.md +++ b/README.uk.md @@ -59,6 +59,7 @@ Sway доступний у багатьох дистрибутивах Linux (а * gdk-pixbuf2 * * pam ** * [scdoc](https://git.sr.ht/~sircmpwn/scdoc) (required for man pages) +* git _\*Лише для swaybar, swaybg та swaylock_ diff --git a/include/sway/commands.h b/include/sway/commands.h index 2f6d31b1..6606775a 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h @@ -39,9 +39,8 @@ struct cmd_results { }; enum expected_args { - EXPECTED_MORE_THAN, EXPECTED_AT_LEAST, - EXPECTED_LESS_THAN, + EXPECTED_AT_MOST, EXPECTED_EQUAL_TO }; diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index a8fa1660..0240f294 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -227,7 +227,6 @@ struct sway_view_child { struct wl_listener surface_map; struct wl_listener surface_unmap; struct wl_listener surface_destroy; - struct wl_listener view_unmap; }; struct sway_xdg_popup_v6 { 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); diff --git a/swaybar/bar.c b/swaybar/bar.c index 71aff691..88de8c04 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -26,11 +26,6 @@ #include "wlr-layer-shell-unstable-v1-client-protocol.h" #include "xdg-output-unstable-v1-client-protocol.h" -static void bar_init(struct swaybar *bar) { - bar->config = init_config(); - wl_list_init(&bar->outputs); -} - void free_workspaces(struct wl_list *list) { struct swaybar_workspace *ws, *tmp; wl_list_for_each_safe(ws, tmp, list, link) { @@ -124,35 +119,45 @@ static void destroy_layer_surface(struct swaybar_output *output) { output->frame_scheduled = false; } +static void set_bar_dirty(struct swaybar *bar) { + struct swaybar_output *output; + wl_list_for_each(output, &bar->outputs, link) { + set_output_dirty(output); + } +} + bool determine_bar_visibility(struct swaybar *bar, bool moving_layer) { struct swaybar_config *config = bar->config; bool visible = !(strcmp(config->mode, "invisible") == 0 || (strcmp(config->mode, config->hidden_state) == 0 // both "hide" && !bar->visible_by_modifier && !bar->visible_by_urgency)); + // Create/destroy layer surfaces as needed struct swaybar_output *output; - if (visible == bar->visible) { - if (visible && moving_layer) { - // need to destroy layer surface to move to a different layer - wl_list_for_each(output, &bar->outputs, link) { - destroy_layer_surface(output); - add_layer_surface(output); - } + wl_list_for_each(output, &bar->outputs, link) { + // When moving to a different layer, we need to destroy and re-create + // the layer surface + if (!visible || moving_layer) { + destroy_layer_surface(output); + } + + if (visible) { + add_layer_surface(output); } - } else { + } + set_bar_dirty(bar); + + if (visible != bar->visible) { bar->visible = visible; - wl_list_for_each(output, &bar->outputs, link) { - if (visible) { - add_layer_surface(output); - } else { - destroy_layer_surface(output); - } + + if (bar->status) { + wlr_log(WLR_DEBUG, "Sending %s signal to status command", + visible ? "cont" : "stop"); + kill(bar->status->pid, visible ? + bar->status->cont_signal : bar->status->stop_signal); } - wlr_log(WLR_DEBUG, "Sending %s signal to status command", - visible ? "cont" : "stop"); - kill(bar->status->pid, - visible ? bar->status->cont_signal : bar->status->stop_signal); } + return visible; } @@ -226,6 +231,8 @@ static void xdg_output_handle_done(void *data, output->surface = wl_compositor_create_surface(bar->compositor); assert(output->surface); + + determine_bar_visibility(bar, false); } } @@ -314,15 +321,10 @@ static const struct wl_registry_listener registry_listener = { .global_remove = handle_global_remove, }; -static void set_bar_dirty(struct swaybar *bar) { - struct swaybar_output *output; - wl_list_for_each(output, &bar->outputs, link) { - set_output_dirty(output); - } -} - bool bar_setup(struct swaybar *bar, const char *socket_path) { - bar_init(bar); + bar->visible = true; + bar->config = init_config(); + wl_list_init(&bar->outputs); bar->eventloop = loop_create(); bar->ipc_socketfd = ipc_open_socket(socket_path); @@ -348,15 +350,13 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) { assert(bar->compositor && bar->layer_shell && bar->shm && bar->xdg_output_manager); - struct swaybar_output *output; - wl_list_for_each(output, &bar->outputs, link) { - add_xdg_output(output); - } + // Second roundtrip for xdg-output wl_display_roundtrip(bar->display); struct swaybar_pointer *pointer = &bar->pointer; int max_scale = 1; + struct swaybar_output *output; wl_list_for_each(output, &bar->outputs, link) { if (output->scale > max_scale) { max_scale = output->scale; @@ -373,16 +373,10 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) { pointer->cursor_surface = wl_compositor_create_surface(bar->compositor); assert(pointer->cursor_surface); - bar->visible = true; if (bar->config->workspace_buttons) { ipc_get_workspaces(bar); } - if (determine_bar_visibility(bar, false)) { - wl_list_for_each(output, &bar->outputs, link) { - add_layer_surface(output); - } - set_bar_dirty(bar); - } + determine_bar_visibility(bar, false); return true; } |