client, screen: use geometry rather coords as keyword
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
2a36b021d1
commit
5ab2497b43
29
client.c
29
client.c
|
@ -1151,7 +1151,7 @@ luaA_client_unmanage(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return client coordinates.
|
/** Return client geometry.
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
* \return The number of elements pushed on stack.
|
* \return The number of elements pushed on stack.
|
||||||
* \luastack
|
* \luastack
|
||||||
|
@ -1159,7 +1159,7 @@ luaA_client_unmanage(lua_State *L)
|
||||||
* \lreturn A table with client coordinates.
|
* \lreturn A table with client coordinates.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
luaA_client_coords(lua_State *L)
|
luaA_client_geometry(lua_State *L)
|
||||||
{
|
{
|
||||||
client_t **c = luaA_checkudata(L, 1, "client");
|
client_t **c = luaA_checkudata(L, 1, "client");
|
||||||
|
|
||||||
|
@ -1181,7 +1181,14 @@ luaA_client_coords(lua_State *L)
|
||||||
return luaA_pusharea(L, (*c)->geometry);
|
return luaA_pusharea(L, (*c)->geometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return client coordinates, using also titlebar and border width.
|
static int
|
||||||
|
luaA_client_coords(lua_State *L)
|
||||||
|
{
|
||||||
|
deprecate();
|
||||||
|
return luaA_client_geometry(L);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return client geometry, using also titlebar and border width.
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
* \return The number of elements pushed on stack.
|
* \return The number of elements pushed on stack.
|
||||||
* \luastack
|
* \luastack
|
||||||
|
@ -1189,7 +1196,7 @@ luaA_client_coords(lua_State *L)
|
||||||
* \lreturn A table with client coordinates.
|
* \lreturn A table with client coordinates.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
luaA_client_fullcoords(lua_State *L)
|
luaA_client_fullgeometry(lua_State *L)
|
||||||
{
|
{
|
||||||
client_t **c = luaA_checkudata(L, 1, "client");
|
client_t **c = luaA_checkudata(L, 1, "client");
|
||||||
area_t geometry;
|
area_t geometry;
|
||||||
|
@ -1215,6 +1222,13 @@ luaA_client_fullcoords(lua_State *L)
|
||||||
(*c)->geometry));
|
(*c)->geometry));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
luaA_client_fullcoords(lua_State *L)
|
||||||
|
{
|
||||||
|
deprecate();
|
||||||
|
return luaA_client_fullgeometry(L);
|
||||||
|
}
|
||||||
|
|
||||||
/** Client newindex.
|
/** Client newindex.
|
||||||
* \param L The Lua VM state.
|
* \param L The Lua VM state.
|
||||||
* \return The number of elements pushed on stack.
|
* \return The number of elements pushed on stack.
|
||||||
|
@ -1586,8 +1600,8 @@ const struct luaL_reg awesome_client_methods[] =
|
||||||
const struct luaL_reg awesome_client_meta[] =
|
const struct luaL_reg awesome_client_meta[] =
|
||||||
{
|
{
|
||||||
{ "isvisible", luaA_client_isvisible },
|
{ "isvisible", luaA_client_isvisible },
|
||||||
{ "coords", luaA_client_coords },
|
{ "geometry", luaA_client_geometry },
|
||||||
{ "fullcoords", luaA_client_fullcoords },
|
{ "fullgeometry", luaA_client_fullgeometry },
|
||||||
{ "buttons", luaA_client_buttons },
|
{ "buttons", luaA_client_buttons },
|
||||||
{ "tags", luaA_client_tags },
|
{ "tags", luaA_client_tags },
|
||||||
{ "kill", luaA_client_kill },
|
{ "kill", luaA_client_kill },
|
||||||
|
@ -1602,6 +1616,9 @@ const struct luaL_reg awesome_client_meta[] =
|
||||||
{ "__eq", luaA_client_eq },
|
{ "__eq", luaA_client_eq },
|
||||||
{ "__gc", luaA_client_gc },
|
{ "__gc", luaA_client_gc },
|
||||||
{ "__tostring", luaA_client_tostring },
|
{ "__tostring", luaA_client_tostring },
|
||||||
|
/* deprecated */
|
||||||
|
{ "coords", luaA_client_coords },
|
||||||
|
{ "fullcoords", luaA_client_fullcoords },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -264,18 +264,18 @@ end
|
||||||
local function get_client_in_direction(dir, c)
|
local function get_client_in_direction(dir, c)
|
||||||
local sel = c or capi.client.focus
|
local sel = c or capi.client.focus
|
||||||
if sel then
|
if sel then
|
||||||
local coords = sel:coords()
|
local geometry = sel:geometry()
|
||||||
local dist, dist_min
|
local dist, dist_min
|
||||||
local target = nil
|
local target = nil
|
||||||
local cls = visible(sel.screen)
|
local cls = visible(sel.screen)
|
||||||
|
|
||||||
-- We check each client.
|
-- We check each client.
|
||||||
for i, c in ipairs(cls) do
|
for i, c in ipairs(cls) do
|
||||||
-- Check coords to see if client is located in the right direction.
|
-- Check geometry to see if client is located in the right direction.
|
||||||
if is_in_direction(dir, coords, c:coords()) then
|
if is_in_direction(dir, geometry, c:geometry()) then
|
||||||
|
|
||||||
-- Calculate distance between focused client and checked client.
|
-- Calculate distance between focused client and checked client.
|
||||||
dist = calculate_distance(dir, coords, c:coords())
|
dist = calculate_distance(dir, geometry, c:geometry())
|
||||||
|
|
||||||
-- If distance is shorter then keep the client.
|
-- If distance is shorter then keep the client.
|
||||||
if not target or dist < dist_min then
|
if not target or dist < dist_min then
|
||||||
|
@ -371,12 +371,12 @@ end
|
||||||
-- @param c The optional client, otherwise focused one is used.
|
-- @param c The optional client, otherwise focused one is used.
|
||||||
function moveresize(x, y, w, h, c)
|
function moveresize(x, y, w, h, c)
|
||||||
local sel = c or capi.client.focus
|
local sel = c or capi.client.focus
|
||||||
local coords = sel:coords()
|
local geometry = sel:geometry()
|
||||||
coords['x'] = coords['x'] + x
|
geometry['x'] = geometry['x'] + x
|
||||||
coords['y'] = coords['y'] + y
|
geometry['y'] = geometry['y'] + y
|
||||||
coords['width'] = coords['width'] + w
|
geometry['width'] = geometry['width'] + w
|
||||||
coords['height'] = coords['height'] + h
|
geometry['height'] = geometry['height'] + h
|
||||||
sel:coords(coords)
|
sel:geometry(geometry)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Maximize a client to use the full workarea.
|
--- Maximize a client to use the full workarea.
|
||||||
|
@ -389,15 +389,15 @@ function maximize(c)
|
||||||
ws.width = ws.width - 2 * sel.border_width
|
ws.width = ws.width - 2 * sel.border_width
|
||||||
ws.height = ws.height - 2 * sel.border_width
|
ws.height = ws.height - 2 * sel.border_width
|
||||||
if (sel.floating or curlay == "floating") and data.maximize[sel] then
|
if (sel.floating or curlay == "floating") and data.maximize[sel] then
|
||||||
sel:coords(data.maximize[sel].coords)
|
sel:geometry(data.maximize[sel].geometry)
|
||||||
sel.floating = data.maximize[sel].floating
|
sel.floating = data.maximize[sel].floating
|
||||||
data.maximize[sel] = nil
|
data.maximize[sel] = nil
|
||||||
else
|
else
|
||||||
data.maximize[sel] = { coords = sel:coords(), floating = sel.floating }
|
data.maximize[sel] = { geometry = sel:geometry(), floating = sel.floating }
|
||||||
if curlay ~= "floating" then
|
if curlay ~= "floating" then
|
||||||
sel.floating = true
|
sel.floating = true
|
||||||
end
|
end
|
||||||
sel:coords(ws)
|
sel:geometry(ws)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -461,7 +461,7 @@ function movetoscreen(c, s)
|
||||||
end
|
end
|
||||||
if s > sc then s = 1 elseif s < 1 then s = sc end
|
if s > sc then s = 1 elseif s < 1 then s = sc end
|
||||||
sel.screen = s
|
sel.screen = s
|
||||||
capi.mouse.coords(capi.screen[s].coords)
|
capi.mouse.coords(capi.screen[s].geometry)
|
||||||
capi.client.focus = sel
|
capi.client.focus = sel
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -101,7 +101,7 @@ end
|
||||||
--- Place the client without it being outside the screen.
|
--- Place the client without it being outside the screen.
|
||||||
-- @param c The client.
|
-- @param c The client.
|
||||||
function no_offscreen(c)
|
function no_offscreen(c)
|
||||||
local geometry = c:fullcoords()
|
local geometry = c:fullgeometry()
|
||||||
local screen_geometry = capi.screen[c.screen].workarea
|
local screen_geometry = capi.screen[c.screen].workarea
|
||||||
|
|
||||||
if geometry.x + geometry.width > screen_geometry.x + screen_geometry.width then
|
if geometry.x + geometry.width > screen_geometry.x + screen_geometry.width then
|
||||||
|
@ -116,7 +116,7 @@ function no_offscreen(c)
|
||||||
geometry.y = screen_geometry.y
|
geometry.y = screen_geometry.y
|
||||||
end
|
end
|
||||||
|
|
||||||
c:fullcoords(geometry)
|
c:fullgeometry(geometry)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Place the client where there's place available with minimum overlap.
|
--- Place the client where there's place available with minimum overlap.
|
||||||
|
@ -125,20 +125,20 @@ function no_overlap(c)
|
||||||
local cls = client.visible(c.screen)
|
local cls = client.visible(c.screen)
|
||||||
local layout = layout.get()
|
local layout = layout.get()
|
||||||
local areas = { capi.screen[c.screen].workarea }
|
local areas = { capi.screen[c.screen].workarea }
|
||||||
local coords = c:coords()
|
local geometry = c:geometry()
|
||||||
local fullcoords = c:fullcoords()
|
local fullgeometry = c:fullgeometry()
|
||||||
for i, cl in pairs(cls) do
|
for i, cl in pairs(cls) do
|
||||||
if cl ~= c and (cl.floating or layout == "floating") then
|
if cl ~= c and (cl.floating or layout == "floating") then
|
||||||
areas = area_remove(areas, cl:fullcoords())
|
areas = area_remove(areas, cl:fullgeometry())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Look for available space
|
-- Look for available space
|
||||||
local found = false
|
local found = false
|
||||||
local new = { x = coords.x, y = coords.y, width = 0, height = 0 }
|
local new = { x = geometry.x, y = geometry.y, width = 0, height = 0 }
|
||||||
for i, r in ipairs(areas) do
|
for i, r in ipairs(areas) do
|
||||||
if r.width >= fullcoords.width
|
if r.width >= fullgeometry.width
|
||||||
and r.height >= fullcoords.height
|
and r.height >= fullgeometry.height
|
||||||
and r.width * r.height > new.width * new.height then
|
and r.width * r.height > new.width * new.height then
|
||||||
found = true
|
found = true
|
||||||
new = r
|
new = r
|
||||||
|
@ -156,19 +156,19 @@ function no_overlap(c)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Restore height and width
|
-- Restore height and width
|
||||||
new.width = coords.width
|
new.width = geometry.width
|
||||||
new.height = coords.height
|
new.height = geometry.height
|
||||||
|
|
||||||
c:coords(new)
|
c:geometry(new)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Place the client under the mouse.
|
--- Place the client under the mouse.
|
||||||
-- @param c The client.
|
-- @param c The client.
|
||||||
function under_mouse(c)
|
function under_mouse(c)
|
||||||
local c_coords = c:coords()
|
local c_geometry = c:geometry()
|
||||||
local m_coords = capi.mouse.coords()
|
local m_coords = capi.mouse.coords()
|
||||||
c:coords({ x = m_coords.x - c_coords.width / 2,
|
c:geometry({ x = m_coords.x - c_geometry.width / 2,
|
||||||
y = m_coords.y - c_coords.height / 2 })
|
y = m_coords.y - c_geometry.height / 2 })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||||
|
|
2
screen.c
2
screen.c
|
@ -500,6 +500,8 @@ luaA_screen_index(lua_State *L)
|
||||||
switch(a_tokenize(buf, len))
|
switch(a_tokenize(buf, len))
|
||||||
{
|
{
|
||||||
case A_TK_COORDS:
|
case A_TK_COORDS:
|
||||||
|
deprecate();
|
||||||
|
case A_TK_GEOMETRY:
|
||||||
luaA_pusharea(L, s->geometry);
|
luaA_pusharea(L, s->geometry);
|
||||||
break;
|
break;
|
||||||
case A_TK_WORKAREA:
|
case A_TK_WORKAREA:
|
||||||
|
|
Loading…
Reference in New Issue