[PATCH xinput 4/5] Add find_output_xrandr to check for output presence
Peter Hutterer
peter.hutterer at who-t.net
Sun Feb 19 19:37:00 PST 2012
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
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;
--
1.7.7.5
More information about the xorg-devel
mailing list