diff --git a/src/config/parse_config.h b/src/config/parse_config.h index fda401d9..62c8fc87 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -282,6 +282,8 @@ typedef struct { double axis_scroll_factor; + char *tablet_map_to_mon; + int32_t blur; int32_t blur_layer; int32_t blur_optimized; @@ -1677,6 +1679,10 @@ bool parse_option(Config *config, char *key, char *value) { config->button_map = atoi(value); } else if (strcmp(key, "axis_scroll_factor") == 0) { 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) { config->gappih = atoi(value); } else if (strcmp(key, "gappiv") == 0) { @@ -3094,6 +3100,11 @@ void free_config(void) { config.cursor_theme = NULL; } + if (config.tablet_map_to_mon) { + free(config.tablet_map_to_mon); + config.tablet_map_to_mon = NULL; + } + // 释放 circle_layout free_circle_layout(&config); @@ -3518,6 +3529,7 @@ bool parse_config(void) { config.tag_rules = NULL; config.tag_rules_count = 0; config.cursor_theme = NULL; + config.tablet_map_to_mon = NULL; strcpy(config.keymode, "default"); create_config_keymap(); diff --git a/src/ext-protocol/tablet.h b/src/ext-protocol/tablet.h index 0bc25396..6aa7ae86 100644 --- a/src/ext-protocol/tablet.h +++ b/src/ext-protocol/tablet.h @@ -317,6 +317,7 @@ void tablettoolproximity(struct wl_listener *listener, void *data) { struct wlr_tablet_tool_proximity_event *event = data; struct wlr_tablet_tool *wlr_tool = event->tool; struct TabletTool *tool = wlr_tool->data; + Monitor *m_iter; if (!tool) { tool = calloc(1, sizeof(struct TabletTool)); @@ -332,6 +333,18 @@ void tablettoolproximity(struct wl_listener *listener, void *data) { wlr_tool->data = tool; wl_signal_add(&tool->tool_v2->wlr_tool->events.destroy, &tool->destroy); 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) {