client: maximize belongs to client internal

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-11-25 11:54:38 +01:00
parent dc6583c3e0
commit 576a1e85fc
9 changed files with 156 additions and 37 deletions

View File

@ -221,7 +221,8 @@ keybinding({ modkey, "Control" }, "r", function ()
keybinding({ modkey, "Shift" }, "q", awesome.quit):add() keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
-- Client manipulation -- Client manipulation
keybinding({ modkey }, "m", awful.client.maximize):add() keybinding({ modkey }, "m", function () if client.focus then client.focus.maximized_horizontal = not client.focus.maximized_horizontal
client.focus.maximized_vertical = not client.focus.maximized_vertical end end):add()
keybinding({ modkey }, "f", function () if client.focus then client.focus.fullscreen = not client.focus.fullscreen end end):add() keybinding({ modkey }, "f", function () if client.focus then client.focus.fullscreen = not client.focus.fullscreen end end):add()
keybinding({ modkey, "Shift" }, "c", function () if client.focus then client.focus:kill() end end):add() keybinding({ modkey, "Shift" }, "c", function () if client.focus then client.focus:kill() end end):add()
keybinding({ modkey }, "j", function () awful.client.focus.byidx(1); if client.focus then client.focus:raise() end end):add() keybinding({ modkey }, "j", function () awful.client.focus.byidx(1); if client.focus then client.focus:raise() end end):add()

118
client.c
View File

@ -332,7 +332,7 @@ client_layer_translator(client_t *c)
return LAYER_ABOVE; return LAYER_ABOVE;
else if(c->isbelow) else if(c->isbelow)
return LAYER_BELOW; return LAYER_BELOW;
else if(c->isfloating) else if(c->isfloating || c->ismaxhoriz || c->ismaxvert)
return LAYER_FLOAT; return LAYER_FLOAT;
/* check for transient attr */ /* check for transient attr */
@ -462,10 +462,10 @@ client_manage(xcb_window_t w, xcb_get_geometry_reply_t *wgeom, int phys_screen,
/* Initial values */ /* Initial values */
c->win = w; c->win = w;
c->geometry.x = c->geometries.floating.x = c->geometries.fullscreen.x = wgeom->x; c->geometry.x = c->geometries.floating.x = wgeom->x;
c->geometry.y = c->geometries.floating.y = c->geometries.fullscreen.y = wgeom->y; c->geometry.y = c->geometries.floating.y = wgeom->y;
c->geometry.width = c->geometries.floating.width = c->geometries.fullscreen.width = wgeom->width; c->geometry.width = c->geometries.floating.width = wgeom->width;
c->geometry.height = c->geometries.floating.height = c->geometries.fullscreen.height = wgeom->height; c->geometry.height = c->geometries.floating.height = wgeom->height;
client_setborder(c, wgeom->border_width); client_setborder(c, wgeom->border_width);
if((icon = ewmh_window_icon_get_reply(ewmh_icon_cookie))) if((icon = ewmh_window_icon_get_reply(ewmh_icon_cookie)))
c->icon = image_ref(&icon); c->icon = image_ref(&icon);
@ -667,7 +667,7 @@ client_resize(client_t *c, area_t geometry, bool hints)
if(client_isfloating(c) if(client_isfloating(c)
|| layout_get_current(new_screen) == layout_floating || layout_get_current(new_screen) == layout_floating
|| layout_get_current(c->screen) == layout_floating) || layout_get_current(c->screen) == layout_floating)
if(!c->isfullscreen) if(!c->isfullscreen && !c->ismaxvert && !c->ismaxhoriz)
c->geometries.floating = geometry; c->geometries.floating = geometry;
titlebar_update_geometry_floating(c); titlebar_update_geometry_floating(c);
@ -769,6 +769,10 @@ client_setfullscreen(client_t *c, bool s)
/* become fullscreen! */ /* become fullscreen! */
if((c->isfullscreen = s)) if((c->isfullscreen = s))
{ {
/* remove any max state */
client_setmaxhoriz(c, false);
client_setmaxvert(c, false);
geometry = screen_area_get(c->screen, NULL, NULL, false); geometry = screen_area_get(c->screen, NULL, NULL, false);
c->geometries.fullscreen = c->geometry; c->geometries.fullscreen = c->geometry;
c->oldborder = c->border; c->oldborder = c->border;
@ -791,6 +795,94 @@ client_setfullscreen(client_t *c, bool s)
} }
} }
/** Set a client horizontally maximized.
* \param c The client.
* \param s The maximized status.
*/
void
client_setmaxhoriz(client_t *c, bool s)
{
if(c->ismaxhoriz != s)
{
area_t geometry;
if((c->ismaxhoriz = s))
{
/* remove fullscreen mode */
client_setfullscreen(c, false);
geometry = screen_area_get(c->screen,
&globalconf.screens[c->screen].wiboxes,
&globalconf.screens[c->screen].padding,
true);
/* Remove space needed for titlebar and border. */
geometry = titlebar_geometry_remove(c->titlebar,
c->border,
geometry);
geometry.y = c->geometry.y;
geometry.height = c->geometry.height;
c->geometries.max.x = c->geometry.x;
c->geometries.max.width = c->geometry.width;
}
else
{
geometry = c->geometry;
geometry.x = c->geometries.max.x;
geometry.width = c->geometries.max.width;
}
client_resize(c, geometry, c->honorsizehints);
client_need_arrange(c);
client_stack();
ewmh_client_update_hints(c);
hooks_property(c, "maximized_horizontal");
}
}
/** Set a client vertically maximized.
* \param c The client.
* \param s The maximized status.
*/
void
client_setmaxvert(client_t *c, bool s)
{
if(c->ismaxvert != s)
{
area_t geometry;
if((c->ismaxvert = s))
{
/* remove fullscreen mode */
client_setfullscreen(c, false);
geometry = screen_area_get(c->screen,
&globalconf.screens[c->screen].wiboxes,
&globalconf.screens[c->screen].padding,
true);
/* Remove space needed for titlebar and border. */
geometry = titlebar_geometry_remove(c->titlebar,
c->border,
geometry);
geometry.x = c->geometry.x;
geometry.width = c->geometry.width;
c->geometries.max.y = c->geometry.y;
c->geometries.max.height = c->geometry.height;
}
else
{
geometry = c->geometry;
geometry.y = c->geometries.max.y;
geometry.height = c->geometries.max.height;
}
client_resize(c, geometry, c->honorsizehints);
client_need_arrange(c);
client_stack();
ewmh_client_update_hints(c);
hooks_property(c, "maximized_vertical");
}
}
/** Set a client above, or not. /** Set a client above, or not.
* \param c The client. * \param c The client.
* \param s Set or not the client above. * \param s Set or not the client above.
@ -1348,6 +1440,12 @@ luaA_client_newindex(lua_State *L)
case A_TK_FULLSCREEN: case A_TK_FULLSCREEN:
client_setfullscreen(*c, luaA_checkboolean(L, 3)); client_setfullscreen(*c, luaA_checkboolean(L, 3));
break; break;
case A_TK_MAXIMIZED_HORIZONTAL:
client_setmaxhoriz(*c, luaA_checkboolean(L, 3));
break;
case A_TK_MAXIMIZED_VERTICAL:
client_setmaxvert(*c, luaA_checkboolean(L, 3));
break;
case A_TK_ICON: case A_TK_ICON:
image = luaA_checkudata(L, 3, "image"); image = luaA_checkudata(L, 3, "image");
image_unref(&(*c)->icon); image_unref(&(*c)->icon);
@ -1433,6 +1531,8 @@ luaA_client_newindex(lua_State *L)
* \lfield opacity The client opacity between 0 and 1. * \lfield opacity The client opacity between 0 and 1.
* \lfield ontop The client is on top of every other windows. * \lfield ontop The client is on top of every other windows.
* \lfield fullscreen The client is fullscreen or not. * \lfield fullscreen The client is fullscreen or not.
* \lfield maximized_horizontal The client is maximized horizontally or not.
* \lfield maximized_vertical The client is maximized vertically or not.
* \lfield transient_for Return the client the window is transient for. * \lfield transient_for Return the client the window is transient for.
* \lfield size_hints A table with size hints of the client: user_position, * \lfield size_hints A table with size hints of the client: user_position,
* user_size, program_position and program_size. * user_size, program_position and program_size.
@ -1546,6 +1646,12 @@ luaA_client_index(lua_State *L)
case A_TK_FULLSCREEN: case A_TK_FULLSCREEN:
lua_pushboolean(L, (*c)->isfullscreen); lua_pushboolean(L, (*c)->isfullscreen);
break; break;
case A_TK_MAXIMIZED_HORIZONTAL:
lua_pushboolean(L, (*c)->ismaxhoriz);
break;
case A_TK_MAXIMIZED_VERTICAL:
lua_pushboolean(L, (*c)->ismaxvert);
break;
case A_TK_ICON: case A_TK_ICON:
if((*c)->icon) if((*c)->icon)
luaA_image_userdata_new(L, (*c)->icon); luaA_image_userdata_new(L, (*c)->icon);

View File

@ -62,6 +62,8 @@ void client_setbelow(client_t *, bool);
void client_setmodal(client_t *, bool); void client_setmodal(client_t *, bool);
void client_setontop(client_t *, bool); void client_setontop(client_t *, bool);
void client_setfullscreen(client_t *, bool); void client_setfullscreen(client_t *, bool);
void client_setmaxhoriz(client_t *, bool);
void client_setmaxvert(client_t *, bool);
void client_setminimized(client_t *, bool); void client_setminimized(client_t *, bool);
void client_setborder(client_t *, int); void client_setborder(client_t *, int);
@ -117,6 +119,8 @@ client_isfloating(client_t *c)
return (c->type != WINDOW_TYPE_NORMAL return (c->type != WINDOW_TYPE_NORMAL
|| c->isfloating || c->isfloating
|| c->isfullscreen || c->isfullscreen
|| c->ismaxhoriz
|| c->ismaxvert
|| client_isfixed(c)); || client_isfixed(c));
} }

View File

@ -26,6 +26,8 @@ _NET_WM_STATE
_NET_WM_STATE_STICKY _NET_WM_STATE_STICKY
_NET_WM_STATE_SKIP_TASKBAR _NET_WM_STATE_SKIP_TASKBAR
_NET_WM_STATE_FULLSCREEN _NET_WM_STATE_FULLSCREEN
_NET_WM_STATE_MAXIMIZED_VERT
_NET_WM_STATE_MAXIMIZED_HORZ
_NET_WM_STATE_ABOVE _NET_WM_STATE_ABOVE
_NET_WM_STATE_BELOW _NET_WM_STATE_BELOW
_NET_WM_STATE_MODAL _NET_WM_STATE_MODAL

View File

@ -47,6 +47,8 @@ len
line line
Lock Lock
machine machine
maximized_horizontal
maximized_vertical
middle middle
minimize minimize
Mod1 Mod1

24
ewmh.c
View File

@ -74,6 +74,8 @@ ewmh_init(int phys_screen)
_NET_WM_STATE_STICKY, _NET_WM_STATE_STICKY,
_NET_WM_STATE_SKIP_TASKBAR, _NET_WM_STATE_SKIP_TASKBAR,
_NET_WM_STATE_FULLSCREEN, _NET_WM_STATE_FULLSCREEN,
_NET_WM_STATE_MAXIMIZED_HORZ,
_NET_WM_STATE_MAXIMIZED_VERT,
_NET_WM_STATE_ABOVE, _NET_WM_STATE_ABOVE,
_NET_WM_STATE_BELOW, _NET_WM_STATE_BELOW,
_NET_WM_STATE_MODAL, _NET_WM_STATE_MODAL,
@ -284,6 +286,24 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set)
else if(set == _NET_WM_STATE_TOGGLE) else if(set == _NET_WM_STATE_TOGGLE)
client_setfullscreen(c, !c->isfullscreen); client_setfullscreen(c, !c->isfullscreen);
} }
else if(state == _NET_WM_STATE_MAXIMIZED_HORZ)
{
if(set == _NET_WM_STATE_REMOVE)
client_setmaxhoriz(c, false);
else if(set == _NET_WM_STATE_ADD)
client_setmaxhoriz(c, true);
else if(set == _NET_WM_STATE_TOGGLE)
client_setmaxhoriz(c, !c->ismaxhoriz);
}
else if(state == _NET_WM_STATE_MAXIMIZED_VERT)
{
if(set == _NET_WM_STATE_REMOVE)
client_setmaxvert(c, false);
else if(set == _NET_WM_STATE_ADD)
client_setmaxvert(c, true);
else if(set == _NET_WM_STATE_TOGGLE)
client_setmaxvert(c, !c->ismaxvert);
}
else if(state == _NET_WM_STATE_ABOVE) else if(state == _NET_WM_STATE_ABOVE)
{ {
if(set == _NET_WM_STATE_REMOVE) if(set == _NET_WM_STATE_REMOVE)
@ -396,6 +416,10 @@ ewmh_client_update_hints(client_t *c)
state[i++] = _NET_WM_STATE_MODAL; state[i++] = _NET_WM_STATE_MODAL;
if(c->isfullscreen) if(c->isfullscreen)
state[i++] = _NET_WM_STATE_FULLSCREEN; state[i++] = _NET_WM_STATE_FULLSCREEN;
if(c->ismaxvert)
state[i++] = _NET_WM_STATE_MAXIMIZED_VERT;
if(c->ismaxhoriz)
state[i++] = _NET_WM_STATE_MAXIMIZED_HORZ;
if(c->issticky) if(c->issticky)
state[i++] = _NET_WM_STATE_STICKY; state[i++] = _NET_WM_STATE_STICKY;
if(c->skiptb) if(c->skiptb)

View File

@ -27,7 +27,6 @@ module("awful.client")
-- Private data -- Private data
local data = {} local data = {}
data.maximize = otable()
data.focus = {} data.focus = {}
data.urgent = {} data.urgent = {}
data.marked = {} data.marked = {}
@ -378,34 +377,8 @@ function moveresize(x, y, w, h, c)
sel:geometry(geometry) sel:geometry(geometry)
end end
--- Maximize a client to use the full workarea. function maximize()
-- @param c A client, or the focused one if nil. util.deprecate("maximized_horizontal and vertical client attributes")
function maximize(c)
local sel = c or capi.client.focus
if sel then
local curlay = layout.get()
local ws = capi.screen[sel.screen].workarea
ws.width = ws.width - 2 * sel.border_width
ws.height = ws.height - 2 * sel.border_width
if (sel.floating or curlay == "floating") and data.maximize[sel] then
sel:geometry(data.maximize[sel].geometry)
sel.floating = data.maximize[sel].floating
data.maximize[sel] = nil
else
data.maximize[sel] = { geometry = sel:geometry(), floating = sel.floating }
if curlay ~= "floating" then
sel.floating = true
end
sel:geometry(ws)
end
end
end
--- Erase eventual client data in maximize.
-- @param c The client.
local function maximize_clean(c)
data.maximize[c] = nil
end end
--- Move a client to a tag. --- Move a client to a tag.
@ -541,7 +514,6 @@ end
-- Register standards hooks -- Register standards hooks
hooks.focus.register(focus.history.add) hooks.focus.register(focus.history.add)
hooks.unmanage.register(focus.history.delete) hooks.unmanage.register(focus.history.delete)
hooks.unmanage.register(maximize_clean)
hooks.property.register(urgent.add) hooks.property.register(urgent.add)
hooks.focus.register(urgent.delete) hooks.focus.register(urgent.delete)

View File

@ -250,6 +250,8 @@ function tasklist.new(label, buttons)
hooks.property.register(function (c, prop) hooks.property.register(function (c, prop)
if prop == "urgent" if prop == "urgent"
or prop == "floating" or prop == "floating"
or prop == "maximized_horizontal"
or prop == "maximized_vertical"
or prop == "icon" or prop == "icon"
or prop == "name" or prop == "name"
or prop == "icon_name" then or prop == "icon_name" then

View File

@ -154,6 +154,8 @@ struct client_t
area_t floating; area_t floating;
/** Client geometry when (un)fullscreen */ /** Client geometry when (un)fullscreen */
area_t fullscreen; area_t fullscreen;
/** Client geometry when (un)-max */
area_t max;
} geometries; } geometries;
/* Size hints */ /* Size hints */
int basew, baseh, incw, inch, maxw, maxh, minw, minh; int basew, baseh, incw, inch, maxw, maxh, minw, minh;
@ -176,6 +178,10 @@ struct client_t
bool isminimized; bool isminimized;
/** True if the client is fullscreen */ /** True if the client is fullscreen */
bool isfullscreen; bool isfullscreen;
/** True if the client is maximized horizontally */
bool ismaxhoriz;
/** True if the client is maximized vertically */
bool ismaxvert;
/** True if the client is above others */ /** True if the client is above others */
bool isabove; bool isabove;
/** True if the client is below others */ /** True if the client is below others */