diff --git a/assets/config.conf b/assets/config.conf index 414ff79d..0881e5ad 100644 --- a/assets/config.conf +++ b/assets/config.conf @@ -182,6 +182,8 @@ bind=SUPER,o,toggleminimap, bind=SUPER,p,canvas_overview_toggle, bind=SUPER,z,canvas_zoom_resize,0.909090909 bind=SUPER,x,canvas_zoom_resize,1.1 +bind=SUPER,u,canvas_fill_viewport, +bind=SUPER,c,canvas_centerview, # scroller layout bind=ALT,e,set_proportion,1.0 diff --git a/src/config/parse_config.h b/src/config/parse_config.h index b9412682..29f8a1c2 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -139,22 +139,6 @@ KeyBinding default_key_bindings[] = { CHVT(10), CHVT(11), CHVT(12), - {WLR_MODIFIER_LOGO, - {.keysym = XKB_KEY_o, .type = KEY_TYPE_SYM}, - toggleminimap, - {0}}, - {WLR_MODIFIER_LOGO, - {.keysym = XKB_KEY_p, .type = KEY_TYPE_SYM}, - canvas_overview_toggle, - {0}}, - {WLR_MODIFIER_LOGO, - {.keysym = XKB_KEY_z, .type = KEY_TYPE_SYM}, - canvas_zoom_resize, - {.f = 1.0f / 1.1f}}, - {WLR_MODIFIER_LOGO, - {.keysym = XKB_KEY_x, .type = KEY_TYPE_SYM}, - canvas_zoom_resize, - {.f = 1.1f}}, }; typedef struct { @@ -1240,6 +1224,8 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value, func = canvas_overview_toggle; } else if (strcmp(func_name, "canvas_fill_viewport") == 0) { func = canvas_fill_viewport; + } else if (strcmp(func_name, "canvas_centerview") == 0) { + func = canvas_centerview; } else { return NULL; } diff --git a/src/dispatch/bind_declare.h b/src/dispatch/bind_declare.h index e719919a..6b8d2e9d 100644 --- a/src/dispatch/bind_declare.h +++ b/src/dispatch/bind_declare.h @@ -74,4 +74,5 @@ int32_t scroller_stack(const Arg *arg); int32_t canvas_zoom_resize(const Arg *arg); int32_t canvas_overview_toggle(const Arg *arg); int32_t canvas_fill_viewport(const Arg *arg); +int32_t canvas_centerview(const Arg *arg); int32_t toggle_all_floating(const Arg *arg); \ No newline at end of file diff --git a/src/dispatch/bind_define.h b/src/dispatch/bind_define.h index 5e2c359d..4fc3ee19 100644 --- a/src/dispatch/bind_define.h +++ b/src/dispatch/bind_define.h @@ -1938,13 +1938,6 @@ int32_t canvas_overview_toggle(const Arg *arg) { selmon->canvas_overview_closing = true; selmon->canvas_overview_anim_start = get_now_in_ms(); } else if (!selmon->canvas_overview_visible) { - if (selmon->minimap_visible) { - selmon->minimap_visible = false; - if (minimap_scene_tree) { - wlr_scene_node_destroy(&minimap_scene_tree->node); - minimap_scene_tree = NULL; - } - } selmon->canvas_overview_visible = true; selmon->canvas_overview_closing = false; selmon->canvas_overview_progress = 0.0f; @@ -1954,6 +1947,27 @@ int32_t canvas_overview_toggle(const Arg *arg) { return 0; } +int32_t canvas_centerview(const Arg *arg) { + if (!selmon || !is_canvas_layout(selmon)) + return 0; + + Client *c = selmon->sel; + if (!c || c->isfullscreen || c->ismaximizescreen) + return 0; + + uint32_t tag = selmon->pertag->curtag; + float zoom = selmon->pertag->canvas_zoom[tag]; + + float cx = c->canvas_geom[tag].x + c->canvas_geom[tag].width / 2.0f; + float cy = c->canvas_geom[tag].y + c->canvas_geom[tag].height / 2.0f; + + selmon->pertag->canvas_pan_x[tag] = cx - (selmon->w.width / zoom) / 2.0f; + selmon->pertag->canvas_pan_y[tag] = cy - (selmon->w.height / zoom) / 2.0f; + + canvas_reposition(selmon); + return 0; +} + int32_t canvas_fill_viewport(const Arg *arg) { if (!selmon || !is_canvas_layout(selmon)) return 0; @@ -1967,10 +1981,12 @@ int32_t canvas_fill_viewport(const Arg *arg) { float pan_x = selmon->pertag->canvas_pan_x[tag]; float pan_y = selmon->pertag->canvas_pan_y[tag]; - c->canvas_geom[tag].x = (int32_t)roundf(pan_x); - c->canvas_geom[tag].y = (int32_t)roundf(pan_y); - c->canvas_geom[tag].width = (int32_t)roundf(selmon->w.width / zoom); - c->canvas_geom[tag].height = (int32_t)roundf(selmon->w.height / zoom); + c->canvas_geom[tag].x = (int32_t)roundf(pan_x + config.gappoh / zoom); + c->canvas_geom[tag].y = (int32_t)roundf(pan_y + config.gappov / zoom); + c->canvas_geom[tag].width = + (int32_t)roundf((selmon->w.width - 2 * config.gappoh) / zoom); + c->canvas_geom[tag].height = + (int32_t)roundf((selmon->w.height - 2 * config.gappov) / zoom); c->iscustomsize = 1; arrange(selmon, false, false); diff --git a/src/mango.c b/src/mango.c index 3c028f6c..e3b30532 100644 --- a/src/mango.c +++ b/src/mango.c @@ -5036,13 +5036,7 @@ int32_t toggleminimap(const Arg *arg) { return 0; selmon->minimap_visible = !selmon->minimap_visible; - if (selmon->minimap_visible) { - if (selmon->canvas_overview_visible && - !selmon->canvas_overview_closing) { - selmon->canvas_overview_closing = true; - selmon->canvas_overview_anim_start = get_now_in_ms(); - } - } else { + if (!selmon->minimap_visible) { if (minimap_scene_tree) { wlr_scene_node_destroy(&minimap_scene_tree->node); minimap_scene_tree = NULL; @@ -5134,7 +5128,7 @@ void rendermon(struct wl_listener *listener, void *data) { // 只有在需要帧时才构建和提交状态 - if (m->minimap_visible && + if (m->minimap_visible && !m->canvas_overview_visible && m->pertag->ltidxs[m->pertag->curtag]->id == CANVAS) { uint32_t tag = m->pertag->curtag;