mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
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
4 changed files with 53 additions and 34 deletions
29
client.c
29
client.c
|
@ -1151,7 +1151,7 @@ luaA_client_unmanage(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/** Return client coordinates.
|
||||
/** Return client geometry.
|
||||
* \param L The Lua VM state.
|
||||
* \return The number of elements pushed on stack.
|
||||
* \luastack
|
||||
|
@ -1159,7 +1159,7 @@ luaA_client_unmanage(lua_State *L)
|
|||
* \lreturn A table with client coordinates.
|
||||
*/
|
||||
static int
|
||||
luaA_client_coords(lua_State *L)
|
||||
luaA_client_geometry(lua_State *L)
|
||||
{
|
||||
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 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.
|
||||
* \return The number of elements pushed on stack.
|
||||
* \luastack
|
||||
|
@ -1189,7 +1196,7 @@ luaA_client_coords(lua_State *L)
|
|||
* \lreturn A table with client coordinates.
|
||||
*/
|
||||
static int
|
||||
luaA_client_fullcoords(lua_State *L)
|
||||
luaA_client_fullgeometry(lua_State *L)
|
||||
{
|
||||
client_t **c = luaA_checkudata(L, 1, "client");
|
||||
area_t geometry;
|
||||
|
@ -1215,6 +1222,13 @@ luaA_client_fullcoords(lua_State *L)
|
|||
(*c)->geometry));
|
||||
}
|
||||
|
||||
static int
|
||||
luaA_client_fullcoords(lua_State *L)
|
||||
{
|
||||
deprecate();
|
||||
return luaA_client_fullgeometry(L);
|
||||
}
|
||||
|
||||
/** Client newindex.
|
||||
* \param L The Lua VM state.
|
||||
* \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[] =
|
||||
{
|
||||
{ "isvisible", luaA_client_isvisible },
|
||||
{ "coords", luaA_client_coords },
|
||||
{ "fullcoords", luaA_client_fullcoords },
|
||||
{ "geometry", luaA_client_geometry },
|
||||
{ "fullgeometry", luaA_client_fullgeometry },
|
||||
{ "buttons", luaA_client_buttons },
|
||||
{ "tags", luaA_client_tags },
|
||||
{ "kill", luaA_client_kill },
|
||||
|
@ -1602,6 +1616,9 @@ const struct luaL_reg awesome_client_meta[] =
|
|||
{ "__eq", luaA_client_eq },
|
||||
{ "__gc", luaA_client_gc },
|
||||
{ "__tostring", luaA_client_tostring },
|
||||
/* deprecated */
|
||||
{ "coords", luaA_client_coords },
|
||||
{ "fullcoords", luaA_client_fullcoords },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
@ -264,18 +264,18 @@ end
|
|||
local function get_client_in_direction(dir, c)
|
||||
local sel = c or capi.client.focus
|
||||
if sel then
|
||||
local coords = sel:coords()
|
||||
local geometry = sel:geometry()
|
||||
local dist, dist_min
|
||||
local target = nil
|
||||
local cls = visible(sel.screen)
|
||||
|
||||
-- We check each client.
|
||||
for i, c in ipairs(cls) do
|
||||
-- Check coords to see if client is located in the right direction.
|
||||
if is_in_direction(dir, coords, c:coords()) then
|
||||
-- Check geometry to see if client is located in the right direction.
|
||||
if is_in_direction(dir, geometry, c:geometry()) then
|
||||
|
||||
-- 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 not target or dist < dist_min then
|
||||
|
@ -371,12 +371,12 @@ end
|
|||
-- @param c The optional client, otherwise focused one is used.
|
||||
function moveresize(x, y, w, h, c)
|
||||
local sel = c or capi.client.focus
|
||||
local coords = sel:coords()
|
||||
coords['x'] = coords['x'] + x
|
||||
coords['y'] = coords['y'] + y
|
||||
coords['width'] = coords['width'] + w
|
||||
coords['height'] = coords['height'] + h
|
||||
sel:coords(coords)
|
||||
local geometry = sel:geometry()
|
||||
geometry['x'] = geometry['x'] + x
|
||||
geometry['y'] = geometry['y'] + y
|
||||
geometry['width'] = geometry['width'] + w
|
||||
geometry['height'] = geometry['height'] + h
|
||||
sel:geometry(geometry)
|
||||
end
|
||||
|
||||
--- Maximize a client to use the full workarea.
|
||||
|
@ -389,15 +389,15 @@ function maximize(c)
|
|||
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:coords(data.maximize[sel].coords)
|
||||
sel:geometry(data.maximize[sel].geometry)
|
||||
sel.floating = data.maximize[sel].floating
|
||||
data.maximize[sel] = nil
|
||||
else
|
||||
data.maximize[sel] = { coords = sel:coords(), floating = sel.floating }
|
||||
data.maximize[sel] = { geometry = sel:geometry(), floating = sel.floating }
|
||||
if curlay ~= "floating" then
|
||||
sel.floating = true
|
||||
end
|
||||
sel:coords(ws)
|
||||
sel:geometry(ws)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -461,7 +461,7 @@ function movetoscreen(c, s)
|
|||
end
|
||||
if s > sc then s = 1 elseif s < 1 then s = sc end
|
||||
sel.screen = s
|
||||
capi.mouse.coords(capi.screen[s].coords)
|
||||
capi.mouse.coords(capi.screen[s].geometry)
|
||||
capi.client.focus = sel
|
||||
end
|
||||
end
|
||||
|
|
|
@ -101,7 +101,7 @@ end
|
|||
--- Place the client without it being outside the screen.
|
||||
-- @param c The client.
|
||||
function no_offscreen(c)
|
||||
local geometry = c:fullcoords()
|
||||
local geometry = c:fullgeometry()
|
||||
local screen_geometry = capi.screen[c.screen].workarea
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
c:fullcoords(geometry)
|
||||
c:fullgeometry(geometry)
|
||||
end
|
||||
|
||||
--- 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 layout = layout.get()
|
||||
local areas = { capi.screen[c.screen].workarea }
|
||||
local coords = c:coords()
|
||||
local fullcoords = c:fullcoords()
|
||||
local geometry = c:geometry()
|
||||
local fullgeometry = c:fullgeometry()
|
||||
for i, cl in pairs(cls) do
|
||||
if cl ~= c and (cl.floating or layout == "floating") then
|
||||
areas = area_remove(areas, cl:fullcoords())
|
||||
areas = area_remove(areas, cl:fullgeometry())
|
||||
end
|
||||
end
|
||||
|
||||
-- Look for available space
|
||||
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
|
||||
if r.width >= fullcoords.width
|
||||
and r.height >= fullcoords.height
|
||||
if r.width >= fullgeometry.width
|
||||
and r.height >= fullgeometry.height
|
||||
and r.width * r.height > new.width * new.height then
|
||||
found = true
|
||||
new = r
|
||||
|
@ -156,19 +156,19 @@ function no_overlap(c)
|
|||
end
|
||||
|
||||
-- Restore height and width
|
||||
new.width = coords.width
|
||||
new.height = coords.height
|
||||
new.width = geometry.width
|
||||
new.height = geometry.height
|
||||
|
||||
c:coords(new)
|
||||
c:geometry(new)
|
||||
end
|
||||
|
||||
--- Place the client under the mouse.
|
||||
-- @param c The client.
|
||||
function under_mouse(c)
|
||||
local c_coords = c:coords()
|
||||
local c_geometry = c:geometry()
|
||||
local m_coords = capi.mouse.coords()
|
||||
c:coords({ x = m_coords.x - c_coords.width / 2,
|
||||
y = m_coords.y - c_coords.height / 2 })
|
||||
c:geometry({ x = m_coords.x - c_geometry.width / 2,
|
||||
y = m_coords.y - c_geometry.height / 2 })
|
||||
end
|
||||
|
||||
-- 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))
|
||||
{
|
||||
case A_TK_COORDS:
|
||||
deprecate();
|
||||
case A_TK_GEOMETRY:
|
||||
luaA_pusharea(L, s->geometry);
|
||||
break;
|
||||
case A_TK_WORKAREA:
|
||||
|
|
Loading…
Reference in a new issue