summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar S. Christoffer Eliesen <christoffer@eliesen.no>2015-10-23 14:32:17 +0200
committerLibravatar S. Christoffer Eliesen <christoffer@eliesen.no>2015-10-23 16:35:48 +0200
commitc1479701dea79aebd2b5fdd83a9b28435f6647fe (patch)
tree857071bb0f3fe2795eacac82071123bfda1a750b
parenthandlers: Don't switch output when mouse button is pressed. (diff)
downloadsway-c1479701dea79aebd2b5fdd83a9b28435f6647fe.tar.gz
sway-c1479701dea79aebd2b5fdd83a9b28435f6647fe.tar.zst
sway-c1479701dea79aebd2b5fdd83a9b28435f6647fe.zip
seamless_mouse: Move pointer only if successfully changed workspace.
If e.g. a window has a popup open then that will lock the current focus, making a workspace switch denied. So don't move the mouse pointer in such cases.
-rw-r--r--include/focus.h4
-rw-r--r--include/workspace.h2
-rw-r--r--sway/focus.c24
-rw-r--r--sway/handlers.c20
-rw-r--r--sway/workspace.c9
5 files changed, 33 insertions, 26 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);
21swayc_t *get_focused_view(swayc_t *parent); 21swayc_t *get_focused_view(swayc_t *parent);
22swayc_t *get_focused_float(swayc_t *ws); 22swayc_t *get_focused_float(swayc_t *ws);
23 23
24void set_focused_container(swayc_t *container); 24bool set_focused_container(swayc_t *container);
25void set_focused_container_for(swayc_t *ancestor, swayc_t *container); 25bool 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;
10char *workspace_next_name(void); 10char *workspace_next_name(void);
11swayc_t *workspace_create(const char*); 11swayc_t *workspace_create(const char*);
12swayc_t *workspace_by_name(const char*); 12swayc_t *workspace_by_name(const char*);
13void workspace_switch(swayc_t*); 13bool workspace_switch(swayc_t*);
14swayc_t *workspace_output_next(); 14swayc_t *workspace_output_next();
15swayc_t *workspace_next(); 15swayc_t *workspace_next();
16swayc_t *workspace_output_prev(); 16swayc_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
76void set_focused_container(swayc_t *c) { 75bool 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
120void set_focused_container_for(swayc_t *a, swayc_t *c) { 120bool 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
166swayc_t *get_focused_view(swayc_t *parent) { 166swayc_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
201void workspace_switch(swayc_t *workspace) { 201bool 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}