diff options
author | Leo (Sunpeng) Li <sunpeng.li@amd.com> | 2018-03-28 15:54:17 -0400 |
---|---|---|
committer | Leo (Sunpeng) Li <sunpeng.li@amd.com> | 2018-05-02 10:13:31 -0400 |
commit | 8f6ee92fffdf2cd647b7f64494354d5102bb8fe7 (patch) | |
tree | fa85eeb45aff8b81a9f1013bc393a6af209767e0 | |
parent | f9e905e71e1e270c8c7a9ac161e6de588387261b (diff) |
Ensure display is opened
Signed-off-by: Leo (Sunpeng) Li <sunpeng.li@amd.com>
-rw-r--r-- | demo.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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); |