From 11bef0795a450865b589c1c906bf97141436d314 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Mon, 16 Sep 2013 12:06:10 +0200 Subject: [PATCH] client.content: Use correct client size (FS#1150) The size saved in c->geometry also includes the titlebars. Thus, for getting the window content, we have to subtract this from the size. Before this, the call to xcb_image_get() was failing with a BadMatch error, because we were asking for an area that is outside of the actual client's window's geometry. Signed-off-by: Uli Schlachter --- objects/client.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/objects/client.c b/objects/client.c index b858622c..126cc544 100644 --- a/objects/client.c +++ b/objects/client.c @@ -1789,11 +1789,16 @@ LUA_OBJECT_EXPORT_PROPERTY(client, client_t, maximized_vertical, lua_pushboolean static int luaA_client_get_content(lua_State *L, client_t *c) { - xcb_image_t *ximage = xcb_image_get(globalconf.connection, + xcb_image_t *ximage; + int width = c->geometry.width; + int height = c->geometry.height; + + width -= c->titlebar[CLIENT_TITLEBAR_LEFT].size + c->titlebar[CLIENT_TITLEBAR_RIGHT].size; + height -= c->titlebar[CLIENT_TITLEBAR_TOP].size + c->titlebar[CLIENT_TITLEBAR_BOTTOM].size; + ximage = xcb_image_get(globalconf.connection, c->window, 0, 0, - c->geometry.width, - c->geometry.height, + width, height, ~0, XCB_IMAGE_FORMAT_Z_PIXMAP); cairo_surface_t *surface = NULL;