Take care of the return code from get_atom_longs().
Free atoms correctly.
long states = { skip_pager_state };
char buffer[16];
long states = { skip_pager_state };
char buffer[16];
- XChangeProperty(DADisplay, DAWindow, client_state_atom, XA_ATOM, 32, PropModeAppend, &states, 1);
+ XChangeProperty(DADisplay, DAWindow, client_state_atom, XA_ATOM, 32, PropModeAppend, (unsigned char *) &states, 1);
if (desktop >= 0) {
if (snprintf(buffer, sizeof(buffer), "Desktop %d", desktop + 1) < 0) return;
if (desktop >= 0) {
if (snprintf(buffer, sizeof(buffer), "Desktop %d", desktop + 1) < 0) return;
XStoreName(DADisplay, DAWindow, buffer);
}
XStoreName(DADisplay, DAWindow, buffer);
}
-void get_atom_longs(Atom atom, Atom type, Window window, long **data, unsigned long *num_items) {
+int get_atom_longs(Atom atom, Atom type, Window window, long **data, unsigned long *num_items) {
Atom actual;
int format;
unsigned long num_bytes;
Atom actual;
int format;
unsigned long num_bytes;
- XGetWindowProperty(DADisplay, window, atom, 0, 8192, False, type, &actual, &format, num_items, &num_bytes, (unsigned char **) data);
+ return XGetWindowProperty(DADisplay, window, atom, 0, 8192, False, type, &actual, &format, num_items, &num_bytes, (unsigned char **) data);
-long get_atom_long(Atom atom, Atom type, Window window) {
+int get_atom_long(Atom atom, Atom type, Window window, long *ret) {
- get_atom_longs(atom, type, window, &data, &num_items);
- if (num_items) ret = data[0];
+ *ret = 0;
+
+ status = get_atom_longs(atom, type, window, &data, &num_items);
+ if (status != Success) return status;
+ if (num_items) *ret = data[0];
scale = (double) root_width / (double) dockapp_attr.width;
aspect = (double) root_height / (double) dockapp_attr.height;
scale = (double) root_width / (double) dockapp_attr.width;
aspect = (double) root_height / (double) dockapp_attr.height;
- *active_window = get_atom_long(active_window_atom, XA_WINDOW, dockapp_attr.root);
- *active_desktop = get_atom_long(current_desktop_atom, XA_CARDINAL, DefaultRootWindow(DADisplay));
+ if (get_atom_long(active_window_atom, XA_WINDOW, dockapp_attr.root, (long *) active_window) != Success) *active_window = 0;
+ if (get_atom_long(current_desktop_atom, XA_CARDINAL, DefaultRootWindow(DADisplay), (long *) active_desktop) != Success) *active_desktop = 0;
if (client_list_supported) {
if (client_list_supported) {
- get_atom_longs(client_list_atom, XA_WINDOW, dockapp_attr.root, &data, num_clients);
+ if (get_atom_longs(client_list_atom, XA_WINDOW, dockapp_attr.root, &data, num_clients) != Success) XFree(data);
}
else {
XQueryTree(DADisplay, dockapp_attr.root, &qroot, &qparent, &wins, (unsigned int *) num_clients);
}
else {
XQueryTree(DADisplay, dockapp_attr.root, &qroot, &qparent, &wins, (unsigned int *) num_clients);
else client = XmuClientWindow(DADisplay, wins[i]);
/* Check the window is on our desktop (or all desktops). */
else client = XmuClientWindow(DADisplay, wins[i]);
/* Check the window is on our desktop (or all desktops). */
- client_desktop = get_atom_long(client_desktop_atom, XA_CARDINAL, client);
+ if (get_atom_long(client_desktop_atom, XA_CARDINAL, client, &client_desktop) != Success) continue;
if (desktop > -1) {
if (client_desktop != desktop && client_desktop != -1) continue;
}
if (desktop > -1) {
if (client_desktop != desktop && client_desktop != -1) continue;
}
/* Make sure it isn't hidden or shaded. */
draw = 1;
/* Make sure it isn't hidden or shaded. */
draw = 1;
- get_atom_longs(client_state_atom, XA_ATOM, client, &states, &num_states);
- for (j = 0; j < num_states; j++) {
- if (states[j] == shaded_state) height = 3.0 * scale;
- if (states[j] == skip_pager_state) draw = 0;
- if (states[j] == hidden_state) draw = 0;
+ if (get_atom_longs(client_state_atom, XA_ATOM, client, &states, &num_states) == Success) {
+ for (j = 0; j < num_states; j++) {
+ if (states[j] == shaded_state) height = 3.0 * scale;
+ if (states[j] == skip_pager_state) draw = 0;
+ if (states[j] == hidden_state) draw = 0;
+ }
+ XFree(states);
if (! draw) continue;
(*clients)[i]->window = client;
if (! draw) continue;
(*clients)[i]->window = client;
- num_desktops = get_atom_long(num_desktops_atom, XA_CARDINAL, DefaultRootWindow(DADisplay));
+ if (get_atom_long(num_desktops_atom, XA_CARDINAL, DefaultRootWindow(DADisplay), &num_desktops) != Success) num_desktops = 1;
- desktop = get_atom_long(current_desktop_atom, XA_CARDINAL, DefaultRootWindow(DADisplay));
+ if (get_atom_long(current_desktop_atom, XA_CARDINAL, DefaultRootWindow(DADisplay), (long *) &desktop) != Success) desktop = 0;
}
else if (desktop < 0) desktop = -1;
else if (desktop-- > num_desktops) {
}
else if (desktop < 0) desktop = -1;
else if (desktop-- > num_desktops) {