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 capi = {
|
||||
awesome = awesome,
|
||||
root = root
|
||||
root = root,
|
||||
screen = screen
|
||||
}
|
||||
local beautiful = require("beautiful")
|
||||
local cairo = require("lgi").cairo
|
||||
|
@ -32,10 +33,10 @@ local function screen_getbycoord(x, y)
|
|||
local geometry = screen[i].geometry
|
||||
if x >= geometry.x and x < geometry.x + geometry.width
|
||||
and y >= geometry.y and y < geometry.y + geometry.height then
|
||||
return i
|
||||
return capi.screen[i]
|
||||
end
|
||||
end
|
||||
return 1
|
||||
return capi.screen[1]
|
||||
end
|
||||
|
||||
-- Get the widget context. This should always return the same table (if
|
||||
|
|
|
@ -66,7 +66,7 @@ end
|
|||
--- Get the preferred size of a textbox.
|
||||
-- This returns the size that the textbox would use if infinite space were
|
||||
-- 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 height.
|
||||
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
|
||||
-- given 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.
|
||||
function textbox:get_height_for_width(width, s)
|
||||
return self:get_height_for_width_at_dpi(width, beautiful.xresources.get_dpi(s))
|
||||
|
|
Loading…
Reference in New Issue