mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-03 06:46:38 -04:00
feat: support movewin
This commit is contained in:
parent
dfaab261c1
commit
d869078b2f
4 changed files with 120 additions and 2 deletions
|
|
@ -277,6 +277,12 @@ bind=ALT+SHIFT,X,incgaps,1
|
|||
bind=ALT+SHIFT,Z,incgaps,-1
|
||||
bind=ALT+SHIFT,R,togglegaps
|
||||
|
||||
# movewin
|
||||
bind=SUPER+CTRL,Up,movewin,up
|
||||
bind=SUPER+CTRL,Down,movewin,down
|
||||
bind=SUPER+CTRL,Left,movewin,left
|
||||
bind=SUPER+CTRL,Right,movewin,right
|
||||
|
||||
#custom app bind example
|
||||
# spawn_on_empty (if tag 4 is empty , open app in this,otherwise view to tag 4)
|
||||
# bind=SUPER,Return,spawn_on_empty,google-chrome,4
|
||||
|
|
|
|||
|
|
@ -35,4 +35,6 @@ void incgaps(const Arg *arg);
|
|||
void focusmon(const Arg *arg);
|
||||
void focusstack(const Arg *arg);
|
||||
void chvt(const Arg *arg);
|
||||
void reload_config(const Arg *arg);
|
||||
void reload_config(const Arg *arg);
|
||||
void movewin(const Arg *arg);
|
||||
void resizewin(const Arg *arg);
|
||||
|
|
|
|||
104
maomao.c
104
maomao.c
|
|
@ -6941,6 +6941,110 @@ void zoom(const Arg *arg) {
|
|||
arrange(selmon, false);
|
||||
}
|
||||
|
||||
void movewin(const Arg *arg) {
|
||||
/* top, bottom, left, right */
|
||||
Client *c, *tc;
|
||||
int nx, ny;
|
||||
int buttom, top, left, right, tar;
|
||||
c = selmon->sel;
|
||||
if (!c || c->isfullscreen)
|
||||
return;
|
||||
if (!c->isfloating)
|
||||
togglefloating(NULL);
|
||||
nx = c->geom.x;
|
||||
ny = c->geom.y;
|
||||
|
||||
switch (arg->i) {
|
||||
case UP:
|
||||
tar = -99999;
|
||||
top = c->geom.y;
|
||||
ny -= c->mon->w.height / 4;
|
||||
|
||||
wl_list_for_each(tc, &clients, link) {
|
||||
if (!VISIBLEON(tc, selmon) || !tc->isfloating || tc == c)
|
||||
continue;
|
||||
if (c->geom.x + c->geom.width < tc->geom.x ||
|
||||
c->geom.x > tc->geom.x + tc->geom.width)
|
||||
continue;
|
||||
buttom = tc->geom.y + tc->geom.height + gappiv;
|
||||
if (top > buttom && ny < buttom) {
|
||||
tar = MAX(tar, buttom);
|
||||
};
|
||||
}
|
||||
|
||||
ny = tar == -99999 ? ny : tar;
|
||||
ny = MAX(ny, c->mon->w.y + gappov);
|
||||
break;
|
||||
case DOWN:
|
||||
tar = 99999;
|
||||
buttom = c->geom.y + c->geom.height;
|
||||
ny += c->mon->w.height / 4;
|
||||
|
||||
wl_list_for_each(tc, &clients, link) {
|
||||
if (!VISIBLEON(tc, selmon) || !tc->isfloating || tc == c)
|
||||
continue;
|
||||
if (c->geom.x + c->geom.width < tc->geom.x ||
|
||||
c->geom.x > tc->geom.x + tc->geom.width)
|
||||
continue;
|
||||
top = tc->geom.y - gappiv;
|
||||
if (buttom < top && (ny + c->geom.height) > top) {
|
||||
tar = MIN(tar, top - c->geom.height);
|
||||
};
|
||||
}
|
||||
ny = tar == 99999 ? ny : tar;
|
||||
ny = MIN(ny, c->mon->w.y + c->mon->w.height - gappov - c->geom.height);
|
||||
break;
|
||||
case LEFT:
|
||||
tar = -99999;
|
||||
left = c->geom.x;
|
||||
nx -= c->mon->w.width / 6;
|
||||
|
||||
wl_list_for_each(tc, &clients, link) {
|
||||
if (!VISIBLEON(tc, selmon) || !tc->isfloating || tc == c)
|
||||
continue;
|
||||
if (c->geom.y + c->geom.height < tc->geom.y ||
|
||||
c->geom.y > tc->geom.y + tc->geom.height)
|
||||
continue;
|
||||
right = tc->geom.x + tc->geom.width + gappih;
|
||||
if (left > right && nx < right) {
|
||||
tar = MAX(tar, right);
|
||||
};
|
||||
}
|
||||
|
||||
nx = tar == -99999 ? nx : tar;
|
||||
nx = MAX(nx, c->mon->w.x + gappoh);
|
||||
break;
|
||||
case RIGHT:
|
||||
tar = 99999;
|
||||
right = c->geom.x + c->geom.width;
|
||||
nx += c->mon->w.width / 6;
|
||||
wl_list_for_each(tc, &clients, link) {
|
||||
if (!VISIBLEON(tc, selmon) || !tc->isfloating || tc == c)
|
||||
continue;
|
||||
if (c->geom.y + c->geom.height < tc->geom.y ||
|
||||
c->geom.y > tc->geom.y + tc->geom.height)
|
||||
continue;
|
||||
left = tc->geom.x - gappih;
|
||||
if (right < left && (nx + c->geom.width) > left) {
|
||||
tar = MIN(tar, left - c->geom.width);
|
||||
};
|
||||
}
|
||||
nx = tar == 99999 ? nx : tar;
|
||||
nx = MIN(nx, c->mon->w.x + c->mon->w.width - gappoh - c->geom.width);
|
||||
break;
|
||||
}
|
||||
|
||||
resize(
|
||||
c,
|
||||
(struct wlr_box){
|
||||
.x = nx, .y = ny, .width = c->geom.width, .height = c->geom.height},
|
||||
1);
|
||||
}
|
||||
|
||||
void resizewin(const Arg *arg) {
|
||||
|
||||
}
|
||||
|
||||
#ifdef XWAYLAND
|
||||
void activatex11(struct wl_listener *listener, void *data) {
|
||||
Client *c = wl_container_of(listener, c, activate);
|
||||
|
|
|
|||
|
|
@ -477,6 +477,12 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value) {
|
|||
} else if (strcmp(func_name, "toggleview") == 0) {
|
||||
func = toggleview;
|
||||
(*arg).ui = 1 << (atoi(arg_value) - 1);
|
||||
} else if (strcmp(func_name, "movewin") == 0) {
|
||||
func = movewin;
|
||||
(*arg).i = parse_direction(arg_value);
|
||||
} else if (strcmp(func_name, "resizewin") == 0) {
|
||||
func = resizewin;
|
||||
(*arg).i = parse_direction(arg_value);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1378,4 +1384,4 @@ void reload_config(const Arg *arg) {
|
|||
}
|
||||
}
|
||||
arrange(selmon, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue