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.
This commit is contained in:
Emmanuel Lepage Vallee 2016-04-05 00:01:31 -04:00
parent b6810576b0
commit 8a0738a4bc
5 changed files with 29 additions and 11 deletions

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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 = {},