#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
if (status == Success && type != None)
{
+ Window ret = kids[i];
if (version)
*version = v;
- return kids[i];
+ XFree (kids);
+ return ret;
}
}
+
+ if (kids) XFree (kids);
return 0;
}
send_xscreensaver_command (Display *dpy, Atom command, long arg,
Window *window_ret, char **error_ret)
{
+ int status = -1;
char *v = 0;
Window window = find_screensaver_window (dpy, &v);
XWindowAttributes xgwa;
if (error_ret)
{
*error_ret = strdup (err);
- return -1;
+ status = -1;
+ goto DONE;
}
if (command == XA_EXIT)
- /* Don't print an error if xscreensaver is already dead. */
- return 1;
+ {
+ /* Don't print an error if xscreensaver is already dead. */
+ status = 1;
+ goto DONE;
+ }
fprintf (stderr, "%s: %s\n", progname, err);
- return -1;
+ status = -1;
+ goto DONE;
}
/* Select for property change events, so that we can read the response. */
*error_ret = strdup (err);
else
fprintf (stderr, "%s: %s\n", progname, err);
- return -1;
+
+ status = -1;
+ goto DONE;
}
XGetClassHint(dpy, window, &hint);
*error_ret = strdup (err);
else
fprintf (stderr, "%s: %s\n", progname, err);
- return -1;
+
+ if (v) free (v);
+ status = -1;
+ goto DONE;
}
fprintf (stdout, "%s %s", hint.res_class, v);
fprintf (stdout, "\n");
fflush (stdout);
fprintf (stderr, "bad status format on root window.\n");
- return -1;
+ status = -1;
+ goto DONE;
}
blanked = (Atom) data[0];
}
if (any && nhacks == 1)
- fprintf (stdout, " (hack #%d)\n", data[2]);
+ fprintf (stdout, " (hack #%d)\n", (int) data[2]);
else if (any)
{
fprintf (stdout, " (hacks: ");
for (i = 0; i < nhacks; i++)
{
- fprintf (stdout, "#%d", data[2 + i]);
+ fprintf (stdout, "#%d", (int) data[2 + i]);
if (i != nhacks-1)
fputs (", ", stdout);
}
fprintf (stdout, "\n");
fflush (stdout);
fprintf (stderr, "no saver status on root window.\n");
- return -1;
+ status = -1;
+ goto DONE;
}
}
/* No need to read a response for these commands. */
- return 1;
+ status = 1;
+ goto DONE;
}
else
{
*error_ret = strdup (err);
else
fprintf (stderr, "%s: %s\n", progname, err);
- return -1;
+ status = -1;
+ goto DONE;
}
}
+
+ status = 0;
+
+ DONE:
+ if (v) free (v);
XSync (dpy, 0);
- return 0;
+ return status;
}