client: add content property
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
48d4c41ed9
commit
bdbcd9352d
|
@ -142,6 +142,7 @@ pkg_check_modules(AWESOME_REQUIRED REQUIRED
|
||||||
xcb-atom>=0.3.0
|
xcb-atom>=0.3.0
|
||||||
xcb-keysyms>=0.3.0
|
xcb-keysyms>=0.3.0
|
||||||
xcb-icccm>=0.3.0
|
xcb-icccm>=0.3.0
|
||||||
|
xcb-image>=0.3.0
|
||||||
cairo-xcb
|
cairo-xcb
|
||||||
xproto>=7.0.11
|
xproto>=7.0.11
|
||||||
imlib2)
|
imlib2)
|
||||||
|
|
41
client.c
41
client.c
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xcb/xcb_atom.h>
|
#include <xcb/xcb_atom.h>
|
||||||
|
#include <xcb/xcb_image.h>
|
||||||
|
|
||||||
#include "cnode.h"
|
#include "cnode.h"
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
|
@ -129,6 +130,40 @@ client_maybevisible(client_t *c, int screen)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Return the content of a client as an image.
|
||||||
|
* That's just take a screenshot.
|
||||||
|
* \param c The client.
|
||||||
|
* \return An image.
|
||||||
|
*/
|
||||||
|
static image_t *
|
||||||
|
client_getcontent(client_t *c)
|
||||||
|
{
|
||||||
|
xcb_image_t *ximage = xcb_image_get(globalconf.connection,
|
||||||
|
c->win,
|
||||||
|
0, 0,
|
||||||
|
c->geometries.internal.width,
|
||||||
|
c->geometries.internal.height,
|
||||||
|
~0, XCB_IMAGE_FORMAT_Z_PIXMAP);
|
||||||
|
|
||||||
|
if(!ximage || ximage->bpp < 24)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
uint32_t *data = p_alloca(uint32_t, ximage->width * ximage->height);
|
||||||
|
|
||||||
|
for(int y = 0; y < ximage->height; y++)
|
||||||
|
for(int x = 0; x < ximage->width; x++)
|
||||||
|
{
|
||||||
|
data[y * ximage->width + x] = xcb_image_get_pixel(ximage, x, y);
|
||||||
|
data[y * ximage->width + x] |= 0xff000000; /* set alpha to 0xff */
|
||||||
|
}
|
||||||
|
|
||||||
|
image_t *image = image_new_from_argb32(ximage->width, ximage->height, data);
|
||||||
|
|
||||||
|
xcb_image_destroy(ximage);
|
||||||
|
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
/** Get a client by its window.
|
/** Get a client by its window.
|
||||||
* \param w The client window to find.
|
* \param w The client window to find.
|
||||||
* \return A client pointer if found, NULL otherwise.
|
* \return A client pointer if found, NULL otherwise.
|
||||||
|
@ -1556,6 +1591,8 @@ luaA_client_index(lua_State *L)
|
||||||
|
|
||||||
switch(a_tokenize(buf, len))
|
switch(a_tokenize(buf, len))
|
||||||
{
|
{
|
||||||
|
image_t *image;
|
||||||
|
|
||||||
case A_TK_NAME:
|
case A_TK_NAME:
|
||||||
lua_pushstring(L, (*c)->name);
|
lua_pushstring(L, (*c)->name);
|
||||||
break;
|
break;
|
||||||
|
@ -1566,6 +1603,10 @@ luaA_client_index(lua_State *L)
|
||||||
case A_TK_SKIP_TASKBAR:
|
case A_TK_SKIP_TASKBAR:
|
||||||
lua_pushboolean(L, (*c)->skiptb);
|
lua_pushboolean(L, (*c)->skiptb);
|
||||||
break;
|
break;
|
||||||
|
case A_TK_CONTENT:
|
||||||
|
if((image = client_getcontent(*c)))
|
||||||
|
return luaA_image_userdata_new(L, image);
|
||||||
|
return 0;
|
||||||
case A_TK_TYPE:
|
case A_TK_TYPE:
|
||||||
switch((*c)->type)
|
switch((*c)->type)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,6 +18,7 @@ client
|
||||||
color
|
color
|
||||||
Control
|
Control
|
||||||
conffile
|
conffile
|
||||||
|
content
|
||||||
Ctrl
|
Ctrl
|
||||||
cursor
|
cursor
|
||||||
east
|
east
|
||||||
|
|
Loading…
Reference in New Issue