On Sun, Jan 15, 2012 at 8:49 PM, Uli Schlachter <[email protected]> wrote:
> So I guess just a new patch which fixes this problem via the new
> screen.by_coords(x, y)?

I tried the attached patch (based on `screen.by_coords()), but I am
getting the following stack trace:

W: awesome: luaA_dofunction:108: error while running function
stack traceback:
        [C]: ?
        /usr/local/share/awesome/lib/awful/placement.lua:110: in function
'no_offscreen'
        /usr/local/share/awesome/lib/awful/tooltip.lua:72: in function 'place'
        /usr/local/share/awesome/lib/awful/tooltip.lua:86: in function 
'set_geometry'
        /usr/local/share/awesome/lib/awful/tooltip.lua:101: in function 'show'
        /usr/local/share/awesome/lib/awful/tooltip.lua:186: in function 'func'
        /usr/local/share/awesome/lib/gears/object.lua:71: in function 
'emit_signal'
        /usr/local/share/awesome/lib/wibox/init.lua:177: in function 
'emit_difference'
        /usr/local/share/awesome/lib/wibox/init.lua:202: in function 'func'
        /usr/local/share/awesome/lib/gears/object.lua:71: in function 
'emit_signal'
        /usr/local/share/awesome/lib/wibox/init.lua:214: in function
</usr/local/share/awesome/lib/wibox/init.lua:213>
error: /usr/local/share/awesome/lib/awful/placement.lua:110: bad
argument #2 to '?' (number expected, got userdata)

-- 
Anurag Priyam
From a6235a16e264303bbdb12b977c3273ad105f2a32 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.

Signed-off-by: Anurag Priyam <[email protected]>
---
 lib/awful/placement.lua.in |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/lib/awful/placement.lua.in b/lib/awful/placement.lua.in
index fa3d37b..7fcc5ad 100644
--- a/lib/awful/placement.lua.in
+++ b/lib/awful/placement.lua.in
@@ -105,8 +105,9 @@ end
 function no_offscreen(c)
     local c = c or capi.client.focus
     local geometry = c:geometry()
+    local screen   = c.screen or capi.screen.by_coords(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 +127,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 cls = client.visible(screen)
     local curlay = layout.get()
-    local areas = { capi.screen[c.screen].workarea }
+    local areas = { capi.screen[screen].workarea }
     local geometry = c:geometry()
+    local screen   = c.screen or capi.screen.by_coords(geometry.x, geometry.y)
     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 +194,12 @@ end
 function centered(c, p)
     local c = c or capi.client.focus
     local c_geometry = c:geometry()
+    local screen = c.screen or capi.screen.by_coords(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 +212,12 @@ end
 function center_horizontal(c, p)
     local c = c or capi.client.focus
     local c_geometry = c:geometry()
+    local screen = c.screen or capi.screen.by_coords(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 +229,12 @@ end
 function center_vertical(c, p)
     local c = c or capi.client.focus
     local c_geometry = c:geometry()
+    local screen = c.screen or capi.screen.by_coords(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

Reply via email to