summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo (Sunpeng) Li <sunpeng.li@amd.com>2018-03-28 15:54:17 -0400
committerLeo (Sunpeng) Li <sunpeng.li@amd.com>2018-05-02 10:13:31 -0400
commit8f6ee92fffdf2cd647b7f64494354d5102bb8fe7 (patch)
treefa85eeb45aff8b81a9f1013bc393a6af209767e0
parentf9e905e71e1e270c8c7a9ac161e6de588387261b (diff)
Ensure display is opened
Signed-off-by: Leo (Sunpeng) Li <sunpeng.li@amd.com>
-rw-r--r--demo.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/demo.c b/demo.c
index 60eb318..e2b7c42 100644
--- a/demo.c
+++ b/demo.c
@@ -662,8 +662,14 @@ int main(int argc, char *const argv[])
}
/* Open the default X display and window, then obtain the RandR screen
- * resource. */
+ * resource. Note that the DISPLAY environment variable must exist. */
dpy = XOpenDisplay(NULL);
+ if (!dpy) {
+ printf("No display specified, check the DISPLAY environment "
+ "variable.\n");
+ return 1;
+ }
+
root = DefaultRootWindow(dpy);
res = XRRGetScreenResourcesCurrent(dpy, root);