diff options
| author | Dana Jansens <danakj@orodu.net> | 2003-05-18 23:06:11 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2003-05-18 23:06:11 +0000 |
| commit | a18c1697b1176c26e74267f2ac7a153a2cf2c442 (patch) | |
| tree | 04d62a0bd4d4f15fe2bbf05e8809755c552753ac /openbox | |
| parent | f41d06f583b0461446aeac93551a2e0931d50ac0 (diff) | |
make icons use pixel32 data, and image_draw takes pixel32 data.
client.c gets pixmap icons as a backup to netwm ones, and they are converted into pixel32 data.
Diffstat (limited to 'openbox')
| -rw-r--r-- | openbox/client.c | 52 | ||||
| -rw-r--r-- | openbox/client.h | 4 |
2 files changed, 47 insertions, 9 deletions
diff --git a/openbox/client.c b/openbox/client.c index 0e5a59f0..8efed96a 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -1142,6 +1142,9 @@ void client_update_wmhints(Client *self) it->data); } + /* the WM_HINTS can contain an icon */ + client_update_icons(self); + /* because the self->transient flag wont change from this call, we don't need to update the window's type and such, only its transient_for, and the transients lists of other windows in @@ -1317,11 +1320,23 @@ void client_update_icons(Client *self) /* store the icons */ i = 0; for (j = 0; j < self->nicons; ++j) { + guint x, y, t; + w = self->icons[j].width = data[i++]; h = self->icons[j].height = data[i++]; - self->icons[j].data = - g_memdup(&data[i], w * h * sizeof(gulong)); - i += w * h; + + self->icons[j].data = g_new(pixel32, w * h); + for (x = 0, y = 0, t = 0; t < w * h; ++t, ++x, ++i) { + if (x >= w) { + x = 0; + ++y; + } + self->icons[j].data[t] = + (((data[i] >> 24) & 0xff) << default_alpha_offset) + + (((data[i] >> 16) & 0xff) << default_red_offset) + + (((data[i] >> 8) & 0xff) << default_green_offset) + + (((data[i] >> 0) & 0xff) << default_blue_offset); + } g_assert(i <= num); } @@ -1331,13 +1346,34 @@ void client_update_icons(Client *self) if (num == 2) { self->nicons++; self->icons = g_new(Icon, self->nicons); - /* XXX WHAT IF THIS FAILS YOU TWIT!@!*()@ */ - render_pixmap_to_rgba(data[0], data[1], - &self->icons[self->nicons-1].width, - &self->icons[self->nicons-1].height, - &self->icons[self->nicons-1].data); + if (!render_pixmap_to_rgba(data[0], data[1], + &self->icons[self->nicons-1].width, + &self->icons[self->nicons-1].height, + &self->icons[self->nicons-1].data)) { + g_free(&self->icons[self->nicons-1]); + self->nicons--; + } } g_free(data); + } else { + XWMHints *hints; + + if ((hints = XGetWMHints(ob_display, self->window))) { + if (hints->flags & IconPixmapHint) { + self->nicons++; + self->icons = g_new(Icon, self->nicons); + if (!render_pixmap_to_rgba(hints->icon_pixmap, + (hints->flags & IconMaskHint ? + hints->icon_mask : None), + &self->icons[self->nicons-1].width, + &self->icons[self->nicons-1].height, + &self->icons[self->nicons-1].data)){ + g_free(&self->icons[self->nicons-1]); + self->nicons--; + } + } + XFree(hints); + } } if (self->frame) diff --git a/openbox/client.h b/openbox/client.h index 7545b860..b4e0494d 100644 --- a/openbox/client.h +++ b/openbox/client.h @@ -3,6 +3,8 @@ #include "geom.h" #include "stacking.h" +#include "render/color.h" + #include <glib.h> #include <X11/Xlib.h> @@ -16,7 +18,7 @@ struct Group; /*! Holds an icon in ARGB format */ typedef struct Icon { int width, height; - gulong *data; + pixel32 *data; } Icon; /*! The MWM Hints as retrieved from the window property |
