mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-10-29 05:40:21 -04:00
feat: add mvoewin resizewin dispatch
This commit is contained in:
parent
3a8ebf549b
commit
c64dd51b69
4 changed files with 122 additions and 8 deletions
29
config.conf
29
config.conf
|
|
@ -286,16 +286,29 @@ bind=ALT+SHIFT,Z,incgaps,-1
|
|||
bind=ALT+SHIFT,R,togglegaps
|
||||
|
||||
# smartmovewin
|
||||
bind=SUPER+SHIFT,Up,smartmovewin,up
|
||||
bind=SUPER+SHIFT,Down,smartmovewin,down
|
||||
bind=SUPER+SHIFT,Left,smartmovewin,left
|
||||
bind=SUPER+SHIFT,Right,smartmovewin,right
|
||||
bind=CTRL+SHIFT,Up,smartmovewin,up
|
||||
bind=CTRL+SHIFT,Down,smartmovewin,down
|
||||
bind=CTRL+SHIFT,Left,smartmovewin,left
|
||||
bind=CTRL+SHIFT,Right,smartmovewin,right
|
||||
|
||||
# movewin
|
||||
# bind=CTRL+SHIFT,Up,movewin,+0,-50
|
||||
# bind=CTRL+SHIFT,Down,movewin,+0,+50
|
||||
# bind=CTRL+SHIFT,Left,movewin,-50,+0
|
||||
# bind=CTRL+SHIFT,Right,movewin,+50,+0
|
||||
|
||||
|
||||
# smartresizewin
|
||||
bind=SUPER+ALT,Up,smartresizewin,up
|
||||
bind=SUPER+ALT,Down,smartresizewin,down
|
||||
bind=SUPER+ALT,Left,smartresizewin,left
|
||||
bind=SUPER+ALT,Right,smartresizewin,right
|
||||
bind=CTRL+ALT,Up,smartresizewin,up
|
||||
bind=CTRL+ALT,Down,smartresizewin,down
|
||||
bind=CTRL+ALT,Left,smartresizewin,left
|
||||
bind=CTRL+ALT,Right,smartresizewin,right
|
||||
|
||||
# resizewin
|
||||
# bind=CTRL+ALT,Up,resizewin,+0,-50
|
||||
# bind=CTRL+ALT,Down,resizewin,+0,+50
|
||||
# bind=CTRL+ALT,Left,resizewin,-50,+0
|
||||
# bind=CTRL+ALT,Right,resizewin,+50,+0
|
||||
|
||||
#custom app bind example
|
||||
# spawn_on_empty (if tag 4 is empty , open app in this,otherwise view to tag 4)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
#define SYSCONFDIR "/etc"
|
||||
#endif
|
||||
|
||||
enum { NUM_TYPE_MINUS, NUM_TYPE_PLUS, NUM_TYPE_DEFAULT };
|
||||
|
||||
typedef struct {
|
||||
uint32_t mod;
|
||||
xkb_keysym_t keysym;
|
||||
|
|
@ -400,6 +402,17 @@ void convert_hex_to_rgba(float *color, unsigned long int hex) {
|
|||
color[3] = (hex & 0xFF) / 255.0f;
|
||||
}
|
||||
|
||||
unsigned int parse_num_type(char *str) {
|
||||
switch (str[0]) {
|
||||
case '-':
|
||||
return NUM_TYPE_MINUS;
|
||||
case '+':
|
||||
return NUM_TYPE_PLUS;
|
||||
default:
|
||||
return NUM_TYPE_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value, char *arg_value2) {
|
||||
|
||||
FuncType func = NULL;
|
||||
|
|
@ -526,6 +539,18 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value, char *arg_v
|
|||
} else if (strcmp(func_name, "smartresizewin") == 0) {
|
||||
func = smartresizewin;
|
||||
(*arg).i = parse_direction(arg_value);
|
||||
} else if (strcmp(func_name, "resizewin") == 0) {
|
||||
func = resizewin;
|
||||
(*arg).ui = parse_num_type(arg_value);
|
||||
(*arg).ui2 = parse_num_type(arg_value2);
|
||||
(*arg).i = (*arg).ui == NUM_TYPE_DEFAULT ? atoi(arg_value) : atoi(arg_value+1);
|
||||
(*arg).i2 = (*arg).ui2 == NUM_TYPE_DEFAULT ? atoi(arg_value2) : atoi(arg_value2+1);
|
||||
} else if (strcmp(func_name, "movewin") == 0) {
|
||||
func = movewin;
|
||||
(*arg).ui = parse_num_type(arg_value);
|
||||
(*arg).ui2 = parse_num_type(arg_value2);
|
||||
(*arg).i = (*arg).ui == NUM_TYPE_DEFAULT ? atoi(arg_value) : atoi(arg_value+1);
|
||||
(*arg).i2 = (*arg).ui2 == NUM_TYPE_DEFAULT ? atoi(arg_value2) : atoi(arg_value2+1);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,3 +51,5 @@ void incigaps(const Arg *arg);
|
|||
void defaultgaps(const Arg *arg);
|
||||
void togglefakefullscreen(const Arg *arg);
|
||||
void toggleoverlay(const Arg *arg);
|
||||
void movewin(const Arg *arg);
|
||||
void resizewin(const Arg *arg);
|
||||
|
|
|
|||
74
src/maomao.c
74
src/maomao.c
|
|
@ -1923,6 +1923,7 @@ void apply_window_snap(Client *c) {
|
|||
c->geom.y = c->geom.y + snap_down;
|
||||
}
|
||||
|
||||
c->oldgeom = c->geom;
|
||||
resize(c, c->geom, 1);
|
||||
}
|
||||
|
||||
|
|
@ -7174,6 +7175,79 @@ void zoom(const Arg *arg) {
|
|||
arrange(selmon, false);
|
||||
}
|
||||
|
||||
void resizewin(const Arg *arg) {
|
||||
Client *c;
|
||||
c = selmon->sel;
|
||||
if (!c || c->isfullscreen)
|
||||
return;
|
||||
if (!c->isfloating)
|
||||
togglefloating(NULL);
|
||||
|
||||
switch(arg->ui) {
|
||||
case NUM_TYPE_MINUS:
|
||||
c->geom.width -= arg->i;
|
||||
break;
|
||||
case NUM_TYPE_PLUS:
|
||||
c->geom.width += arg->i;
|
||||
break;
|
||||
default:
|
||||
c->geom.width = arg->i;
|
||||
break;
|
||||
}
|
||||
|
||||
switch(arg->ui2) {
|
||||
case NUM_TYPE_MINUS:
|
||||
c->geom.height -= arg->i2;
|
||||
break;
|
||||
case NUM_TYPE_PLUS:
|
||||
c->geom.height += arg->i2;
|
||||
break;
|
||||
default:
|
||||
c->geom.height = arg->i2;
|
||||
break;
|
||||
}
|
||||
|
||||
c->oldgeom = c->geom;
|
||||
resize(c, c->geom, 0);
|
||||
}
|
||||
|
||||
void movewin(const Arg *arg) {
|
||||
Client *c;
|
||||
c = selmon->sel;
|
||||
if (!c || c->isfullscreen)
|
||||
return;
|
||||
if (!c->isfloating)
|
||||
togglefloating(NULL);
|
||||
|
||||
switch(arg->ui) {
|
||||
case NUM_TYPE_MINUS:
|
||||
c->geom.x -= arg->i;
|
||||
break;
|
||||
case NUM_TYPE_PLUS:
|
||||
c->geom.x += arg->i;
|
||||
break;
|
||||
default:
|
||||
c->geom.x = arg->i;
|
||||
break;
|
||||
}
|
||||
|
||||
switch(arg->ui2) {
|
||||
case NUM_TYPE_MINUS:
|
||||
c->geom.y -= arg->i2;
|
||||
break;
|
||||
case NUM_TYPE_PLUS:
|
||||
c->geom.y += arg->i2;
|
||||
break;
|
||||
default:
|
||||
c->geom.y = arg->i2;
|
||||
break;
|
||||
}
|
||||
|
||||
c->oldgeom = c->geom;
|
||||
resize(c, c->geom, 0);
|
||||
}
|
||||
|
||||
|
||||
void smartmovewin(const Arg *arg) {
|
||||
Client *c, *tc;
|
||||
int nx, ny;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue