awful.menu: Fix menu hide/show overloading
[awesome.git] / lib / awful / screen.lua.in
blob0ca10fd349da768c0076e5d97574ddda5193c54c
1 ---------------------------------------------------------------------------
2 -- @author Julien Danjou <julien@danjou.info>
3 -- @copyright 2008 Julien Danjou
4 -- @release @AWESOME_VERSION@
5 ---------------------------------------------------------------------------
7 -- Grab environment we need
8 local capi =
10 mouse = mouse,
11 screen = screen,
12 client = client
14 local util = require("awful.util")
15 local client = require("awful.client")
17 --- Screen module for awful
18 module("awful.screen")
20 local data = {}
21 data.padding = {}
23 --- Give the focus to a screen, and move pointer.
24 -- @param screen Screen number.
25 function focus(screen)
26 if screen > capi.screen.count() then screen = capi.mouse.screen end
27 local c = client.focus.history.get(screen, 0)
28 if c then capi.client.focus = c end
29 -- Move the mouse on the screen
30 capi.mouse.screen = screen
31 end
33 --- Give the focus to a screen, and move pointer, but relative to the current
34 -- focused screen.
35 -- @param i Value to add to the current focused screen index. 1 will focus next
36 -- screen, -1 would focus the previous one.
37 function focus_relative(i)
38 return focus(util.cycle(capi.screen.count(), capi.mouse.screen + i))
39 end
41 --- Get or set the screen padding.
42 -- @param screen The screen object to change the padding on
43 -- @param padding The padding, an table with 'top', 'left', 'right' and/or
44 -- 'bottom'. Can be nil if you only want to retrieve padding
45 function padding(screen, padding)
46 if padding then
47 data.padding[screen] = padding
48 screen:emit_signal("padding")
49 end
50 return data.padding[screen]
51 end
53 -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80