From b570e6d34783acf5a9408d73fcc67cfffce4491a Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 23 Apr 2017 04:49:15 -0400 Subject: [PATCH] client: Add request::geometry for client maximization This way the correct logic can be implented in Lua --- ewmh.c | 34 ++++++++++++++++++++++++++++------ lib/awful/ewmh.lua | 4 ++++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/ewmh.c b/ewmh.c index 5bec656ec..af7a23a48 100644 --- a/ewmh.c +++ b/ewmh.c @@ -207,6 +207,28 @@ ewmh_init(void) father, _NET_WM_PID, XCB_ATOM_CARDINAL, 32, 1, &i); } +static void +ewmh_update_maximize(bool h, bool status, bool toggle) +{ + lua_State *L = globalconf_get_lua_State(); + + if (h) + lua_pushstring(L, "client_maximize_horizontal"); + else + lua_pushstring(L, "client_maximize_vertical"); + + /* Create table argument with raise=true. */ + lua_newtable(L); + lua_pushstring(L, "toggle"); + lua_pushboolean(L, toggle); + lua_settable(L, -3); + lua_pushstring(L, "status"); + lua_pushboolean(L, status); + lua_settable(L, -3); + + luaA_object_emit_signal(L, -3, "request::geometry", 2); +} + void ewmh_init_lua(void) { @@ -333,20 +355,20 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set) else if(state == _NET_WM_STATE_MAXIMIZED_HORZ) { if(set == _NET_WM_STATE_REMOVE) - client_set_maximized_horizontal(L, -1, false); + ewmh_update_maximize(true, false, false); else if(set == _NET_WM_STATE_ADD) - client_set_maximized_horizontal(L, -1, true); + ewmh_update_maximize(true, true, false); else if(set == _NET_WM_STATE_TOGGLE) - client_set_maximized_horizontal(L, -1, !c->maximized_horizontal); + ewmh_update_maximize(true, false, true); } else if(state == _NET_WM_STATE_MAXIMIZED_VERT) { if(set == _NET_WM_STATE_REMOVE) - client_set_maximized_vertical(L, -1, false); + ewmh_update_maximize(false, false, false); else if(set == _NET_WM_STATE_ADD) - client_set_maximized_vertical(L, -1, true); + ewmh_update_maximize(false, true, false); else if(set == _NET_WM_STATE_TOGGLE) - client_set_maximized_vertical(L, -1, !c->maximized_vertical); + ewmh_update_maximize(false, false, true); } else if(state == _NET_WM_STATE_ABOVE) { diff --git a/lib/awful/ewmh.lua b/lib/awful/ewmh.lua index 2b7861d94..29b69a7ac 100644 --- a/lib/awful/ewmh.lua +++ b/lib/awful/ewmh.lua @@ -247,6 +247,10 @@ local context_mapper = { function ewmh.geometry(c, context, hints) local layout = c.screen.selected_tag and c.screen.selected_tag.layout or nil + --TODO handle `client_maximize_horizontal` and `client_maximize_vertical` + -- so the clients can request being maximized. Currently they can set the + -- atom, but it is ignored. + -- Setting the geometry will not work unless the client is floating. if (not c.floating) and (not layout == asuit.floating) then return