#pragma once #include #include typedef struct monitor_t monitor_t; typedef struct client_t client_t; typedef struct layout_t { const char *symbol; void (*arrange)(monitor_t *monitor); } layout_t; /* 避免引入 xcb 头文件 */ typedef uint32_t xcb_window_t; struct monitor_t { uint32_t index; int32_t monitor_x, monitor_y, window_x, window_y; uint32_t monitor_width, monitor_height, window_width, window_height; uint32_t selected_tags; char **tags; /* 为了避免引入 cairo 相关头文件,这里用 void * * 指针代替实际的指针类型,使用时强转为相应指针类型使用即可 */ void *cr; /* cairo_t */ const layout_t *layout; monitor_t *next; client_t *clients; client_t *clients_stack; client_t *selected_client; xcb_window_t bar_window; }; struct client_t { char name[256]; int32_t x, y, old_x, old_y; uint32_t width, height, border_width, old_width, old_height, old_border_width; uint32_t tags; bool fullscreen; bool floating; bool maximize; monitor_t *monitor; client_t *next; client_t *stack_next; xcb_window_t window; }; #define CLIENT_VISIBLE(C) ((C)->tags & (C)->monitor->selected_tags) typedef struct wallpaper_config_t { uint32_t count; char **path_list; } wallpaper_config_t; /* 窗口默认屏幕和 tags */ typedef struct rule_tag_t { const uint32_t monitor_amount; uint32_t monitor_index; uint32_t tags; } rule_tag_t; typedef struct rule_action_t { bool switch_to_tag; bool fullscreen; bool maximize; bool floating; } rule_action_t; /* 新建窗口规则 */ typedef struct rule_t { /* 规则匹配字段组 */ const char *class; const char *instance; const char *title; const rule_tag_t *tag; /* 默认所在屏幕和 tags 设置,以 {0} 结尾 */ const rule_action_t action; } rule_t; typedef union user_action_arg_t { bool b; int32_t i; uint32_t ui; float f; const void *ptr; } user_action_arg_t; typedef struct keybinding_t { uint32_t modifiers; uint32_t key_symbol; void (*func)(const user_action_arg_t *); const user_action_arg_t arg; } keybinding_t; typedef struct color_t { uint32_t rgba; uint32_t argb; double red; double green; double blue; double alpha; } color_t; typedef struct color_set_t { color_t bar_bg; color_t tag_bg; color_t active_tag_bg; color_t tag_color; color_t active_tag_color; color_t layout_color; color_t client_name_bg; color_t client_name_color; color_t active_client_name_bg; color_t active_client_name_color; color_t status_color; color_t border_color; color_t active_border_color; } color_set_t; typedef struct { char mem_used_text[32]; char swap_used_text[32]; float mem_percent; float swap_percent; uint64_t mem_used; uint64_t swap_used; uint64_t mem_total; uint64_t mem_free; uint64_t buffers; uint64_t cached; uint64_t swap_total; uint64_t swap_free; uint64_t s_reclaimable; } memory_usage_t; typedef struct { uint64_t rx_bytes; uint64_t tx_bytes; char up[128]; char down[128]; } net_speed_t; typedef struct { uint32_t index; int mute; int avg_volume; /* 各通道平均音量(百分比) */ int volumes[5]; /* 各通道音量(百分比) */ char device[512]; /* 音频设备名称 */ } pulse_t; typedef struct { pulse_t pulse; net_speed_t net_speed; memory_usage_t mem_usage; double cpu_usage_percent; char time[256]; } status_t;