#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdint.h>
#if !X_DISPLAY_MISSING
# include <X11/Intrinsic.h>
enum { ICON_16x16, ICON_24x24, ICON_32x32, ICON_48x48, ICON_MAX };
-static unsigned long scale16to8(unsigned x)
+static unsigned long scale16to8(uint_least32_t x)
{
- return x*0xfful / 0xffff;
+ return x*0xff / 0xffff;
}
static unsigned long wm_pixel(const XColor *c)
{
- return 0xff000000
- | scale16to8(c->red) << 16
- | scale16to8(c->green) << 8
- | scale16to8(c->blue);
+ uint_least32_t t = -1;
+
+ t = (t << 8) + scale16to8(c->red);
+ t = (t << 8) + scale16to8(c->green);
+ t = (t << 8) + scale16to8(c->blue);
+
+ return t & 0xffffffff;
+}
+
+void ewmh_icon_prepare_cmap(XColor *map, unsigned n)
+{
+ unsigned i;
+
+ for (i = 0; i < n; i++) {
+ map[i].pixel = wm_pixel(&map[i]);
+ }
}
static void do_remap(void *icon, unsigned area, const XColor *map)
area--;
for (i = 0; i <= area; i++) {
- argb[area-i] = wm_pixel(map + index[area-i]);
+ argb[area-i] = (map + index[area-i])->pixel;
}
}