client: merge icon_path and netwm icon
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
2fad185fcf
commit
856192fa99
29
client.c
29
client.c
|
@ -24,6 +24,7 @@
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
#include <xcb/xcb_atom.h>
|
#include <xcb/xcb_atom.h>
|
||||||
|
|
||||||
|
#include "image.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
@ -389,6 +390,7 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen,
|
||||||
{
|
{
|
||||||
xcb_get_property_cookie_t ewmh_icon_cookie;
|
xcb_get_property_cookie_t ewmh_icon_cookie;
|
||||||
client_t *c;
|
client_t *c;
|
||||||
|
draw_image_t *icon;
|
||||||
const uint32_t select_input_val[] =
|
const uint32_t select_input_val[] =
|
||||||
{
|
{
|
||||||
XCB_EVENT_MASK_STRUCTURE_NOTIFY
|
XCB_EVENT_MASK_STRUCTURE_NOTIFY
|
||||||
|
@ -419,7 +421,11 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen,
|
||||||
c->geometry.width = c->f_geometry.width = c->m_geometry.width = wgeom->width;
|
c->geometry.width = c->f_geometry.width = c->m_geometry.width = wgeom->width;
|
||||||
c->geometry.height = c->f_geometry.height = c->m_geometry.height = wgeom->height;
|
c->geometry.height = c->f_geometry.height = c->m_geometry.height = wgeom->height;
|
||||||
client_setborder(c, wgeom->border_width);
|
client_setborder(c, wgeom->border_width);
|
||||||
c->icon = ewmh_window_icon_get_reply(ewmh_icon_cookie);
|
if((icon = ewmh_window_icon_get_reply(ewmh_icon_cookie)))
|
||||||
|
{
|
||||||
|
c->icon = image_new(icon);
|
||||||
|
image_ref(&c->icon);
|
||||||
|
}
|
||||||
|
|
||||||
/* we honor size hints by default */
|
/* we honor size hints by default */
|
||||||
c->honorsizehints = true;
|
c->honorsizehints = true;
|
||||||
|
@ -1017,7 +1023,7 @@ luaA_client_visible_get(lua_State *L)
|
||||||
for(c = globalconf.clients; c; c = c->next)
|
for(c = globalconf.clients; c; c = c->next)
|
||||||
if(client_isvisible(c, screen))
|
if(client_isvisible(c, screen))
|
||||||
{
|
{
|
||||||
luaA_client_userdata_new(globalconf.L, c);
|
luaA_client_userdata_new(L, c);
|
||||||
lua_rawseti(L, -2, i++);
|
lua_rawseti(L, -2, i++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1274,6 +1280,7 @@ luaA_client_newindex(lua_State *L)
|
||||||
double d;
|
double d;
|
||||||
int i;
|
int i;
|
||||||
titlebar_t **t = NULL;
|
titlebar_t **t = NULL;
|
||||||
|
image_t **image;
|
||||||
|
|
||||||
if((*c)->invalid)
|
if((*c)->invalid)
|
||||||
luaL_error(L, "client is invalid\n");
|
luaL_error(L, "client is invalid\n");
|
||||||
|
@ -1316,10 +1323,11 @@ luaA_client_newindex(lua_State *L)
|
||||||
case A_TK_FULLSCREEN:
|
case A_TK_FULLSCREEN:
|
||||||
client_setfullscreen(*c, luaA_checkboolean(L, 3));
|
client_setfullscreen(*c, luaA_checkboolean(L, 3));
|
||||||
break;
|
break;
|
||||||
case A_TK_ICON_PATH:
|
case A_TK_ICON:
|
||||||
buf = luaL_checkstring(L, 3);
|
image = luaA_checkudata(L, 3, "image");
|
||||||
p_delete(&(*c)->icon_path);
|
image_unref(&(*c)->icon);
|
||||||
(*c)->icon_path = a_strdup(buf);
|
image_ref(image);
|
||||||
|
(*c)->icon = *image;
|
||||||
widget_invalidate_cache((*c)->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache((*c)->screen, WIDGET_CACHE_CLIENTS);
|
||||||
break;
|
break;
|
||||||
case A_TK_OPACITY:
|
case A_TK_OPACITY:
|
||||||
|
@ -1525,8 +1533,11 @@ luaA_client_index(lua_State *L)
|
||||||
case A_TK_FULLSCREEN:
|
case A_TK_FULLSCREEN:
|
||||||
lua_pushboolean(L, (*c)->isfullscreen);
|
lua_pushboolean(L, (*c)->isfullscreen);
|
||||||
break;
|
break;
|
||||||
case A_TK_ICON_PATH:
|
case A_TK_ICON:
|
||||||
lua_pushstring(L, (*c)->icon_path);
|
if((*c)->icon)
|
||||||
|
luaA_image_userdata_new(L, (*c)->icon);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
break;
|
break;
|
||||||
case A_TK_OPACITY:
|
case A_TK_OPACITY:
|
||||||
if((d = window_opacity_get((*c)->win)) >= 0)
|
if((d = window_opacity_get((*c)->win)) >= 0)
|
||||||
|
@ -1554,7 +1565,7 @@ luaA_client_index(lua_State *L)
|
||||||
break;
|
break;
|
||||||
case A_TK_TITLEBAR:
|
case A_TK_TITLEBAR:
|
||||||
if((*c)->titlebar)
|
if((*c)->titlebar)
|
||||||
return luaA_titlebar_userdata_new(globalconf.L, (*c)->titlebar);
|
return luaA_titlebar_userdata_new(L, (*c)->titlebar);
|
||||||
return 0;
|
return 0;
|
||||||
case A_TK_URGENT:
|
case A_TK_URGENT:
|
||||||
lua_pushboolean(L, (*c)->isurgent);
|
lua_pushboolean(L, (*c)->isurgent);
|
||||||
|
|
|
@ -24,8 +24,8 @@ grow
|
||||||
height
|
height
|
||||||
hide
|
hide
|
||||||
honorsizehints
|
honorsizehints
|
||||||
|
icon
|
||||||
icon_name
|
icon_name
|
||||||
icon_path
|
|
||||||
image
|
image
|
||||||
instance
|
instance
|
||||||
invert
|
invert
|
||||||
|
|
11
event.c
11
event.c
|
@ -668,9 +668,16 @@ event_handle_propertynotify(void *data __attribute__ ((unused)),
|
||||||
else if(ev->atom == _NET_WM_ICON)
|
else if(ev->atom == _NET_WM_ICON)
|
||||||
{
|
{
|
||||||
xcb_get_property_cookie_t icon_q = ewmh_window_icon_get_unchecked(c->win);
|
xcb_get_property_cookie_t icon_q = ewmh_window_icon_get_unchecked(c->win);
|
||||||
draw_image_delete(&c->icon);
|
draw_image_t *icon;
|
||||||
|
image_unref(&c->icon);
|
||||||
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS);
|
||||||
c->icon = ewmh_window_icon_get_reply(icon_q);
|
if((icon = ewmh_window_icon_get_reply(icon_q)))
|
||||||
|
{
|
||||||
|
c->icon = image_new(icon);
|
||||||
|
image_ref(&c->icon);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
c->icon = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
image.c
2
image.c
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
extern awesome_t globalconf;
|
extern awesome_t globalconf;
|
||||||
|
|
||||||
DO_LUA_NEW(static, image_t, image, "image", image_ref)
|
DO_LUA_NEW(extern, image_t, image, "image", image_ref)
|
||||||
DO_LUA_GC(image_t, image, "image", image_unref)
|
DO_LUA_GC(image_t, image, "image", image_unref)
|
||||||
DO_LUA_EQ(image_t, image, "image")
|
DO_LUA_EQ(image_t, image, "image")
|
||||||
|
|
||||||
|
|
17
image.h
17
image.h
|
@ -22,7 +22,10 @@
|
||||||
#ifndef AWESOME_IMAGE_H
|
#ifndef AWESOME_IMAGE_H
|
||||||
#define AWESOME_IMAGE_H
|
#define AWESOME_IMAGE_H
|
||||||
|
|
||||||
|
#include <lua.h>
|
||||||
|
|
||||||
#include "draw.h"
|
#include "draw.h"
|
||||||
|
#include "common/refcount.h"
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -43,5 +46,19 @@ image_delete(image_t **i)
|
||||||
|
|
||||||
DO_RCNT(image_t, image, image_delete)
|
DO_RCNT(image_t, image, image_delete)
|
||||||
|
|
||||||
|
int luaA_image_userdata_new(lua_State *, image_t *);
|
||||||
|
|
||||||
|
/** Create a new image from a draw_image_t object.
|
||||||
|
* \param i The image data.
|
||||||
|
* \return A image_t object.
|
||||||
|
*/
|
||||||
|
static inline image_t *
|
||||||
|
image_new(draw_image_t *i)
|
||||||
|
{
|
||||||
|
image_t *image = p_new(image_t, 1);
|
||||||
|
image->image = i;
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
|
@ -30,10 +30,10 @@
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
#include "swindow.h"
|
#include "swindow.h"
|
||||||
#include "xscreen.h"
|
#include "xscreen.h"
|
||||||
|
#include "image.h"
|
||||||
#include "common/xutil.h"
|
#include "common/xutil.h"
|
||||||
#include "common/xembed.h"
|
#include "common/xembed.h"
|
||||||
#include "common/refcount.h"
|
#include "common/refcount.h"
|
||||||
#include "draw.h"
|
|
||||||
|
|
||||||
/** Stacking layout layers */
|
/** Stacking layout layers */
|
||||||
typedef enum
|
typedef enum
|
||||||
|
@ -329,7 +329,7 @@ struct client_t
|
||||||
/** Button bindings */
|
/** Button bindings */
|
||||||
button_array_t buttons;
|
button_array_t buttons;
|
||||||
/** Icon */
|
/** Icon */
|
||||||
draw_image_t *icon;
|
image_t *icon;
|
||||||
/** Size hints */
|
/** Size hints */
|
||||||
xcb_size_hints_t size_hints;
|
xcb_size_hints_t size_hints;
|
||||||
/** Next and previous clients */
|
/** Next and previous clients */
|
||||||
|
|
|
@ -56,11 +56,9 @@ appicon_draw(draw_context_t *ctx, int screen __attribute__ ((unused)),
|
||||||
|
|
||||||
if(c)
|
if(c)
|
||||||
{
|
{
|
||||||
if(!(image = draw_image_new(c->icon_path)))
|
if(c->icon)
|
||||||
image = c->icon;
|
|
||||||
|
|
||||||
if(image)
|
|
||||||
{
|
{
|
||||||
|
image = c->icon->image;
|
||||||
w->area.width = ((double) ctx->height / (double) image->height) * image->width;
|
w->area.width = ((double) ctx->height / (double) image->height) * image->width;
|
||||||
w->area.x = widget_calculate_offset(ctx->width,
|
w->area.x = widget_calculate_offset(ctx->width,
|
||||||
w->area.width,
|
w->area.width,
|
||||||
|
@ -68,8 +66,6 @@ appicon_draw(draw_context_t *ctx, int screen __attribute__ ((unused)),
|
||||||
w->widget->align);
|
w->widget->align);
|
||||||
draw_image(ctx, w->area.x,
|
draw_image(ctx, w->area.x,
|
||||||
w->area.y, ctx->height, image);
|
w->area.y, ctx->height, image);
|
||||||
if(image != c->icon)
|
|
||||||
draw_image_delete(&image);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -142,20 +142,12 @@ tasklist_draw_item(draw_context_t *ctx,
|
||||||
else
|
else
|
||||||
parser_data = NULL;
|
parser_data = NULL;
|
||||||
|
|
||||||
/* use image from icon_path, otherwise netwm icon */
|
if(odata->client_labels.tab[i].client->icon)
|
||||||
if(!(image = draw_image_new(odata->client_labels.tab[i].client->icon_path)))
|
|
||||||
image = odata->client_labels.tab[i].client->icon;
|
|
||||||
|
|
||||||
if(image)
|
|
||||||
{
|
{
|
||||||
|
image = odata->client_labels.tab[i].client->icon->image;
|
||||||
icon_width = ((double) ctx->height / (double) image->height) * image->width;
|
icon_width = ((double) ctx->height / (double) image->height) * image->width;
|
||||||
draw_image(ctx, w->area.x + odata->box_width * i,
|
draw_image(ctx, w->area.x + odata->box_width * i,
|
||||||
w->area.y, ctx->height, image);
|
w->area.y, ctx->height, image);
|
||||||
|
|
||||||
/* a bit hackish */
|
|
||||||
if(image != odata->client_labels.tab[i].client->icon)
|
|
||||||
draw_image_delete(&image);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue