diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-10-23 10:48:09 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-10-23 10:48:09 -0400 |
commit | c0f4a17c2a5810a012449d06e2ad242c75727b61 (patch) | |
tree | 857071bb0f3fe2795eacac82071123bfda1a750b | |
parent | Merge pull request #201 from sce/cmd_results (diff) | |
parent | seamless_mouse: Move pointer only if successfully changed workspace. (diff) | |
download | sway-c0f4a17c2a5810a012449d06e2ad242c75727b61.tar.gz sway-c0f4a17c2a5810a012449d06e2ad242c75727b61.tar.zst sway-c0f4a17c2a5810a012449d06e2ad242c75727b61.zip |
Merge pull request #202 from sce/seamless_mouse_adjustments
Seamless mouse adjustments
-rw-r--r-- | include/focus.h | 4 | ||||
-rw-r--r-- | include/workspace.h | 2 | ||||
-rw-r--r-- | sway/focus.c | 24 | ||||
-rw-r--r-- | sway/handlers.c | 23 | ||||
-rw-r--r-- | sway/workspace.c | 9 |
5 files changed, 35 insertions, 27 deletions
diff --git a/include/focus.h b/include/focus.h index 1ab63a6c..10d5182b 100644 --- a/include/focus.h +++ b/include/focus.h | |||
@@ -21,8 +21,8 @@ swayc_t *get_focused_container(swayc_t *parent); | |||
21 | swayc_t *get_focused_view(swayc_t *parent); | 21 | swayc_t *get_focused_view(swayc_t *parent); |
22 | swayc_t *get_focused_float(swayc_t *ws); | 22 | swayc_t *get_focused_float(swayc_t *ws); |
23 | 23 | ||
24 | void set_focused_container(swayc_t *container); | 24 | bool set_focused_container(swayc_t *container); |
25 | void set_focused_container_for(swayc_t *ancestor, swayc_t *container); | 25 | bool set_focused_container_for(swayc_t *ancestor, swayc_t *container); |
26 | 26 | ||
27 | // lock focused container/view. locked by windows with OVERRIDE attribute | 27 | // lock focused container/view. locked by windows with OVERRIDE attribute |
28 | // and unlocked when they are destroyed | 28 | // and unlocked when they are destroyed |
diff --git a/include/workspace.h b/include/workspace.h index 7343b055..b916f715 100644 --- a/include/workspace.h +++ b/include/workspace.h | |||
@@ -10,7 +10,7 @@ extern char *prev_workspace_name; | |||
10 | char *workspace_next_name(void); | 10 | char *workspace_next_name(void); |
11 | swayc_t *workspace_create(const char*); | 11 | swayc_t *workspace_create(const char*); |
12 | swayc_t *workspace_by_name(const char*); | 12 | swayc_t *workspace_by_name(const char*); |
13 | void workspace_switch(swayc_t*); | 13 | bool workspace_switch(swayc_t*); |
14 | swayc_t *workspace_output_next(); | 14 | swayc_t *workspace_output_next(); |
15 | swayc_t *workspace_next(); | 15 | swayc_t *workspace_next(); |
16 | swayc_t *workspace_output_prev(); | 16 | swayc_t *workspace_output_prev(); |
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 24105130..09c020e9 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -362,7 +362,8 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
362 | // | 362 | // |
363 | // Since this doesn't currently support moving windows between outputs we | 363 | // Since this doesn't currently support moving windows between outputs we |
364 | // don't do the switch if the pointer is in a mode. | 364 | // don't do the switch if the pointer is in a mode. |
365 | if (config->seamless_mouse && !pointer_state.mode) { | 365 | if (config->seamless_mouse && !pointer_state.mode && |
366 | !pointer_state.left.held && !pointer_state.right.held && !pointer_state.scroll.held) { | ||
366 | swayc_t *output = swayc_active_output(); | 367 | swayc_t *output = swayc_active_output(); |
367 | 368 | ||
368 | // TODO: This implementation is naïve: We assume all outputs are | 369 | // TODO: This implementation is naïve: We assume all outputs are |
@@ -376,8 +377,9 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
376 | } | 377 | } |
377 | if (c->y == output->y && c->x + c->width == output->x) { | 378 | if (c->y == output->y && c->x + c->width == output->x) { |
378 | 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); |
379 | workspace_switch(c); | 380 | if (workspace_switch(c)) { |
380 | new_origin.x = c->width; | 381 | new_origin.x = c->width; |
382 | } | ||
381 | } | 383 | } |
382 | } | 384 | } |
383 | } else if ((double)origin->x == output->width) { // Right edge | 385 | } else if ((double)origin->x == output->width) { // Right edge |
@@ -388,8 +390,9 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
388 | } | 390 | } |
389 | if (c->y == output->y && output->x + output->width == c->x) { | 391 | if (c->y == output->y && output->x + output->width == c->x) { |
390 | 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); |
391 | workspace_switch(c); | 393 | if (workspace_switch(c)) { |
392 | new_origin.x = 0; | 394 | new_origin.x = 0; |
395 | } | ||
393 | } | 396 | } |
394 | } | 397 | } |
395 | } | 398 | } |
@@ -401,8 +404,9 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
401 | } | 404 | } |
402 | if (output->x == c->x && c->y + c->height == output->y) { | 405 | if (output->x == c->x && c->y + c->height == output->y) { |
403 | 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); |
404 | workspace_switch(c); | 407 | if (workspace_switch(c)) { |
405 | new_origin.y = c->height; | 408 | new_origin.y = c->height; |
409 | } | ||
406 | } | 410 | } |
407 | } | 411 | } |
408 | } else if ((double)origin->y == output->height) { // Bottom edge | 412 | } else if ((double)origin->y == output->height) { // Bottom edge |
@@ -413,8 +417,9 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
413 | } | 417 | } |
414 | if (output->x == c->x && output->y + output->height == c->y) { | 418 | if (output->x == c->x && output->y + output->height == c->y) { |
415 | 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); |
416 | workspace_switch(c); | 420 | if (workspace_switch(c)) { |
417 | new_origin.y = 0; | 421 | new_origin.y = 0; |
422 | } | ||
418 | } | 423 | } |
419 | } | 424 | } |
420 | } | 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 | } |