diff options
author | 2015-11-16 00:35:25 +0100 | |
---|---|---|
committer | 2015-11-16 21:32:18 +0100 | |
commit | 236f26f62e56cef8278d88f6111720b738d4a85f (patch) | |
tree | bdac5630c32099785a6eade4dfa8ceb04a3c11dd /sway/commands.c | |
parent | Merge pull request #232 from sce/replace_output_config (diff) | |
download | sway-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/commands.c')
-rw-r--r-- | sway/commands.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/sway/commands.c b/sway/commands.c index f194681e..dfb3c12d 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -377,11 +377,13 @@ static struct cmd_results *cmd_focus(int argc, char **argv) { | |||
377 | struct cmd_results *error = NULL; | 377 | struct cmd_results *error = NULL; |
378 | if (argc > 0 && strcasecmp(argv[0], "output") == 0) { | 378 | if (argc > 0 && strcasecmp(argv[0], "output") == 0) { |
379 | swayc_t *output = NULL; | 379 | swayc_t *output = NULL; |
380 | struct wlc_point abs_pos; | ||
381 | get_absolute_center_position(get_focused_container(&root_container), &abs_pos); | ||
380 | if ((error = checkarg(argc, "focus", EXPECTED_EQUAL_TO, 2))) { | 382 | if ((error = checkarg(argc, "focus", EXPECTED_EQUAL_TO, 2))) { |
381 | return error; | 383 | return error; |
382 | } else if (!(output = output_by_name(argv[1]))) { | 384 | } else if (!(output = output_by_name(argv[1], &abs_pos))) { |
383 | return cmd_results_new(CMD_FAILURE, "focus output", | 385 | return cmd_results_new(CMD_FAILURE, "focus output", |
384 | "Can't find output with name/at direction %s", argv[1]); | 386 | "Can't find output with name/at direction '%s' @ (%i,%i)", argv[1], abs_pos.x, abs_pos.y); |
385 | } else if (!workspace_switch(swayc_active_workspace_for(output))) { | 387 | } else if (!workspace_switch(swayc_active_workspace_for(output))) { |
386 | return cmd_results_new(CMD_FAILURE, "focus output", | 388 | return cmd_results_new(CMD_FAILURE, "focus output", |
387 | "Switching to workspace on output '%s' was blocked", argv[1]); | 389 | "Switching to workspace on output '%s' was blocked", argv[1]); |
@@ -591,11 +593,13 @@ static struct cmd_results *cmd_move(int argc, char **argv) { | |||
591 | } else if (strcasecmp(argv[1], "to") == 0 && strcasecmp(argv[2], "output") == 0) { | 593 | } else if (strcasecmp(argv[1], "to") == 0 && strcasecmp(argv[2], "output") == 0) { |
592 | // move container to output x | 594 | // move container to output x |
593 | swayc_t *output = NULL; | 595 | swayc_t *output = NULL; |
596 | struct wlc_point abs_pos; | ||
597 | get_absolute_center_position(view, &abs_pos); | ||
594 | if (view->type != C_CONTAINER && view->type != C_VIEW) { | 598 | if (view->type != C_CONTAINER && view->type != C_VIEW) { |
595 | return cmd_results_new(CMD_FAILURE, "move", "Can only move containers and views."); | 599 | return cmd_results_new(CMD_FAILURE, "move", "Can only move containers and views."); |
596 | } else if (!(output = output_by_name(argv[3]))) { | 600 | } else if (!(output = output_by_name(argv[3], &abs_pos))) { |
597 | return cmd_results_new(CMD_FAILURE, "move", | 601 | return cmd_results_new(CMD_FAILURE, "move", |
598 | "Can't find output with name/direction '%s'", argv[3]); | 602 | "Can't find output with name/direction '%s' @ (%i,%i)", argv[3], abs_pos.x, abs_pos.y); |
599 | } else { | 603 | } else { |
600 | swayc_t *container = get_focused_container(output); | 604 | swayc_t *container = get_focused_container(output); |
601 | if (container->is_floating) { | 605 | if (container->is_floating) { |
@@ -610,13 +614,15 @@ static struct cmd_results *cmd_move(int argc, char **argv) { | |||
610 | } else if (strcasecmp(argv[0], "workspace") == 0) { | 614 | } else if (strcasecmp(argv[0], "workspace") == 0) { |
611 | // move workspace (to output x) | 615 | // move workspace (to output x) |
612 | swayc_t *output = NULL; | 616 | swayc_t *output = NULL; |
617 | struct wlc_point abs_pos; | ||
618 | get_absolute_center_position(view, &abs_pos); | ||
613 | if ((error = checkarg(argc, "move workspace", EXPECTED_EQUAL_TO, 4))) { | 619 | if ((error = checkarg(argc, "move workspace", EXPECTED_EQUAL_TO, 4))) { |
614 | return error; | 620 | return error; |
615 | } else if (strcasecmp(argv[1], "to") != 0 || strcasecmp(argv[2], "output") != 0) { | 621 | } else if (strcasecmp(argv[1], "to") != 0 || strcasecmp(argv[2], "output") != 0) { |
616 | return cmd_results_new(CMD_INVALID, "move", expected_syntax); | 622 | return cmd_results_new(CMD_INVALID, "move", expected_syntax); |
617 | } else if (!(output = output_by_name(argv[3]))) { | 623 | } else if (!(output = output_by_name(argv[3], &abs_pos))) { |
618 | return cmd_results_new(CMD_FAILURE, "move workspace", | 624 | return cmd_results_new(CMD_FAILURE, "move workspace", |
619 | "Can't find output with name/at direction '%s'", argv[3]); | 625 | "Can't find output with name/direction '%s' @ (%i,%i)", argv[3], abs_pos.x, abs_pos.y); |
620 | } | 626 | } |
621 | if (view->type == C_WORKSPACE) { | 627 | if (view->type == C_WORKSPACE) { |
622 | // This probably means we're moving an empty workspace, but | 628 | // This probably means we're moving an empty workspace, but |