From 8a0738a4bc2195b7dae97831a2e71307029cee1b Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Tue, 5 Apr 2016 00:01:31 -0400 Subject: [PATCH] gears.screen: Merge into awful.screen gears modules usually don't depend on Awesome C-API. This code has been placed there for unclear reasons. Also, there is ongoing work to unify each "concepts" API into one single page. Having `gears.screen` go against this effort. --- awesomerc.lua | 6 +++--- lib/awful/screen.lua | 16 ++++++++++++++++ lib/gears/screen.lua | 12 ++++++------ lib/gears/wallpaper.lua | 4 +++- lib/naughty/core.lua | 2 +- 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/awesomerc.lua b/awesomerc.lua index af58640a..69f78132 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 4d9c81fc..c6662670 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 fea8fd1e..0baadf83 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 491d8124..ca4e4d8e 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 7e1c38bf..f28c95dd 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 = {},