diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 71027b67..a9b4314b 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -262,6 +262,8 @@ typedef struct { char autostart[3][256]; + char *tablet_output_name; + ConfigTagRule *tag_rules; // 动态数组 int tag_rules_count; // 数量 @@ -1983,6 +1985,11 @@ void parse_config_line(Config *config, const char *line) { } else if (strncmp(key, "source", 6) == 0) { parse_config_file(config, value); + } else if (strcmp(key, "tablet_output") == 0) { + if (config->tablet_output_name) { + free(config->tablet_output_name); + } + config->tablet_output_name = strdup(value); } else { fprintf(stderr, "Error: Unknown key: %s\n", key); } @@ -2270,6 +2277,11 @@ void free_config(void) { config.cursor_theme = NULL; } + if (config.tablet_output_name) { + free(config.tablet_output_name); + config.tablet_output_name = NULL; + } + // 释放 circle_layout free_circle_layout(&config); @@ -2559,6 +2571,10 @@ void set_value_default() { config.shadows_position_y = shadows_position_y; config.focused_opacity = focused_opacity; config.unfocused_opacity = unfocused_opacity; + + /* tablet */ + config.tablet_output_name = strdup(""); + // memcpy(config.shadowscolor, shadowscolor, sizeof(shadowscolor)); memcpy(config.animation_curve_move, animation_curve_move, diff --git a/src/ext-protocol/tablet.h b/src/ext-protocol/tablet.h index 2e1f21eb..3e15c107 100644 --- a/src/ext-protocol/tablet.h +++ b/src/ext-protocol/tablet.h @@ -1,6 +1,7 @@ #include #include #include +#include static const int tabletmaptosurface = 0; /* map tablet input to surface(1) or monitor(0) */ @@ -32,6 +33,7 @@ static struct wl_listener tablet_tool_destroy = {.notify = destroytablettool}; static struct wl_listener tablet_tool_proximity = {.notify = tablettoolproximity}; static struct wl_listener tablet_tool_tip = {.notify = tablettooltip}; +static Monitor *find_monitor_by_name(const char *output_name); void createtablet(struct wlr_input_device *device) { if (!tablet) { @@ -47,6 +49,15 @@ void createtablet(struct wlr_input_device *device) { libinput_device_config_send_events_set_mode(device_handle, send_events_mode); wlr_cursor_attach_input_device(cursor, device); + // Map tablet to specific monitor if configured + if (config.tablet_output_name[0] != '\0') { + Monitor *target_monitor = find_monitor_by_name(config.tablet_output_name); + if (target_monitor) { + wlr_log(WLR_INFO, "Mapping input to output for device: %s", config.tablet_output_name); + wlr_cursor_map_input_to_output(cursor, device, + target_monitor->wlr_output); + } + } } } else if (device == tablet->wlr_device) { wlr_log(WLR_ERROR, "createtablet: duplicate device"); diff --git a/src/mango.c b/src/mango.c index db226a00..101d158a 100644 --- a/src/mango.c +++ b/src/mango.c @@ -5616,6 +5616,17 @@ static void setgeometrynotify(struct wl_listener *listener, void *data) { } #endif +static Monitor *find_monitor_by_name(const char *output_name) { + if (!output_name) return NULL; + Monitor *m; + wl_list_for_each(m, &mons, link) { + if (m->wlr_output && strcmp(m->wlr_output->name, output_name) == 0) { + return m; + } + } + return NULL; +} + int main(int argc, char *argv[]) { char *startup_cmd = NULL; int c;