Commit 0894e052ab127adb3c3a9a9aa6b415a22aace330 Parent: 0426767a7328b421c11aebe39319a23dead764ae Author: mcol <mcol@posteo.net> Date: 2021-01-24 23:44:39 +0000 Committer: mcol <mcol@posteo.net> Committed: 2021-01-24 23:44:39 +0000 add move_window action
wimp.conf Modified
@@ -78,6 +78,7 @@ # Possible mouse bindings: motion, scroll (+ additional modifiers) bind scroll pan_desk_mouse bind Shift scroll zoom_mouse +bind motion move_window # Scroll direction. Can be one of: natural, reverse #scroll_direction natural
src/cursor.h Modified
@@ -3,6 +3,10 @@ #include "types.h" +struct view *view_at( + double lx, double ly, struct wlr_surface **surface, double *sx, double *sy +); + void set_up_cursor(); #endif
src/cursor.c Modified
@@ -44,7 +44,7 @@ } -static bool view_at( +static bool _view_at( struct view *view, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy ) { @@ -66,14 +66,14 @@ } -static struct view *desktop_view_at( - double lx, double ly, struct wlr_surface **surface, double *sx, double *sy, double zoom +struct view *view_at( + double lx, double ly, struct wlr_surface **surface, double *sx, double *sy ) { struct view *view; - lx /= zoom; - ly /= zoom; + lx /= wimp.current_desk->zoom; + ly /= wimp.current_desk->zoom; wl_list_for_each(view, &wimp.current_desk->views, link) { - if (view_at(view, lx, ly, surface, sx, sy)) { + if (_view_at(view, lx, ly, surface, sx, sy)) { return view; } } @@ -94,7 +94,7 @@ case CURSOR_PASSTHROUGH: seat = wimp.seat; surface = NULL; - view = desktop_view_at(wimp.cursor->x, wimp.cursor->y, &surface, &sx, &sy, zoom); + view = view_at(wimp.cursor->x, wimp.cursor->y, &surface, &sx, &sy); if (!view) { wlr_xcursor_manager_set_cursor_image(wimp.cursor_manager, "left_ptr", wimp.cursor); } @@ -154,8 +154,8 @@ } else { double sx, sy; struct wlr_surface *surface; - struct view *view = desktop_view_at( - wimp.cursor->x, wimp.cursor->y, &surface, &sx, &sy, wimp.current_desk->zoom + struct view *view = view_at( + wimp.cursor->x, wimp.cursor->y, &surface, &sx, &sy ); focus_view(view, surface); }
src/config.c Modified
@@ -122,6 +122,7 @@ { "shutdown", &shutdown, NULL }, { "exec", &exec_command, &str_handler }, { "close_window", &close_window, NULL }, + { "move_window", &move_window, NULL }, { "focus", &focus_in_direction, &dir_handler }, { "next_desk", &next_desk, NULL }, { "prev_desk", &prev_desk, NULL },
src/action.h Modified
@@ -7,6 +7,7 @@ void exec_command(void *data); void change_vt(void *data); void close_window(void *data); +void move_window(void *data); void focus_in_direction(void *data); void next_desk(void *data); void prev_desk(void *data);
src/action.c Modified
@@ -5,6 +5,7 @@ #include "action.h" #include "config.h" +#include "cursor.h" #include "desk.h" #include "shell.h" #include "types.h" @@ -42,6 +43,21 @@ } +void move_window(void *data) { + struct wlr_surface *surface; + double sx, sy; + struct view *view = view_at( + wimp.cursor->x, wimp.cursor->y, &surface, &sx, &sy + ); + if (!view) { + return; + } + struct motion motion = *(struct motion*)data; + view->x += motion.dx; + view->y += motion.dy; +} + + void focus_in_direction(void *data) { if (wl_list_empty(&wimp.current_desk->views)) return;