diff options
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sway/commands.c b/sway/commands.c index 8fec1223..b8af0d06 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -854,6 +854,27 @@ static struct cmd_results *cmd_move(int argc, char **argv) { | |||
854 | focused = swayc_active_workspace(); | 854 | focused = swayc_active_workspace(); |
855 | } | 855 | } |
856 | set_focused_container(focused); | 856 | set_focused_container(focused); |
857 | } else if (strcasecmp(argv[0], "position") == 0 && strcasecmp(argv[1], "mouse") == 0) { | ||
858 | if (view->is_floating) { | ||
859 | swayc_t *output = swayc_parent_by_type(view, C_OUTPUT); | ||
860 | const struct wlc_geometry *geometry = wlc_view_get_geometry(view->handle); | ||
861 | const struct wlc_size *size = wlc_output_get_resolution(output->handle); | ||
862 | struct wlc_geometry g = *geometry; | ||
863 | |||
864 | struct wlc_point origin; | ||
865 | wlc_pointer_get_position(&origin); | ||
866 | |||
867 | int32_t x = origin.x - g.size.w / 2; | ||
868 | int32_t y = origin.y - g.size.h / 2; | ||
869 | |||
870 | uint32_t w = size->w - g.size.w; | ||
871 | uint32_t h = size->h - g.size.h; | ||
872 | |||
873 | view->x = g.origin.x = MIN(w, MAX(x, 0)); | ||
874 | view->y = g.origin.y = MIN(h, MAX(y, 0)); | ||
875 | |||
876 | wlc_view_set_geometry(view->handle, 0, &g); | ||
877 | } | ||
857 | } else { | 878 | } else { |
858 | return cmd_results_new(CMD_INVALID, "move", expected_syntax); | 879 | return cmd_results_new(CMD_INVALID, "move", expected_syntax); |
859 | } | 880 | } |