On Sun, Jan 15, 2012 at 8:43 PM, Uli Schlachter <psyc...@znc.in> wrote: > Patch gets a NACK, see next paragraph. :-)
Attached is a 3 parts series I wrote in the evening, but decided to get a snack before sending it to the list. The first can be applied as it is, but I will need to re-roll 2nd and 3rd to account for the changes you just made. I am still sending the original series in case you decide my approach is better and want to revert your commit -- I decided to put the `by_ccord` in `awful.screen` as `awful.screen.getbycoord`. -- Anurag Priyam
From 91d63bda08e02d91301894d46617d1d5176ca976 Mon Sep 17 00:00:00 2001 From: Anurag Priyam <anurag08pri...@gmail.com> Date: Sun, 15 Jan 2012 16:42:03 +0530 Subject: [PATCH 1/3] do not set non existent, screen property on wiboxes The `screen` property on wibox (drawin) was removed in the commit - 'drawin: Remove screen property'. Signed-off-by: Anurag Priyam <anurag08pri...@gmail.com> --- lib/awful/mouse/finder.lua.in | 2 -- lib/awful/tooltip.lua.in | 2 -- 2 files changed, 0 insertions(+), 4 deletions(-) diff --git a/lib/awful/mouse/finder.lua.in b/lib/awful/mouse/finder.lua.in index 32c9b52..d1d61fb 100644 --- a/lib/awful/mouse/finder.lua.in +++ b/lib/awful/mouse/finder.lua.in @@ -77,8 +77,6 @@ local function show(self) -- do nothing if the mouse finder is already shown if data[self].wibox.visible then return end if not data[self].timer.started then - -- make sure the mouse finder is on the same screen as the mouse - data[self].wibox.screen = mouse.screen data[self].wibox:geometry({width = data[self].radius, height = data[self].radius }) a_wibox.rounded_corners(data[self].wibox, data[self].radius/2 -1) data[self].timer:start() diff --git a/lib/awful/tooltip.lua.in b/lib/awful/tooltip.lua.in index 92dad35..49b0b7b 100644 --- a/lib/awful/tooltip.lua.in +++ b/lib/awful/tooltip.lua.in @@ -92,8 +92,6 @@ end local function show(self) -- do nothing if the tooltip is already shown if self.visible then return end - -- make sure the tooltip is on the same screen as the mouse - self.wibox.screen = mouse.screen if data[self].timer then if not data[self].timer.started then data[self].timer_function() -- 1.7.8.2
From 34b63837c78d6cebd53c7929a672e0a2a2e40c7d Mon Sep 17 00:00:00 2001 From: Anurag Priyam <anurag08pri...@gmail.com> Date: Sun, 15 Jan 2012 15:58:17 +0530 Subject: [PATCH 2/3] awful.screen: define getbycoord() to compute screen number of a pixel Given an object's coordinates, `awful.screen.getbycoord` can be used to determine the screen than the object is, or should be attached to. Signed-off-by: Anurag Priyam <anurag08pri...@gmail.com> --- lib/awful/screen.lua.in | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/lib/awful/screen.lua.in b/lib/awful/screen.lua.in index d15d516..9fba87b 100644 --- a/lib/awful/screen.lua.in +++ b/lib/awful/screen.lua.in @@ -20,6 +20,22 @@ module("awful.screen") local data = {} data.padding = {} +--- +-- Return Xinerama screen number corresponding to the given (pixel) coordinates. +-- The number returned can be used as an index into the global +-- `screen` table/object. +-- @param x The x coordinate +-- @param y The y coordinate +function getbycoord(x, y) + for i = 1, capi.screen:count() do + local geometry = capi.screen[i].geometry + if((x < 0 or (x >= geometry.x and x < geometry.x + geometry.width)) + and (y < 0 or (y >= geometry.y and y < geometry.y + geometry.height))) then + return i; + end + end +end + --- Give the focus to a screen, and move pointer. -- @param screen Screen number. function focus(screen) -- 1.7.8.2
From c8255ad2a968a8426281c73c6b5ed47e5f782531 Mon Sep 17 00:00:00 2001 From: Anurag Priyam <anurag08pri...@gmail.com> Date: Sun, 15 Jan 2012 16:27:47 +0530 Subject: [PATCH 3/3] 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 <anurag08pri...@gmail.com> --- lib/awful/placement.lua.in | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/awful/placement.lua.in b/lib/awful/placement.lua.in index fa3d37b..a3d0926 100644 --- a/lib/awful/placement.lua.in +++ b/lib/awful/placement.lua.in @@ -16,6 +16,7 @@ local capi = client = client } local client = require("awful.client") +local screen = require("awful.screen") local layout = require("awful.layout") --- Places client according to special criteria. @@ -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 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 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 screen.getbycoord(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 +195,12 @@ end function centered(c, p) local c = c or capi.client.focus local c_geometry = c:geometry() + local screen = c.screen or 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 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 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