diff options
-rw-r--r-- | sway/commands/move.c | 26 | ||||
-rw-r--r-- | sway/sway.5.scd | 11 |
2 files changed, 29 insertions, 8 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c index 51e52665..a4eedf7f 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -765,7 +765,8 @@ static struct cmd_results *move_in_direction(struct sway_container *container, | |||
765 | 765 | ||
766 | static const char *expected_position_syntax = | 766 | static const char *expected_position_syntax = |
767 | "Expected 'move [absolute] position <x> [px] <y> [px]' or " | 767 | "Expected 'move [absolute] position <x> [px] <y> [px]' or " |
768 | "'move [absolute] position center|mouse'"; | 768 | "'move [absolute] position center' or " |
769 | "'move position cursor|mouse|pointer'"; | ||
769 | 770 | ||
770 | static struct cmd_results *move_to_position(struct sway_container *container, | 771 | static struct cmd_results *move_to_position(struct sway_container *container, |
771 | int argc, char **argv) { | 772 | int argc, char **argv) { |
@@ -777,7 +778,10 @@ static struct cmd_results *move_to_position(struct sway_container *container, | |||
777 | if (!argc) { | 778 | if (!argc) { |
778 | return cmd_results_new(CMD_FAILURE, "move", expected_position_syntax); | 779 | return cmd_results_new(CMD_FAILURE, "move", expected_position_syntax); |
779 | } | 780 | } |
781 | |||
782 | bool absolute = false; | ||
780 | if (strcmp(argv[0], "absolute") == 0) { | 783 | if (strcmp(argv[0], "absolute") == 0) { |
784 | absolute = true; | ||
781 | --argc; | 785 | --argc; |
782 | ++argv; | 786 | ++argv; |
783 | } | 787 | } |
@@ -791,7 +795,8 @@ static struct cmd_results *move_to_position(struct sway_container *container, | |||
791 | if (!argc) { | 795 | if (!argc) { |
792 | return cmd_results_new(CMD_FAILURE, "move", expected_position_syntax); | 796 | return cmd_results_new(CMD_FAILURE, "move", expected_position_syntax); |
793 | } | 797 | } |
794 | if (strcmp(argv[0], "mouse") == 0) { | 798 | if (strcmp(argv[0], "cursor") == 0 || strcmp(argv[0], "mouse") == 0 || |
799 | strcmp(argv[0], "pointer") == 0) { | ||
795 | struct sway_seat *seat = config->handler_context.seat; | 800 | struct sway_seat *seat = config->handler_context.seat; |
796 | if (!seat->cursor) { | 801 | if (!seat->cursor) { |
797 | return cmd_results_new(CMD_FAILURE, "move", "No cursor device"); | 802 | return cmd_results_new(CMD_FAILURE, "move", "No cursor device"); |
@@ -801,9 +806,15 @@ static struct cmd_results *move_to_position(struct sway_container *container, | |||
801 | container_floating_move_to(container, lx, ly); | 806 | container_floating_move_to(container, lx, ly); |
802 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 807 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
803 | } else if (strcmp(argv[0], "center") == 0) { | 808 | } else if (strcmp(argv[0], "center") == 0) { |
804 | struct sway_container *ws = container_parent(container, C_WORKSPACE); | 809 | double lx, ly; |
805 | double lx = ws->x + (ws->width - container->width) / 2; | 810 | if (absolute) { |
806 | double ly = ws->y + (ws->height - container->height) / 2; | 811 | lx = root_container.x + (root_container.width - container->width) / 2; |
812 | ly = root_container.y + (root_container.height - container->height) / 2; | ||
813 | } else { | ||
814 | struct sway_container *ws = container_parent(container, C_WORKSPACE); | ||
815 | lx = ws->x + (ws->width - container->width) / 2; | ||
816 | ly = ws->y + (ws->height - container->height) / 2; | ||
817 | } | ||
807 | container_floating_move_to(container, lx, ly); | 818 | container_floating_move_to(container, lx, ly); |
808 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 819 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
809 | } | 820 | } |
@@ -835,6 +846,11 @@ static struct cmd_results *move_to_position(struct sway_container *container, | |||
835 | "Invalid position specified"); | 846 | "Invalid position specified"); |
836 | } | 847 | } |
837 | 848 | ||
849 | if (!absolute) { | ||
850 | struct sway_container *ws = container_parent(container, C_WORKSPACE); | ||
851 | lx += ws->x; | ||
852 | ly += ws->y; | ||
853 | } | ||
838 | container_floating_move_to(container, lx, ly); | 854 | container_floating_move_to(container, lx, ly); |
839 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 855 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
840 | } | 856 | } |
diff --git a/sway/sway.5.scd b/sway/sway.5.scd index 83188067..927bf55c 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd | |||
@@ -133,10 +133,15 @@ They are expected to be used with *bindsym* or at runtime through *swaymsg*(1). | |||
133 | tiled containers. | 133 | tiled containers. |
134 | 134 | ||
135 | *move* [absolute] position <pos\_x> [px] <pos\_y> [px] | 135 | *move* [absolute] position <pos\_x> [px] <pos\_y> [px] |
136 | Moves the focused container to the specified position. | 136 | Moves the focused container to the specified position in the workspace. If |
137 | _absolute_ is used, the position is relative to all outputs. | ||
137 | 138 | ||
138 | *move* [absolute] position center|mouse | 139 | *move* [absolute] position center |
139 | Moves the focused container to be centered on the workspace or mouse. | 140 | Moves the focused container to be centered on the workspace. If _absolute_ |
141 | is used, it is moved to the center of all outputs. | ||
142 | |||
143 | *move* position cursor|mouse|pointer | ||
144 | Moves the focused container to be centered on the cursor. | ||
140 | 145 | ||
141 | *move* container|window [to] mark <mark> | 146 | *move* container|window [to] mark <mark> |
142 | Moves the focused container to the specified mark. | 147 | Moves the focused container to the specified mark. |