diff options
author | Simon Rettberg | 2021-04-15 15:52:25 +0200 |
---|---|---|
committer | Simon Rettberg | 2021-04-15 15:52:25 +0200 |
commit | 3ade930ff190bce05e75ed86e8d0eaae26644307 (patch) | |
tree | ebdbba366bc6df09b968ca50156b84947e85b4e3 | |
parent | Don't make the return key press the Cancel button... (diff) | |
download | printergui-3ade930ff190bce05e75ed86e8d0eaae26644307.tar.gz printergui-3ade930ff190bce05e75ed86e8d0eaae26644307.tar.xz printergui-3ade930ff190bce05e75ed86e8d0eaae26644307.zip |
Fix Display handle leak
-rw-r--r-- | src/x11workaround.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/x11workaround.cpp b/src/x11workaround.cpp index c093362..3554963 100644 --- a/src/x11workaround.cpp +++ b/src/x11workaround.cpp @@ -6,6 +6,8 @@ void movePointer(int x, int y) { int root_x, root_y, win_x, win_y; unsigned int mask_return; Display* dpy = XOpenDisplay(0); + if (dpy == nullptr) + return; Window root = DefaultRootWindow(dpy); Window window_returned; result = XQueryPointer(dpy, root, &window_returned, &window_returned, &root_x, &root_y, &win_x, &win_y, &mask_return); @@ -15,6 +17,7 @@ void movePointer(int x, int y) { } XWarpPointer(dpy, None,root, 0, 0, 0, 0, root_x - x ,root_y - y); XFlush(dpy); + XCloseDisplay(dpy); } void wiggle() { |