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 <anurag08priyam@gmail.com> Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
9793ec0b71
commit
7f8ef18cd8
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue