From 3fa6dedf61929fc73aad4f558f60b381da8416f9 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 3 May 2015 13:05:31 +0200 Subject: add support for PREFERRED_DISPLAY MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/lib/libgamma-facade.c.gpp | 40 +++++++++++++++++++++++++++++++++++++--- 1 file 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 -- cgit v1.2.3-70-g09d2