diff --git a/src/animation/layer.h b/src/animation/layer.h index 568d52b3..56130956 100644 --- a/src/animation/layer.h +++ b/src/animation/layer.h @@ -27,21 +27,21 @@ void get_layer_target_geometry(LayerSurface *l, struct wlr_box *target_box) { const struct wlr_layer_surface_v1_state *state = &l->layer_surface->current; - // 限制区域 - // waybar一般都是大于0,表示要占用多少区域,所以计算位置也要用全部区域作为基准 - // 如果是-1可能表示独占所有可用空间 - // 如果是0,应该是表示使用exclusive_zone外的可用区域 + // Exclusive zone handling: + // Waybar typically uses > 0, indicating how much area to reserve (use full + // monitor bounds) If -1, may indicate exclusive use of all available space + // If 0, indicates use of available area outside exclusive zones struct wlr_box bounds; if (state->exclusive_zone > 0 || state->exclusive_zone == -1) bounds = l->mon->m; else bounds = l->mon->w; - // 初始化几何位置 + // Initialize geometry struct wlr_box box = {.width = state->desired_width, .height = state->desired_height}; - // 水平方向定位 + // Horizontal positioning const int32_t both_horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT; if (box.width == 0) { @@ -56,7 +56,7 @@ void get_layer_target_geometry(LayerSurface *l, struct wlr_box *target_box) { box.x = bounds.x + ((bounds.width - box.width) / 2); } - // 垂直方向定位 + // Vertical positioning const int32_t both_vert = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; if (box.height == 0) { @@ -71,7 +71,7 @@ void get_layer_target_geometry(LayerSurface *l, struct wlr_box *target_box) { box.y = bounds.y + ((bounds.height - box.height) / 2); } - // 应用边距 + // Apply margins if (box.width == 0) { box.x += state->margin.left; box.width = bounds.width - (state->margin.left + state->margin.right); @@ -412,8 +412,8 @@ void init_fadeout_layers(LayerSurface *l) { fadeout_layer->animation_type_close = l->animation_type_close; fadeout_layer->animation_type_open = l->animation_type_open; - // 这里snap节点的坐标设置是使用的相对坐标,不能用绝对坐标 - // 这跟普通node有区别 + // Snapshot node coordinates use relative coordinates, not absolute + // This differs from regular nodes fadeout_layer->animation.initial.x = 0; fadeout_layer->animation.initial.y = 0; diff --git a/src/common/util.c b/src/common/util.c index a15cca7c..59f50455 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -59,7 +59,7 @@ int32_t regex_match(const char *pattern, const char *str) { } pcre2_code *re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED, - PCRE2_UTF, // 启用 UTF-8 支持 + PCRE2_UTF, // Enable UTF-8 support &errnum, &erroffset, NULL); if (!re) { PCRE2_UCHAR errbuf[256]; diff --git a/src/mango.c b/src/mango.c index e1f3c3a0..f1f1e7f2 100644 --- a/src/mango.c +++ b/src/mango.c @@ -97,31 +97,43 @@ /* macros */ #define MAX(A, B) ((A) > (B) ? (A) : (B)) #define MIN(A, B) ((A) < (B) ? (A) : (B)) +/* Get value if >= 0, otherwise return 0 */ #define GEZERO(A) ((A) >= 0 ? (A) : 0) +/* Remove caps lock modifier from mask */ #define CLEANMASK(mask) (mask & ~WLR_MODIFIER_CAPS) +/* Check if client A is fully inside its monitor bounds */ #define INSIDEMON(A) \ (A->geom.x >= A->mon->m.x && A->geom.y >= A->mon->m.y && \ A->geom.x + A->geom.width <= A->mon->m.x + A->mon->m.width && \ A->geom.y + A->geom.height <= A->mon->m.y + A->mon->m.height) +/* Check if geometry A is fully inside monitor M bounds */ #define GEOMINSIDEMON(A, M) \ (A->x >= M->m.x && A->y >= M->m.y && \ A->x + A->width <= M->m.x + M->m.width && \ A->y + A->height <= M->m.y + M->m.height) +/* Check if client is in tiled state (not floating, minimized, killing, etc.) */ #define ISTILED(A) \ (A && !(A)->isfloating && !(A)->isminimized && !(A)->iskilling && \ !(A)->ismaximizescreen && !(A)->isfullscreen && !(A)->isunglobal) +/* Check if client is tiled for scroller layout (less restrictive than ISTILED) + */ #define ISSCROLLTILED(A) \ (A && !(A)->isfloating && !(A)->isminimized && !(A)->iskilling && \ !(A)->isunglobal) +/* Check if client C is visible on monitor M (matching tags) */ #define VISIBLEON(C, M) \ ((C) && (M) && (C)->mon == (M) && ((C)->tags & (M)->tagset[(M)->seltags])) #define LENGTH(X) (sizeof X / sizeof X[0]) #define END(A) ((A) + LENGTH(A)) +/* Generate bitmask for all tags */ #define TAGMASK ((1 << LENGTH(tags)) - 1) +/* Register event listener: adds signal handler H to event E with listener L */ #define LISTEN(E, L, H) wl_signal_add((E), ((L)->notify = (H), (L))) +/* Check if client is in any fullscreen-like state */ #define ISFULLSCREEN(A) \ ((A)->isfullscreen || (A)->ismaximizescreen || \ (A)->overview_ismaximizescreenbak || (A)->overview_isfullscreenbak) +/* Register static event listener (allocates listener internally) */ #define LISTEN_STATIC(E, H) \ do { \ struct wl_listener *_l = ecalloc(1, sizeof(*_l)); \ @@ -129,18 +141,22 @@ wl_signal_add((E), _l); \ } while (0) +/* Apply integer property from rule to object if set (>= 0) */ #define APPLY_INT_PROP(obj, rule, prop) \ if (rule->prop >= 0) \ obj->prop = rule->prop +/* Apply float property from rule to object if set (> 0.0) */ #define APPLY_FLOAT_PROP(obj, rule, prop) \ if (rule->prop > 0.0f) \ obj->prop = rule->prop +/* Apply string property from rule to object if set (not NULL) */ #define APPLY_STRING_PROP(obj, rule, prop) \ if (rule->prop != NULL) \ obj->prop = rule->prop +/* Number of pre-calculated animation curve points for performance */ #define BAKED_POINTS_COUNT 256 /* enums */