diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/focus.c | 24 | ||||
-rw-r--r-- | sway/handlers.c | 20 | ||||
-rw-r--r-- | sway/workspace.c | 9 |
3 files changed, 30 insertions, 23 deletions
diff --git a/sway/focus.c b/sway/focus.c index 45108a11..0c1f8c9e 100644 --- a/sway/focus.c +++ b/sway/focus.c | |||
@@ -53,11 +53,10 @@ bool move_focus(enum movement_direction direction) { | |||
53 | view = get_swayc_in_direction(view, direction); | 53 | view = get_swayc_in_direction(view, direction); |
54 | if (view) { | 54 | if (view) { |
55 | if (direction == MOVE_PARENT) { | 55 | if (direction == MOVE_PARENT) { |
56 | set_focused_container(view); | 56 | return set_focused_container(view); |
57 | } else { | 57 | } else { |
58 | set_focused_container(get_focused_view(view)); | 58 | return set_focused_container(get_focused_view(view)); |
59 | } | 59 | } |
60 | return true; | ||
61 | } | 60 | } |
62 | return false; | 61 | return false; |
63 | } | 62 | } |
@@ -73,9 +72,9 @@ swayc_t *get_focused_container(swayc_t *parent) { | |||
73 | return parent; | 72 | return parent; |
74 | } | 73 | } |
75 | 74 | ||
76 | void set_focused_container(swayc_t *c) { | 75 | bool set_focused_container(swayc_t *c) { |
77 | if (locked_container_focus || !c) { | 76 | if (locked_container_focus || !c) { |
78 | return; | 77 | return false; |
79 | } | 78 | } |
80 | sway_log(L_DEBUG, "Setting focus to %p:%ld", c, c->handle); | 79 | sway_log(L_DEBUG, "Setting focus to %p:%ld", c, c->handle); |
81 | 80 | ||
@@ -84,7 +83,7 @@ void set_focused_container(swayc_t *c) { | |||
84 | swayc_t *focused = get_focused_view(workspace); | 83 | swayc_t *focused = get_focused_view(workspace); |
85 | // if the workspace we are changing focus to has a fullscreen view return | 84 | // if the workspace we are changing focus to has a fullscreen view return |
86 | if (swayc_is_fullscreen(focused) && focused != c) { | 85 | if (swayc_is_fullscreen(focused) && focused != c) { |
87 | return; | 86 | return false; |
88 | } | 87 | } |
89 | 88 | ||
90 | // update container focus from here to root, making necessary changes along | 89 | // update container focus from here to root, making necessary changes along |
@@ -115,17 +114,18 @@ void set_focused_container(swayc_t *c) { | |||
115 | } | 114 | } |
116 | } | 115 | } |
117 | } | 116 | } |
117 | return true; | ||
118 | } | 118 | } |
119 | 119 | ||
120 | void set_focused_container_for(swayc_t *a, swayc_t *c) { | 120 | bool set_focused_container_for(swayc_t *a, swayc_t *c) { |
121 | if (locked_container_focus || !c) { | 121 | if (locked_container_focus || !c) { |
122 | return; | 122 | return false; |
123 | } | 123 | } |
124 | swayc_t *find = c; | 124 | swayc_t *find = c; |
125 | // Ensure that a is an ancestor of c | 125 | // Ensure that a is an ancestor of c |
126 | while (find != a && (find = find->parent)) { | 126 | while (find != a && (find = find->parent)) { |
127 | if (find == &root_container) { | 127 | if (find == &root_container) { |
128 | return; | 128 | return false; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
@@ -134,7 +134,7 @@ void set_focused_container_for(swayc_t *a, swayc_t *c) { | |||
134 | swayc_t *focused = get_focused_view(workspace); | 134 | swayc_t *focused = get_focused_view(workspace); |
135 | // if the workspace we are changing focus to has a fullscreen view return | 135 | // if the workspace we are changing focus to has a fullscreen view return |
136 | if (swayc_is_fullscreen(focused) && c != focused) { | 136 | if (swayc_is_fullscreen(focused) && c != focused) { |
137 | return; | 137 | return false; |
138 | } | 138 | } |
139 | 139 | ||
140 | // Check if we changing a parent container that will see chnage | 140 | // Check if we changing a parent container that will see chnage |
@@ -147,8 +147,7 @@ void set_focused_container_for(swayc_t *a, swayc_t *c) { | |||
147 | } | 147 | } |
148 | if (effective) { | 148 | if (effective) { |
149 | // Go to set_focused_container | 149 | // Go to set_focused_container |
150 | set_focused_container(c); | 150 | return set_focused_container(c); |
151 | return; | ||
152 | } | 151 | } |
153 | 152 | ||
154 | sway_log(L_DEBUG, "Setting focus for %p:%ld to %p:%ld", | 153 | sway_log(L_DEBUG, "Setting focus for %p:%ld to %p:%ld", |
@@ -161,6 +160,7 @@ void set_focused_container_for(swayc_t *a, swayc_t *c) { | |||
161 | p = p->parent; | 160 | p = p->parent; |
162 | p->is_focused = false; | 161 | p->is_focused = false; |
163 | } | 162 | } |
163 | return true; | ||
164 | } | 164 | } |
165 | 165 | ||
166 | swayc_t *get_focused_view(swayc_t *parent) { | 166 | swayc_t *get_focused_view(swayc_t *parent) { |
diff --git a/sway/handlers.c b/sway/handlers.c index 5acdd096..09c020e9 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -377,8 +377,9 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
377 | } | 377 | } |
378 | if (c->y == output->y && c->x + c->width == output->x) { | 378 | if (c->y == output->y && c->x + c->width == output->x) { |
379 | sway_log(L_DEBUG, "%s is right of %s", output->name, c->name); | 379 | sway_log(L_DEBUG, "%s is right of %s", output->name, c->name); |
380 | workspace_switch(c); | 380 | if (workspace_switch(c)) { |
381 | new_origin.x = c->width; | 381 | new_origin.x = c->width; |
382 | } | ||
382 | } | 383 | } |
383 | } | 384 | } |
384 | } else if ((double)origin->x == output->width) { // Right edge | 385 | } else if ((double)origin->x == output->width) { // Right edge |
@@ -389,8 +390,9 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
389 | } | 390 | } |
390 | if (c->y == output->y && output->x + output->width == c->x) { | 391 | if (c->y == output->y && output->x + output->width == c->x) { |
391 | sway_log(L_DEBUG, "%s is left of %s", output->name, c->name); | 392 | sway_log(L_DEBUG, "%s is left of %s", output->name, c->name); |
392 | workspace_switch(c); | 393 | if (workspace_switch(c)) { |
393 | new_origin.x = 0; | 394 | new_origin.x = 0; |
395 | } | ||
394 | } | 396 | } |
395 | } | 397 | } |
396 | } | 398 | } |
@@ -402,8 +404,9 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
402 | } | 404 | } |
403 | if (output->x == c->x && c->y + c->height == output->y) { | 405 | if (output->x == c->x && c->y + c->height == output->y) { |
404 | sway_log(L_DEBUG, "%s is below %s", output->name, c->name); | 406 | sway_log(L_DEBUG, "%s is below %s", output->name, c->name); |
405 | workspace_switch(c); | 407 | if (workspace_switch(c)) { |
406 | new_origin.y = c->height; | 408 | new_origin.y = c->height; |
409 | } | ||
407 | } | 410 | } |
408 | } | 411 | } |
409 | } else if ((double)origin->y == output->height) { // Bottom edge | 412 | } else if ((double)origin->y == output->height) { // Bottom edge |
@@ -414,8 +417,9 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
414 | } | 417 | } |
415 | if (output->x == c->x && output->y + output->height == c->y) { | 418 | if (output->x == c->x && output->y + output->height == c->y) { |
416 | sway_log(L_DEBUG, "%s is above %s", output->name, c->name); | 419 | sway_log(L_DEBUG, "%s is above %s", output->name, c->name); |
417 | workspace_switch(c); | 420 | if (workspace_switch(c)) { |
418 | new_origin.y = 0; | 421 | new_origin.y = 0; |
422 | } | ||
419 | } | 423 | } |
420 | } | 424 | } |
421 | } | 425 | } |
diff --git a/sway/workspace.c b/sway/workspace.c index c169c1cb..b7e9760b 100644 --- a/sway/workspace.c +++ b/sway/workspace.c | |||
@@ -198,9 +198,9 @@ swayc_t *workspace_prev() { | |||
198 | return workspace_prev_next_impl(swayc_active_workspace(), false); | 198 | return workspace_prev_next_impl(swayc_active_workspace(), false); |
199 | } | 199 | } |
200 | 200 | ||
201 | void workspace_switch(swayc_t *workspace) { | 201 | bool workspace_switch(swayc_t *workspace) { |
202 | if (!workspace) { | 202 | if (!workspace) { |
203 | return; | 203 | return false; |
204 | } | 204 | } |
205 | swayc_t *active_ws = swayc_active_workspace(); | 205 | swayc_t *active_ws = swayc_active_workspace(); |
206 | if (config->auto_back_and_forth && active_ws == workspace && prev_workspace_name) { | 206 | if (config->auto_back_and_forth && active_ws == workspace && prev_workspace_name) { |
@@ -217,6 +217,9 @@ void workspace_switch(swayc_t *workspace) { | |||
217 | } | 217 | } |
218 | 218 | ||
219 | sway_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name); | 219 | sway_log(L_DEBUG, "Switching to workspace %p:%s", workspace, workspace->name); |
220 | set_focused_container(get_focused_view(workspace)); | 220 | if (!set_focused_container(get_focused_view(workspace))) { |
221 | return false; | ||
222 | } | ||
221 | arrange_windows(workspace, -1, -1); | 223 | arrange_windows(workspace, -1, -1); |
224 | return true; | ||
222 | } | 225 | } |