client: emit ewmh geometry requests as signals

This commit is contained in:
BuildTools 2017-02-25 22:47:15 -08:00 committed by Daniel Hahler
parent 9bc46e4648
commit 37d2654d5d
2 changed files with 45 additions and 3 deletions

32
event.c
View File

@ -341,6 +341,8 @@ event_handle_configurerequest(xcb_configure_request_event_t *ev)
uint16_t deco_bottom = bw + tb_bottom;
int16_t diff_w = 0, diff_h = 0, diff_border = 0;
lua_State *L = globalconf_get_lua_State();
if(ev->value_mask & XCB_CONFIG_WINDOW_X)
{
int16_t diff = 0;
@ -373,8 +375,6 @@ event_handle_configurerequest(xcb_configure_request_event_t *ev)
}
if(ev->value_mask & XCB_CONFIG_WINDOW_BORDER_WIDTH)
{
lua_State *L = globalconf_get_lua_State();
diff_border = ev->border_width - bw;
diff_h += diff_border;
diff_w += diff_border;
@ -396,7 +396,33 @@ event_handle_configurerequest(xcb_configure_request_event_t *ev)
}
c->got_configure_request = true;
client_resize(c, geometry, false);
/* Request the changes to be applied */
luaA_object_push(L, c);
lua_pushstring(L, "ewmh"); /* context */
lua_newtable(L); /* props */
/* area, it needs to be directly in the `hints` table to comply with
the "protocol"
*/
lua_pushstring(L, "x");
lua_pushinteger(L, geometry.x);
lua_rawset(L, -3);
lua_pushstring(L, "y");
lua_pushinteger(L, geometry.y);
lua_rawset(L, -3);
lua_pushstring(L, "width");
lua_pushinteger(L, geometry.width);
lua_rawset(L, -3);
lua_pushstring(L, "height");
lua_pushinteger(L, geometry.height);
lua_rawset(L, -3);
luaA_object_emit_signal(L, -3, "request::geometry", 2);
lua_pop(L, 1);
}
else if (xembed_getbywin(&globalconf.embedded, ev->window))
{

View File

@ -364,11 +364,27 @@ function ewmh.merge_maximization(c, context, hints)
end
end
--- Allow the client to move itself.
--
-- This is the default geometry request handler when the context is `ewmh`.
--
-- @signalhandler awful.ewmh.client_geometry_requests
-- @tparam client c The client
-- @tparam string context The context
-- @tparam[opt={}] table hints The hints to pass to the handler
function ewmh.client_geometry_requests(c, context, hints)
if context == "ewmh" and hints then
c:geometry(hints)
end
end
client.connect_signal("request::activate", ewmh.activate)
client.connect_signal("request::tag", ewmh.tag)
client.connect_signal("request::urgent", ewmh.urgent)
client.connect_signal("request::geometry", ewmh.geometry)
client.connect_signal("request::geometry", ewmh.merge_maximization)
client.connect_signal("request::geometry", ewmh.client_geometry_requests)
client.connect_signal("property::border_width", repair_geometry)
client.connect_signal("property::screen", repair_geometry)
screen.connect_signal("property::workarea", function(s)