diff options
Diffstat (limited to 'sway/handlers.c')
-rw-r--r-- | sway/handlers.c | 61 |
1 files changed, 15 insertions, 46 deletions
diff --git a/sway/handlers.c b/sway/handlers.c index c0b775db..c777e692 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include "stringop.h" | 13 | #include "stringop.h" |
14 | #include "workspace.h" | 14 | #include "workspace.h" |
15 | #include "container.h" | 15 | #include "container.h" |
16 | #include "output.h" | ||
16 | #include "focus.h" | 17 | #include "focus.h" |
17 | #include "input_state.h" | 18 | #include "input_state.h" |
18 | #include "resize.h" | 19 | #include "resize.h" |
@@ -364,62 +365,30 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct | |||
364 | // don't do the switch if the pointer is in a mode. | 365 | // don't do the switch if the pointer is in a mode. |
365 | if (config->seamless_mouse && !pointer_state.mode && | 366 | if (config->seamless_mouse && !pointer_state.mode && |
366 | !pointer_state.left.held && !pointer_state.right.held && !pointer_state.scroll.held) { | 367 | !pointer_state.left.held && !pointer_state.right.held && !pointer_state.scroll.held) { |
367 | swayc_t *output = swayc_active_output(); | ||
368 | 368 | ||
369 | // TODO: This implementation is naïve: We assume all outputs are | 369 | swayc_t *output = swayc_active_output(), *adjacent = NULL; |
370 | // perfectly aligned (ie. only a single output per edge which covers | ||
371 | // the whole edge). | ||
372 | if (origin->x == 0) { // Left edge | 370 | if (origin->x == 0) { // Left edge |
373 | for(int i = 0; i < root_container.children->length; ++i) { | 371 | if ((adjacent = swayc_adjacent_output(output, MOVE_LEFT))) { |
374 | swayc_t *c = root_container.children->items[i]; | 372 | if (workspace_switch(adjacent)) { |
375 | if (c == output || c->type != C_OUTPUT) { | 373 | new_origin.x = adjacent->width; |
376 | continue; | ||
377 | } | ||
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); | ||
380 | if (workspace_switch(c)) { | ||
381 | new_origin.x = c->width; | ||
382 | } | ||
383 | } | 374 | } |
384 | } | 375 | } |
385 | } else if ((double)origin->x == output->width) { // Right edge | 376 | } else if ((double)origin->x == output->width) { // Right edge |
386 | for(int i = 0; i < root_container.children->length; ++i) { | 377 | if ((adjacent = swayc_adjacent_output(output, MOVE_RIGHT))) { |
387 | swayc_t *c = root_container.children->items[i]; | 378 | if (workspace_switch(adjacent)) { |
388 | if (c == output || c->type != C_OUTPUT) { | 379 | new_origin.x = 0; |
389 | continue; | ||
390 | } | ||
391 | if (c->y == output->y && output->x + output->width == c->x) { | ||
392 | sway_log(L_DEBUG, "%s is left of %s", output->name, c->name); | ||
393 | if (workspace_switch(c)) { | ||
394 | new_origin.x = 0; | ||
395 | } | ||
396 | } | 380 | } |
397 | } | 381 | } |
398 | } | 382 | } else if (origin->y == 0) { // Top edge |
399 | if (origin->y == 0) { // Top edge | 383 | if ((adjacent = swayc_adjacent_output(output, MOVE_UP))) { |
400 | for(int i = 0; i < root_container.children->length; ++i) { | 384 | if (workspace_switch(adjacent)) { |
401 | swayc_t *c = root_container.children->items[i]; | 385 | new_origin.y = adjacent->height; |
402 | if (c == output || c->type != C_OUTPUT) { | ||
403 | continue; | ||
404 | } | ||
405 | if (output->x == c->x && c->y + c->height == output->y) { | ||
406 | sway_log(L_DEBUG, "%s is below %s", output->name, c->name); | ||
407 | if (workspace_switch(c)) { | ||
408 | new_origin.y = c->height; | ||
409 | } | ||
410 | } | 386 | } |
411 | } | 387 | } |
412 | } else if ((double)origin->y == output->height) { // Bottom edge | 388 | } else if ((double)origin->y == output->height) { // Bottom edge |
413 | for(int i = 0; i < root_container.children->length; ++i) { | 389 | if ((adjacent = swayc_adjacent_output(output, MOVE_DOWN))) { |
414 | swayc_t *c = root_container.children->items[i]; | 390 | if (workspace_switch(adjacent)) { |
415 | if (c == output || c->type != C_OUTPUT) { | 391 | new_origin.y = 0; |
416 | continue; | ||
417 | } | ||
418 | if (output->x == c->x && output->y + output->height == c->y) { | ||
419 | sway_log(L_DEBUG, "%s is above %s", output->name, c->name); | ||
420 | if (workspace_switch(c)) { | ||
421 | new_origin.y = 0; | ||
422 | } | ||
423 | } | 392 | } |
424 | } | 393 | } |
425 | } | 394 | } |