From fc2eaf144d2c6fe939945dde7ca23f9d8fe49fbc Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Mon, 5 May 2025 11:19:57 +0800 Subject: [PATCH] feat: support widht and height set in toggle_named_scratch --- src/config/parse_config.h | 2 ++ src/maomao.c | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 953f543..cdab7c0 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -557,6 +557,8 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value, char *arg_v func = toggle_named_scratch; (*arg).v = strdup(arg_value); (*arg).v2 = strdup(arg_value2); + (*arg).ui = arg_value3 ? atoi(arg_value3) : 0; + (*arg).ui2 = arg_value4 ? atoi(arg_value4) : 0; } else { return NULL; } diff --git a/src/maomao.c b/src/maomao.c index 0faee45..e41d669 100644 --- a/src/maomao.c +++ b/src/maomao.c @@ -203,7 +203,7 @@ typedef struct Client Client; struct Client { /* Must keep these three elements in this order */ unsigned int type; /* XDGShell or X11* */ - struct wlr_box geom, pending, oldgeom, animainit_geom, overview_backup_geom, + struct wlr_box geom, pending, oldgeom,scratch_geom, animainit_geom, overview_backup_geom, current; /* layout-relative, includes border */ Monitor *mon; struct wlr_scene_tree *scene; @@ -1308,10 +1308,10 @@ void show_scratchpad(Client *c) { /* return if fullscreen */ if (!c->isfloating) { setfloating(c, 1); - c->geom.width = c->mon->w.width * 0.7; - c->geom.height = c->mon->w.height * 0.8; + c->geom.width = c->scratch_geom.width ? c->scratch_geom.width: c->mon->w.width * 0.7; + c->geom.height = c->scratch_geom.height? c->scratch_geom.height : c->mon->w.height * 0.8; // 重新计算居中的坐标 - c->geom = setclient_coordinate_center(c->geom, 0, 0); + c->geom = c->animainit_geom = c->animation.current = setclient_coordinate_center(c->geom, 0, 0); resize(c, c->geom, 0); } c->oldtags = selmon->tagset[selmon->seltags]; @@ -1494,6 +1494,9 @@ void toggle_named_scratch(const Arg *arg) { } } + target_client->scratch_geom.width = arg->ui; + target_client->scratch_geom.height = arg->ui2; + if(!target_client->is_in_scratchpad) set_minized(target_client); else