summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sway/commands.c4
-rw-r--r--sway/container.c5
-rw-r--r--sway/handlers.c8
-rw-r--r--sway/layout.c3
-rw-r--r--sway/movement.c4
-rw-r--r--sway/stringop.c67
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) {
285 return false; 285 return false;
286 } 286 }
287 if (strcasecmp(argv[0], "v") == 0 || strcasecmp(argv[0], "vertical") == 0) { 287 if (strcasecmp(argv[0], "v") == 0 || strcasecmp(argv[0], "vertical") == 0) {
288 _do_split(config, argc, argv, L_VERT); 288 _do_split(config, argc - 1, argv + 1, L_VERT);
289 } else if (strcasecmp(argv[0], "h") == 0 || strcasecmp(argv[0], "horizontal") == 0) { 289 } else if (strcasecmp(argv[0], "h") == 0 || strcasecmp(argv[0], "horizontal") == 0) {
290 _do_split(config, argc, argv, L_HORIZ); 290 _do_split(config, argc - 1, argv + 1, L_HORIZ);
291 } else { 291 } else {
292 sway_log(L_ERROR, "Invalid split command (expected either horiziontal or vertical)."); 292 sway_log(L_ERROR, "Invalid split command (expected either horiziontal or vertical).");
293 return false; 293 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) {
31 } 31 }
32 remove_child(c->parent, c); 32 remove_child(c->parent, c);
33 } 33 }
34 if (c->name) {
35 free(c->name);
36 }
34 free(c); 37 free(c);
35} 38}
36 39
@@ -43,9 +46,9 @@ static void add_output_widths(swayc_t *container, void *_width) {
43} 46}
44 47
45swayc_t *new_output(wlc_handle handle) { 48swayc_t *new_output(wlc_handle handle) {
46 sway_log(L_DEBUG, "Added output %d", handle);
47 const struct wlc_size* size = wlc_output_get_resolution(handle); 49 const struct wlc_size* size = wlc_output_get_resolution(handle);
48 const char *name = wlc_output_get_name(handle); 50 const char *name = wlc_output_get_name(handle);
51 sway_log(L_DEBUG, "Added output %d %s", handle, name);
49 52
50 swayc_t *output = new_swayc(C_OUTPUT); 53 swayc_t *output = new_swayc(C_OUTPUT);
51 output->width = size->w; 54 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
199static bool handle_pointer_motion(wlc_handle view, uint32_t time, const struct wlc_origin *origin) { 199static bool handle_pointer_motion(wlc_handle view, uint32_t time, const struct wlc_origin *origin) {
200 mouse_origin = *origin; 200 mouse_origin = *origin;
201 if (!config->focus_follows_mouse) { 201 if (!config->focus_follows_mouse) {
202 return true; 202 return false;
203 } 203 }
204 focus_pointer(); 204 focus_pointer();
205 return true; 205 return false;
206} 206}
207 207
208static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, 208static 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
210 swayc_t *focused = get_focused_container(&root_container); 210 swayc_t *focused = get_focused_container(&root_container);
211 if (state == WLC_BUTTON_STATE_PRESSED) { 211 if (state == WLC_BUTTON_STATE_PRESSED) {
212 swayc_t *pointer = focus_pointer(); 212 swayc_t *pointer = focus_pointer();
213 return !(pointer && pointer != focused); 213 return (pointer && pointer != focused);
214 } 214 }
215 return true; 215 return false;
216} 216}
217 217
218static void handle_wlc_ready(void) { 218static 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) {
244 } 244 }
245 while (view && view->type != C_VIEW) { 245 while (view && view->type != C_VIEW) {
246 view = view->focused; 246 view = view->focused;
247 if (view && view->type == C_OUTPUT) {
248 wlc_output_focus(view->handle);
249 }
247 } 250 }
248 if (view) { 251 if (view) {
249 wlc_view_set_state(view->handle, WLC_BIT_ACTIVATED, true); 252 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) {
28 bool can_move = false; 28 bool can_move = false;
29 int diff = 0; 29 int diff = 0;
30 if (direction == MOVE_LEFT || direction == MOVE_RIGHT) { 30 if (direction == MOVE_LEFT || direction == MOVE_RIGHT) {
31 if (parent->layout == L_HORIZ) { 31 if (parent->layout == L_HORIZ || parent->type == C_ROOT) {
32 can_move = true; 32 can_move = true;
33 diff = direction == MOVE_LEFT ? -1 : 1; 33 diff = direction == MOVE_LEFT ? -1 : 1;
34 } 34 }
@@ -61,7 +61,7 @@ bool move_focus(enum movement_direction direction) {
61 sway_log(L_DEBUG, "Can't move at current level, moving up tree"); 61 sway_log(L_DEBUG, "Can't move at current level, moving up tree");
62 current = parent; 62 current = parent;
63 parent = parent->parent; 63 parent = parent->parent;
64 if (parent->type == C_ROOT) { 64 if (!parent) {
65 // Nothing we can do 65 // Nothing we can do
66 return false; 66 return false;
67 } 67 }
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) {
53list_t *split_string(const char *str, const char *delims) { 53list_t *split_string(const char *str, const char *delims) {
54 list_t *res = create_list(); 54 list_t *res = create_list();
55 int i, j; 55 int i, j;
56 for (i = 0, j = 0; i < strlen(str) + 1; ++i) { 56 int len = strlen(str);
57 if (strchr(delims, str[i]) || i == strlen(str)) { 57 for (i = 0, j = 0; i < len + 1; ++i) {
58 if (strchr(delims, str[i]) || i == len) {
58 if (i - j == 0) { 59 if (i - j == 0) {
59 continue; 60 continue;
60 } 61 }
@@ -63,7 +64,7 @@ list_t *split_string(const char *str, const char *delims) {
63 left[i - j] = 0; 64 left[i - j] = 0;
64 list_add(res, left); 65 list_add(res, left);
65 j = i + 1; 66 j = i + 1;
66 while (j <= strlen(str) && str[j] && strchr(delims, str[j])) { 67 while (j <= len && str[j] && strchr(delims, str[j])) {
67 j++; 68 j++;
68 i++; 69 i++;
69 } 70 }
@@ -110,40 +111,72 @@ int unescape_string(char *string) {
110 for (i = 0; string[i]; ++i) { 111 for (i = 0; string[i]; ++i) {
111 if (string[i] == '\\') { 112 if (string[i] == '\\') {
112 --len; 113 --len;
114 int shift = 0;
113 switch (string[++i]) { 115 switch (string[++i]) {
114 case '0': 116 case '0':
115 string[i - 1] = '\0'; 117 string[i - 1] = '\0';
116 memmove(string + i, string + i + 1, len - i); 118 shift = 1;
117 break; 119 break;
118 case 'a': 120 case 'a':
119 string[i - 1] = '\a'; 121 string[i - 1] = '\a';
120 memmove(string + i, string + i + 1, len - i); 122 shift = 1;
121 break; 123 break;
122 case 'b': 124 case 'b':
123 string[i - 1] = '\b'; 125 string[i - 1] = '\b';
124 memmove(string + i, string + i + 1, len - i); 126 shift = 1;
125 break; 127 break;
126 case 't': 128 case 'f':
127 string[i - 1] = '\t'; 129 string[i - 1] = '\f';
128 memmove(string + i, string + i + 1, len - i); 130 shift = 1;
129 break; 131 break;
130 case 'n': 132 case 'n':
131 string[i - 1] = '\n'; 133 string[i - 1] = '\n';
132 memmove(string + i, string + i + 1, len - i); 134 shift = 1;
135 break;
136 case 'r':
137 string[i - 1] = '\r';
138 shift = 1;
139 break;
140 case 't':
141 string[i - 1] = '\t';
142 shift = 1;
133 break; 143 break;
134 case 'v': 144 case 'v':
135 string[i - 1] = '\v'; 145 string[i - 1] = '\v';
136 memmove(string + i, string + i + 1, len - i); 146 shift = 1;
137 break; 147 break;
138 case 'f': 148 case '\\':
139 string[i - 1] = '\f'; 149 shift = 1;
140 memmove(string + i, string + i + 1, len - i);
141 break; 150 break;
142 case 'r': 151 case '\'':
143 string[i - 1] = '\r'; 152 string[i - 1] = '\'';
144 memmove(string + i, string + i + 1, len - i); 153 shift = 1;
154 break;
155 case '\"':
156 string[i - 1] = '\"';
157 shift = 1;
158 break;
159 case '?':
160 string[i - 1] = '?';
161 shift = 1;
145 break; 162 break;
163 case 'x':
164 {
165 unsigned char c = 0;
166 shift = 1;
167 if (string[i+1] >= '0' && string[i+1] <= '9') {
168 shift = 2;
169 c = string[i+1] - '0';
170 if (string[i+2] >= '0' && string[i+2] <= '9') {
171 shift = 3;
172 c *= 0x10;
173 c += string[i+2] - '0';
174 }
175 }
176 string[i - 1] = c;
177 }
146 } 178 }
179 memmove(string + i, string + i + shift, len - i);
147 } 180 }
148 } 181 }
149 return len; 182 return len;