wibox: Add screen properties

This commit is contained in:
Emmanuel Lepage Vallee 2016-05-10 00:01:35 -04:00
parent 0dcc545f35
commit a141dbfd06
1 changed files with 15 additions and 1 deletions

View File

@ -8,7 +8,8 @@
local capi = { local capi = {
drawin = drawin, drawin = drawin,
root = root, root = root,
awesome = awesome awesome = awesome,
screen = screen
} }
local setmetatable = setmetatable local setmetatable = setmetatable
local pairs = pairs local pairs = pairs
@ -16,6 +17,7 @@ local type = type
local object = require("gears.object") local object = require("gears.object")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local base = require("wibox.widget.base") local base = require("wibox.widget.base")
local ascreen = require("awful.screen")
--- This provides widget box windows. Every wibox can also be used as if it were --- This provides widget box windows. Every wibox can also be used as if it were
-- a drawin. All drawin functions and properties are also available on wiboxes! -- a drawin. All drawin functions and properties are also available on wiboxes!
@ -268,6 +270,18 @@ function wibox:find_widgets(x, y)
return self._drawable:find_widgets(x, y) return self._drawable:find_widgets(x, y)
end end
function wibox:get_screen()
return capi.screen[ascreen.getbycoord(self.x, self.y)]
end
function wibox:set_screen(s)
s = capi.screen[s or 1]
if s ~= self:get_screen() then
self.x = s.geometry.x
self.y = s.geometry.y
end
end
for _, k in pairs{ "buttons", "struts", "geometry", "get_xproperty", "set_xproperty" } do for _, k in pairs{ "buttons", "struts", "geometry", "get_xproperty", "set_xproperty" } do
wibox[k] = function(self, ...) wibox[k] = function(self, ...)
return self.drawin[k](self.drawin, ...) return self.drawin[k](self.drawin, ...)