On Fri, Jan 13, 2012 at 10:20 PM, Uli Schlachter <[email protected]> wrote:
> On 13.01.2012 15:17, Anurag Priyam wrote:
[...]
>> That essentially means awful.tooltip and awful.mouse.finder are broken
>> (in git master). Doesn't look like it has anything to do with my
>> particular setup. I will see if I can fix it later.
>
> Looking through awful.mouse.finder, I can only find one place where .screen is
> still used and that can just be dropped.
[...]
> local screen = c.screen or calculate_screen(c:geometry())
>
> (Where calculate_screen() figures out on which screen the point given by arg.x
> and arg.y is, this is just what the "old" screen property did, too)
This does seem like an easy fix for now. I have attached a patch for
review. It is not the entire series; just an implementation of
`calculate_screen` and its use in `awful.placement.no_offscreen`. I
shamelessly copied the logic from `screen_getbycoord` in `screen.c`.
Can't I somehow just call `screen_getbycoord` from Lua, instead of
re-implementing it in Lua?
So, Xinerama treats multiple heads as one giant screen? I can't see
how this logic could possibly work otherwise.
Also, would you prefer
local screen = c.screen or c:screen()
instead? And perhaps define `screen()` in drawin?
> Alternatively someone could come up with a magic way to modify
> common/luaobject.c so that lua code can add arbitrary properties to an object.
> That'd be nicer, but I don't see that happening any time soon. :-(
+1. This would be super awesome. I am completely oblivious to the
lua-C interface, but still, how do you think can one approach this?
--
Anurag Priyam
From 951d504be596758c8369b2e7987610d7d4121798 Mon Sep 17 00:00:00 2001
From: Anurag Priyam <[email protected]>
Date: Sat, 14 Jan 2012 17:29:33 +0530
Subject: [PATCH] awful.tooltip: determine screen number from client geometry
---
lib/awful/placement.lua.in | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/lib/awful/placement.lua.in b/lib/awful/placement.lua.in
index fa3d37b..0e8bd19 100644
--- a/lib/awful/placement.lua.in
+++ b/lib/awful/placement.lua.in
@@ -21,6 +21,21 @@ local layout = require("awful.layout")
--- Places client according to special criteria.
module("awful.placement")
+-- Compute screen number of an object from the given geometry
+-- @param geometry
+local function calculate_screen(geometry)
+ local x = geometry.x
+ local y = geometry.y
+
+ for i = 1, capi.screen:count() do
+ local s_geometry = capi.screen[i].geometry
+ if((x < 0 or (x >= s_geometry.x and x < s_geometry.x + s_geometry.width))
+ and (y < 0 or (y >= s_geometry.y and y < s_geometry.y + s_geometry.height))) then
+ return i;
+ end
+ end
+end
+
-- Check if an area intersect another area.
-- @param a The area.
-- @param b The other area.
@@ -105,8 +120,9 @@ end
function no_offscreen(c)
local c = c or capi.client.focus
local geometry = c:geometry()
+ local screen = c.screen or calculate_screen(geometry)
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
--
1.7.8.2