summaryrefslogtreecommitdiffstats
path: root/sway/handlers.c
diff options
context:
space:
mode:
authorLibravatar S. Christoffer Eliesen <christoffer@eliesen.no>2015-11-16 00:35:25 +0100
committerLibravatar S. Christoffer Eliesen <christoffer@eliesen.no>2015-11-16 21:32:18 +0100
commit236f26f62e56cef8278d88f6111720b738d4a85f (patch)
treebdac5630c32099785a6eade4dfa8ceb04a3c11dd /sway/handlers.c
parentMerge pull request #232 from sce/replace_output_config (diff)
downloadsway-236f26f62e56cef8278d88f6111720b738d4a85f.tar.gz
sway-236f26f62e56cef8278d88f6111720b738d4a85f.tar.zst
sway-236f26f62e56cef8278d88f6111720b738d4a85f.zip
output: Support multiple adjacent outputs.
When querying for an adjacent output we now need an absolute position in order to know which adjacent output that matches. (The position is either the current mouse position or the center of the currently focused container, depending on context.) If two outputs have one edge each that at least partially align with each other they now count as adjacent. Seamless mouse is affected by this and now properly moves and positions itself between outputs with "uneven" placement (as long as they have at least some part of the edge adjacent to each other). When focusing or moving a container in a specified direction the center of the current focused container decides where to look for an adjacent output. So if e.g. an output has two adjacent outputs to the right and a "focus right" command is issued then it's the placement of the currently focused container that decides which output actually gets focused. Also, if an output has at least one output adjacent in some direction but the entire edge is not covered (ie. it has "holes" with no outputs), then the algorithm will choose the output that is closest to the currently focused container (this does not apply to seamless mouse, the pointer will just stop at the edge in that case).
Diffstat (limited to 'sway/handlers.c')
-rw-r--r--sway/handlers.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index cadfce5c..3f3c1bdd 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -305,28 +305,39 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
305 !pointer_state.left.held && !pointer_state.right.held && !pointer_state.scroll.held) { 305 !pointer_state.left.held && !pointer_state.right.held && !pointer_state.scroll.held) {
306 306
307 swayc_t *output = swayc_active_output(), *adjacent = NULL; 307 swayc_t *output = swayc_active_output(), *adjacent = NULL;
308 struct wlc_point abs_pos = *origin;
309 abs_pos.x += output->x;
310 abs_pos.y += output->y;
308 if (origin->x == 0) { // Left edge 311 if (origin->x == 0) { // Left edge
309 if ((adjacent = swayc_adjacent_output(output, MOVE_LEFT))) { 312 if ((adjacent = swayc_adjacent_output(output, MOVE_LEFT, &abs_pos, false))) {
310 if (workspace_switch(swayc_active_workspace_for(adjacent))) { 313 if (workspace_switch(swayc_active_workspace_for(adjacent))) {
311 new_origin.x = adjacent->width; 314 new_origin.x = adjacent->width;
315 // adjust for differently aligned outputs (well, this is
316 // only correct when the two outputs have the same
317 // resolution or the same dpi I guess, it should take
318 // physical attributes into account)
319 new_origin.y += (output->y - adjacent->y);
312 } 320 }
313 } 321 }
314 } else if ((double)origin->x == output->width) { // Right edge 322 } else if ((double)origin->x == output->width) { // Right edge
315 if ((adjacent = swayc_adjacent_output(output, MOVE_RIGHT))) { 323 if ((adjacent = swayc_adjacent_output(output, MOVE_RIGHT, &abs_pos, false))) {
316 if (workspace_switch(swayc_active_workspace_for(adjacent))) { 324 if (workspace_switch(swayc_active_workspace_for(adjacent))) {
317 new_origin.x = 0; 325 new_origin.x = 0;
326 new_origin.y += (output->y - adjacent->y);
318 } 327 }
319 } 328 }
320 } else if (origin->y == 0) { // Top edge 329 } else if (origin->y == 0) { // Top edge
321 if ((adjacent = swayc_adjacent_output(output, MOVE_UP))) { 330 if ((adjacent = swayc_adjacent_output(output, MOVE_UP, &abs_pos, false))) {
322 if (workspace_switch(swayc_active_workspace_for(adjacent))) { 331 if (workspace_switch(swayc_active_workspace_for(adjacent))) {
323 new_origin.y = adjacent->height; 332 new_origin.y = adjacent->height;
333 new_origin.x += (output->x - adjacent->x);
324 } 334 }
325 } 335 }
326 } else if ((double)origin->y == output->height) { // Bottom edge 336 } else if ((double)origin->y == output->height) { // Bottom edge
327 if ((adjacent = swayc_adjacent_output(output, MOVE_DOWN))) { 337 if ((adjacent = swayc_adjacent_output(output, MOVE_DOWN, &abs_pos, false))) {
328 if (workspace_switch(swayc_active_workspace_for(adjacent))) { 338 if (workspace_switch(swayc_active_workspace_for(adjacent))) {
329 new_origin.y = 0; 339 new_origin.y = 0;
340 new_origin.x += (output->x - adjacent->x);
330 } 341 }
331 } 342 }
332 } 343 }