diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 2 | ||||
-rw-r--r-- | sway/commands/bind.c | 2 | ||||
-rw-r--r-- | sway/commands/border.c | 6 | ||||
-rw-r--r-- | sway/criteria.c | 45 | ||||
-rw-r--r-- | sway/desktop/layer_shell.c | 3 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 1 | ||||
-rw-r--r-- | sway/input/seat.c | 2 |
7 files changed, 48 insertions, 13 deletions
diff --git a/sway/commands.c b/sway/commands.c index d9c54adc..13f5983e 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -118,6 +118,8 @@ static struct cmd_handler handlers[] = { { "input", cmd_input }, { "mode", cmd_mode }, { "mouse_warping", cmd_mouse_warping }, + { "new_float", cmd_default_floating_border }, + { "new_window", cmd_default_border }, { "no_focus", cmd_no_focus }, { "output", cmd_output }, { "seat", cmd_seat }, diff --git a/sway/commands/bind.c b/sway/commands/bind.c index 8270b958..b134c92f 100644 --- a/sway/commands/bind.c +++ b/sway/commands/bind.c @@ -310,7 +310,7 @@ void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding) bool reload = false; // if this is a reload command we need to make a duplicate of the // binding since it will be gone after the reload has completed. - if (strcasecmp(binding->command, "reload") == 0) { + if (strcasestr(binding->command, "reload")) { reload = true; binding_copy = sway_binding_dup(binding); if (!binding_copy) { diff --git a/sway/commands/border.c b/sway/commands/border.c index 9c19e20a..9502c877 100644 --- a/sway/commands/border.c +++ b/sway/commands/border.c @@ -27,9 +27,6 @@ struct cmd_results *cmd_border(int argc, char **argv) { view->border = B_NORMAL; } else if (strcmp(argv[0], "pixel") == 0) { view->border = B_PIXEL; - if (argc == 2) { - view->border_thickness = atoi(argv[1]); - } } else if (strcmp(argv[0], "toggle") == 0) { view->border = (view->border + 1) % 3; } else { @@ -37,6 +34,9 @@ struct cmd_results *cmd_border(int argc, char **argv) { "Expected 'border <none|normal|pixel|toggle>' " "or 'border pixel <px>'"); } + if (argc == 2) { + view->border_thickness = atoi(argv[1]); + } if (container_is_floating(view->swayc)) { container_set_geometry_from_floating_view(view->swayc); diff --git a/sway/criteria.c b/sway/criteria.c index 5452c4ee..13176fa1 100644 --- a/sway/criteria.c +++ b/sway/criteria.c @@ -2,6 +2,7 @@ #include <stdlib.h> #include <stdio.h> #include <stdbool.h> +#include <strings.h> #include <pcre.h> #include "sway/criteria.h" #include "sway/tree/container.h" @@ -25,7 +26,7 @@ bool criteria_is_empty(struct criteria *criteria) { && !criteria->id #endif && !criteria->window_role - && !criteria->window_type + && criteria->window_type == ATOM_LAST && !criteria->floating && !criteria->tiling && !criteria->urgent @@ -50,6 +51,23 @@ static int regex_cmp(const char *item, const pcre *regex) { return pcre_exec(regex, NULL, item, strlen(item), 0, 0, NULL, 0); } +static bool view_has_window_type(struct sway_view *view, enum atom_name name) { +#ifdef HAVE_XWAYLAND + if (view->type != SWAY_VIEW_XWAYLAND) { + return false; + } + struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface; + struct sway_xwayland *xwayland = &server.xwayland; + xcb_atom_t desired_atom = xwayland->atoms[name]; + for (size_t i = 0; i < surface->window_type_len; ++i) { + if (surface->window_type[i] == desired_atom) { + return true; + } + } +#endif + return false; +} + static int cmp_urgent(const void *_a, const void *_b) { struct sway_view *a = *(void **)_a; struct sway_view *b = *(void **)_b; @@ -144,9 +162,8 @@ static bool criteria_matches_view(struct criteria *criteria, // TODO } - if (criteria->window_type) { - uint32_t type = view_get_window_type(view); - if (!type || type != criteria->window_type) { + if (criteria->window_type != ATOM_LAST) { + if (!view_has_window_type(view, criteria->window_type)) { return false; } } @@ -254,6 +271,21 @@ static bool generate_regex(pcre **regex, char *value) { return true; } +static enum atom_name parse_window_type(const char *type) { + if (strcasecmp(type, "normal") == 0) { + return NET_WM_WINDOW_TYPE_NORMAL; + } else if (strcasecmp(type, "dialog") == 0) { + return NET_WM_WINDOW_TYPE_DIALOG; + } else if (strcasecmp(type, "utility") == 0) { + return NET_WM_WINDOW_TYPE_UTILITY; + } else if (strcasecmp(type, "toolbar") == 0) { + return NET_WM_WINDOW_TYPE_TOOLBAR; + } else if (strcasecmp(type, "splash") == 0) { + return NET_WM_WINDOW_TYPE_SPLASH; + } + return ATOM_LAST; // ie. invalid +} + enum criteria_token { T_APP_ID, T_CLASS, @@ -434,7 +466,7 @@ static bool parse_token(struct criteria *criteria, char *name, char *value) { generate_regex(&criteria->window_role, effective_value); break; case T_WINDOW_TYPE: - // TODO: This is a string but will be stored as an enum or integer + criteria->window_type = parse_window_type(effective_value); break; #ifdef HAVE_XWAYLAND case T_ID: @@ -526,7 +558,8 @@ struct criteria *criteria_parse(char *raw, char **error_arg) { } ++head; - struct criteria *criteria = calloc(sizeof(struct criteria), 1); + struct criteria *criteria = calloc(1, sizeof(struct criteria)); + criteria->window_type = ATOM_LAST; // default value char *name = NULL, *value = NULL; bool in_quotes = false; diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index 1fae5db2..a4f7f928 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c @@ -176,7 +176,7 @@ void arrange_layers(struct sway_output *output) { sizeof(struct wlr_box)) != 0) { wlr_log(WLR_DEBUG, "Usable area changed, rearranging output"); memcpy(&output->usable_area, &usable_area, sizeof(struct wlr_box)); - container_set_dirty(output->swayc); + arrange_output(output->swayc); } // Arrange non-exlusive surfaces from top->bottom @@ -247,7 +247,6 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) { layer_surface->surface, false); } - arrange_windows(output->swayc); transaction_commit_dirty(); } diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 4e401008..2adc28c5 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -17,6 +17,7 @@ #include "sway/tree/view.h" static const char *atom_map[ATOM_LAST] = { + "_NET_WM_WINDOW_TYPE_NORMAL", "_NET_WM_WINDOW_TYPE_DIALOG", "_NET_WM_WINDOW_TYPE_UTILITY", "_NET_WM_WINDOW_TYPE_TOOLBAR", diff --git a/sway/input/seat.c b/sway/input/seat.c index 6a6e3096..4b7c7893 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -779,7 +779,7 @@ void seat_set_focus_layer(struct sway_seat *seat, wlr_log(WLR_DEBUG, "Returning focus to %p %s '%s'", previous, container_type_to_str(previous->type), previous->name); // Hack to get seat to re-focus the return value of get_focus - seat_set_focus(seat, previous->parent); + seat_set_focus(seat, NULL); seat_set_focus(seat, previous); } return; |