--- src/wmspec.c.old	2005-11-04 23:48:53.000000000 +0100
+++ src/wmspec.c	2005-11-04 23:49:13.000000000 +0100
@@ -35,6 +35,7 @@
 
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
+#include <X11/Xarch.h>
 #include <string.h>
 
 #include "WindowMaker.h"
@@ -322,63 +323,63 @@ setSupportedHints(WScreen *scr)
 void
 wNETWMUpdateDesktop(WScreen *scr)
 {
-    CARD32 *views, sizes[2];
+    long *views, sizes[2];
     int count, i;
 
     if (scr->workspace_count==0)
         return;
 
     count = scr->workspace_count * 2;
-    views = wmalloc(sizeof(CARD32) * count);
-    /*memset(views, 0, sizeof(CARD32) * count);*/
+    views = wmalloc(sizeof(long) * count);
+    /*memset(views, 0, sizeof(long) * count);*/
 
 #ifdef VIRTUAL_DESKTOP
-    sizes[0] = scr->workspaces[scr->current_workspace]->width;
-    sizes[1] = scr->workspaces[scr->current_workspace]->height;
+	    sizes[0] = scr->workspaces[scr->current_workspace]->width;
+	    sizes[1] = scr->workspaces[scr->current_workspace]->height;
 #else
-    sizes[0] = scr->scr_width;
-    sizes[1] = scr->scr_height;
+	    sizes[0] = scr->scr_width;
+	    sizes[1] = scr->scr_height;
 #endif
 
-    for (i=0; i<scr->workspace_count; i++) {
+	    for (i=0; i<scr->workspace_count; i++) {
 #ifdef VIRTUAL_DESKTOP
-        views[2*i + 0] = scr->workspaces[i]->view_x;
-        views[2*i + 1] = scr->workspaces[i]->view_y;
+		views[2*i + 0] = scr->workspaces[i]->view_x;
+		views[2*i + 1] = scr->workspaces[i]->view_y;
 #else
-        views[2*i + 0] = 0;
-        views[2*i + 1] = 0;
+		views[2*i + 0] = 0;
+		views[2*i + 1] = 0;
 #endif
-    }
+	    }
 
-    XChangeProperty(dpy, scr->root_win, net_desktop_geometry, XA_CARDINAL, 32,
-                    PropModeReplace, (unsigned char*)sizes, 2);
+	    XChangeProperty(dpy, scr->root_win, net_desktop_geometry, XA_CARDINAL, 32,
+			    PropModeReplace, (unsigned char*)sizes, 2);
 
-    XChangeProperty(dpy, scr->root_win, net_desktop_viewport, XA_CARDINAL, 32,
-                    PropModeReplace, (unsigned char*)views, count);
+	    XChangeProperty(dpy, scr->root_win, net_desktop_viewport, XA_CARDINAL, 32,
+			    PropModeReplace, (unsigned char*)views, count);
 
-    wfree(views);
-}
+	    wfree(views);
+	}
 
 
-int
-wNETWMGetCurrentDesktopFromHint(WScreen *scr)
-{
-    int count;
-    unsigned char *prop;
+	int
+	wNETWMGetCurrentDesktopFromHint(WScreen *scr)
+	{
+	    int count;
+	    unsigned char *prop;
 
-    prop= PropGetCheckProperty(scr->root_win, net_current_desktop, XA_CARDINAL,
-                               0, 1, &count);
-    if (prop)
-    {
-        int desktop= *(CARD32*)prop;
-        XFree(prop);
-        return desktop;
-    }
-    return -1;
-}
+	    prop= PropGetCheckProperty(scr->root_win, net_current_desktop, XA_CARDINAL,
+				       0, 1, &count);
+	    if (prop)
+	    {
+		int desktop= *(long*)prop;
+		XFree(prop);
+		return desktop;
+	    }
+	    return -1;
+	}
 
 
-/*
+	/*
  * Find the best icon to be used by Window Maker for appicon/miniwindows.
  * Currently the algorithm is to take the image with the size closest
  * to icon_size x icon_size, but never bigger than that.
@@ -389,12 +390,12 @@ wNETWMGetCurrentDesktopFromHint(WScreen 
  *
  * The logic can also be changed to accept bigger images and scale them down.
  */
-static CARD32*
-findBestIcon(CARD32 *data, unsigned long items)
+static unsigned long*
+findBestIcon(unsigned long *data, unsigned long items)
 {
     int size, wanted, d, distance;
     unsigned long i;
-    CARD32 *icon;
+    unsigned long *icon;
 
     /* better use only 75% of icon_size. For 64x64 this means 48x48
      * This leaves room around the icon for the miniwindow title and
@@ -418,12 +419,12 @@ findBestIcon(CARD32 *data, unsigned long
 
 
 static RImage*
-makeRImageFromARGBData(CARD32 *data)
+makeRImageFromARGBData(long *data)
 {
     int size, width, height, i;
     RImage *image;
     unsigned char *imgdata;
-    CARD32 pixel;
+    long pixel;
 
     width  = data[0];
     height = data[1];
@@ -436,10 +437,17 @@ makeRImageFromARGBData(CARD32 *data)
 
     for (imgdata=image->data, i=2; i<size+2; i++, imgdata+=4) {
         pixel = data[i];
+#if BYTE_ORDER == BIG_ENDIAN
+        imgdata[2] = (pixel >> 24) & 0xff; /* A */
+        imgdata[1] = (pixel >> 16) & 0xff; /* R */
+        imgdata[0] = (pixel >>  8) & 0xff; /* G */
+        imgdata[3] = (pixel >>  0) & 0xff; /* B */
+#else /* Little endian */
         imgdata[3] = (pixel >> 24) & 0xff; /* A */
         imgdata[0] = (pixel >> 16) & 0xff; /* R */
         imgdata[1] = (pixel >>  8) & 0xff; /* G */
         imgdata[2] = (pixel >>  0) & 0xff; /* B */
+#endif /* endianness */
     }
 
     return image;
@@ -449,7 +457,7 @@ makeRImageFromARGBData(CARD32 *data)
 static void
 updateIconImage(WScreen *scr, WWindow *wwin)
 {
-    CARD32 *property, *data;
+    unsigned long *property, *data;
     unsigned long items, rest;
     Atom type;
     int format;
@@ -487,7 +495,7 @@ updateIconImage(WScreen *scr, WWindow *w
 static void
 updateShowDesktop(WScreen * scr, Bool show)
 {
-    CARD32 foo;
+    long foo;
 
     foo = (show == True);
     XChangeProperty(dpy, scr->root_win, net_showing_desktop, XA_CARDINAL, 32,
@@ -660,7 +668,7 @@ wNETWMUpdateActions(WWindow *wwin, Bool 
 void
 wNETWMUpdateWorkarea(WScreen *scr, WArea usableArea)
 {
-    CARD32 *area;
+    long *area;
     int count, i;
 
     /* XXX: not Xinerama compatible,
@@ -670,7 +678,7 @@ wNETWMUpdateWorkarea(WScreen *scr, WArea
         return;
 
     count = scr->workspace_count * 4;
-    area = wmalloc(sizeof(CARD32) * count);
+    area = wmalloc(sizeof(long) * count);
     for (i=0; i<scr->workspace_count; i++) {
         area[4*i + 0] = usableArea.x1;
         area[4*i + 1] = usableArea.y1;
@@ -793,7 +801,7 @@ updateClientListStacking(WScreen *scr, W
 static void
 updateWorkspaceCount(WScreen *scr) /* changeable */
 {
-    CARD32 count;
+    long count;
 
     count = scr->workspace_count;
 
@@ -805,7 +813,7 @@ updateWorkspaceCount(WScreen *scr) /* ch
 static void
 updateCurrentWorkspace(WScreen *scr) /* changeable */
 {
-    CARD32 count;
+    long count;
 
     count = scr->current_workspace;
 
@@ -852,7 +860,7 @@ updateFocusHint(WScreen *scr, WWindow *w
 static void
 updateWorkspaceHint(WWindow *wwin, Bool fake, Bool del)
 {
-    CARD32 l;
+    long l;
 
     if (del) {
         XDeleteProperty(dpy, wwin->client_win, net_wm_desktop);

