diff options
-rw-r--r-- | sway/commands.c | 4 | ||||
-rw-r--r-- | sway/container.c | 5 | ||||
-rw-r--r-- | sway/handlers.c | 8 | ||||
-rw-r--r-- | sway/layout.c | 3 | ||||
-rw-r--r-- | sway/movement.c | 4 | ||||
-rw-r--r-- | sway/stringop.c | 67 |
6 files changed, 65 insertions, 26 deletions
diff --git a/sway/commands.c b/sway/commands.c index 91fadb86..d4f588de 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -285,9 +285,9 @@ static bool cmd_split(struct sway_config *config, int argc, char **argv) { return false; } if (strcasecmp(argv[0], "v") == 0 || strcasecmp(argv[0], "vertical") == 0) { - _do_split(config, argc, argv, L_VERT); + _do_split(config, argc - 1, argv + 1, L_VERT); } else if (strcasecmp(argv[0], "h") == 0 || strcasecmp(argv[0], "horizontal") == 0) { - _do_split(config, argc, argv, L_HORIZ); + _do_split(config, argc - 1, argv + 1, L_HORIZ); } else { sway_log(L_ERROR, "Invalid split command (expected either horiziontal or vertical)."); return false; diff --git a/sway/container.c b/sway/container.c index 1f9b250f..3158b8b0 100644 --- a/sway/container.c +++ b/sway/container.c @@ -31,6 +31,9 @@ static void free_swayc(swayc_t *c) { } remove_child(c->parent, c); } + if (c->name) { + free(c->name); + } free(c); } @@ -43,9 +46,9 @@ static void add_output_widths(swayc_t *container, void *_width) { } swayc_t *new_output(wlc_handle handle) { - sway_log(L_DEBUG, "Added output %d", handle); const struct wlc_size* size = wlc_output_get_resolution(handle); const char *name = wlc_output_get_name(handle); + sway_log(L_DEBUG, "Added output %d %s", handle, name); swayc_t *output = new_swayc(C_OUTPUT); output->width = size->w; diff --git a/sway/handlers.c b/sway/handlers.c index d843f44b..32b0051d 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -199,10 +199,10 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier static bool handle_pointer_motion(wlc_handle view, uint32_t time, const struct wlc_origin *origin) { mouse_origin = *origin; if (!config->focus_follows_mouse) { - return true; + return false; } focus_pointer(); - return true; + return false; } static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, @@ -210,9 +210,9 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w swayc_t *focused = get_focused_container(&root_container); if (state == WLC_BUTTON_STATE_PRESSED) { swayc_t *pointer = focus_pointer(); - return !(pointer && pointer != focused); + return (pointer && pointer != focused); } - return true; + return false; } static void handle_wlc_ready(void) { diff --git a/sway/layout.c b/sway/layout.c index 918da9f0..20b5999c 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -244,6 +244,9 @@ void focus_view(swayc_t *view) { } while (view && view->type != C_VIEW) { view = view->focused; + if (view && view->type == C_OUTPUT) { + wlc_output_focus(view->handle); + } } if (view) { wlc_view_set_state(view->handle, WLC_BIT_ACTIVATED, true); diff --git a/sway/movement.c b/sway/movement.c index de987679..12726392 100644 --- a/sway/movement.c +++ b/sway/movement.c @@ -28,7 +28,7 @@ bool move_focus(enum movement_direction direction) { bool can_move = false; int diff = 0; if (direction == MOVE_LEFT || direction == MOVE_RIGHT) { - if (parent->layout == L_HORIZ) { + if (parent->layout == L_HORIZ || parent->type == C_ROOT) { can_move = true; diff = direction == MOVE_LEFT ? -1 : 1; } @@ -61,7 +61,7 @@ bool move_focus(enum movement_direction direction) { sway_log(L_DEBUG, "Can't move at current level, moving up tree"); current = parent; parent = parent->parent; - if (parent->type == C_ROOT) { + if (!parent) { // Nothing we can do return false; } diff --git a/sway/stringop.c b/sway/stringop.c index bbc0bcdf..1dff97bf 100644 --- a/sway/stringop.c +++ b/sway/stringop.c @@ -53,8 +53,9 @@ char *strip_comments(char *str) { list_t *split_string(const char *str, const char *delims) { list_t *res = create_list(); int i, j; - for (i = 0, j = 0; i < strlen(str) + 1; ++i) { - if (strchr(delims, str[i]) || i == strlen(str)) { + int len = strlen(str); + for (i = 0, j = 0; i < len + 1; ++i) { + if (strchr(delims, str[i]) || i == len) { if (i - j == 0) { continue; } @@ -63,7 +64,7 @@ list_t *split_string(const char *str, const char *delims) { left[i - j] = 0; list_add(res, left); j = i + 1; - while (j <= strlen(str) && str[j] && strchr(delims, str[j])) { + while (j <= len && str[j] && strchr(delims, str[j])) { j++; i++; } @@ -110,40 +111,72 @@ int unescape_string(char *string) { for (i = 0; string[i]; ++i) { if (string[i] == '\\') { --len; + int shift = 0; switch (string[++i]) { case '0': string[i - 1] = '\0'; - memmove(string + i, string + i + 1, len - i); + shift = 1; break; case 'a': string[i - 1] = '\a'; - memmove(string + i, string + i + 1, len - i); + shift = 1; break; case 'b': string[i - 1] = '\b'; - memmove(string + i, string + i + 1, len - i); + shift = 1; break; - case 't': - string[i - 1] = '\t'; - memmove(string + i, string + i + 1, len - i); + case 'f': + string[i - 1] = '\f'; + shift = 1; break; case 'n': string[i - 1] = '\n'; - memmove(string + i, string + i + 1, len - i); + shift = 1; + break; + case 'r': + string[i - 1] = '\r'; + shift = 1; + break; + case 't': + string[i - 1] = '\t'; + shift = 1; break; case 'v': string[i - 1] = '\v'; - memmove(string + i, string + i + 1, len - i); + shift = 1; break; - case 'f': - string[i - 1] = '\f'; - memmove(string + i, string + i + 1, len - i); + case '\\': + shift = 1; break; - case 'r': - string[i - 1] = '\r'; - memmove(string + i, string + i + 1, len - i); + case '\'': + string[i - 1] = '\''; + shift = 1; + break; + case '\"': + string[i - 1] = '\"'; + shift = 1; + break; + case '?': + string[i - 1] = '?'; + shift = 1; break; + case 'x': + { + unsigned char c = 0; + shift = 1; + if (string[i+1] >= '0' && string[i+1] <= '9') { + shift = 2; + c = string[i+1] - '0'; + if (string[i+2] >= '0' && string[i+2] <= '9') { + shift = 3; + c *= 0x10; + c += string[i+2] - '0'; + } + } + string[i - 1] = c; + } } + memmove(string + i, string + i + shift, len - i); } } return len; |