feat: map tablet input to config.tablet_map_to_mon on tool creation

This commit is contained in:
werapi 2026-03-25 16:37:23 +01:00
parent 1d43c23991
commit 4ed8301c7f
2 changed files with 25 additions and 0 deletions

View file

@ -282,6 +282,8 @@ typedef struct {
double axis_scroll_factor; double axis_scroll_factor;
char *tablet_map_to_mon;
int32_t blur; int32_t blur;
int32_t blur_layer; int32_t blur_layer;
int32_t blur_optimized; int32_t blur_optimized;
@ -1677,6 +1679,10 @@ bool parse_option(Config *config, char *key, char *value) {
config->button_map = atoi(value); config->button_map = atoi(value);
} else if (strcmp(key, "axis_scroll_factor") == 0) { } else if (strcmp(key, "axis_scroll_factor") == 0) {
config->axis_scroll_factor = atof(value); config->axis_scroll_factor = atof(value);
} else if (strcmp(key, "tablet_map_to_mon") == 0) {
if (config->tablet_map_to_mon)
free(config->tablet_map_to_mon);
config->tablet_map_to_mon = strdup(value);
} else if (strcmp(key, "gappih") == 0) { } else if (strcmp(key, "gappih") == 0) {
config->gappih = atoi(value); config->gappih = atoi(value);
} else if (strcmp(key, "gappiv") == 0) { } else if (strcmp(key, "gappiv") == 0) {
@ -3094,6 +3100,11 @@ void free_config(void) {
config.cursor_theme = NULL; config.cursor_theme = NULL;
} }
if (config.tablet_map_to_mon) {
free(config.tablet_map_to_mon);
config.tablet_map_to_mon = NULL;
}
// 释放 circle_layout // 释放 circle_layout
free_circle_layout(&config); free_circle_layout(&config);
@ -3518,6 +3529,7 @@ bool parse_config(void) {
config.tag_rules = NULL; config.tag_rules = NULL;
config.tag_rules_count = 0; config.tag_rules_count = 0;
config.cursor_theme = NULL; config.cursor_theme = NULL;
config.tablet_map_to_mon = NULL;
strcpy(config.keymode, "default"); strcpy(config.keymode, "default");
create_config_keymap(); create_config_keymap();

View file

@ -317,6 +317,7 @@ void tablettoolproximity(struct wl_listener *listener, void *data) {
struct wlr_tablet_tool_proximity_event *event = data; struct wlr_tablet_tool_proximity_event *event = data;
struct wlr_tablet_tool *wlr_tool = event->tool; struct wlr_tablet_tool *wlr_tool = event->tool;
struct TabletTool *tool = wlr_tool->data; struct TabletTool *tool = wlr_tool->data;
Monitor *m_iter;
if (!tool) { if (!tool) {
tool = calloc(1, sizeof(struct TabletTool)); tool = calloc(1, sizeof(struct TabletTool));
@ -332,6 +333,18 @@ void tablettoolproximity(struct wl_listener *listener, void *data) {
wlr_tool->data = tool; wlr_tool->data = tool;
wl_signal_add(&tool->tool_v2->wlr_tool->events.destroy, &tool->destroy); wl_signal_add(&tool->tool_v2->wlr_tool->events.destroy, &tool->destroy);
wl_signal_add(&tool->tool_v2->events.set_cursor, &tool->set_cursor); wl_signal_add(&tool->tool_v2->events.set_cursor, &tool->set_cursor);
if (config.tablet_map_to_mon) {
wl_list_for_each(m_iter, &mons, link) {
if (match_monitor_spec(config.tablet_map_to_mon, m_iter)) {
wlr_log(WLR_DEBUG, "Mapping tablet %s to output %s",
event->tablet->base.name, config.tablet_map_to_mon);
wlr_cursor_map_input_to_output(cursor, &event->tablet->base,
m_iter->wlr_output);
break;
}
}
}
} }
switch (event->state) { switch (event->state) {