maximize: Stop doing it in 2 operations.
Before 4.0, maximizing could only be done in 2 operations. 4.0 add an unified way, but kept doing 2 operations. The old Lua EWMH code to serialize the 2 operations was dropped when the codepath was simplified and replaced by a generic version in awful.placement. However this version never implemented combining multiple mementos into 1. This commit unify the maximize C code, drop the ugly macro template and actually fixes a couple more issues that were caused because request::geometry was sent twice.
This commit is contained in:
parent
27173163cb
commit
3b1599bd99
|
@ -224,6 +224,7 @@ end
|
||||||
local context_mapper = {
|
local context_mapper = {
|
||||||
maximized_vertical = "maximize_vertically",
|
maximized_vertical = "maximize_vertically",
|
||||||
maximized_horizontal = "maximize_horizontally",
|
maximized_horizontal = "maximize_horizontally",
|
||||||
|
maximized = "maximize",
|
||||||
fullscreen = "maximize"
|
fullscreen = "maximize"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -460,13 +460,11 @@ end
|
||||||
-- @param c The client for which the button is wanted.
|
-- @param c The client for which the button is wanted.
|
||||||
function titlebar.widget.maximizedbutton(c)
|
function titlebar.widget.maximizedbutton(c)
|
||||||
local widget = titlebar.widget.button(c, "maximized", function(cl)
|
local widget = titlebar.widget.button(c, "maximized", function(cl)
|
||||||
return cl.maximized_horizontal or cl.maximized_vertical
|
return cl.maximized
|
||||||
end, function(cl, state)
|
end, function(cl, state)
|
||||||
cl.maximized_horizontal = not state
|
cl.maximized = not state
|
||||||
cl.maximized_vertical = not state
|
|
||||||
end)
|
end)
|
||||||
c:connect_signal("property::maximized_vertical", widget.update)
|
c:connect_signal("property::maximized", widget.update)
|
||||||
c:connect_signal("property::maximized_horizontal", widget.update)
|
|
||||||
return widget
|
return widget
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -453,6 +453,7 @@ function tasklist.new(screen, filter, buttons, style, update_function, base_widg
|
||||||
capi.client.connect_signal("property::floating", u)
|
capi.client.connect_signal("property::floating", u)
|
||||||
capi.client.connect_signal("property::maximized_horizontal", u)
|
capi.client.connect_signal("property::maximized_horizontal", u)
|
||||||
capi.client.connect_signal("property::maximized_vertical", u)
|
capi.client.connect_signal("property::maximized_vertical", u)
|
||||||
|
capi.client.connect_signal("property::maximized", u)
|
||||||
capi.client.connect_signal("property::minimized", u)
|
capi.client.connect_signal("property::minimized", u)
|
||||||
capi.client.connect_signal("property::name", u)
|
capi.client.connect_signal("property::name", u)
|
||||||
capi.client.connect_signal("property::icon_name", u)
|
capi.client.connect_signal("property::icon_name", u)
|
||||||
|
|
|
@ -805,9 +805,16 @@
|
||||||
* @function set_newindex_miss_handler
|
* @function set_newindex_miss_handler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CLIENT_MAXIMIZED_NONE = 0 << 0,
|
||||||
|
CLIENT_MAXIMIZED_V = 1 << 0,
|
||||||
|
CLIENT_MAXIMIZED_H = 1 << 1,
|
||||||
|
} client_maximized_t;
|
||||||
|
|
||||||
static area_t titlebar_get_area(client_t *c, client_titlebar_t bar);
|
static area_t titlebar_get_area(client_t *c, client_titlebar_t bar);
|
||||||
static drawable_t *titlebar_get_drawable(lua_State *L, client_t *c, int cl_idx, client_titlebar_t bar);
|
static drawable_t *titlebar_get_drawable(lua_State *L, client_t *c, int cl_idx, client_titlebar_t bar);
|
||||||
static void client_resize_do(client_t *c, area_t geometry);
|
static void client_resize_do(client_t *c, area_t geometry);
|
||||||
|
static void client_set_maximized_common(lua_State *L, int cidx, bool s, const char* type, const int val);
|
||||||
|
|
||||||
/** Collect a client.
|
/** Collect a client.
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
|
@ -1948,38 +1955,68 @@ client_get_maximized(client_t *c)
|
||||||
* \param cidx The client index.
|
* \param cidx The client index.
|
||||||
* \param s The maximized status.
|
* \param s The maximized status.
|
||||||
*/
|
*/
|
||||||
#define DO_FUNCTION_CLIENT_MAXIMIZED(type) \
|
void
|
||||||
void \
|
client_set_maximized_common(lua_State *L, int cidx, bool s, const char* type, const int val)
|
||||||
client_set_maximized_##type(lua_State *L, int cidx, bool s) \
|
{
|
||||||
{ \
|
client_t *c = luaA_checkudata(L, cidx, &client_class);
|
||||||
client_t *c = luaA_checkudata(L, cidx, &client_class); \
|
|
||||||
if(c->maximized_##type != s) \
|
/* Store the current and next state on 2 bit */
|
||||||
{ \
|
const client_maximized_t current = (
|
||||||
int abs_cidx = luaA_absindex(L, cidx); \
|
(c->maximized_vertical ? CLIENT_MAXIMIZED_V : CLIENT_MAXIMIZED_NONE)|
|
||||||
int max_before = client_get_maximized(c); \
|
(c->maximized_horizontal ? CLIENT_MAXIMIZED_H : CLIENT_MAXIMIZED_NONE)
|
||||||
c->maximized_##type = s; \
|
);
|
||||||
lua_pushstring(L, "maximized_"#type);\
|
const client_maximized_t next = s ? val : CLIENT_MAXIMIZED_NONE;
|
||||||
luaA_object_emit_signal(L, abs_cidx, "request::geometry", 1); \
|
|
||||||
luaA_object_emit_signal(L, abs_cidx, "property::maximized_" #type, 0); \
|
if(current != next)
|
||||||
if(max_before != client_get_maximized(c)) \
|
{
|
||||||
luaA_object_emit_signal(L, abs_cidx, "property::maximized", 0); \
|
int abs_cidx = luaA_absindex(L, cidx);
|
||||||
stack_windows(); \
|
int max_before = client_get_maximized(c);
|
||||||
} \
|
int h_before = c->maximized_horizontal;
|
||||||
}
|
int v_before = c->maximized_vertical;
|
||||||
DO_FUNCTION_CLIENT_MAXIMIZED(vertical)
|
|
||||||
DO_FUNCTION_CLIENT_MAXIMIZED(horizontal)
|
/*Update the client properties */
|
||||||
#undef DO_FUNCTION_CLIENT_MAXIMIZED
|
c->maximized_horizontal = !!(next & CLIENT_MAXIMIZED_H);
|
||||||
|
c->maximized_vertical = !!(next & CLIENT_MAXIMIZED_V);
|
||||||
|
|
||||||
|
/* Request the changes to be applied */
|
||||||
|
lua_pushstring(L, type);
|
||||||
|
luaA_object_emit_signal(L, abs_cidx, "request::geometry", 1);
|
||||||
|
|
||||||
|
/* Notify changes in the relevant properties */
|
||||||
|
if (h_before != c->maximized_horizontal)
|
||||||
|
luaA_object_emit_signal(L, abs_cidx, "property::maximized_horizontal", 0);
|
||||||
|
if (v_before != c->maximized_vertical)
|
||||||
|
luaA_object_emit_signal(L, abs_cidx, "property::maximized_vertical", 0);
|
||||||
|
if(max_before != client_get_maximized(c))
|
||||||
|
luaA_object_emit_signal(L, abs_cidx, "property::maximized", 0);
|
||||||
|
|
||||||
|
stack_windows();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Set a client maximized (horizontally and vertically).
|
|
||||||
* \param L The Lua VM state.
|
|
||||||
* \param cidx The client index.
|
|
||||||
* \param s Set or not the client maximized attribute.
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
client_set_maximized(lua_State *L, int cidx, bool s)
|
client_set_maximized(lua_State *L, int cidx, bool s)
|
||||||
{
|
{
|
||||||
client_set_maximized_horizontal(L, cidx, s);
|
return client_set_maximized_common(
|
||||||
client_set_maximized_vertical(L, cidx, s);
|
L, cidx, s, "maximized",
|
||||||
|
CLIENT_MAXIMIZED_H | CLIENT_MAXIMIZED_V
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_set_maximized_horizontal(lua_State *L, int cidx, bool s)
|
||||||
|
{
|
||||||
|
return client_set_maximized_common(
|
||||||
|
L, cidx, s, "maximized_horizontal", CLIENT_MAXIMIZED_H
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_set_maximized_vertical(lua_State *L, int cidx, bool s)
|
||||||
|
{
|
||||||
|
return client_set_maximized_common(
|
||||||
|
L, cidx, s, "maximized_vertical", CLIENT_MAXIMIZED_V
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set a client above, or not.
|
/** Set a client above, or not.
|
||||||
|
|
Loading…
Reference in New Issue