From 699d489f936826a808f955c47442342e850bfc1b Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Fri, 25 Aug 2017 08:58:02 -0400 Subject: [PATCH] add cursor configuration --- examples/config.c | 9 +++++++++ examples/config.h | 4 ++++ examples/pointer.c | 9 +++++++++ examples/wlr-example.ini.example | 7 +++++++ 4 files changed, 29 insertions(+) diff --git a/examples/config.c b/examples/config.c index bca2b44b..909a2463 100644 --- a/examples/config.c +++ b/examples/config.c @@ -67,6 +67,12 @@ static int config_ini_handler(void *user, const char *section, const char *name, wlr_log(L_ERROR, "got unknown transform value: %s", value); } } + } else if (strcmp(section, "cursor") == 0) { + if (strcmp(name, "map-to-output") == 0) { + config->cursor.mapped_output = strdup(value); + } else { + wlr_log(L_ERROR, "got unknown cursor config: %s", name); + } } else { wlr_log(L_ERROR, "got unknown config section: %s", section); } @@ -128,6 +134,9 @@ void example_config_destroy(struct example_config *config) { if (config->config_path) { free(config->config_path); } + if (config->cursor.mapped_output) { + free(config->cursor.mapped_output); + } free(config); } diff --git a/examples/config.h b/examples/config.h index d02d1a2c..c5f0c8dd 100644 --- a/examples/config.h +++ b/examples/config.h @@ -13,6 +13,10 @@ struct output_config { }; struct example_config { + struct { + char *mapped_output; + } cursor; + struct wl_list outputs; char *config_path; }; diff --git a/examples/pointer.c b/examples/pointer.c index fcf9805f..88fdaef7 100644 --- a/examples/pointer.c +++ b/examples/pointer.c @@ -70,6 +70,11 @@ static void handle_output_add(struct output_state *ostate) { sample->layout = configure_layout(sample->config, &ostate->compositor->outputs); wlr_cursor_attach_output_layout(sample->cursor, sample->layout); + char *mapped_output = sample->config->cursor.mapped_output; + if (mapped_output && strcmp(mapped_output, wlr_output->name) == 0) { + wlr_cursor_map_to_output(sample->cursor, wlr_output); + } + /* // TODO configuration if (strcmp("DP-1", ostate->output->name) == 0) { @@ -95,6 +100,10 @@ static void handle_output_remove(struct output_state *ostate) { wlr_output_layout_destroy(sample->layout); sample->layout = configure_layout(sample->config, &ostate->compositor->outputs); wlr_cursor_attach_output_layout(sample->cursor, sample->layout); + + if (strcmp(sample->config->cursor.mapped_output, ostate->output->name) == 0) { + wlr_cursor_map_to_output(sample->cursor, NULL); + } } static void handle_output_resolution(struct compositor_state *state, diff --git a/examples/wlr-example.ini.example b/examples/wlr-example.ini.example index 283439f0..a9dff591 100644 --- a/examples/wlr-example.ini.example +++ b/examples/wlr-example.ini.example @@ -30,4 +30,11 @@ rotate=270 x=1080 y=232 +# Cursor Configuration +# ~~~~~~~~~~~~~~~~~~~~ +# Value "map-to-output" specifies the output to which the cursor is +# constrained. +[cursor] +map-to-output=HDMI-A-1 + # vim:filetype=dosini