diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2012-02-17 14:33:56 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2012-02-21 11:19:17 +1000 |
commit | eb40d9cc5d59321263fd8fa3f76ddd912d1fb804 (patch) | |
tree | 9c8910234e8218c0503782c51b5a8ff5cf90629e | |
parent | 5d32964533e4ebe3c69f1dfa34c709a1f447ad86 (diff) |
Add find_output_xrandr to check for output presence
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | src/transform.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/transform.c b/src/transform.c index 3ea7ff8..15fda59 100644 --- a/src/transform.c +++ b/src/transform.c @@ -135,13 +135,14 @@ set_transformation_matrix(Display *dpy, Matrix *m, int offset_x, int offset_y, #endif } -static int -map_output_xrandr(Display *dpy, int deviceid, const char *output_name) +/* Caller must free return value */ +static XRROutputInfo* +find_output_xrandr(Display *dpy, const char *output_name) { - int i, found = 0; - int rc = EXIT_FAILURE; XRRScreenResources *res; - XRROutputInfo *output_info; + XRROutputInfo *output_info = NULL; + int i; + int found = 0; res = XRRGetScreenResources(dpy, DefaultRootWindow(dpy)); @@ -159,8 +160,26 @@ map_output_xrandr(Display *dpy, int deviceid, const char *output_name) XRRFreeOutputInfo(output_info); } + XRRFreeScreenResources(res); + + if (!found) + output_info = NULL; + + return output_info; +} + +static int +map_output_xrandr(Display *dpy, int deviceid, const char *output_name) +{ + int rc = EXIT_FAILURE; + XRRScreenResources *res; + XRROutputInfo *output_info; + + res = XRRGetScreenResources(dpy, DefaultRootWindow(dpy)); + output_info = find_output_xrandr(dpy, output_name); + /* crtc holds our screen info, need to compare to actual screen size */ - if (found) + if (output_info) { XRRCrtcInfo *crtc_info; Matrix m; |