Commit ea26690302a73e82fe1028842f3e17d00167e682 Parent: 5544905926ce50e9832f79bcec805b0d26140031 Author: mcol <mcol@posteo.net> Date: 2020-11-11 23:24:40 +0000 Committer: mcol <mcol@posteo.net> Committed: 2020-11-11 23:24:40 +0000 apply zoom factor when moving mouse and dragging windows
src/shell.c Modified
@@ -81,8 +81,9 @@ server->cursor_mode = mode; if (mode == CURSOR_MOVE) { - server->grab_x = server->cursor->x - view->x; - server->grab_y = server->cursor->y - view->y; + double zoom = server->current_desk->zoom; + server->grab_x = server->cursor->x - view->x * zoom; + server->grab_y = server->cursor->y - view->y * zoom; } else { struct wlr_box geo_box; wlr_xdg_surface_get_geometry(view->surface, &geo_box);
src/input.h Modified
@@ -3,7 +3,7 @@ #include "types.h" -void process_cursor_move(struct server *server, uint32_t time); +void process_cursor_move(struct server *server, uint32_t time, double zoom); void process_cursor_resize(struct server *server, uint32_t time); bool view_at( struct view *view, double lx, double ly, struct wlr_surface **surface,
src/input.c Modified
@@ -13,9 +13,9 @@ enum wlr_keyboard_modifier MOD = WLR_MODIFIER_LOGO; -void process_cursor_move(struct server *server, uint32_t time) { - server->grabbed_view->x = server->cursor->x - server->grab_x; - server->grabbed_view->y = server->cursor->y - server->grab_y; +void process_cursor_move(struct server *server, uint32_t time, double zoom) { + server->grabbed_view->x = (server->cursor->x - server->grab_x) / zoom; + server->grabbed_view->y = (server->cursor->y - server->grab_y) / zoom; } @@ -104,13 +104,16 @@ struct wlr_seat *seat; struct wlr_surface *surface; struct view *view; + double zoom = server->current_desk->zoom; + dx /= zoom; + dy /= zoom; switch (server->cursor_mode) { case CURSOR_PASSTHROUGH: seat = server->seat; surface = NULL; - view = desktop_view_at(server, server->cursor->x, - server->cursor->y, &surface, &sx, &sy); + view = desktop_view_at(server, server->cursor->x / zoom, + server->cursor->y / zoom, &surface, &sx, &sy); if (!view) { wlr_xcursor_manager_set_cursor_image( server->cursor_manager, "left_ptr", server->cursor @@ -128,8 +131,6 @@ break; case CURSOR_PAN: - dx /= server->current_desk->zoom; - dy /= server->current_desk->zoom; wl_list_for_each(view, &server->current_desk->views, link) { view->x += dx; view->y += dy; @@ -139,7 +140,7 @@ break; case CURSOR_MOVE: - process_cursor_move(server, time); + process_cursor_move(server, time, zoom); break; case CURSOR_RESIZE: