wibox: Support screen objects
This commit documents that a textbox already accepts a screen object where a screen index is expected. Also, this changes the widget API in that a widget's context.screen is now a screen object instead of a screen index. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
8de29856b8
commit
65b403c34a
|
@ -10,7 +10,8 @@
|
||||||
local drawable = {}
|
local drawable = {}
|
||||||
local capi = {
|
local capi = {
|
||||||
awesome = awesome,
|
awesome = awesome,
|
||||||
root = root
|
root = root,
|
||||||
|
screen = screen
|
||||||
}
|
}
|
||||||
local beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
local cairo = require("lgi").cairo
|
local cairo = require("lgi").cairo
|
||||||
|
@ -32,10 +33,10 @@ local function screen_getbycoord(x, y)
|
||||||
local geometry = screen[i].geometry
|
local geometry = screen[i].geometry
|
||||||
if x >= geometry.x and x < geometry.x + geometry.width
|
if x >= geometry.x and x < geometry.x + geometry.width
|
||||||
and y >= geometry.y and y < geometry.y + geometry.height then
|
and y >= geometry.y and y < geometry.y + geometry.height then
|
||||||
return i
|
return capi.screen[i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return 1
|
return capi.screen[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get the widget context. This should always return the same table (if
|
-- Get the widget context. This should always return the same table (if
|
||||||
|
|
|
@ -66,7 +66,7 @@ end
|
||||||
--- Get the preferred size of a textbox.
|
--- Get the preferred size of a textbox.
|
||||||
-- This returns the size that the textbox would use if infinite space were
|
-- This returns the size that the textbox would use if infinite space were
|
||||||
-- available.
|
-- available.
|
||||||
-- @tparam integer s The screen number on which the textbox will be displayed.
|
-- @tparam integer|screen s The screen on which the textbox will be displayed.
|
||||||
-- @treturn number The preferred width.
|
-- @treturn number The preferred width.
|
||||||
-- @treturn number The preferred height.
|
-- @treturn number The preferred height.
|
||||||
function textbox:get_preferred_size(s)
|
function textbox:get_preferred_size(s)
|
||||||
|
@ -77,7 +77,7 @@ end
|
||||||
-- This returns the height that the textbox would use when it is limited to the
|
-- This returns the height that the textbox would use when it is limited to the
|
||||||
-- given width.
|
-- given width.
|
||||||
-- @tparam number width The available width.
|
-- @tparam number width The available width.
|
||||||
-- @tparam integer s The screen number on which the textbox will be displayed.
|
-- @tparam integer|screen s The screen on which the textbox will be displayed.
|
||||||
-- @treturn number The needed height.
|
-- @treturn number The needed height.
|
||||||
function textbox:get_height_for_width(width, s)
|
function textbox:get_height_for_width(width, s)
|
||||||
return self:get_height_for_width_at_dpi(width, beautiful.xresources.get_dpi(s))
|
return self:get_height_for_width_at_dpi(width, beautiful.xresources.get_dpi(s))
|
||||||
|
|
Loading…
Reference in New Issue