]> git.draconx.ca Git - rrace.git/blobdiff - src/ewmhicon.c
Allow compilation without X11.
[rrace.git] / src / ewmhicon.c
index e071ceceb9a3b24f54fc953b414e4fc227b34cb6..32392a802df6af414a2bafbae25b937d7ef7f30f 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
-#include <X11/Intrinsic.h>
-#include <X11/Xatom.h>
-#include "motif.h"
+#if !X_DISPLAY_MISSING
+#  include <X11/Intrinsic.h>
+#  include <X11/Xatom.h>
+#endif
+#include "ewmhicon.h"
 
 static unsigned long scale16to8(unsigned x)
 {
@@ -143,6 +145,39 @@ void ewmh_tile48(unsigned long *icon, const XColor *c, int tile_x, int tile_y)
        }
 }
 
+void *ewmh_icon_alloc(unsigned long **sizes)
+{
+       unsigned long *buf;
+
+       buf = calloc(sizeof *buf, EWMH_ICON_NELEM);
+       if (buf) {
+               sizes[ICON_16x16] = buf;
+               *sizes[ICON_16x16]++ = 16;
+               *sizes[ICON_16x16]++ = 16;
+
+               sizes[ICON_24x24] = sizes[ICON_16x16] + 16*16;
+               *sizes[ICON_24x24]++ = 24;
+               *sizes[ICON_24x24]++ = 24;
+
+               sizes[ICON_32x32] = sizes[ICON_24x24] + 24*24;
+               *sizes[ICON_32x32]++ = 32;
+               *sizes[ICON_32x32]++ = 32;
+
+               sizes[ICON_48x48] = sizes[ICON_32x32] + 32*32;
+               *sizes[ICON_48x48]++ = 48;
+               *sizes[ICON_48x48]++ = 48;
+       }
+
+       return buf;
+}
+
+#if !X_DISPLAY_MISSING
+
+/*
+ * EWMH-supporting window managers that handle _NET_WM_ICON add this atom to
+ * the _NET_SUPPORTED list on the root window.  Look for that and return 1
+ * if it is found, or 0 otherwise.
+ */
 int ewmh_probe_wm_icon(Widget shell)
 {
        Display *display = XtDisplay(shell);
@@ -154,12 +189,12 @@ int ewmh_probe_wm_icon(Widget shell)
        unsigned char *prop_return;
        int format;
 
-       net_wm_icon = XInternAtom(display, "_NET_WM_ICON", FALSE);
-       net_supported = XInternAtom(display, "_NET_SUPPORTED", FALSE);
+       net_wm_icon = XInternAtom(display, "_NET_WM_ICON", 0);
+       net_supported = XInternAtom(display, "_NET_SUPPORTED", 0);
        do {
                XGetWindowProperty(display, root, net_supported, offset, 10,
-                                           FALSE, XA_ATOM, &type,
-                                           &format, &nitems, &bytes_after,
+                                           0, XA_ATOM, &type, &format,
+                                           &nitems, &bytes_after,
                                            &prop_return);
 
                if (format != 32 || type != XA_ATOM)
@@ -177,28 +212,4 @@ int ewmh_probe_wm_icon(Widget shell)
        return 0;
 }
 
-void *ewmh_icon_alloc(unsigned long **sizes)
-{
-       unsigned long *buf;
-
-       buf = calloc(sizeof *buf, EWMH_ICON_NELEM);
-       if (buf) {
-               sizes[ICON_16x16] = buf;
-               *sizes[ICON_16x16]++ = 16;
-               *sizes[ICON_16x16]++ = 16;
-
-               sizes[ICON_24x24] = sizes[ICON_16x16] + 16*16;
-               *sizes[ICON_24x24]++ = 24;
-               *sizes[ICON_24x24]++ = 24;
-
-               sizes[ICON_32x32] = sizes[ICON_24x24] + 24*24;
-               *sizes[ICON_32x32]++ = 32;
-               *sizes[ICON_32x32]++ = 32;
-
-               sizes[ICON_48x48] = sizes[ICON_32x32] + 32*32;
-               *sizes[ICON_48x48]++ = 48;
-               *sizes[ICON_48x48]++ = 48;
-       }
-
-       return buf;
-}
+#endif