From 575e5d4a471bd0b7f87dea1043301dc2e0278e15 Mon Sep 17 00:00:00 2001 From: DreamMaoMao <2523610504@qq.com> Date: Sun, 27 Jul 2025 13:35:36 +0800 Subject: [PATCH] opt: refresh is float type --- src/config/parse_config.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 0ebc184..760112a 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -70,14 +70,15 @@ typedef struct { } ConfigWinRule; typedef struct { - const char *name; // 显示器名称 - float mfact; // 主区域比例 - int nmaster; // 主区域窗口数量 - const char *layout; // 布局名称(字符串) - int rr; // 旋转和翻转(假设为整数) - float scale; // 显示器缩放比例 - int x, y; // 显示器位置 - int width, height, refresh; // 显示器分辨率和刷新率 + const char *name; // 显示器名称 + float mfact; // 主区域比例 + int nmaster; // 主区域窗口数量 + const char *layout; // 布局名称(字符串) + int rr; // 旋转和翻转(假设为整数) + float scale; // 显示器缩放比例 + int x, y; // 显示器位置 + int width, height; // 显示器分辨率 + float refresh; // 刷新率 } ConfigMonitorRule; // 修改后的宏定义 @@ -1567,7 +1568,7 @@ void parse_config_line(Config *config, const char *line) { rule->y = atoi(raw_y); rule->width = atoi(raw_width); rule->height = atoi(raw_height); - rule->refresh = atoi(raw_refresh); + rule->refresh = atof(raw_refresh); if (!rule->name || !rule->layout) { if (rule->name) @@ -2600,7 +2601,8 @@ void reapply_monitor_rules(void) { if (mr->width > 0 && mr->height > 0 && mr->refresh > 0) { wlr_output_state_set_custom_mode( - &state, mr->width, mr->height, mr->refresh * 1000); + &state, mr->width, mr->height, + (int)roundf(mr->refresh * 1000)); } wlr_output_state_set_scale(&state, mr->scale);