mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-03-26 07:58:16 -04:00
Improve consistency of tag types; streamline CLAMP macro
This commit is contained in:
parent
923c7add5b
commit
686bd7f6ec
5 changed files with 36 additions and 31 deletions
|
|
@ -8,15 +8,19 @@
|
|||
#define SYSCONFDIR "/etc"
|
||||
#endif
|
||||
|
||||
// Clamps value in range while preserving numeric type
|
||||
#define CLAMP(x, min, max) \
|
||||
((x) < (min) ? (min) : ((x) > (max) ? (max) : (x)))
|
||||
|
||||
// 整数版本 - 截断小数部分
|
||||
// Deprecated: use CLAMP or CLAMP with explicit casts instead
|
||||
#define CLAMP_INT(x, min, max) \
|
||||
((int32_t)(x) < (int32_t)(min) \
|
||||
? (int32_t)(min) \
|
||||
: ((int32_t)(x) > (int32_t)(max) ? (int32_t)(max) : (int32_t)(x)))
|
||||
CLAMP((int32_t)(x), (int32_t)(min), (int32_t)(max))
|
||||
|
||||
// 浮点数版本 - 保留小数部分
|
||||
// Deprecated: use CLAMP instead
|
||||
#define CLAMP_FLOAT(x, min, max) \
|
||||
((x) < (min) ? (min) : ((x) > (max) ? (max) : (x)))
|
||||
CLAMP(x, min, max)
|
||||
|
||||
enum { NUM_TYPE_MINUS, NUM_TYPE_PLUS, NUM_TYPE_DEFAULT };
|
||||
|
||||
|
|
@ -159,7 +163,7 @@ typedef struct {
|
|||
} GestureBinding;
|
||||
|
||||
typedef struct {
|
||||
int32_t id;
|
||||
uint32_t id;
|
||||
char *layout_name;
|
||||
char *monitor_name;
|
||||
char *monitor_make;
|
||||
|
|
@ -314,7 +318,7 @@ typedef struct {
|
|||
|
||||
char autostart[3][256];
|
||||
|
||||
int32_t tag_count;
|
||||
uint32_t tag_count;
|
||||
ConfigTagRule *tag_rules; // 动态数组
|
||||
int32_t tag_rules_count; // 数量
|
||||
|
||||
|
|
@ -1586,7 +1590,7 @@ bool parse_option(Config *config, char *key, char *value) {
|
|||
} else if (strcmp(key, "default_nmaster") == 0) {
|
||||
config->default_nmaster = atoi(value);
|
||||
} else if (strcmp(key, "tag_count") == 0) {
|
||||
config->tag_count = CLAMP_INT(atoi(value), 1, 32);
|
||||
config->tag_count = CLAMP(atoi(value), 1, 32);
|
||||
tag_count = config->tag_count;
|
||||
} else if (strcmp(key, "center_master_overspread") == 0) {
|
||||
config->center_master_overspread = atoi(value);
|
||||
|
|
@ -3707,7 +3711,7 @@ void reapply_pointer(void) {
|
|||
|
||||
void reapply_master(void) {
|
||||
|
||||
int32_t i;
|
||||
uint32_t i;
|
||||
Monitor *m = NULL;
|
||||
for (i = 0; i <= tag_count; i++) {
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
|
|
@ -3725,7 +3729,7 @@ void reapply_master(void) {
|
|||
}
|
||||
|
||||
void parse_tagrule(Monitor *m) {
|
||||
int32_t i, jk;
|
||||
uint32_t i, jk;
|
||||
ConfigTagRule tr;
|
||||
Client *c = NULL;
|
||||
bool match_rule = false;
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
|
|||
/* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
|
||||
#define MODKEY WLR_MODIFIER_ALT
|
||||
|
||||
int32_t tag_count = 9;
|
||||
uint32_t tag_count = 9;
|
||||
|
||||
float focused_opacity = 1.0;
|
||||
float unfocused_opacity = 1.0;
|
||||
|
|
|
|||
|
|
@ -112,15 +112,15 @@ void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) {
|
|||
Client *c = NULL, *focused = NULL;
|
||||
struct wlr_keyboard *keyboard;
|
||||
xkb_layout_index_t current;
|
||||
int32_t tagmask, state, numclients, focused_client, tag;
|
||||
uint32_t tagmask, state, numclients, focused_client, tag_idx;
|
||||
const char *title, *appid, *symbol;
|
||||
char kb_layout[32];
|
||||
focused = focustop(monitor);
|
||||
zdwl_ipc_output_v2_send_active(ipc_output->resource, monitor == selmon);
|
||||
|
||||
for (tag = 0; tag < tag_count; tag++) {
|
||||
for (tag_idx = 0; tag_idx < tag_count; tag_idx++) {
|
||||
numclients = state = focused_client = 0;
|
||||
tagmask = 1 << tag;
|
||||
tagmask = 1 << tag_idx;
|
||||
if ((tagmask & monitor->tagset[monitor->seltags]) != 0)
|
||||
state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_ACTIVE;
|
||||
wl_list_for_each(c, &clients, link) {
|
||||
|
|
@ -134,7 +134,7 @@ void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) {
|
|||
state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_URGENT;
|
||||
numclients++;
|
||||
}
|
||||
zdwl_ipc_output_v2_send_tag(ipc_output->resource, tag, state,
|
||||
zdwl_ipc_output_v2_send_tag(ipc_output->resource, tag_idx, state,
|
||||
numclients, focused_client);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ static void handle_ext_workspace_deactivate(struct wl_listener *listener,
|
|||
|
||||
static void get_name_from_tag_number(char *dst_buf, size_t dst_len,
|
||||
uint32_t tag_number) {
|
||||
assert(tag_number <= (uint32_t)tag_count);
|
||||
assert(tag_number <= tag_count);
|
||||
if (tag_number == 0)
|
||||
snprintf(dst_buf, dst_len, "overview");
|
||||
else
|
||||
|
|
@ -169,7 +169,7 @@ void dwl_ext_workspace_printstatus(Monitor *m) {
|
|||
}
|
||||
|
||||
void refresh_monitors_workspaces_status(Monitor *m) {
|
||||
int32_t i;
|
||||
uint32_t i;
|
||||
|
||||
if (m->isoverview) {
|
||||
for (i = 1; i <= tag_count; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue