From: Dana Jansens Date: Thu, 21 Jun 2007 16:20:43 +0000 (+0000) Subject: look, thumbnails in alt-tab. its such crap though. oh well, just for fun. X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=19ecd4d6d403e71abecb0e77f7ff0f4efa400be3;p=chaz%2Fopenbox look, thumbnails in alt-tab. its such crap though. oh well, just for fun. --- diff --git a/openbox/client.c b/openbox/client.c index cf6965ae..771294a4 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -4083,3 +4083,30 @@ gboolean client_has_group_siblings(ObClient *self) { return self->group && self->group->members->next; } + +ObClientIcon *client_thumbnail(ObClient *self, gint wantw, gint wanth) +{ + ObClientIcon *ret; + RrPixel32 *data; + gint w, h; + + if (!self->frame->pixmap) return NULL; + if (!RrPixmapToRGBA(ob_rr_inst, self->frame->pixmap, None, &w, &h, &data)) + return NULL; + + /* resize the thumbnail (within aspect ratio) to the given sizes */ + + ret = g_new(ObClientIcon, 1); + ret->data = data; + ret->width = w; + ret->height = h; + return ret; +} + +void clienticon_free(ObClientIcon *ci) +{ + if (ci) { + g_free(ci->data); + g_free(ci); + } +} diff --git a/openbox/client.h b/openbox/client.h index ed677926..b30db198 100644 --- a/openbox/client.h +++ b/openbox/client.h @@ -611,6 +611,8 @@ void client_get_type_and_transientness(ObClient *self); const ObClientIcon *client_icon(ObClient *self, gint w, gint h); +ObClientIcon *client_thumbnail(ObClient *self, gint w, gint h); + /*! Return TRUE if the client is transient for some other window. Return FALSE if it's not transient or there is no window for it to be transient for */ @@ -695,4 +697,6 @@ ObClient* client_under_pointer(); gboolean client_has_group_siblings(ObClient *self); +void clienticon_free(ObClientIcon *ci); + #endif diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index 477619f5..595fb9df 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -397,6 +397,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) they can pick up the hilite changes in the backgroud */ if (!p->mapped || newtarget == target || p->last_target == target) { const ObClientIcon *icon; + ObClientIcon *thumb; const gint row = i / icons_per_row; /* starting from 0 */ const gint col = i % icons_per_row; /* starting from 0 */ gint innerx, innery; @@ -412,17 +413,27 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) innerx, innery, innerw, innerh); /* get the icon from the client */ - icon = client_icon(target->client, innerw, innerh); - p->a_icon->texture[0].data.rgba.width = icon->width; - p->a_icon->texture[0].data.rgba.height = icon->height; - p->a_icon->texture[0].data.rgba.alpha = - target->client->iconic ? OB_ICONIC_ALPHA : 0xff; - p->a_icon->texture[0].data.rgba.data = icon->data; + if ((thumb = client_thumbnail(target->client))) { + p->a_icon->texture[0].data.rgba.width = thumb->width; + p->a_icon->texture[0].data.rgba.height = thumb->height; + p->a_icon->texture[0].data.rgba.alpha = + target->client->iconic ? OB_ICONIC_ALPHA : 0xff; + p->a_icon->texture[0].data.rgba.data = thumb->data; + } else { + icon = client_icon(target->client, innerw, innerh); + p->a_icon->texture[0].data.rgba.width = icon->width; + p->a_icon->texture[0].data.rgba.height = icon->height; + p->a_icon->texture[0].data.rgba.alpha = + target->client->iconic ? OB_ICONIC_ALPHA : 0xff; + p->a_icon->texture[0].data.rgba.data = icon->data; + } /* draw the icon */ p->a_icon->surface.parentx = innerx; p->a_icon->surface.parenty = innery; RrPaint(p->a_icon, target->win, innerw, innerh); + + clienticon_free(thumb); } }