awesome/lib/awful/screen.lua.in
Uli Schlachter ab4c151ed8 Add signals before using them
This commit makes it an error if an unknown signal is connected, disconnected or
emitted. All signals have to be added before they can be used.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2010-08-25 23:00:36 +02:00

57 lines
1.7 KiB
Lua

---------------------------------------------------------------------------
-- @author Julien Danjou &lt;julien@danjou.info&gt;
-- @copyright 2008 Julien Danjou
-- @release @AWESOME_VERSION@
---------------------------------------------------------------------------
-- Grab environment we need
local capi =
{
mouse = mouse,
screen = screen,
client = client
}
local util = require("awful.util")
local client = require("awful.client")
--- Screen module for awful
module("awful.screen")
local data = {}
data.padding = {}
--- Give the focus to a screen, and move pointer.
-- @param screen Screen number.
function focus(screen)
if screen > capi.screen.count() then screen = capi.mouse.screen end
local c = client.focus.history.get(screen, 0)
if c then capi.client.focus = c end
-- Move the mouse on the screen
capi.mouse.screen = screen
end
--- Give the focus to a screen, and move pointer, but relative to the current
-- focused screen.
-- @param i Value to add to the current focused screen index. 1 will focus next
-- screen, -1 would focus the previous one.
function focus_relative(i)
return focus(util.cycle(capi.screen.count(), capi.mouse.screen + i))
end
--- Get or set the screen padding.
-- @param screen The screen object to change the padding on
-- @param padding The padding, an table with 'top', 'left', 'right' and/or
-- 'bottom'. Can be nil if you only want to retrieve padding
function padding(screen, padding)
if padding then
data.padding[screen] = padding
screen:emit_signal("padding")
end
return data.padding[screen]
end
for s = 1, capi.screen.count() do
capi.screen[s]:add_signal("padding")
end
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80