diff --git a/awesomerc.lua.in b/awesomerc.lua.in
index a2044bce5..2385f9473 100644
--- a/awesomerc.lua.in
+++ b/awesomerc.lua.in
@@ -1,7 +1,7 @@
-- Standard awesome library
-require("awful")
+local awful = require("awful")
+awful.rules = require("awful.rules")
require("awful.autofocus")
-require("awful.rules")
-- Widget and layout library
local wibox = require("wibox")
-- Theme handling library
diff --git a/lib/awful/autofocus.lua.in b/lib/awful/autofocus.lua.in
index e551a633a..f697ff610 100644
--- a/lib/awful/autofocus.lua.in
+++ b/lib/awful/autofocus.lua.in
@@ -11,7 +11,7 @@ local atag = require("awful.tag")
--- When loaded, this module makes sure that there's always a client that will have focus
-- on event such as tag switching, client unmanaging, etc.
-module("awful.autofocus")
+-- awful.autofocus
-- Give focus when clients appear/disappear.
-- @param obj An object that should have a .screen property.
diff --git a/lib/awful/button.lua.in b/lib/awful/button.lua.in
index 049d38c00..1d3b31c3a 100644
--- a/lib/awful/button.lua.in
+++ b/lib/awful/button.lua.in
@@ -11,7 +11,8 @@ local capi = { button = button }
local util = require("awful.util")
--- Create easily new buttons objects ignoring certain modifiers.
-module("awful.button")
+-- awful.button
+local button = { mt = {} }
--- Modifiers to ignore.
-- By default this is initialized as { "Lock", "Mod2" }
@@ -19,7 +20,7 @@ module("awful.button")
-- when pressing keys.
-- @name ignore_modifiers
-- @class table
-ignore_modifiers = { "Lock", "Mod2" }
+local ignore_modifiers = { "Lock", "Mod2" }
--- Create a new button to use as binding.
-- This function is useful to create several buttons from one, because it will use
@@ -31,12 +32,12 @@ ignore_modifiers = { "Lock", "Mod2" }
-- CapsLock off.
-- @see button
-- @return A table with one or several button objects.
-function new(mod, button, press, release)
+function button.new(mod, _button, press, release)
local ret = {}
local subsets = util.subsets(ignore_modifiers)
for _, set in ipairs(subsets) do
ret[#ret + 1] = capi.button({ modifiers = util.table.join(mod, set),
- button = button })
+ button = _button })
if press then
ret[#ret]:connect_signal("press", function(bobj, ...) press(...) end)
end
@@ -47,6 +48,10 @@ function new(mod, button, press, release)
return ret
end
-setmetatable(_M, { __call = function(_, ...) return new(...) end })
+function button.mt:__call(...)
+ return button.new(...)
+end
+
+return setmetatable(button, button.mt)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
diff --git a/lib/awful/client.lua.in b/lib/awful/client.lua.in
index 1a86634cc..35fa8f554 100644
--- a/lib/awful/client.lua.in
+++ b/lib/awful/client.lua.in
@@ -21,30 +21,31 @@ local capi =
}
--- Useful client manipulation functions.
-module("awful.client")
+-- awful.client
+local client = {}
-- Private data
-data = {}
-data.focus = {}
-data.urgent = {}
-data.marked = {}
-data.properties = setmetatable({}, { __mode = 'k' })
+client.data = {}
+client.data.focus = {}
+client.data.urgent = {}
+client.data.marked = {}
+client.data.properties = setmetatable({}, { __mode = 'k' })
-- Functions
-urgent = {}
-focus = {}
-focus.history = {}
-swap = {}
-floating = {}
-dockable = {}
-property = {}
+client.urgent = {}
+client.focus = {}
+client.focus.history = {}
+client.swap = {}
+client.floating = {}
+client.dockable = {}
+client.property = {}
---
-- Jump to the given client. Takes care of focussing the screen, the right tag,
-- etc.
-- @param c the client to jump to
-- @param merge If true then merge tags when clients are not visible.
-function jumpto(c, merge)
+function client.jumpto(c, merge)
local s = capi.client.focus and capi.client.focus.screen or capi.mouse.screen
-- focus the screen
if s ~= c.screen then
@@ -68,9 +69,9 @@ end
--- Get the first client that got the urgent hint.
-- @return The first urgent client.
-function urgent.get()
- if #data.urgent > 0 then
- return data.urgent[1]
+function client.urgent.get()
+ if #client.data.urgent > 0 then
+ return client.data.urgent[1]
else
-- fallback behaviour: iterate through clients and get the first urgent
local clients = capi.client.get()
@@ -84,28 +85,28 @@ end
--- Jump to the client that received the urgent hint first.
-- @param merge If true then merge tags when clients are not visible.
-function urgent.jumpto(merge)
- local c = urgent.get()
+function client.urgent.jumpto(merge)
+ local c = client.urgent.get()
if c then
- jumpto(c, merge)
+ client.jumpto(c, merge)
end
end
--- Adds client to urgent stack.
-- @param c The client object.
-- @param prop The property which is updated.
-function urgent.add(c, prop)
+function client.urgent.add(c, prop)
if type(c) == "client" and prop == "urgent" and c.urgent then
- table.insert(data.urgent, c)
+ table.insert(client.data.urgent, c)
end
end
--- Remove client from urgent stack.
-- @param c The client object.
-function urgent.delete(c)
- for k, cl in ipairs(data.urgent) do
+function client.urgent.delete(c)
+ for k, cl in ipairs(client.data.urgent) do
if c == cl then
- table.remove(data.urgent, k)
+ table.remove(client.data.urgent, k)
break
end
end
@@ -113,10 +114,10 @@ end
--- Remove a client from the focus history
-- @param c The client that must be removed.
-function focus.history.delete(c)
- for k, v in ipairs(data.focus) do
+function client.focus.history.delete(c)
+ for k, v in ipairs(client.data.focus) do
if v == c then
- table.remove(data.focus, k)
+ table.remove(client.data.focus, k)
break
end
end
@@ -127,7 +128,7 @@ end
-- not registered and cannot get focus.
-- @param c A client.
-- @return The same client if it's ok, nil otherwise.
-function focus.filter(c)
+function client.focus.filter(c)
if c.type == "desktop"
or c.type == "dock"
or c.type == "splash"
@@ -139,11 +140,11 @@ end
--- Update client focus history.
-- @param c The client that has been focused.
-function focus.history.add(c)
+function client.focus.history.add(c)
-- Remove the client if its in stack
- focus.history.delete(c)
+ client.focus.history.delete(c)
-- Record the client has latest focused
- table.insert(data.focus, 1, c)
+ table.insert(client.data.focus, 1, c)
end
--- Get the latest focused client for a screen in history.
@@ -151,11 +152,11 @@ end
-- @param idx The index: 0 will return first candidate,
-- 1 will return second, etc.
-- @return A client.
-function focus.history.get(screen, idx)
+function client.focus.history.get(screen, idx)
-- When this counter is equal to idx, we return the client
local counter = 0
- local vc = visible(screen)
- for k, c in ipairs(data.focus) do
+ local vc = client.visible(screen)
+ for k, c in ipairs(client.data.focus) do
if c.screen == screen then
for j, vcc in ipairs(vc) do
if vcc == c then
@@ -173,7 +174,7 @@ function focus.history.get(screen, idx)
-- that passes the filter.
if counter == 0 then
for k, v in ipairs(vc) do
- if focus.filter(v) then
+ if client.focus.filter(v) then
return v
end
end
@@ -181,7 +182,7 @@ function focus.history.get(screen, idx)
end
--- Focus the previous client in history.
-function focus.history.previous()
+function client.focus.history.previous()
local sel = capi.client.focus
local s
if sel then
@@ -189,14 +190,14 @@ function focus.history.previous()
else
s = capi.mouse.screen
end
- local c = focus.history.get(s, 1)
+ local c = client.focus.history.get(s, 1)
if c then capi.client.focus = c end
end
--- Get visible clients from a screen.
-- @param screen The screen number, or nil for all screens.
-- @return A table with all visible clients.
-function visible(screen)
+function client.visible(screen)
local cls = capi.client.get(screen)
local vcls = {}
for k, c in pairs(cls) do
@@ -210,12 +211,12 @@ end
--- Get visible and tiled clients
-- @param screen The screen number, or nil for all screens.
-- @return A tabl with all visible and tiled clients.
-function tiled(screen)
- local clients = visible(screen)
+function client.tiled(screen)
+ local clients = client.visible(screen)
local tclients = {}
-- Remove floating clients
for k, c in pairs(clients) do
- if not floating.get(c) then
+ if not client.floating.get(c) then
table.insert(tclients, c)
end
end
@@ -227,16 +228,16 @@ end
-- @param i The index.
-- @param c Optional client.
-- @return A client, or nil if no client is available.
-function next(i, c)
+function client.next(i, c)
-- Get currently focused client
local sel = c or capi.client.focus
if sel then
-- Get all visible clients
- local cls = visible(sel.screen)
+ local cls = client.visible(sel.screen)
local fcls = {}
-- Remove all non-normal clients
for idx, c in ipairs(cls) do
- if focus.filter(c) or c == sel then
+ if client.focus.filter(c) or c == sel then
table.insert(fcls, c)
end
end
@@ -307,7 +308,7 @@ local function get_client_in_direction(dir, c)
local geometry = sel:geometry()
local dist, dist_min
local target = nil
- local cls = visible(sel.screen)
+ local cls = client.visible(sel.screen)
-- We check each client.
for i, c in ipairs(cls) do
@@ -332,7 +333,7 @@ end
--- Focus a client by the given direction.
-- @param dir The direction, can be either "up", "down", "left" or "right".
-- @param c Optional client.
-function focus.bydirection(dir, c)
+function client.focus.bydirection(dir, c)
local sel = c or capi.client.focus
if sel then
local target = get_client_in_direction(dir, sel)
@@ -347,8 +348,8 @@ end
--- Focus a client by its relative index.
-- @param i The index.
-- @param c Optional client.
-function focus.byidx(i, c)
- local target = next(i, c)
+function client.focus.byidx(i, c)
+ local target = client.next(i, c)
if target then
capi.client.focus = target
end
@@ -357,7 +358,7 @@ end
--- Swap a client with another client in the given direction
-- @param dir The direction, can be either "up", "down", "left" or "right".
-- @param c Optional client.
-function swap.bydirection(dir, c)
+function client.swap.bydirection(dir, c)
local sel = c or capi.client.focus
if sel then
local target = get_client_in_direction(dir, sel)
@@ -372,7 +373,7 @@ end
--- Swap a client by its relative index.
-- @param i The index.
-- @param c Optional client, otherwise focused one is used.
-function swap.byidx(i, c)
+function client.swap.byidx(i, c)
local sel = c or capi.client.focus
local target = next(i, sel)
if target then
@@ -383,9 +384,9 @@ end
--- Cycle clients.
-- @param clockwise True to cycle clients clockwise.
-- @param screen Optional screen where to cycle clients.
-function cycle(clockwise, screen)
+function client.cycle(clockwise, screen)
local screen = screen or capi.mouse.screen
- local cls = visible(screen)
+ local cls = client.visible(screen)
-- We can't rotate without at least 2 clients, buddy.
if #cls >= 2 then
local c = table.remove(cls, 1)
@@ -404,14 +405,14 @@ end
--- Get the master window.
-- @param screen Optional screen number, otherwise screen mouse is used.
-- @return The master window.
-function getmaster(screen)
+function client.getmaster(screen)
local s = screen or capi.mouse.screen
- return visible(s)[1]
+ return client.visible(s)[1]
end
--- Set the client as slave: put it at the end of other windows.
-- @param c The window to set as slave.
-function setslave(c)
+function client.setslave(c)
local cls = capi.client.get(c.screen)
for k, v in pairs(cls) do
c:swap(v)
@@ -424,7 +425,7 @@ end
-- @param w The relative width.
-- @param h The relative height.
-- @param c The optional client, otherwise focused one is used.
-function moveresize(x, y, w, h, c)
+function client.moveresize(x, y, w, h, c)
local sel = c or capi.client.focus
local geometry = sel:geometry()
geometry['x'] = geometry['x'] + x
@@ -437,7 +438,7 @@ end
--- Move a client to a tag.
-- @param target The tag to move the client to.
-- @param c Optional client to move, otherwise the focused one is used.
-function movetotag(target, c)
+function client.movetotag(target, c)
local sel = c or capi.client.focus
if sel and target.screen then
-- Set client on the same screen as the tag.
@@ -449,7 +450,7 @@ end
--- Toggle a tag on a client.
-- @param target The tag to toggle.
-- @param c Optional client to toggle, otherwise the focused one is used.
-function toggletag(target, c)
+function client.toggletag(target, c)
local sel = c or capi.client.focus
-- Check that tag and client screen are identical
if sel and sel.screen == target.screen then
@@ -475,7 +476,7 @@ end
--- Move a client to a screen. Default is next screen, cycling.
-- @param c The client to move.
-- @param s The screen number, default to current + 1.
-function movetoscreen(c, s)
+function client.movetoscreen(c, s)
local sel = c or capi.client.focus
if sel then
local sc = capi.screen.count()
@@ -491,16 +492,16 @@ end
--- Mark a client, and then call 'marked' hook.
-- @param c The client to mark, the focused one if not specified.
-- @return True if the client has been marked. False if the client was already marked.
-function mark(c)
+function client.mark(c)
local cl = c or capi.client.focus
if cl then
- for k, v in pairs(data.marked) do
+ for k, v in pairs(client.data.marked) do
if cl == v then
return false
end
end
- table.insert(data.marked, cl)
+ table.insert(client.data.marked, cl)
-- Call callback
cl:emit_signal("marked")
@@ -511,12 +512,12 @@ end
--- Unmark a client and then call 'unmarked' hook.
-- @param c The client to unmark, or the focused one if not specified.
-- @return True if the client has been unmarked. False if the client was not marked.
-function unmark(c)
+function client.unmark(c)
local cl = c or capi.client.focus
- for k, v in pairs(data.marked) do
+ for k, v in pairs(client.data.marked) do
if cl == v then
- table.remove(data.marked, k)
+ table.remove(client.data.marked, k)
cl:emit_signal("unmarked")
return true
end
@@ -527,10 +528,10 @@ end
--- Check if a client is marked.
-- @param c The client to check, or the focused one otherwise.
-function ismarked(c)
+function client.ismarked(c)
local cl = c or capi.client.focus
if cl then
- for k, v in pairs(data.marked) do
+ for k, v in pairs(client.data.marked) do
if cl == v then
return true
end
@@ -541,23 +542,23 @@ end
--- Toggle a client as marked.
-- @param c The client to toggle mark.
-function togglemarked(c)
+function client.togglemarked(c)
local cl = c or capi.client.focus
- if not mark(c) then
- unmark(c)
+ if not client.mark(c) then
+ client.unmark(c)
end
end
--- Return the marked clients and empty the marked table.
-- @return A table with all marked clients.
-function getmarked()
- for k, v in pairs(data.marked) do
+function client.getmarked()
+ for k, v in pairs(client.data.marked) do
v:emit_signal("unmarked")
end
- t = data.marked
- data.marked = {}
+ t = client.data.marked
+ client.data.marked = {}
return t
end
@@ -565,28 +566,28 @@ end
-- Floating client are not handled by tiling layouts.
-- @param c A client.
-- @param s True or false.
-function floating.set(c, s)
+function client.floating.set(c, s)
local c = c or capi.client.focus
- if c and property.get(c, "floating") ~= s then
- property.set(c, "floating", s)
+ if c and client.property.get(c, "floating") ~= s then
+ client.property.set(c, "floating", s)
local screen = c.screen
if s == true then
- c:geometry(property.get(c, "floating_geometry"))
+ c:geometry(client.property.get(c, "floating_geometry"))
end
c.screen = screen
end
end
local function store_floating_geometry(c)
- if floating.get(c) then
- property.set(c, "floating_geometry", c:geometry())
+ if client.floating.get(c) then
+ client.property.set(c, "floating_geometry", c:geometry())
end
end
-- Store the initial client geometry.
capi.client.connect_signal("new", function(c)
local function store_init_geometry(c)
- property.set(c, "floating_geometry", c:geometry())
+ client.property.set(c, "floating_geometry", c:geometry())
c:disconnect_signal("property::border_width", store_init_geometry)
end
c:connect_signal("property::border_width", store_init_geometry)
@@ -598,7 +599,7 @@ end)
--- Return if a client has a fixe size or not.
-- @param c The client.
-function isfixed(c)
+function client.isfixed(c)
local c = c or capi.client.focus
if not c then return end
local h = c.size_hints
@@ -618,10 +619,10 @@ end
-- @return True or false. Note that some windows might be floating even if you
-- did not set them manually. For example, windows with a type different than
-- normal.
-function floating.get(c)
+function client.floating.get(c)
local c = c or capi.client.focus
if c then
- local value = property.get(c, "floating")
+ local value = client.property.get(c, "floating")
if value ~= nil then
return value
end
@@ -629,7 +630,7 @@ function floating.get(c)
or c.fullscreen
or c.maximized_vertical
or c.maximized_horizontal
- or isfixed(c) then
+ or client.isfixed(c) then
return true
end
return false
@@ -638,26 +639,26 @@ end
--- Toggle the floating state of a client between 'auto' and 'true'.
-- @param c A client.
-function floating.toggle(c)
+function client.floating.toggle(c)
local c = c or capi.client.focus
-- If it has been set to floating
- if floating.get(c) then
- floating.set(c, false)
+ if client.floating.get(c) then
+ client.floating.set(c, false)
else
- floating.set(c, true)
+ client.floating.set(c, true)
end
end
--- Remove the floating information on a client.
-- @param c The client.
-function floating.delete(c)
- floating.set(c, nil)
+function client.floating.delete(c)
+ client.floating.set(c, nil)
end
--- Restore (=unminimize) a random client.
-- @param s The screen to use.
-- @return True if some client was restored.
-function restore(s)
+function client.restore(s)
local s = s or (capi.client.focus and capi.client.focus.screen) or capi.mouse.screen
local cls = capi.client.get(s)
local tags = tag.selectedlist(s)
@@ -706,11 +707,11 @@ end
-- @return col the column number
-- @return idx index of the client in the column
-- @return num the number of visible clients in the column
-function idx(c)
+function client.idx(c)
local c = c or capi.client.focus
if not c then return end
- local clients = tiled(c.screen)
+ local clients = client.tiled(c.screen)
local idx = nil
for k, cl in ipairs(clients) do
if cl == c then
@@ -758,15 +759,15 @@ end
--- Set the window factor of a client
-- @param wfact the window factor value
-- @param c the client
-function setwfact(wfact, c)
+function client.setwfact(wfact, c)
-- get the currently selected window
local c = c or capi.client.focus
if not c or not c:isvisible() then return end
local t = tag.selected(c.screen)
- local w = idx(c)
+ local w = client.idx(c)
- local cls = tiled(t.screen)
+ local cls = client.tiled(t.screen)
local nmaster = tag.getnmaster(t)
-- n is the number of windows currently visible for which we have to be concerned with the properties
@@ -797,13 +798,13 @@ end
--- Increment a client's window factor
-- @param add amount to increase the client's window
-- @param c the client
-function incwfact(add, c)
+function client.incwfact(add, c)
local c = c or capi.client.focus
if not c then return end
local t = tag.selected(c.screen)
- local w = idx(c)
+ local w = client.idx(c)
local nmaster = tag.getnmaster(t)
local data = tag.getproperty(t, "windowfact") or {}
@@ -822,8 +823,8 @@ end
-- @return True or false. Note that some windows might be dockable even if you
-- did not set them manually. For example, windows with a type "utility", "toolbar"
-- or "dock"
-function dockable.get(c)
- local value = property.get(c, "dockable")
+function client.dockable.get(c)
+ local value = client.property.get(c, "dockable")
-- Some sane defaults
if value == nil then
@@ -842,17 +843,17 @@ end
-- to the edge of the workarea.
-- @param c A client.
-- @param value True or false.
-function dockable.set(c, value)
- property.set(c, "dockable", value)
+function client.dockable.set(c, value)
+ client.property.set(c, "dockable", value)
end
--- Get a client property.
-- @param c The client.
-- @param prop The property name.
-- @return The property.
-function property.get(c, prop)
- if data.properties[c] then
- return data.properties[c][prop]
+function client.property.get(c, prop)
+ if client.data.properties[c] then
+ return client.data.properties[c][prop]
end
end
@@ -861,11 +862,11 @@ end
-- @param c The client.
-- @param prop The property name.
-- @param value The value.
-function property.set(c, prop, value)
- if not data.properties[c] then
- data.properties[c] = {}
+function client.property.set(c, prop, value)
+ if not client.data.properties[c] then
+ client.data.properties[c] = {}
end
- data.properties[c][prop] = value
+ client.data.properties[c][prop] = value
c:emit_signal("property::" .. prop)
end
@@ -888,7 +889,7 @@ end
-- c.minimized = false
-- end
--
You should fill this table with your rule and properties to apply.
@@ -100,13 +101,13 @@ module("awful.rules")
--
-- @class table
-- @name rules
-rules = {}
+rules.rules = {}
--- Check if a client match a rule.
-- @param c The client.
-- @param rule The rule to check.
-- @return True if it matches, false otherwise.
-function match(c, rule)
+function rules.match(c, rule)
if not rule then return false end
for field, value in pairs(rule) do
if c[field] then
@@ -128,7 +129,7 @@ end
-- @param c The client.
-- @param rules The rule to check.
-- @return True if at least one rule is matched, false otherwise.
-function match_any(c, rule)
+function rules.match_any(c, rule)
if not rule then return false end
for field, values in pairs(rule) do
if c[field] then
@@ -146,12 +147,12 @@ end
--- Apply rules to a client.
-- @param c The client.
-function apply(c)
+function rules.apply(c)
local props = {}
local callbacks = {}
- for _, entry in ipairs(rules) do
- if (match(c, entry.rule) or match_any(c, entry.rule_any)) and
- (not match(c, entry.except) and not match_any(c, entry.except_any)) then
+ for _, entry in ipairs(rules.rules) do
+ if (rules.match(c, entry.rule) or rules.match_any(c, entry.rule_any)) and
+ (not rules.match(c, entry.except) and not rules.match_any(c, entry.except_any)) then
if entry.properties then
for property, value in pairs(entry.properties) do
props[property] = value
@@ -202,7 +203,9 @@ function apply(c)
end
end
-client.connect_signal("manage", apply)
+client.connect_signal("manage", rules.apply)
client.disconnect_signal("manage", atag.withcurrent)
+return rules
+
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
diff --git a/lib/awful/screen.lua.in b/lib/awful/screen.lua.in
index 9fba87b8b..d9a46258c 100644
--- a/lib/awful/screen.lua.in
+++ b/lib/awful/screen.lua.in
@@ -15,7 +15,8 @@ local util = require("awful.util")
local client = require("awful.client")
--- Screen module for awful
-module("awful.screen")
+-- awful.screen
+local screen = {}
local data = {}
data.padding = {}
@@ -26,7 +27,7 @@ data.padding = {}
-- `screen` table/object.
-- @param x The x coordinate
-- @param y The y coordinate
-function getbycoord(x, y)
+function screen.getbycoord(x, y)
for i = 1, capi.screen:count() do
local geometry = capi.screen[i].geometry
if((x < 0 or (x >= geometry.x and x < geometry.x + geometry.width))
@@ -38,36 +39,38 @@ end
--- 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)
+function screen.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
+ 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))
+function screen.focus_relative(i)
+ return screen.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)
+function screen.padding(_screen, padding)
if padding then
- data.padding[screen] = padding
- screen:emit_signal("padding")
+ data.padding[_screen] = padding
+ _screen:emit_signal("padding")
end
- return data.padding[screen]
+ return data.padding[_screen]
end
for s = 1, capi.screen.count() do
capi.screen[s]:add_signal("padding")
end
+return screen
+
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
diff --git a/lib/awful/startup_notification.lua.in b/lib/awful/startup_notification.lua.in
index be5420ba8..80a0a3677 100644
--- a/lib/awful/startup_notification.lua.in
+++ b/lib/awful/startup_notification.lua.in
@@ -14,11 +14,11 @@ local capi =
}
--- Startup notification module for awful
-module("awful.startup_notification")
+-- awful.startup_notification
local app_starting = {}
-cursor_waiting = "watch"
+local cursor_waiting = "watch"
local function update_cursor()
if #app_starting > 0 then
diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in
index 06d7fb034..56fb8d686 100644
--- a/lib/awful/tag.lua.in
+++ b/lib/awful/tag.lua.in
@@ -20,7 +20,8 @@ local capi =
}
--- Useful functions for tag manipulation.
-module("awful.tag")
+-- awful.tag
+local tag = { mt = {} }
-- Private data
local data = {}
@@ -28,13 +29,13 @@ data.history = {}
data.tags = setmetatable({}, { __mode = 'k' })
-- History functions
-history = {}
-history.limit = 20
+tag.history = {}
+tag.history.limit = 20
--- Move a tag to an absolute position in the screen[]:tags() table.
-- @param new_index Integer absolute position in the table to insert.
-function move(new_index, target_tag)
- local target_tag = target_tag or selected()
+function tag.move(new_index, target_tag)
+ local target_tag = target_tag or tag.selected()
local scr = target_tag.screen
local tmp_tags = capi.screen[scr]:tags()
@@ -57,13 +58,13 @@ end
-- @param name The tag name, a string
-- @param props The tags properties, a table
-- @return The created tag
-function add(name, props)
+function tag.add(name, props)
local properties = props or {}
local newtag = capi.tag{name = name}
newtag.screen = properties.screen or capi.mouse.screen
for k, v in pairs(properties) do
- setproperty(newtag, k, v)
+ tag.setproperty(newtag, k, v)
end
return newtag
@@ -74,11 +75,11 @@ end
-- @param screen The tag screen, or 1 if not set.
-- @param layout The layout or layout table to set for this tags by default.
-- @return A table with all created tags.
-function new(names, screen, layout)
+function tag.new(names, screen, layout)
local screen = screen or 1
local tags = {}
for id, name in ipairs(names) do
- table.insert(tags, id, add(name, {screen = screen,
+ table.insert(tags, id, tag.add(name, {screen = screen,
layout = (layout and layout[id]) or
layout}))
-- Select the first tag.
@@ -93,9 +94,9 @@ end
--- Find a suitable fallback tag.
-- @param screen The screen number to look for a tag on. [mouse.screen]
-- @param target A table of tags we consider unacceptable. [selectedlist(scr)]
-function find_fallback(screen, invalids)
+function tag.find_fallback(screen, invalids)
local scr = screen or capi.mouse.screen
- local t = invalids or selectedlist(scr)
+ local t = invalids or tag.selectedlist(scr)
for _, v in pairs(capi.screen[scr]:tags()) do
if not util.table.hasitem(t, v) then return v end
@@ -110,9 +111,9 @@ end
-- stickied clients are assigned to the optional 'fallback_tag'.
-- If after deleting the tag there is no selected tag, try and restore from
-- history or select the first tag on the screen.
-function delete(target_tag, fallback_tag)
+function tag.delete(target_tag, fallback_tag)
-- abort if no tag is passed or currently selected
- local target_tag = target_tag or selected()
+ local target_tag = target_tag or tag.selected()
if target_tag == nil then return end
local ntags = #capi.screen[target_tag.screen]:tags()
@@ -124,7 +125,7 @@ function delete(target_tag, fallback_tag)
-- No fallback_tag provided, try and get one.
if fallback_tag == nil then
- fallback_tag = find_fallback(target_scr, {target_tag})
+ fallback_tag = tag.find_fallback(target_scr, {target_tag})
end
-- Abort if we would have un-tagged clients.
@@ -148,9 +149,9 @@ function delete(target_tag, fallback_tag)
target_tag.screen = nil
-- If no tags are visible, try and view one.
- if selected(target_scr) == nil and ntags > 0 then
- history.restore()
- if selected(target_scr) == nil then
+ if tag.selected(target_scr) == nil and ntags > 0 then
+ tag.history.restore()
+ if tag.selected(target_scr) == nil then
capi.screen[target_scr]:tags()[1].selected = true
end
end
@@ -160,9 +161,9 @@ end
--- Update the tag history.
-- @param obj Screen object.
-function history.update(obj)
+function tag.history.update(obj)
local s = obj.index
- local curtags = selectedlist(s)
+ local curtags = tag.selectedlist(s)
-- create history table
if not data.history[s] then
data.history[s] = {}
@@ -170,8 +171,8 @@ function history.update(obj)
if data.history[s].current then
-- Check that the list is not identical
local identical = true
- for idx, tag in ipairs(data.history[s].current) do
- if curtags[idx] ~= tag then
+ for idx, _tag in ipairs(data.history[s].current) do
+ if curtags[idx] ~= _tag then
identical = false
break
end
@@ -182,8 +183,8 @@ function history.update(obj)
end
-- Limit history
- if #data.history[s] >= history.limit then
- for i = history.limit, #data.history[s] do
+ if #data.history[s] >= tag.history.limit then
+ for i = tag.history.limit, #data.history[s] do
data.history[s][i] = nil
end
end
@@ -201,20 +202,20 @@ end
-- @param idx Index in history. Defaults to "previous" which is a special index
-- toggling between last two selected sets of tags. Number (eg 1) will go back
-- to the given index in history.
-function history.restore(screen, idx)
+function tag.history.restore(screen, idx)
local s = screen or capi.mouse.screen
local i = idx or "previous"
- local sel = selectedlist(s)
+ local sel = tag.selectedlist(s)
-- do nothing if history empty
if not data.history[s] or not data.history[s][i] then return end
-- if all tags been deleted, try next entry
if #data.history[s][i] == 0 then
if i == "previous" then i = 0 end
- history.restore(s, i + 1)
+ tag.history.restore(s, i + 1)
return
end
-- deselect all tags
- viewnone(s)
+ tag.viewnone(s)
-- select tags from the history entry
for _, t in ipairs(data.history[s][i]) do
t.selected = true
@@ -230,7 +231,7 @@ end
--- Return a table with all visible tags
-- @param s Screen number.
-- @return A table with all selected tags.
-function selectedlist(s)
+function tag.selectedlist(s)
local screen = s or capi.mouse.screen
local tags = capi.screen[screen]:tags()
local vtags = {}
@@ -244,96 +245,96 @@ end
--- Return only the first visible tag.
-- @param s Screen number.
-function selected(s)
- return selectedlist(s)[1]
+function tag.selected(s)
+ return tag.selectedlist(s)[1]
end
--- Set master width factor.
-- @param mwfact Master width factor.
-function setmwfact(mwfact, t)
- local t = t or selected()
+function tag.setmwfact(mwfact, t)
+ local t = t or tag.selected()
if mwfact >= 0 and mwfact <= 1 then
- setproperty(t, "mwfact", mwfact)
+ tag.setproperty(t, "mwfact", mwfact)
end
end
--- Increase master width factor.
-- @param add Value to add to master width factor.
-function incmwfact(add, t)
- setmwfact(getmwfact(t) + add, t)
+function tag.incmwfact(add, t)
+ tag.setmwfact(tag.getmwfact(t) + add, t)
end
--- Get master width factor.
-- @param t Optional tag.
-function getmwfact(t)
- local t = t or selected()
- return getproperty(t, "mwfact") or 0.5
+function tag.getmwfact(t)
+ local t = t or tag.selected()
+ return tag.getproperty(t, "mwfact") or 0.5
end
--- Set the number of master windows.
-- @param nmaster The number of master windows.
-- @param t Optional tag.
-function setnmaster(nmaster, t)
- local t = t or selected()
+function tag.setnmaster(nmaster, t)
+ local t = t or tag.selected()
if nmaster >= 0 then
- setproperty(t, "nmaster", nmaster)
+ tag.setproperty(t, "nmaster", nmaster)
end
end
--- Get the number of master windows.
-- @param t Optional tag.
-function getnmaster(t)
- local t = t or selected()
- return getproperty(t, "nmaster") or 1
+function tag.getnmaster(t)
+ local t = t or tag.selected()
+ return tag.getproperty(t, "nmaster") or 1
end
--- Increase the number of master windows.
-- @param add Value to add to number of master windows.
-function incnmaster(add, t)
- setnmaster(getnmaster(t) + add, t)
+function tag.incnmaster(add, t)
+ tag.setnmaster(tag.getnmaster(t) + add, t)
end
--- Set the tag icon
-- @param icon the icon to set, either path or image object
-- @param tag the tag
-function seticon(icon, tag)
- local tag = tag or selected()
- setproperty(tag, "icon", icon)
+function tag.seticon(icon, _tag)
+ local _tag = _tag or tag.selected()
+ tag.setproperty(_tag, "icon", icon)
end
--- Get the tag icon
-- @param t the tag
-function geticon(tag)
- local tag = tag or selected()
- return getproperty(tag, "icon")
+function tag.geticon(_tag)
+ local _tag = _tag or tag.selected()
+ return tag.getproperty(_tag, "icon")
end
--- Set number of column windows.
-- @param ncol The number of column.
-function setncol(ncol, t)
- local t = t or selected()
+function tag.setncol(ncol, t)
+ local t = t or tag.selected()
if ncol >= 1 then
- setproperty(t, "ncol", ncol)
+ tag.setproperty(t, "ncol", ncol)
end
end
--- Get number of column windows.
-- @param t Optional tag.
-function getncol(t)
- local t = t or selected()
- return getproperty(t, "ncol") or 1
+function tag.getncol(t)
+ local t = t or tag.selected()
+ return tag.getproperty(t, "ncol") or 1
end
--- Increase number of column windows.
-- @param add Value to add to number of column windows.
-function incncol(add, t)
- setncol(getncol(t) + add, t)
+function tag.incncol(add, t)
+ tag.setncol(tag.getncol(t) + add, t)
end
--- View no tag.
-- @param Optional screen number.
-function viewnone(screen)
+function tag.viewnone(screen)
local tags = capi.screen[screen or capi.mouse.screen]:tags()
for i, t in pairs(tags) do
t.selected = false
@@ -343,17 +344,17 @@ end
--- View a tag by its taglist index.
-- @param i The relative index to see.
-- @param screen Optional screen number.
-function viewidx(i, screen)
+function tag.viewidx(i, screen)
local screen = screen and screen.index or capi.mouse.screen
local tags = capi.screen[screen]:tags()
local showntags = {}
for k, t in ipairs(tags) do
- if not getproperty(t, "hide") then
+ if not tag.getproperty(t, "hide") then
table.insert(showntags, t)
end
end
- local sel = selected(screen)
- viewnone(screen)
+ local sel = tag.selected(screen)
+ tag.viewnone(screen)
for k, t in ipairs(showntags) do
if t == sel then
showntags[util.cycle(#showntags, k + i)].selected = true
@@ -365,8 +366,8 @@ end
--- Get a tag's index in the screen[]:tags() table.
-- @param query_tag The tag object to find. [selected()]
-- @return The index of the tag, nil if the tag is not found.
-function getidx(query_tag)
- local query_tag = query_tag or selected()
+function tag.getidx(query_tag)
+ local query_tag = query_tag or tag.selected()
if query_tag == nil then return end
for i, t in ipairs(capi.screen[query_tag.screen]:tags()) do
@@ -378,24 +379,24 @@ end
--- View next tag. This is the same as tag.viewidx(1).
-- @param screen The screen number.
-function viewnext(screen)
- return viewidx(1, screen)
+function tag.viewnext(screen)
+ return tag.viewidx(1, screen)
end
--- View previous tag. This is the same a tag.viewidx(-1).
-- @param screen The screen number.
-function viewprev(screen)
- return viewidx(-1, screen)
+function tag.viewprev(screen)
+ return tag.viewidx(-1, screen)
end
--- View only a tag.
-- @param t The tag object.
-function viewonly(t)
+function tag.viewonly(t)
local tags = capi.screen[t.screen]:tags()
-- First, untag everyone except the viewed tag.
- for _, tag in pairs(tags) do
- if tag ~= t then
- tag.selected = false
+ for _, _tag in pairs(tags) do
+ if _tag ~= t then
+ _tag.selected = false
end
end
-- Then, set this one to selected.
@@ -408,22 +409,22 @@ end
--- View only a set of tags.
-- @param tags A table with tags to view only.
-- @param screen Optional screen number of the tags.
-function viewmore(tags, screen)
+function tag.viewmore(tags, screen)
local screen_tags = capi.screen[screen or capi.mouse.screen]:tags()
- for _, tag in ipairs(screen_tags) do
- if not util.table.hasitem(tags, tag) then
- tag.selected = false
+ for _, _tag in ipairs(screen_tags) do
+ if not util.table.hasitem(tags, _tag) then
+ _tag.selected = false
end
end
- for _, tag in ipairs(tags) do
- tag.selected = true
+ for _, _tag in ipairs(tags) do
+ _tag.selected = true
end
capi.screen[screen]:emit_signal("tag::history::update")
end
--- Toggle selection of a tag
-- @param tag Tag to be toggled
-function viewtoggle(t)
+function tag.viewtoggle(t)
t.selected = not t.selected
capi.screen[t.screen]:emit_signal("tag::history::update")
end
@@ -431,17 +432,17 @@ end
--- Get tag data table.
-- @param tag The Tag.
-- @return The data table.
-function getdata(tag)
- return data.tags[tag]
+function tag.getdata(_tag)
+ return data.tags[_tag]
end
--- Get a tag property.
-- @param tag The tag.
-- @param prop The property name.
-- @return The property.
-function getproperty(tag, prop)
- if data.tags[tag] then
- return data.tags[tag][prop]
+function tag.getproperty(_tag, prop)
+ if data.tags[_tag] then
+ return data.tags[_tag][prop]
end
end
@@ -451,41 +452,41 @@ end
-- @param tag The tag.
-- @param prop The property name.
-- @param value The value.
-function setproperty(tag, prop, value)
- if not data.tags[tag] then
- data.tags[tag] = {}
+function tag.setproperty(_tag, prop, value)
+ if not data.tags[_tag] then
+ data.tags[_tag] = {}
end
- data.tags[tag][prop] = value
- tag:emit_signal("property::" .. prop)
+ data.tags[_tag][prop] = value
+ _tag:emit_signal("property::" .. prop)
end
--- Tag a client with the set of current tags.
-- @param c The client to tag.
-- @param startup Optional: don't do anything if true.
-function withcurrent(c, startup)
+function tag.withcurrent(c, startup)
if startup ~= true then
if #c:tags() == 0 then
- c:tags(selectedlist(c.screen))
+ c:tags(tag.selectedlist(c.screen))
end
end
end
local function attached_connect_signal_screen(screen, sig, func)
- capi.screen[screen]:connect_signal("tag::attach", function (s, tag)
- tag:connect_signal(sig, func)
+ capi.screen[screen]:connect_signal("tag::attach", function (s, _tag)
+ _tag:connect_signal(sig, func)
end)
- capi.screen[screen]:connect_signal("tag::detach", function (s, tag)
- tag:disconnect_signal(sig, func)
+ capi.screen[screen]:connect_signal("tag::detach", function (s, _tag)
+ _tag:disconnect_signal(sig, func)
end)
- for _, tag in ipairs(capi.screen[screen]:tags()) do
- tag:connect_signal(sig, func)
+ for _, _tag in ipairs(capi.screen[screen]:tags()) do
+ _tag:connect_signal(sig, func)
end
end
--- Add a signal to all attached tag and all tag that will be attached in the
-- future. When a tag is detach from the screen, its signal is removed.
-- @param screen The screen concerned, or all if nil.
-function attached_connect_signal(screen, ...)
+function tag.attached_connect_signal(screen, ...)
if screen then
attached_connect_signal_screen(screen, ...)
else
@@ -510,10 +511,10 @@ capi.client.connect_signal("manage", function(c, startup)
c.screen = capi.mouse.screen
end
end
- c:connect_signal("property::screen", withcurrent)
+ c:connect_signal("property::screen", tag.withcurrent)
end)
-capi.client.connect_signal("manage", withcurrent)
+capi.client.connect_signal("manage", tag.withcurrent)
capi.tag.add_signal("property::hide")
capi.tag.add_signal("property::icon")
@@ -525,9 +526,13 @@ capi.tag.add_signal("property::windowfact")
for s = 1, capi.screen.count() do
capi.screen[s]:add_signal("tag::history::update")
- capi.screen[s]:connect_signal("tag::history::update", history.update)
+ capi.screen[s]:connect_signal("tag::history::update", tag.history.update)
end
-setmetatable(_M, { __call = function (_, ...) return new(...) end })
+function tag.mt:__call(...)
+ return tag.new(...)
+end
+
+return setmetatable(tag, tag.mt)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
diff --git a/lib/awful/tooltip.lua.in b/lib/awful/tooltip.lua.in
index 49b0b7be1..aaf12c949 100644
--- a/lib/awful/tooltip.lua.in
+++ b/lib/awful/tooltip.lua.in
@@ -46,7 +46,8 @@ local ipairs = ipairs
--
-- Now the same tooltip is only attached to myclock
.
--