X-Git-Url: http://git.draconx.ca/gitweb/rrace.git/blobdiff_plain/85522c518d168600f1a3038aebfdd87bc9b62c3d..f6be82664a5b8e8bc34c048b56417b591dcd5a5e:/src/ewmhicon.h diff --git a/src/ewmhicon.h b/src/ewmhicon.h index d073067..1f83853 100644 --- a/src/ewmhicon.h +++ b/src/ewmhicon.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef EWMHICON_H_ -#define EWMHICON_H_ +#ifndef RRACE_EWMHICON_H_ +#define RRACE_EWMHICON_H_ /* * Define X_DISPLAY_MISSING to allow building without X11 (for test purposes) @@ -32,40 +32,34 @@ typedef struct { unsigned short red, green, blue; } XColor; -typedef struct stub_widget *Widget; - #endif -enum { COLOUR_PRIMARY, COLOUR_DARK, COLOUR_LIGHT, COLOUR_MAX }; - /* - * Helpers for drawing window icons in various sizes. The tileXX functions - * draw one (out of 9) tiles at a particular size using a particular colour - * set. Call for each tile position to draw a complete icon. + * Size of generated EWMH icon data (nelements argument to XChangeProperty). */ -enum { ICON_16x16, ICON_24x24, ICON_32x32, ICON_48x48, ICON_MAX }; #define EWMH_ICON_NELEM (2+16*16 + 2+24*24 + 2+32*32 + 2+48*48) -void ewmh_tile16(unsigned long *icon, const XColor *c, int tile_x, int tile_y); -void ewmh_tile24(unsigned long *icon, const XColor *c, int tile_x, int tile_y); -void ewmh_tile32(unsigned long *icon, const XColor *c, int tile_x, int tile_y); -void ewmh_tile48(unsigned long *icon, const XColor *c, int tile_x, int tile_y); - /* - * Allocate storage for the EWMH _NET_WM_ICON array. The sizes array is - * populated with pointers to the beginning of each icon's pixel data. For - * example, sizes[ICON_24x24] points to the first pixel of the 24x24 image. + * Generate EWMH icon data based on a sequence of tile colours. Internally, + * this calls icon_tile16 and friends to draw each of the icon patterns. + * + * The sequence specifies the colour of all 9 icon tiles, beginning from the + * top left in row-major order. Each value specifies three offsets into + * the provided colour map, encoded in the same manner as icon_tile16 et al. * - * The returned value can then be passed to XChangeProperty to set the icon, - * (use EWMH_ICON_NELEM for the number of elements) and must be freed by the - * caller. + * Returns a newly-allocated buffer which is suitable for use directly with + * XChangeProperty, and should be freed by the caller. + * + * If allocation fails, a null pointer is returned. */ -void *ewmh_icon_alloc(unsigned long **sizes); +void *ewmh_icon_generate(const unsigned long *seq, const XColor *map); +#if !X_DISPLAY_MISSING /* * Check if the root window indicates support for EWMH icons. Returns 1 if * supported, or 0 otherwise. */ int ewmh_probe_wm_icon(Widget shell); +#endif #endif