diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-05-03 13:05:31 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-05-03 13:05:31 +0200 |
commit | 3fa6dedf61929fc73aad4f558f60b381da8416f9 (patch) | |
tree | d8d333cae7df36147769051d4b20e4b9b58e160f /src/lib | |
parent | wayland: set and get gamma (diff) | |
download | libgamma-3fa6dedf61929fc73aad4f558f60b381da8416f9.tar.gz libgamma-3fa6dedf61929fc73aad4f558f60b381da8416f9.tar.bz2 libgamma-3fa6dedf61929fc73aad4f558f60b381da8416f9.tar.xz |
add support for PREFERRED_DISPLAY
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/lib/libgamma-facade.c.gpp | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/src/lib/libgamma-facade.c.gpp b/src/lib/libgamma-facade.c.gpp index 9c31db6..8d10c5d 100644 --- a/src/lib/libgamma-facade.c.gpp +++ b/src/lib/libgamma-facade.c.gpp @@ -179,12 +179,46 @@ size_t libgamma_list_methods(int* restrict methods, size_t buf_size, int operati (void) operation; return 0; #else - size_t n = 0; + size_t n = 0, len; + int included[LIBGAMMA_METHOD_COUNT]; + char* begin; + char* end; + + memset(included, 0, LIBGAMMA_METHOD_COUNT * sizeof(int)); + begin = getenv("PREFERRED_DISPLAY"); + while (begin && *begin) + { + end = strchr(begin, ' '); + len = (size_t)(end - begin); + if (len == 0); +#ifdef HAVE_LIBGAMMA_METHOD_WAYLAND + else if ((len == 7) && !strncmp(begin, "wayland", len)) /* 7 is strlen("wayland") */ + { + if (libgamma_list_method_test(LIBGAMMA_METHOD_WAYLAND, operation) && (n++ < buf_size)) + methods[n - 1] = LIBGAMMA_METHOD_WAYLAND, included[methods[n - 1]] = 1; + } +#endif +#if defined(HAVE_LIBGAMMA_METHOD_X_RANDR) || defined(HAVE_LIBGAMMA_METHOD_X_VIDMODE) + else if ((len == 3) && !strncmp(begin, "x11", len)) /* 3 is strlen("x11") */ + { +# ifdef HAVE_LIBGAMMA_METHOD_X_RANDR + if (libgamma_list_method_test(LIBGAMMA_METHOD_X_RANDR, operation) && (n++ < buf_size)) + methods[n - 1] = LIBGAMMA_METHOD_X_RANDR, included[methods[n - 1]] = 1; +# endif +# ifdef HAVE_LIBGAMMA_METHOD_X_VIDMODE + if (libgamma_list_method_test(LIBGAMMA_METHOD_X_VIDMODE, operation) && (n++ < buf_size)) + methods[n - 1] = LIBGAMMA_METHOD_X_VIDMODE, included[methods[n - 1]] = 1; +# endif + } +#endif + begin = end + 1; + } $>for method in $(get-methods); do #ifdef HAVE_LIBGAMMA_METHOD_${method} - if (libgamma_list_method_test(LIBGAMMA_METHOD_${method}, operation) && (n++ < buf_size)) - methods[n - 1] = LIBGAMMA_METHOD_${method}; + if (included[LIBGAMMA_METHOD_${method}] == 0) + if (libgamma_list_method_test(LIBGAMMA_METHOD_${method}, operation) && (n++ < buf_size)) + methods[n - 1] = LIBGAMMA_METHOD_${method}; #endif $>done |