diff --git a/awesomerc.lua b/awesomerc.lua index af58640a3..69f78132d 100755 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -91,7 +91,7 @@ end -- {{{ Wallpaper if beautiful.wallpaper then - gears.screen.connect_for_each_screen(function(s) + awful.screen.connect_for_each_screen(function(s) gears.wallpaper.maximized(beautiful.wallpaper, s, true) end) end @@ -100,7 +100,7 @@ end -- {{{ Tags -- Define a tag table which hold all screen tags. tags = {} -gears.screen.connect_for_each_screen(function(s) +awful.screen.connect_for_each_screen(function(s) -- Each screen has its own tag table. tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, awful.layout.layouts[1]) end) @@ -175,7 +175,7 @@ mytasklist.buttons = awful.util.table.join( awful.client.focus.byidx(-1) end)) -gears.screen.connect_for_each_screen(function(s) +awful.screen.connect_for_each_screen(function(s) -- Create a promptbox for each screen mypromptbox[s] = awful.widget.prompt() -- Create an imagebox widget which will contains an icon indicating which layout we're using. diff --git a/lib/awful/screen.lua b/lib/awful/screen.lua index 4d9c81fcb..c66626704 100644 --- a/lib/awful/screen.lua +++ b/lib/awful/screen.lua @@ -242,6 +242,22 @@ function screen.get_bounding_geometry(s, args) return geo end +--- Call a function for each existing and created-in-the-future screen. +-- @tparam function func The function to call. +-- @tparam screen func.screen The screen +function screen.connect_for_each_screen(func) + for s in capi.screen do + func(s) + end + capi.screen.connect_signal("added", func) +end + +--- Undo the effect of connect_for_each_screen. +-- @tparam function func The function that should no longer be called. +function screen.disconnect_for_each_screen(func) + capi.screen.disconnect_signal("added", func) +end + capi.screen.add_signal("padding") -- Extend the luaobject diff --git a/lib/gears/screen.lua b/lib/gears/screen.lua index fea8fd1ed..0baadf830 100644 --- a/lib/gears/screen.lua +++ b/lib/gears/screen.lua @@ -5,23 +5,23 @@ -- @classmod gears.screen --------------------------------------------------------------------------- -local screen = screen +local ascreen = require("awful.screen") +local util = require("awful.util") local module = {} --- Call a function for each existing and created-in-the-future screen. -- @tparam function func The function to call. function module.connect_for_each_screen(func) - for s in screen do - func(s) - end - screen.connect_signal("added", func) + util.deprecate("Use awful.screen.connect_for_each_screen") + ascreen.connect_for_each_screen(func) end --- Undo the effect of connect_for_each_screen. -- @tparam function func The function that should no longer be called. function module.disconnect_for_each_screen(func) - screen.disconnect_signal("added", func) + util.deprecate("Use awful.screen.disconnect_for_each_screen") + ascreen.disconnect_for_each_screen(func) end return module diff --git a/lib/gears/wallpaper.lua b/lib/gears/wallpaper.lua index 491d81241..ca4e4d8e0 100644 --- a/lib/gears/wallpaper.lua +++ b/lib/gears/wallpaper.lua @@ -14,7 +14,9 @@ local wallpaper = { mt = {} } -- The size of the root window local root_geom = { x = 0, y = 0, width = 0, height = 0 } -require("gears.screen").connect_for_each_screen(function(s) + +-- Gears should not depend on awful or C-API, this should be fixed eventually +require("awful.screen").connect_for_each_screen(function(s) local g = s.geometry root_geom.width = math.max(root_geom.width, g.x + g.width) root_geom.height = math.max(root_geom.height, g.y + g.height) diff --git a/lib/naughty/core.lua b/lib/naughty/core.lua index 7e1c38bfd..f28c95dde 100644 --- a/lib/naughty/core.lua +++ b/lib/naughty/core.lua @@ -143,7 +143,7 @@ local suspended = false -- @field id Unique notification id based on a counter -- @table notifications naughty.notifications = { suspended = { } } -require("gears.screen").connect_for_each_screen(function(s) +screen.connect_for_each_screen(function(s) naughty.notifications[s] = { top_left = {}, top_middle = {},