Commit d380f3285d4d326d2f691f4fabcf0fb326b09f7e Parent: 3a10d94a2a266bd90ad27f8e29506f26735aabec Author: mcol <mcol@posteo.net> Date: 2021-01-24 16:36:24 +0000 Committer: mcol <mcol@posteo.net> Committed: 2021-01-24 16:36:24 +0000 Pan to window when focussing in direction if not visible
src/shell.h Modified
@@ -6,6 +6,7 @@ void unmap_view(struct view *view); void map_view(struct view *view); void focus_view(struct view *view, struct wlr_surface *surface); +void pan_to_view(struct view *view); void fullscreen_xdg_surface( struct view *view, struct wlr_xdg_surface *xdg_surface, struct wlr_output *output );
src/shell.c Modified
@@ -1,6 +1,7 @@ #include <wlr/types/wlr_xdg_shell.h> #include <wlr/util/edges.h> +#include "action.h" #include "types.h" @@ -43,6 +44,34 @@ } +void pan_to_view(struct view *view) { + struct server *server = view->server; + int border_width = server->current_desk->border_width; + double x = view->x - border_width; + double y = view->y - border_width; + double width = view->surface->geometry.width + border_width * 2; + double height = view->surface->geometry.height + border_width * 2; + struct wlr_box *extents = wlr_output_layout_get_box(server->output_layout, NULL); + struct motion motion = { + .dx = 0, + .dy = 0, + .is_percentage = false, + }; + + if (x < 0) { + motion.dx = x; + } else if (x + width > extents->width) { + motion.dx = x + width - extents->width; + } + if (y < 0) { + motion.dy = y; + } else if (y + height > extents->height) { + motion.dy = y + height - extents->height; + } + pan_desk(server, &motion); +} + + void fullscreen_xdg_surface( struct view *view, struct wlr_xdg_surface *xdg_surface, struct wlr_output *output ) {
src/action.c Modified
@@ -76,8 +76,10 @@ } } - if (next) + if (next) { + pan_to_view(next); focus_view(next, next->surface->surface); + } }
readme.rst Modified
@@ -16,7 +16,6 @@ To do list: - make configuration much nicer and remove all the strcmps - fix issue where Shift-using key bindings require pre-shifted key in config - - pan desk when focussing window in direction that isn't in view - xwayland - pinch gestures for desk zooming - draw rect with mouse when zoomed out to set new view