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 -- {{{ Wallpaper
if beautiful.wallpaper then 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) gears.wallpaper.maximized(beautiful.wallpaper, s, true)
end) end)
end end
@ -100,7 +100,7 @@ end
-- {{{ Tags -- {{{ Tags
-- Define a tag table which hold all screen tags. -- Define a tag table which hold all screen tags.
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. -- 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]) tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, awful.layout.layouts[1])
end) end)
@ -175,7 +175,7 @@ mytasklist.buttons = awful.util.table.join(
awful.client.focus.byidx(-1) awful.client.focus.byidx(-1)
end)) end))
gears.screen.connect_for_each_screen(function(s) awful.screen.connect_for_each_screen(function(s)
-- Create a promptbox for each screen -- Create a promptbox for each screen
mypromptbox[s] = awful.widget.prompt() mypromptbox[s] = awful.widget.prompt()
-- Create an imagebox widget which will contains an icon indicating which layout we're using. -- 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 return geo
end 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") capi.screen.add_signal("padding")
-- Extend the luaobject -- Extend the luaobject

View File

@ -5,23 +5,23 @@
-- @classmod gears.screen -- @classmod gears.screen
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
local screen = screen local ascreen = require("awful.screen")
local util = require("awful.util")
local module = {} local module = {}
--- Call a function for each existing and created-in-the-future screen. --- Call a function for each existing and created-in-the-future screen.
-- @tparam function func The function to call. -- @tparam function func The function to call.
function module.connect_for_each_screen(func) function module.connect_for_each_screen(func)
for s in screen do util.deprecate("Use awful.screen.connect_for_each_screen")
func(s) ascreen.connect_for_each_screen(func)
end
screen.connect_signal("added", func)
end end
--- Undo the effect of connect_for_each_screen. --- Undo the effect of connect_for_each_screen.
-- @tparam function func The function that should no longer be called. -- @tparam function func The function that should no longer be called.
function module.disconnect_for_each_screen(func) 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 end
return module return module

View File

@ -14,7 +14,9 @@ local wallpaper = { mt = {} }
-- The size of the root window -- The size of the root window
local root_geom = { x = 0, y = 0, width = 0, height = 0 } 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 local g = s.geometry
root_geom.width = math.max(root_geom.width, g.x + g.width) root_geom.width = math.max(root_geom.width, g.x + g.width)
root_geom.height = math.max(root_geom.height, g.y + g.height) 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 -- @field id Unique notification id based on a counter
-- @table notifications -- @table notifications
naughty.notifications = { suspended = { } } naughty.notifications = { suspended = { } }
require("gears.screen").connect_for_each_screen(function(s) screen.connect_for_each_screen(function(s)
naughty.notifications[s] = { naughty.notifications[s] = {
top_left = {}, top_left = {},
top_middle = {}, top_middle = {},