From c18f5f22f955252e35a56e7805c7d1432e707623 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Tue, 6 Nov 2012 20:51:54 +0100 Subject: [PATCH] client: Re-add shape support Same reasoning as for the recent commit which adds these to drawins. Signed-off-by: Uli Schlachter --- luadoc/client.lua | 2 ++ objects/client.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/luadoc/client.lua b/luadoc/client.lua index 2df330273..02a342d49 100644 --- a/luadoc/client.lua +++ b/luadoc/client.lua @@ -41,6 +41,8 @@ module("client") -- @field sticky Set the client sticky, i.e. available on all tags. -- @field modal Indicate if the client is modal. -- @field focusable True if the client can receive the input focus. +-- @field shape_bounding The client's bounding shape as a (native) cairo surface. +-- @field shape_clip The client's clip shape as a (native) cairo surface. -- @class table -- @name client diff --git a/objects/client.c b/objects/client.c index 9b10aab42..20b614d1c 100644 --- a/objects/client.c +++ b/objects/client.c @@ -21,6 +21,7 @@ #include #include +#include #include #include "objects/tag.h" @@ -1843,6 +1844,38 @@ luaA_client_get_size_hints(lua_State *L, client_t *c) return 1; } +/** Set the client's bounding shape. + * \param L The Lua VM state. + * \param client The client object. + * \return The number of elements pushed on stack. + */ +static int +luaA_client_set_shape_bounding(lua_State *L, client_t *c) +{ + cairo_surface_t *surf = NULL; + if(!lua_isnil(L, -1)) + surf = (cairo_surface_t *)lua_touserdata(L, -1); + xwindow_set_shape(c->frame_window, c->geometry.width, c->geometry.height, + XCB_SHAPE_SK_BOUNDING, surf, -c->border_width); + return 0; +} + +/** Set the client's clip shape. + * \param L The Lua VM state. + * \param client The client object. + * \return The number of elements pushed on stack. + */ +static int +luaA_client_set_shape_clip(lua_State *L, client_t *c) +{ + cairo_surface_t *surf = NULL; + if(!lua_isnil(L, -1)) + surf = (cairo_surface_t *)lua_touserdata(L, -1); + xwindow_set_shape(c->frame_window, c->geometry.width, c->geometry.height, + XCB_SHAPE_SK_CLIP, surf, 0); + return 0; +} + /** Get or set keys bindings for a client. * \param L The Lua VM state. * \return The number of element pushed on stack. @@ -2061,6 +2094,14 @@ client_class_setup(lua_State *L) NULL, (lua_class_propfunc_t) luaA_client_get_focusable, NULL); + luaA_class_add_property(&client_class, "shape_bounding", + (lua_class_propfunc_t) luaA_client_set_shape_bounding, + NULL, + (lua_class_propfunc_t) luaA_client_set_shape_bounding); + luaA_class_add_property(&client_class, "shape_clip", + (lua_class_propfunc_t) luaA_client_set_shape_clip, + NULL, + (lua_class_propfunc_t) luaA_client_set_shape_clip); signal_add(&client_class.signals, "focus"); signal_add(&client_class.signals, "list");