On Sun, Jan 15, 2012 at 9:26 PM, Uli Schlachter <[email protected]> wrote:
> Heh. First two patches are merged.
Cool.
> For the third one:
>> local client = require("awful.client")
>> +local screen = require("awful.screen")
[...]
>> function no_offscreen(c)
>> local c = c or capi.client.focus
>> local geometry = c:geometry()
>> + local screen = c.screen or screen.getbycoord(geometry.x, geometry.y)
>
> We now have two variables named screen, the global one and the local one. Also
> "local foo = bar or foo.foobar()" looks weird.
>
> However, I don't have any ideas how to change that. The best I can think of is
> "local a_screen = require("awful.screen")" instead of the above version.
I went with that since that seems to be the convention.
>> + local cls = client.visible(screen)
>
> Uhm, what?! This doesn't look like it has any chance of not erroring out.
Oops. This is why I waited to get a snack before sending the patch
series; I intended to review and hopefully catch this silly error. But
seeing your mail the first thing when I got back, I couldn't resist.
> (client.visible() will call capi.client.get(screen) and the C code will
> complain
> that awful.screen is not a screen object)
You mean index, not screen object, right?
> Search and replace error?
Yep :-|. My tooltip was working, so that lowered my guards too.
Fixed in the attached patch.
git fetch origin isn't returning anything. You messaged too early?
Or server issues?
--
Anurag Priyam
From 44d6903d983d1690a5e6725409075e415ffa9472 Mon Sep 17 00:00:00 2001
From: Anurag Priyam <[email protected]>
Date: Sun, 15 Jan 2012 16:27:47 +0530
Subject: [PATCH] awful.placement: can now operate on any object with a set
geometry
So the utility of `awful.placement` is not merely limited to client objects,
but also to wiboxes.
[us: use appropriate naming convention; catch misplaced statement]
Signed-off-by: Anurag Priyam <[email protected]>
---
lib/awful/placement.lua.in | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/lib/awful/placement.lua.in b/lib/awful/placement.lua.in
index fa3d37b..9520faa 100644
--- a/lib/awful/placement.lua.in
+++ b/lib/awful/placement.lua.in
@@ -17,6 +17,7 @@ local capi =
}
local client = require("awful.client")
local layout = require("awful.layout")
+local a_screen = require("awful.screen")
--- Places client according to special criteria.
module("awful.placement")
@@ -105,8 +106,9 @@ end
function no_offscreen(c)
local c = c or capi.client.focus
local geometry = c:geometry()
+ local screen = c.screen or a_screen.getbycoord(geometry.x, geometry.y)
local border = c.border_width
- local screen_geometry = capi.screen[c.screen].workarea
+ local screen_geometry = capi.screen[screen].workarea
if geometry.x + geometry.width + 2*border > screen_geometry.x + screen_geometry.width then
geometry.x = screen_geometry.x + screen_geometry.width - geometry.width
@@ -126,10 +128,11 @@ end
--- Place the client where there's place available with minimum overlap.
-- @param c The client.
function no_overlap(c)
- local cls = client.visible(c.screen)
- local curlay = layout.get()
- local areas = { capi.screen[c.screen].workarea }
local geometry = c:geometry()
+ local screen = c.screen or a_screen.getbycoord(geometry.x, geometry.y)
+ local cls = client.visible(screen)
+ local curlay = layout.get()
+ local areas = { capi.screen[screen].workarea }
for i, cl in pairs(cls) do
if cl ~= c and cl.type ~= "desktop" and (client.floating.get(cl) or curlay == layout.suit.floating) then
areas = area_remove(areas, cl:geometry())
@@ -192,11 +195,12 @@ end
function centered(c, p)
local c = c or capi.client.focus
local c_geometry = c:geometry()
+ local screen = c.screen or a_screen.getbycoord(c_geometry.x, c_geometry.y)
local s_geometry
if p then
s_geometry = p:geometry()
else
- s_geometry = capi.screen[c.screen].geometry
+ s_geometry = capi.screen[screen].geometry
end
return c:geometry({ x = s_geometry.x + (s_geometry.width - c_geometry.width) / 2,
y = s_geometry.y + (s_geometry.height - c_geometry.height) / 2 })
@@ -209,11 +213,12 @@ end
function center_horizontal(c, p)
local c = c or capi.client.focus
local c_geometry = c:geometry()
+ local screen = c.screen or a_screen.getbycoord(c_geometry.x, c_geometry.y)
local s_geometry
if p then
s_geometry = p:geometry()
else
- s_geometry = capi.screen[c.screen].geometry
+ s_geometry = capi.screen[screen].geometry
end
return c:geometry({ x = s_geometry.x + (s_geometry.width - c_geometry.width) / 2 })
end
@@ -225,11 +230,12 @@ end
function center_vertical(c, p)
local c = c or capi.client.focus
local c_geometry = c:geometry()
+ local screen = c.screen or a_screen.getbycoord(c_geometry.x, c_geometry.y)
local s_geometry
if p then
s_geometry = p:geometry()
else
- s_geometry = capi.screen[c.screen].geometry
+ s_geometry = capi.screen[screen].geometry
end
return c:geometry({ y = s_geometry.y + (s_geometry.height - c_geometry.height) / 2 })
end
--
1.7.8.2