aboutsummaryrefslogtreecommitdiff
path: root/util/fluxbox-remote.cc
diff options
context:
space:
mode:
Diffstat (limited to 'util/fluxbox-remote.cc')
-rw-r--r--util/fluxbox-remote.cc25
1 files changed, 20 insertions, 5 deletions
diff --git a/util/fluxbox-remote.cc b/util/fluxbox-remote.cc
index 05f251a..5c66583 100644
--- a/util/fluxbox-remote.cc
+++ b/util/fluxbox-remote.cc
@@ -25,6 +25,14 @@
25#include <stdlib.h> 25#include <stdlib.h>
26#include <stdio.h> 26#include <stdio.h>
27 27
28bool g_gotError;
29static int HandleIPCError(Display *disp, XErrorEvent*ptr)
30{
31 // ptr->error_code contains the actual error flags
32 g_gotError=true;
33 return( 0 );
34}
35
28int main(int argc, char **argv) { 36int main(int argc, char **argv) {
29 37
30 if (argc <= 1) { 38 if (argc <= 1) {
@@ -42,14 +50,21 @@ int main(int argc, char **argv) {
42 Window root = DefaultRootWindow(disp); 50 Window root = DefaultRootWindow(disp);
43 51
44 char *str = argv[1]; 52 char *str = argv[1];
45 int ret = XChangeProperty(disp, root, fbcmd_atom, 53
54 typedef int (*x_error_handler_t)(Display*,XErrorEvent*);
55
56 // assign the custom handler, clear the flag, sync the data, then check it for success/failure
57 x_error_handler_t handler = XSetErrorHandler( HandleIPCError );
58 g_gotError=false;
59 XChangeProperty(disp, root, fbcmd_atom,
46 XA_STRING, 8, PropModeReplace, 60 XA_STRING, 8, PropModeReplace,
47 (unsigned char *) str, strlen(str)); 61 (unsigned char *) str, strlen(str));
48 XCloseDisplay(disp); 62 XSync(disp,False);
63 int ret=(g_gotError?EXIT_FAILURE:EXIT_SUCCESS);
64 XSetErrorHandler(handler);
49 65
50 if (ret == Success) 66 XCloseDisplay(disp);
51 return EXIT_SUCCESS;
52 67
53 return EXIT_FAILURE; 68 return ret;
54} 69}
55 70