I force a couple of floating clients to align to the bottom and/or right edge
of the screen by setting a large x or y in c:geometry(). If the height or
width is set afterwards he client is moved away from the edge.

Patch attached (not sure if it's the best though :)
From f5c04c2f8c36dbdc69705666e62998a4926e8b44 Mon Sep 17 00:00:00 2001
From: Jacob Winther <[email protected]>
Date: Sat, 12 Sep 2009 07:17:30 +1200
Subject: [PATCH 2/2] awful.rules: apply positioning after sizing

If y + height > workarea then the client should be aligned to the
bottom on the screen. If height is set after y this can break.

Signed-off-by: Jacob Winther <[email protected]>
---
 lib/awful/rules.lua.in |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/lib/awful/rules.lua.in b/lib/awful/rules.lua.in
index 8b6151f..2e316d9 100644
--- a/lib/awful/rules.lua.in
+++ b/lib/awful/rules.lua.in
@@ -77,6 +77,15 @@ function match(c, rule)
     end
     return true
 end
+--- Apply single geometry value to client
+-- @param c The client.
+-- @param property The geometry property to change.
+-- @param value The property value.
+local function apply_geo(c, property, value)
+    local geo = c:geometry()
+    geo[property] = value
+    c:geometry(geo)
+end
 
 --- Apply rules to a client.
 -- @param c The client.
@@ -91,17 +100,21 @@ function apply(c)
                 elseif property == "switchtotag" and value
                     and entry.properties["tag"] then
                     atag.viewonly(entry.properties["tag"])
-                elseif property == "height" or property == "width" or
-                       property == "x" or property == "y" then
-                    local geo = c:geometry();
-                    geo[property] = value
-                    c:geometry(geo);
+                elseif property == "height" or property == "width" then
+                    apply_geo(c, property, value)
                 elseif type(c[property]) == "function" then
                     c[property](c, value)
                 else
                     c[property] = value
                 end
             end
+            -- move the client after height and width have been set
+            if entry.properties.x then
+                apply_geo(c, 'x', entry.properties.x)
+            end
+            if entry.properties.y then
+                apply_geo(c, 'y', entry.properties.y)
+            end
             -- Do this at last so we do not erase things done by the focus
             -- signal.
             if entry.properties.focus then
-- 
1.6.4.2

Reply via email to