mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-05 06:47:12 -04:00
feat: focusdir now moves the viewport too, making it center the new focused window
This commit is contained in:
parent
1e217af3d9
commit
3045ef3095
3 changed files with 31 additions and 0 deletions
|
|
@ -142,6 +142,8 @@ int32_t focusdir(const Arg *arg) {
|
|||
focusclient(c, 1);
|
||||
if (config.warpcursor)
|
||||
warp_cursor(c);
|
||||
if (selmon && is_canvas_layout(selmon))
|
||||
canvas_pan_to_client(selmon, c);
|
||||
} else {
|
||||
if (config.focus_cross_tag) {
|
||||
if (arg->i == LEFT || arg->i == UP)
|
||||
|
|
|
|||
|
|
@ -119,3 +119,31 @@ static void canvas(Monitor *m) {
|
|||
apply_visual_zoom(c, effective_zoom);
|
||||
}
|
||||
}
|
||||
|
||||
static void canvas_pan_to_client(Monitor *m, Client *c) {
|
||||
if (!m || !c || !is_canvas_layout(m))
|
||||
return;
|
||||
|
||||
uint32_t tag = m->pertag->curtag;
|
||||
if (c->canvas_geom[tag].width <= 0 || c->canvas_geom[tag].height <= 0)
|
||||
return;
|
||||
|
||||
float zoom = m->pertag->canvas_zoom[tag];
|
||||
float pan_x = m->pertag->canvas_pan_x[tag];
|
||||
float pan_y = m->pertag->canvas_pan_y[tag];
|
||||
float vp_w = m->w.width / zoom;
|
||||
float vp_h = m->w.height / zoom;
|
||||
|
||||
float cx = c->canvas_geom[tag].x;
|
||||
float cy = c->canvas_geom[tag].y;
|
||||
float cw = c->canvas_geom[tag].width;
|
||||
float ch = c->canvas_geom[tag].height;
|
||||
|
||||
if (cx >= pan_x && cy >= pan_y &&
|
||||
cx + cw <= pan_x + vp_w && cy + ch <= pan_y + vp_h)
|
||||
return;
|
||||
|
||||
m->pertag->canvas_pan_x[tag] = cx + cw / 2.0f - vp_w / 2.0f;
|
||||
m->pertag->canvas_pan_y[tag] = cy + ch / 2.0f - vp_h / 2.0f;
|
||||
canvas_reposition(m);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1036,6 +1036,7 @@ static struct wl_event_source *sync_keymap;
|
|||
#include "animation/layer.h"
|
||||
#include "animation/tag.h"
|
||||
static void canvas_reposition(Monitor *m);
|
||||
static void canvas_pan_to_client(Monitor *m, Client *c);
|
||||
#include "dispatch/bind_define.h"
|
||||
#include "ext-protocol/all.h"
|
||||
#include "fetch/fetch.h"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue