diff options
author | Mattias Andrée <m@maandree.se> | 2025-03-23 16:09:45 +0100 |
---|---|---|
committer | Mattias Andrée <m@maandree.se> | 2025-03-23 16:09:45 +0100 |
commit | 1f2e45f01cf3457ea8075593b366fe2ceea7ae4f (patch) | |
tree | dc9fc60678b116dc686628bbfa2e59e51850529a | |
parent | Clearify that N is an ordinal rather than any type of number (diff) | |
download | redshift-ng-1f2e45f01cf3457ea8075593b366fe2ceea7ae4f.tar.gz redshift-ng-1f2e45f01cf3457ea8075593b366fe2ceea7ae4f.tar.bz2 redshift-ng-1f2e45f01cf3457ea8075593b366fe2ceea7ae4f.tar.xz |
add display option + update doc about all screens being the default
Signed-off-by: Mattias Andrée <m@maandree.se>
-rw-r--r-- | README | 16 | ||||
-rw-r--r-- | redshift.1 | 16 | ||||
-rw-r--r-- | src/backend-direct.c | 77 | ||||
-rw-r--r-- | src/common.h | 10 |
4 files changed, 104 insertions, 15 deletions
@@ -603,10 +603,14 @@ EXTENDED DESCRIPTION Options for the location provider "randr" (preferred method for X) are: - screen = integer - X screen to apply adjustments to. Default is determined + display = name + X display to apply adjustments to. Default is determined by the environment variable DISPLAY. + screen = integer + X screen to apply adjustments to. All will be used if not + specified. + crtc = integer list or all Comma-separated (,) list of CRTC indices for monitors to apply adjustments to. All available CRTCs are used if the @@ -618,10 +622,14 @@ EXTENDED DESCRIPTION Options for the location provider "vidmode" (fallback method for X) are: - screen = integer - X screen to apply adjustments to. Default is determined + display = name + X display to apply adjustments to. Default is determined by the environment variable DISPLAY. + screen = integer + X screen to apply adjustments to. All will be used if not + specified. + Options for the location provider "drm" (method for Linux without display server) are: @@ -933,11 +933,15 @@ Options for the location provider .B randr (preferred method for X) are: .TP -.BI screen\fR\ =\ integer -X screen to apply adjustments to. Default is determined +.BI display\fR\ =\ name +X display to apply adjustments to. Default is determined by the environment variable .IR DISPLAY . .TP +.BI screen\fR\ =\ integer +X screen to apply adjustments to. All will be used if not +specified. +.TP .BI crtc\fR\ =\ "integer list or " all Comma-separated (,) list of CRTC indices for monitors to apply adjustments to. All available CRTCs are used if the @@ -952,10 +956,14 @@ Options for the location provider .B vidmode (fallback method for X) are: .TP -.BI screen\fR\ =\ integer -X screen to apply adjustments to. Default is determined +.BI display\fR\ =\ name +X display to apply adjustments to. Default is determined by the environment variable .IR DISPLAY . +.TP +.BI screen\fR\ =\ integer +X screen to apply adjustments to. All will be used if not +specified. .PP Options for the location provider .B drm diff --git a/src/backend-direct.c b/src/backend-direct.c index 41a4053..dd381fb 100644 --- a/src/backend-direct.c +++ b/src/backend-direct.c @@ -126,6 +126,16 @@ struct gamma_state { unsigned crtcs_selected : 1; /** + * Whether the program has connected to the site + */ + unsigned connected : 1; + + /** + * The libgamma constant for the adjustment method + */ + int method; + + /** * Selected parition (if `partition_selected`) */ size_t selected_partition; @@ -142,10 +152,18 @@ struct gamma_state { /** * Indices of selected CRTCs + * + * Deallocated by when no longer needed */ size_t *selected_crtcs; /** + * Name of site to connect to, `NULL` if not selected + * or once connected to the site + */ + char *site_name; + + /** * State for selected paritions */ struct partition_state *partitions; @@ -180,11 +198,16 @@ direct_create(struct gamma_state **state_out, int method, const char *method_nam state = *state_out = ecalloc(1, sizeof(**state_out)); state->selected_crtcs = NULL; state->partitions = NULL; + state->site_name = NULL; + state->method = method; state->multiple_sites = caps.multiple_sites; state->multiple_partitions = caps.multiple_partitions; state->multiple_crtcs = caps.multiple_crtcs; state->partitions_are_graphics_cards = caps.partitions_are_graphics_cards; - + + if (state->multiple_sites) + return 0; + err = libgamma_site_initialise(&state->site, method, NULL); if (err) { weprintf("libgamma_site_initialise %s NULL: %s", libgamma_const_of_method(method), libgamma_strerror(err)); @@ -208,16 +231,19 @@ direct_print_help(FILE *f, int method) return; } + if (caps.multiple_sites) + fprintf(f, " display=%s %s\n", _("NAME "), _("Display server instance to apply adjustments to")); + if (caps.multiple_partitions && caps.partitions_are_graphics_cards) /* TRANSLATORS: "N" represents "ordinal"; right-pad with spaces to preserve display width */ - fprintf(f, " card=%s %s\n", _("N "), _("Graphics card to apply adjustments to")); + fprintf(f, " card=%s %s\n", _("N "), _("Graphics card to apply adjustments to")); else if (caps.multiple_partitions) - fprintf(f, " screen=%s %s\n", _("N "), _("X screen to apply adjustments to")); + fprintf(f, " screen=%s %s\n", _("N "), _("X screen to apply adjustments to")); if (caps.multiple_crtcs) - fprintf(f, " crtc=%s %s\n", _("N "), _("List of comma-separated CRTCs to apply adjustments to")); + fprintf(f, " crtc=%s %s\n", _("N "), _("List of comma-separated CRTCs to apply adjustments to")); - if (caps.multiple_partitions || caps.multiple_crtcs) + if (caps.multiple_sites || caps.multiple_partitions || caps.multiple_crtcs) fprintf(f, "\n"); } @@ -225,7 +251,9 @@ direct_print_help(FILE *f, int method) int direct_set_option(struct gamma_state *state, const char *key, const char *value) { - if (state->multiple_partitions && !strcasecmp(key, state->partitions_are_graphics_cards ? "card" : "screen")) { + if (state->multiple_sites && !strcasecmp(key, "display")) { + return direct_set_site(state, key, value); + } else if (state->multiple_partitions && !strcasecmp(key, state->partitions_are_graphics_cards ? "card" : "screen")) { return direct_set_partitions(state, key, value); } else if (state->multiple_crtcs && !strcasecmp(key, "crtc")) { return direct_set_crtcs(state, key, value); @@ -240,6 +268,18 @@ direct_set_option(struct gamma_state *state, const char *key, const char *value) int +direct_set_site(struct gamma_state *state, const char *key, const char *value) +{ + if (state->site_name) { + weprintf(_("`%s' option specified multiple times, using last selection."), key); + free(state->site_name); + } + state->site_name = estrdup(value); + return 0; +} + + +int direct_set_partitions(struct gamma_state *state, const char *key, const char *value) { const char *end; @@ -310,6 +350,25 @@ direct_start(struct gamma_state *state) size_t i, j, k, num, part; int err; + /* Connect to display server */ + if (state->multiple_sites) { + if (state->site_name && !*state->site_name) { + free(state->site_name); + state->site_name = NULL; + } + err = libgamma_site_initialise(&state->site, state->method, state->site_name); + if (err) { + weprintf("libgamma_site_initialise %s %s: %s", + libgamma_const_of_method(state->method), + state->site_name ? state->site_name : "NULL", + libgamma_strerror(err)); + return -1; + } + state->connected = 1; + free(state->site_name); + state->site_name = NULL; + } + /* Allocate partition states */ if (state->partition_selected) { state->partitions = ecalloc(1, sizeof(*state->partitions)); @@ -505,6 +564,8 @@ direct_start(struct gamma_state *state) return -1; } + free(state->selected_crtcs); + state->selected_crtcs = NULL; return 0; } @@ -646,6 +707,8 @@ direct_free(struct gamma_state *state) free(state->partitions); } free(state->selected_crtcs); - libgamma_site_destroy(&state->site); + if (state->connected) + libgamma_site_destroy(&state->site); + free(state->site_name); free(state); } diff --git a/src/common.h b/src/common.h index a14e8d4..dc0312b 100644 --- a/src/common.h +++ b/src/common.h @@ -1220,6 +1220,16 @@ void direct_print_help(FILE *f, int method); int direct_set_option(GAMMA_STATE *state, const char *key, const char *value); /** + * Select site to apply adjustments to using direct gamma adjustments + * + * @param state State object for the adjustment method + * @param key Option to configure + * @param value Option value to set + * @return 0 on success, -1 on failure + */ +int direct_set_site(GAMMA_STATE *state, const char *key, const char *value); + +/** * Select partitions to apply adjustments to using direct gamma adjustments * * @param state State object for the adjustment method |