Partial revert of "awful.client: use signal and geometry attributes"

Partial revert of 1da49640b5.

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-08-21 21:15:19 +02:00
parent e25a8ba6f4
commit b3214e589e
1 changed files with 16 additions and 22 deletions

View File

@ -77,8 +77,9 @@ end
--- Adds client to urgent stack. --- Adds client to urgent stack.
-- @param c The client object. -- @param c The client object.
function urgent.add(c) -- @param prop The property which is updated.
if c.urgent then function urgent.add(c, prop)
if type(c) == "client" and prop == "urgent" and c.urgent then
table.insert(data.urgent, c) table.insert(data.urgent, c)
end end
end end
@ -288,7 +289,7 @@ 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 geometry = { x = c.x, y = c.y, width = c.width, height = c.height } 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)
@ -296,11 +297,10 @@ local function get_client_in_direction(dir, c)
-- We check each client. -- We check each client.
for i, c in ipairs(cls) do for i, c in ipairs(cls) do
-- Check geometry to see if client is located in the right direction. -- Check geometry to see if client is located in the right direction.
local g = { x = c.x, y = c.y, width = c.width, height = c.height } if is_in_direction(dir, geometry, c:geometry()) then
if is_in_direction(dir, geometry, g) then
-- Calculate distance between focused client and checked client. -- Calculate distance between focused client and checked client.
dist = calculate_distance(dir, geometry, g) 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
@ -410,11 +410,13 @@ end
-- @param h The relative height. -- @param h The relative height.
-- @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 c = c or capi.client.focus local sel = c or capi.client.focus
c.x = c.x + x local geometry = sel:geometry()
c.y = c.y + y geometry['x'] = geometry['x'] + x
c.width = c.width + width geometry['y'] = geometry['y'] + y
c.height = c.height + height geometry['width'] = geometry['width'] + w
geometry['height'] = geometry['height'] + h
sel:geometry(geometry)
end end
--- Move a client to a tag. --- Move a client to a tag.
@ -555,28 +557,20 @@ function floating.set(c, s)
property.set(c, "floating", s) property.set(c, "floating", s)
local screen = c.screen local screen = c.screen
if s == true then if s == true then
local g = property.get(c, "floating_geometry") c:geometry(property.get(c, "floating_geometry"))
c.x = g.x
c.y = g.y
c.width = g.width
c.height = g.height
end end
c.screen = screen c.screen = screen
end end
end end
capi.client.add_signal("manage", function (c)
property.set(c, "floating_geometry", { x = c.x, y = c.y, width = c.width, height = c.height })
end)
local function store_floating_geometry(c) local function store_floating_geometry(c)
if floating.get(c) then if floating.get(c) then
property.set(c, "floating_geometry", property.set(c, "floating_geometry", c:geometry())
{ x = c.x, y = c.y, width = c.width, height = c.height })
end end
end end
capi.client.add_signal("manage", function(c) capi.client.add_signal("manage", function(c)
property.set(c, "floating_geometry", c:geometry())
c:add_signal("property::x", store_floating_geometry) c:add_signal("property::x", store_floating_geometry)
c:add_signal("property::y", store_floating_geometry) c:add_signal("property::y", store_floating_geometry)
c:add_signal("property::width", store_floating_geometry) c:add_signal("property::width", store_floating_geometry)