feat: add cursor_size and cursor_theme option in config

This commit is contained in:
DreamMaoMao 2025-05-05 17:45:25 +08:00
parent bf6e39ad4f
commit 614a28abd1
4 changed files with 24 additions and 7 deletions

View file

@ -51,6 +51,8 @@ focus_cross_monitor=0
focus_cross_tag=1
enable_floating_snap=0
snap_distance=30
cursor_size=24
# cursro_theme=Buuf
# keyboard
repeat_rate=25

View file

@ -204,6 +204,9 @@ typedef struct {
char **exec_once;
int exec_once_count;
char *cursor_theme;
unsigned int cursor_size;
} Config;
typedef void (*FuncType)(const Arg *);
@ -832,6 +835,10 @@ void parse_config_line(Config *config, const char *line) {
config->mouse_natural_scrolling = atoi(value);
} else if (strcmp(key, "trackpad_natural_scrolling") == 0) {
config->trackpad_natural_scrolling = atoi(value);
} else if (strcmp(key, "cursor_size") == 0) {
config->cursor_size = atoi(value);
} else if (strcmp(key, "cursor_theme") == 0) {
config->cursor_theme = strdup(value);
} else if (strcmp(key, "disable_while_typing") == 0) {
config->disable_while_typing = atoi(value);
} else if (strcmp(key, "left_handed") == 0) {
@ -1464,11 +1471,17 @@ void free_config(void) {
config.scroller_proportion_preset_count = 0;
}
if(config.cursor_theme) {
free(config.cursor_theme);
config.cursor_theme = NULL;
}
// 释放 circle_layout
free_circle_layout(&config);
// 释放动画资源
free_baked_points();
}
void override_config(void) {
@ -1534,6 +1547,7 @@ void override_config(void) {
tap_and_drag = config.tap_and_drag;
drag_lock = config.drag_lock;
mouse_natural_scrolling = config.mouse_natural_scrolling;
cursor_size = config.cursor_size;
trackpad_natural_scrolling = config.trackpad_natural_scrolling;
disable_while_typing = config.disable_while_typing;
left_handed = config.left_handed;
@ -1622,6 +1636,7 @@ void set_value_default() {
config.tap_and_drag = tap_and_drag;
config.drag_lock = drag_lock;
config.mouse_natural_scrolling = mouse_natural_scrolling;
config.cursor_size = cursor_size;
config.trackpad_natural_scrolling = trackpad_natural_scrolling;
config.disable_while_typing = disable_while_typing;
config.left_handed = left_handed;
@ -1703,6 +1718,7 @@ void parse_config(void) {
config.circle_layout_count = 0;
config.tag_rules = NULL;
config.tag_rules_count = 0;
config.cursor_theme = NULL;
// 获取 MAOMAOCONFIG 环境变量
const char *maomaoconfig = getenv("MAOMAOCONFIG");

View file

@ -53,6 +53,7 @@ int focus_cross_monitor = 0;
int focus_cross_tag = 0;
int snap_distance = 30;
int enable_floating_snap = 0;
unsigned int cursor_size = 24;
unsigned int swipe_min_threshold = 20;

View file

@ -5588,13 +5588,12 @@ void handle_foreign_destroy(struct wl_listener *listener, void *data) {
void setup(void) {
// signal(SIGSEGV, signalhandler);
parse_config();
init_baked_points();
setenv("XCURSOR_SIZE", "24", 1);
setenv("XDG_CURRENT_DESKTOP", "maomao", 1);
parse_config();
init_baked_points();
int drm_fd, i, sig[] = {SIGCHLD, SIGINT, SIGTERM, SIGPIPE};
struct sigaction sa = {.sa_flags = SA_RESTART, .sa_handler = handlesig};
sigemptyset(&sa.sa_mask);
@ -5750,8 +5749,7 @@ void setup(void) {
* images are available at all scale factors on the screen (necessary for
* HiDPI support). Scaled cursors will be loaded with each output. */
// cursor_mgr = wlr_xcursor_manager_create(cursor_theme, 24);
cursor_mgr = wlr_xcursor_manager_create(NULL, 24);
setenv("XCURSOR_SIZE", "24", 1);
cursor_mgr = wlr_xcursor_manager_create(config.cursor_theme, cursor_size);
/*
* wlr_cursor *only* displays an image on screen. It does not move around