Merge pull request #780 from psychon/screen-add-signal
Add screen add signal
This commit is contained in:
commit
3ad0a9d8d2
|
@ -643,9 +643,6 @@ main(int argc, char **argv)
|
|||
/* init atom cache */
|
||||
atoms_init(globalconf.connection);
|
||||
|
||||
/* init screens information */
|
||||
screen_scan();
|
||||
|
||||
/* do this only for real screen */
|
||||
ewmh_init();
|
||||
systray_init();
|
||||
|
@ -702,6 +699,9 @@ main(int argc, char **argv)
|
|||
|
||||
xdgWipeHandle(&xdg);
|
||||
|
||||
/* init screens information */
|
||||
screen_scan();
|
||||
|
||||
/* scan existing windows */
|
||||
scan(tree_c);
|
||||
|
||||
|
|
|
@ -91,19 +91,19 @@ end
|
|||
|
||||
-- {{{ Wallpaper
|
||||
if beautiful.wallpaper then
|
||||
for s in screen do
|
||||
gears.screen.connect_for_each_screen(function(s)
|
||||
gears.wallpaper.maximized(beautiful.wallpaper, s, true)
|
||||
end
|
||||
end)
|
||||
end
|
||||
-- }}}
|
||||
|
||||
-- {{{ Tags
|
||||
-- Define a tag table which hold all screen tags.
|
||||
tags = {}
|
||||
for s in screen do
|
||||
gears.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
|
||||
end)
|
||||
-- }}}
|
||||
|
||||
-- {{{ Menu
|
||||
|
@ -175,7 +175,7 @@ mytasklist.buttons = awful.util.table.join(
|
|||
awful.client.focus.byidx(-1)
|
||||
end))
|
||||
|
||||
for s in screen do
|
||||
gears.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.
|
||||
|
@ -213,7 +213,7 @@ for s in screen do
|
|||
mylayoutbox[s],
|
||||
},
|
||||
}
|
||||
end
|
||||
end)
|
||||
-- }}}
|
||||
|
||||
-- {{{ Mouse bindings
|
||||
|
|
|
@ -18,6 +18,7 @@ return
|
|||
matrix = require("gears.matrix");
|
||||
shape = require("gears.shape");
|
||||
protected_call = require("gears.protected_call");
|
||||
screen = require("gears.screen");
|
||||
}
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
---------------------------------------------------------------------------
|
||||
-- @author Uli Schlachter
|
||||
-- @copyright 2016 Uli Schlachter
|
||||
-- @release @AWESOME_VERSION@
|
||||
-- @classmod gears.screen
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
local screen = screen
|
||||
|
||||
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)
|
||||
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)
|
||||
end
|
||||
|
||||
return module
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
|
@ -13,20 +13,12 @@ local timer = require("gears.timer")
|
|||
local wallpaper = { mt = {} }
|
||||
|
||||
-- The size of the root window
|
||||
local root_geom
|
||||
do
|
||||
local geom = screen[1].geometry
|
||||
root_geom = {
|
||||
x = 0, y = 0,
|
||||
width = geom.x + geom.width,
|
||||
height = geom.y + geom.height
|
||||
}
|
||||
for s in screen do
|
||||
local g = screen[s].geometry
|
||||
local root_geom = { x = 0, y = 0, width = 0, height = 0 }
|
||||
require("gears.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)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- A cairo surface that we still want to set as the wallpaper
|
||||
local pending_wallpaper = nil
|
||||
|
|
|
@ -143,8 +143,8 @@ local suspended = false
|
|||
-- @field id Unique notification id based on a counter
|
||||
-- @table notifications
|
||||
naughty.notifications = { suspended = { } }
|
||||
for s in capi.screen do
|
||||
naughty.notifications[get_screen(s)] = {
|
||||
require("gears.screen").connect_for_each_screen(function(s)
|
||||
naughty.notifications[s] = {
|
||||
top_left = {},
|
||||
top_middle = {},
|
||||
top_right = {},
|
||||
|
@ -152,7 +152,7 @@ for s in capi.screen do
|
|||
bottom_middle = {},
|
||||
bottom_right = {},
|
||||
}
|
||||
end
|
||||
end)
|
||||
|
||||
--- Notification state
|
||||
function naughty.is_suspended()
|
||||
|
|
|
@ -145,8 +145,12 @@ screen_add(lua_State *L, int sidx)
|
|||
return;
|
||||
}
|
||||
|
||||
sidx = luaA_absindex(L, sidx);
|
||||
lua_pushvalue(L, sidx);
|
||||
luaA_object_ref(L, sidx);
|
||||
screen_array_append(&globalconf.screens, new_screen);
|
||||
luaA_object_emit_signal(L, -1, "added", 0);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -755,6 +759,11 @@ screen_class_setup(lua_State *L)
|
|||
* @signal primary_changed
|
||||
*/
|
||||
signal_add(&screen_class.signals, "primary_changed");
|
||||
/**
|
||||
* This signal is emitted when a new screen is added to the current setup.
|
||||
* @signal added
|
||||
*/
|
||||
signal_add(&screen_class.signals, "added");
|
||||
}
|
||||
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
Loading…
Reference in New Issue