+
+ ++j;
+ }
+
+ g_free(data);
+ } else {
+ XWMHints *hints;
+
+ if ((hints = XGetWMHints(obt_display, self->window))) {
+ if (hints->flags & IconPixmapHint) {
+ self->nicons = 1;
+ self->icons = g_new(ObClientIcon, self->nicons);
+ obt_display_ignore_errors(TRUE);
+ if (!RrPixmapToRGBA(ob_rr_inst,
+ hints->icon_pixmap,
+ (hints->flags & IconMaskHint ?
+ hints->icon_mask : None),
+ &self->icons[0].width,
+ &self->icons[0].height,
+ &self->icons[0].data))
+ {
+ g_free(self->icons);
+ self->nicons = 0;
+ }
+ obt_display_ignore_errors(FALSE);
+ }
+ XFree(hints);
+ }
+ }
+
+ /* set the default icon onto the window
+ in theory, this could be a race, but if a window doesn't set an icon
+ or removes it entirely, it's not very likely it is going to set one
+ right away afterwards
+
+ if it has parents, then one of them will have an icon already
+ */
+ if (self->nicons == 0 && !self->parents) {
+ RrPixel32 *icon = ob_rr_theme->def_win_icon;
+ gulong *data;
+
+ data = g_new(gulong, 48*48+2);
+ data[0] = data[1] = 48;
+ for (i = 0; i < 48*48; ++i)
+ data[i+2] = (((icon[i] >> RrDefaultAlphaOffset) & 0xff) << 24) +
+ (((icon[i] >> RrDefaultRedOffset) & 0xff) << 16) +
+ (((icon[i] >> RrDefaultGreenOffset) & 0xff) << 8) +
+ (((icon[i] >> RrDefaultBlueOffset) & 0xff) << 0);
+ OBT_PROP_SETA32(self->window, NET_WM_ICON, CARDINAL, data, 48*48+2);
+ g_free(data);
+ } else if (self->frame)
+ /* don't draw the icon empty if we're just setting one now anyways,
+ we'll get the property change any second */
+ frame_adjust_icon(self->frame);
+}
+
+void client_update_icon_geometry(ObClient *self)
+{
+ guint num;
+ guint32 *data;
+
+ RECT_SET(self->icon_geometry, 0, 0, 0, 0);
+
+ if (OBT_PROP_GETA32(self->window, NET_WM_ICON_GEOMETRY, CARDINAL,
+ &data, &num))
+ {
+ if (num == 4)
+ /* don't let them set it with an area < 0 */
+ RECT_SET(self->icon_geometry, data[0], data[1],
+ MAX(data[2],0), MAX(data[3],0));
+ g_free(data);
+ }
+}
+
+static void client_get_session_ids(ObClient *self)
+{
+ guint32 leader;
+ gboolean got;
+ gchar *s;
+ gchar **ss;
+
+ if (!OBT_PROP_GET32(self->window, WM_CLIENT_LEADER, WINDOW, &leader))
+ leader = None;
+
+ /* get the SM_CLIENT_ID */
+ got = FALSE;
+ if (leader)
+ got = OBT_PROP_GETS(leader, SM_CLIENT_ID, locale, &self->sm_client_id);
+ if (!got)
+ OBT_PROP_GETS(self->window, SM_CLIENT_ID, locale, &self->sm_client_id);
+
+ /* get the WM_CLASS (name and class). make them "" if they are not
+ provided */
+ got = FALSE;
+ if (leader)
+ got = OBT_PROP_GETSS(leader, WM_CLASS, locale, &ss);
+ if (!got)
+ got = OBT_PROP_GETSS(self->window, WM_CLASS, locale, &ss);
+
+ if (got) {
+ if (ss[0]) {
+ self->name = g_strdup(ss[0]);
+ if (ss[1])
+ self->class = g_strdup(ss[1]);