2008-09-29 16:49:18 +02:00
|
|
|
---------------------------------------------------------------------------
|
2014-05-20 13:02:39 +02:00
|
|
|
--- Screen module for awful
|
|
|
|
--
|
2008-09-29 16:49:18 +02:00
|
|
|
-- @author Julien Danjou <julien@danjou.info>
|
|
|
|
-- @copyright 2008 Julien Danjou
|
|
|
|
-- @release @AWESOME_VERSION@
|
2016-04-05 05:34:35 +02:00
|
|
|
-- @module screen
|
2008-09-29 16:49:18 +02:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-- Grab environment we need
|
|
|
|
local capi =
|
|
|
|
{
|
|
|
|
mouse = mouse,
|
|
|
|
screen = screen,
|
|
|
|
client = client
|
|
|
|
}
|
|
|
|
local util = require("awful.util")
|
2016-03-13 08:44:27 +01:00
|
|
|
local object = require("gears.object")
|
2012-09-28 23:53:58 +02:00
|
|
|
|
2016-02-26 19:56:07 +01:00
|
|
|
local function get_screen(s)
|
2016-02-29 09:09:16 +01:00
|
|
|
return s and capi.screen[s]
|
2016-02-26 19:56:07 +01:00
|
|
|
end
|
|
|
|
|
2012-09-28 23:53:58 +02:00
|
|
|
-- we use require("awful.client") inside functions to prevent circular dependencies.
|
|
|
|
local client
|
2008-09-29 16:49:18 +02:00
|
|
|
|
2016-04-05 05:34:35 +02:00
|
|
|
local screen = {object={}}
|
2008-09-29 16:49:18 +02:00
|
|
|
|
2009-05-04 11:09:19 +02:00
|
|
|
local data = {}
|
|
|
|
data.padding = {}
|
|
|
|
|
2015-10-09 20:54:17 +02:00
|
|
|
screen.mouse_per_screen = {}
|
2015-10-08 03:52:03 +02:00
|
|
|
|
2016-03-26 08:07:20 +01:00
|
|
|
--- Take an input geometry and substract/add a delta
|
|
|
|
-- @tparam table geo A geometry (width, height, x, y) table
|
|
|
|
-- @tparam table delta A delata table (top, bottom, x, y)
|
|
|
|
-- @treturn table A geometry (width, height, x, y) table
|
|
|
|
local function apply_geometry_ajustments(geo, delta)
|
|
|
|
return {
|
|
|
|
x = geo.x + (delta.left or 0),
|
|
|
|
y = geo.y + (delta.top or 0),
|
|
|
|
width = geo.width - (delta.left or 0) - (delta.right or 0),
|
|
|
|
height = geo.height - (delta.top or 0) - (delta.bottom or 0),
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2016-04-05 05:34:35 +02:00
|
|
|
--- Get the square distance between a `screen` and a point
|
2016-04-05 05:35:03 +02:00
|
|
|
-- @deprecated awful.screen.getdistance_sq
|
2016-02-26 19:56:07 +01:00
|
|
|
-- @param s Screen
|
2015-10-10 20:16:49 +02:00
|
|
|
-- @param x X coordinate of point
|
|
|
|
-- @param y Y coordinate of point
|
|
|
|
-- @return The squared distance of the screen to the provided point
|
2016-04-07 06:09:20 +02:00
|
|
|
-- @see screen.get_square_distance
|
2015-10-10 20:16:49 +02:00
|
|
|
function screen.getdistance_sq(s, x, y)
|
2016-04-05 05:35:03 +02:00
|
|
|
util.deprecate "Use s:get_square_distance(x, y) instead of awful.screen.getdistance_sq"
|
|
|
|
|
|
|
|
return screen.object.get_square_distance(s, x, y)
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Get the square distance between a `screen` and a point
|
|
|
|
-- @function screen.get_square_distance
|
|
|
|
-- @tparam number x X coordinate of point
|
|
|
|
-- @tparam number y Y coordinate of point
|
|
|
|
-- @treturn number The squared distance of the screen to the provided point
|
|
|
|
function screen.object.get_square_distance(self, x, y)
|
|
|
|
self = get_screen(self)
|
|
|
|
local geom = self.geometry
|
2015-10-10 20:16:49 +02:00
|
|
|
local dist_x, dist_y = 0, 0
|
|
|
|
if x < geom.x then
|
|
|
|
dist_x = geom.x - x
|
|
|
|
elseif x >= geom.x + geom.width then
|
|
|
|
dist_x = x - geom.x - geom.width
|
|
|
|
end
|
|
|
|
if y < geom.y then
|
|
|
|
dist_y = geom.y - y
|
|
|
|
elseif y >= geom.y + geom.height then
|
|
|
|
dist_y = y - geom.y - geom.height
|
|
|
|
end
|
|
|
|
return dist_x * dist_x + dist_y * dist_y
|
|
|
|
end
|
|
|
|
|
2012-01-15 11:28:17 +01:00
|
|
|
---
|
2016-02-26 19:56:07 +01:00
|
|
|
-- Return screen number corresponding to the given (pixel) coordinates.
|
2012-01-15 11:28:17 +01:00
|
|
|
-- The number returned can be used as an index into the global
|
|
|
|
-- `screen` table/object.
|
2016-04-05 05:34:35 +02:00
|
|
|
-- @function awful.screen.getbycoord
|
2012-01-15 11:28:17 +01:00
|
|
|
-- @param x The x coordinate
|
|
|
|
-- @param y The y coordinate
|
2015-10-10 20:16:49 +02:00
|
|
|
function screen.getbycoord(x, y)
|
2016-02-29 09:09:16 +01:00
|
|
|
local s = capi.screen[1]
|
2016-04-05 05:35:03 +02:00
|
|
|
local dist = screen.object.get_square_distance(s, x, y)
|
2016-03-06 13:31:30 +01:00
|
|
|
for i in capi.screen do
|
2016-04-05 05:35:03 +02:00
|
|
|
local d = screen.object.get_square_distance(i, x, y)
|
2015-10-10 20:16:49 +02:00
|
|
|
if d < dist then
|
2016-02-29 09:09:16 +01:00
|
|
|
s, dist = capi.screen[i], d
|
2012-01-15 11:28:17 +01:00
|
|
|
end
|
|
|
|
end
|
2016-02-26 19:56:07 +01:00
|
|
|
return s.index
|
2012-01-15 11:28:17 +01:00
|
|
|
end
|
|
|
|
|
2015-10-08 03:52:03 +02:00
|
|
|
--- Give the focus to a screen, and move pointer to last known position on this
|
|
|
|
-- screen, or keep position relative to the current focused screen
|
2016-04-05 05:34:35 +02:00
|
|
|
-- @function awful.screen.focus
|
2015-01-31 16:40:46 +01:00
|
|
|
-- @param _screen Screen number (defaults / falls back to mouse.screen).
|
2012-06-12 20:13:09 +02:00
|
|
|
function screen.focus(_screen)
|
2012-09-28 23:53:58 +02:00
|
|
|
client = client or require("awful.client")
|
2016-02-26 19:56:07 +01:00
|
|
|
if type(_screen) == "number" and _screen > capi.screen.count() then _screen = screen.focused() end
|
|
|
|
_screen = get_screen(_screen)
|
2012-09-14 20:14:22 +02:00
|
|
|
|
|
|
|
-- screen and pos for current screen
|
2016-02-26 19:56:07 +01:00
|
|
|
local s = get_screen(capi.mouse.screen)
|
2015-10-08 03:52:03 +02:00
|
|
|
local pos
|
|
|
|
|
2015-10-09 20:54:17 +02:00
|
|
|
if not screen.mouse_per_screen[_screen] then
|
2015-10-08 03:52:03 +02:00
|
|
|
-- This is the first time we enter this screen,
|
|
|
|
-- keep relative mouse position on the new screen
|
2015-10-11 12:44:28 +02:00
|
|
|
pos = capi.mouse.coords()
|
2016-02-26 19:56:07 +01:00
|
|
|
local relx = (pos.x - s.geometry.x) / s.geometry.width
|
|
|
|
local rely = (pos.y - s.geometry.y) / s.geometry.height
|
2012-09-14 20:14:22 +02:00
|
|
|
|
2016-02-26 19:56:07 +01:00
|
|
|
pos.x = _screen.geometry.x + relx * _screen.geometry.width
|
|
|
|
pos.y = _screen.geometry.y + rely * _screen.geometry.height
|
2015-10-08 03:52:03 +02:00
|
|
|
else
|
|
|
|
-- restore mouse position
|
2015-10-09 20:54:17 +02:00
|
|
|
pos = screen.mouse_per_screen[_screen]
|
2015-10-08 03:52:03 +02:00
|
|
|
end
|
2012-09-14 20:14:22 +02:00
|
|
|
|
2015-10-08 04:40:59 +02:00
|
|
|
-- save pointer position of current screen
|
2015-10-09 20:54:17 +02:00
|
|
|
screen.mouse_per_screen[s] = capi.mouse.coords()
|
2015-10-08 04:40:59 +02:00
|
|
|
|
2012-09-14 20:14:22 +02:00
|
|
|
-- move cursor without triggering signals mouse::enter and mouse::leave
|
|
|
|
capi.mouse.coords(pos, true)
|
|
|
|
|
2016-02-27 09:24:19 +01:00
|
|
|
local c = client.focus.history.get(_screen, 0)
|
2015-05-13 13:36:28 +02:00
|
|
|
if c then
|
2015-06-19 22:24:12 +02:00
|
|
|
c:emit_signal("request::activate", "screen.focus", {raise=false})
|
2015-05-13 13:36:28 +02:00
|
|
|
end
|
2009-08-21 16:05:02 +02:00
|
|
|
end
|
|
|
|
|
2015-10-08 03:52:03 +02:00
|
|
|
--- Give the focus to a screen, and move pointer to last known position on this
|
|
|
|
-- screen, or keep position relative to the current focused screen
|
2016-04-05 05:34:35 +02:00
|
|
|
-- @function awful.screen.focus_bydirection
|
2012-09-14 21:49:14 +02:00
|
|
|
-- @param dir The direction, can be either "up", "down", "left" or "right".
|
2016-02-26 19:56:07 +01:00
|
|
|
-- @param _screen Screen.
|
2012-09-14 21:49:14 +02:00
|
|
|
function screen.focus_bydirection(dir, _screen)
|
2016-02-26 19:56:07 +01:00
|
|
|
local sel = get_screen(_screen or screen.focused())
|
2012-09-14 21:49:14 +02:00
|
|
|
if sel then
|
|
|
|
local geomtbl = {}
|
2016-03-06 13:31:30 +01:00
|
|
|
for s in capi.screen do
|
2012-09-14 21:49:14 +02:00
|
|
|
geomtbl[s] = capi.screen[s].geometry
|
|
|
|
end
|
2016-02-26 19:56:07 +01:00
|
|
|
local target = util.get_rectangle_in_direction(dir, geomtbl, sel.geometry)
|
2012-09-14 21:49:14 +02:00
|
|
|
if target then
|
|
|
|
return screen.focus(target)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-10-08 03:52:03 +02:00
|
|
|
--- Give the focus to a screen, and move pointer to last known position on this
|
|
|
|
-- screen, or keep position relative to the current focused screen
|
2016-04-05 05:34:35 +02:00
|
|
|
-- @function awful.screen.focus_relative
|
2009-08-21 16:05:02 +02:00
|
|
|
-- @param i Value to add to the current focused screen index. 1 will focus next
|
|
|
|
-- screen, -1 would focus the previous one.
|
2012-06-12 20:13:09 +02:00
|
|
|
function screen.focus_relative(i)
|
2016-03-28 10:35:16 +02:00
|
|
|
return screen.focus(util.cycle(capi.screen.count(), screen.focused().index + i))
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
2009-05-04 11:09:19 +02:00
|
|
|
--- Get or set the screen padding.
|
2016-04-05 05:35:03 +02:00
|
|
|
-- @deprecated awful.screen.padding
|
2012-11-19 14:09:10 +01:00
|
|
|
-- @param _screen The screen object to change the padding on
|
2016-03-26 08:05:17 +01:00
|
|
|
-- @param[opt=nil] padding The padding, a table with 'top', 'left', 'right' and/or
|
|
|
|
-- 'bottom' or a number value to apply set the same padding on all sides. Can be
|
|
|
|
-- nil if you only want to retrieve padding
|
2016-03-26 08:05:45 +01:00
|
|
|
-- @treturn table A table with left, right, top and bottom number values.
|
2016-04-05 05:35:03 +02:00
|
|
|
-- @see padding
|
2012-06-12 20:13:09 +02:00
|
|
|
function screen.padding(_screen, padding)
|
2016-04-05 05:35:03 +02:00
|
|
|
util.deprecate "Use _screen.padding = value instead of awful.screen.padding"
|
2016-03-26 08:05:17 +01:00
|
|
|
|
2009-05-04 11:09:19 +02:00
|
|
|
if padding then
|
2016-04-05 05:35:03 +02:00
|
|
|
screen.object.set_padding(_screen, padding)
|
2009-05-04 11:09:19 +02:00
|
|
|
end
|
2016-03-26 08:05:17 +01:00
|
|
|
|
2016-04-05 05:35:03 +02:00
|
|
|
return screen.object.get_padding(_screen)
|
|
|
|
end
|
|
|
|
|
|
|
|
--- The screen padding.
|
|
|
|
-- Add a "buffer" section on each side of the screen where the tiled client
|
|
|
|
-- wont be.
|
|
|
|
--
|
|
|
|
-- **Signal:**
|
|
|
|
--
|
|
|
|
-- * *property::padding*
|
|
|
|
--
|
|
|
|
-- @property padding
|
|
|
|
-- @param table
|
|
|
|
-- @tfield integer table.x The horizontal position
|
|
|
|
-- @tfield integer table.y The vertical position
|
|
|
|
-- @tfield integer table.width The width
|
|
|
|
-- @tfield integer table.height The height
|
|
|
|
|
|
|
|
function screen.object.get_padding(self)
|
|
|
|
local p = data.padding[self] or {}
|
2016-03-26 08:05:45 +01:00
|
|
|
|
|
|
|
-- Create a copy to avoid accidental mutation and nil values
|
|
|
|
return {
|
|
|
|
left = p.left or 0,
|
|
|
|
right = p.right or 0,
|
|
|
|
top = p.top or 0,
|
|
|
|
bottom = p.bottom or 0,
|
|
|
|
}
|
2009-05-04 11:09:19 +02:00
|
|
|
end
|
|
|
|
|
2016-04-05 05:35:03 +02:00
|
|
|
function screen.object.set_padding(self, padding)
|
|
|
|
if type(padding) == "number" then
|
|
|
|
padding = {
|
|
|
|
left = padding,
|
|
|
|
right = padding,
|
|
|
|
top = padding,
|
|
|
|
bottom = padding,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
self = get_screen(self)
|
|
|
|
if padding then
|
|
|
|
data.padding[self] = padding
|
|
|
|
self:emit_signal("padding")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-04-05 05:34:35 +02:00
|
|
|
--- The defaults arguments for `awful.screen.focused`
|
|
|
|
-- @tfield[opt=nil] table awful.screen.default_focused_args
|
|
|
|
|
2015-01-31 16:40:46 +01:00
|
|
|
--- Get the focused screen.
|
2016-03-26 08:12:07 +01:00
|
|
|
--
|
|
|
|
-- It is possible to set `awful.screen.default_focused_args` to override the
|
|
|
|
-- default settings.
|
|
|
|
--
|
2016-04-05 05:34:35 +02:00
|
|
|
-- @function awful.screen.focused
|
2016-04-04 23:49:43 +02:00
|
|
|
-- @tparam[opt] table args
|
2016-04-05 05:34:35 +02:00
|
|
|
-- @tparam[opt=false] boolean args.client Use the client screen instead of the
|
2016-04-04 23:49:43 +02:00
|
|
|
-- mouse screen.
|
2016-04-05 05:35:03 +02:00
|
|
|
-- @tparam[opt=true] boolean args.mouse Use the mouse screen
|
2016-04-04 23:49:43 +02:00
|
|
|
-- @treturn ?screen The focused screen object, or `nil` in case no screen is
|
|
|
|
-- present currently.
|
2016-03-26 08:12:07 +01:00
|
|
|
function screen.focused(args)
|
|
|
|
args = args or screen.default_focused_args or {}
|
|
|
|
return get_screen(args.client and capi.client.screen or capi.mouse.screen)
|
2015-01-31 16:40:46 +01:00
|
|
|
end
|
|
|
|
|
2016-03-26 08:07:20 +01:00
|
|
|
--- Get a placement bounding geometry.
|
|
|
|
-- This method compute different variants of the "usable" screen geometry.
|
|
|
|
--
|
|
|
|
-- Valid arguments are:
|
|
|
|
--
|
|
|
|
-- * **honor_padding**: Honor the screen padding.
|
|
|
|
-- * **honor_workarea**: Honor the screen workarea
|
|
|
|
-- * **margins**: Apply some margins on the output. This can wither be a number
|
|
|
|
-- or a table with *left*, *right*, *top* and *bottom* keys.
|
|
|
|
-- * **tag**: Use the tag screen instead of `s`
|
|
|
|
-- * **parent**: A parent drawable to use a base geometry
|
|
|
|
-- * **bounding_rect**: A bounding rectangle. This parameter is incompatible with
|
|
|
|
-- `honor_workarea`.
|
|
|
|
--
|
2016-04-05 05:35:03 +02:00
|
|
|
-- @function screen.get_bounding_geometry
|
2016-03-26 08:07:20 +01:00
|
|
|
-- @tparam[opt={}] table args The arguments
|
|
|
|
-- @treturn table A table with *x*, *y*, *width* and *height*.
|
2016-04-05 05:35:03 +02:00
|
|
|
-- @usage local geo = screen:get_bounding_geometry {
|
|
|
|
-- honor_padding = true,
|
|
|
|
-- honor_workarea = true,
|
|
|
|
-- margins = {
|
|
|
|
-- left = 20,
|
|
|
|
-- },
|
|
|
|
-- }
|
|
|
|
function screen.object.get_bounding_geometry(self, args)
|
2016-03-26 08:07:20 +01:00
|
|
|
args = args or {}
|
|
|
|
|
|
|
|
-- If the tag has a geometry, assume it is right
|
|
|
|
if args.tag then
|
2016-04-05 05:35:03 +02:00
|
|
|
self = args.tag.screen
|
2016-03-26 08:07:20 +01:00
|
|
|
end
|
|
|
|
|
2016-04-05 05:35:03 +02:00
|
|
|
self = get_screen(self or capi.mouse.screen)
|
2016-03-26 08:07:20 +01:00
|
|
|
|
|
|
|
local geo = args.bounding_rect or (args.parent and args.parent:geometry()) or
|
2016-04-05 05:35:03 +02:00
|
|
|
self[args.honor_workarea and "workarea" or "geometry"]
|
2016-03-26 08:07:20 +01:00
|
|
|
|
|
|
|
if (not args.parent) and (not args.bounding_rect) and args.honor_padding then
|
2016-04-05 05:35:03 +02:00
|
|
|
local padding = self.padding
|
2016-03-26 08:07:20 +01:00
|
|
|
geo = apply_geometry_ajustments(geo, padding)
|
|
|
|
end
|
|
|
|
|
|
|
|
if args.margins then
|
|
|
|
geo = apply_geometry_ajustments(geo,
|
|
|
|
type(args.margins) == "table" and args.margins or {
|
|
|
|
left = args.margins, right = args.margins,
|
|
|
|
top = args.margins, bottom = args.margins,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
return geo
|
|
|
|
end
|
|
|
|
|
2016-04-07 06:09:20 +02:00
|
|
|
--- Get the list of the screen visible clients.
|
|
|
|
--
|
|
|
|
-- Minimized and unmanaged clients are not included in this list as they are
|
|
|
|
-- technically not on the screen.
|
|
|
|
--
|
2016-04-05 09:02:00 +02:00
|
|
|
-- The clients on tags currently not visible are not part of this list.
|
|
|
|
--
|
2016-04-07 06:09:20 +02:00
|
|
|
-- @property clients
|
|
|
|
-- @param table The clients list, ordered top to bottom
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @see all_clients
|
|
|
|
-- @see hidden_clients
|
|
|
|
-- @see client.get
|
2016-04-07 06:09:20 +02:00
|
|
|
|
|
|
|
function screen.object.get_clients(s)
|
|
|
|
local cls = capi.client.get(s, true)
|
|
|
|
local vcls = {}
|
|
|
|
for _, c in pairs(cls) do
|
|
|
|
if c:isvisible() then
|
|
|
|
table.insert(vcls, c)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return vcls
|
|
|
|
end
|
|
|
|
|
|
|
|
function screen.object.set_clients() end
|
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
--- Get the list of the clients assigned to the screen but not currently
|
|
|
|
-- visible.
|
|
|
|
--
|
|
|
|
-- This include minimized clients and clients on hidden tags.
|
|
|
|
--
|
|
|
|
-- @property hidden_clients
|
|
|
|
-- @param table The clients list, ordered top to bottom
|
|
|
|
-- @see clients
|
|
|
|
-- @see all_clients
|
|
|
|
-- @see client.get
|
|
|
|
|
|
|
|
function screen.object.get_hidden_clients(s)
|
|
|
|
local cls = capi.client.get(s, true)
|
|
|
|
local vcls = {}
|
|
|
|
for _, c in pairs(cls) do
|
|
|
|
if not c:isvisible() then
|
|
|
|
table.insert(vcls, c)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return vcls
|
|
|
|
end
|
|
|
|
|
|
|
|
function screen.object.set_hidden_clients() end
|
|
|
|
|
|
|
|
--- Get all clients assigned to the screen.
|
|
|
|
--
|
|
|
|
-- @property all_clients
|
|
|
|
-- @param table The clients list, ordered top to bottom
|
|
|
|
-- @see clients
|
|
|
|
-- @see hidden_clients
|
|
|
|
-- @see client.get
|
|
|
|
|
|
|
|
function screen.object.get_all_clients(s)
|
|
|
|
return capi.client.get(s, true)
|
|
|
|
end
|
|
|
|
|
|
|
|
function screen.object.set_all_clients() end
|
|
|
|
|
2016-04-07 06:09:20 +02:00
|
|
|
--- Get the list of the screen tiled clients.
|
|
|
|
--
|
|
|
|
-- Same as s.clients, but excluding:
|
|
|
|
--
|
|
|
|
-- * fullscreen clients
|
|
|
|
-- * maximized clients
|
|
|
|
-- * floating clients
|
|
|
|
--
|
|
|
|
-- @property tiled_clients
|
|
|
|
-- @param table The clients list, ordered top to bottom
|
|
|
|
|
|
|
|
function screen.object.get_tiled_clients(s)
|
|
|
|
local clients = s.clients
|
|
|
|
local tclients = {}
|
|
|
|
-- Remove floating clients
|
|
|
|
for _, c in pairs(clients) do
|
|
|
|
if not c.floating
|
|
|
|
and not c.fullscreen
|
|
|
|
and not c.maximized_vertical
|
|
|
|
and not c.maximized_horizontal then
|
|
|
|
table.insert(tclients, c)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return tclients
|
|
|
|
end
|
|
|
|
|
|
|
|
function screen.object.set_tiled_clients() end
|
|
|
|
|
2016-04-05 06:01:31 +02:00
|
|
|
--- Call a function for each existing and created-in-the-future screen.
|
2016-04-07 06:09:20 +02:00
|
|
|
-- @function awful.screen.connect_for_each_screen
|
2016-04-05 06:01:31 +02:00
|
|
|
-- @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.
|
2016-04-07 06:09:20 +02:00
|
|
|
-- @function awful.screen.disconnect_for_each_screen
|
2016-04-05 06:01:31 +02:00
|
|
|
-- @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
|
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
--- A list of all tags on the screen.
|
|
|
|
--
|
|
|
|
-- This property is read only, use `tag.screen`, `awful.tag.add`, `awful.tag.new`
|
|
|
|
-- or `t:delete()` to alter this list.
|
|
|
|
--
|
|
|
|
-- @property tags
|
|
|
|
-- @param table
|
|
|
|
-- @treturn table A table with all available tags
|
|
|
|
|
|
|
|
function screen.object.get_tags(s, unordered)
|
|
|
|
local tags = {}
|
|
|
|
|
|
|
|
for _, t in ipairs(root.tags()) do
|
|
|
|
if get_screen(t.screen) == s then
|
|
|
|
table.insert(tags, t)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Avoid infinite loop, + save some time
|
|
|
|
if not unordered then
|
|
|
|
table.sort(tags, function(a, b)
|
|
|
|
return (a.index or 9999) < (b.index or 9999)
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
return tags
|
|
|
|
end
|
|
|
|
|
|
|
|
function screen.object.set_tags() end
|
|
|
|
|
|
|
|
--- A list of all selected tags on the screen.
|
|
|
|
-- @property selected_tags
|
|
|
|
-- @param table
|
|
|
|
-- @treturn table A table with all selected tags.
|
|
|
|
-- @see tag.selected
|
|
|
|
-- @see client.to_selected_tags
|
|
|
|
|
|
|
|
function screen.object.get_selected_tags(s)
|
|
|
|
local tags = screen.object.get_tags(s, true)
|
|
|
|
|
|
|
|
local vtags = {}
|
|
|
|
for _, t in pairs(tags) do
|
|
|
|
if t.selected then
|
|
|
|
vtags[#vtags + 1] = t
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return vtags
|
|
|
|
end
|
|
|
|
|
|
|
|
function screen.object.set_selected_tags() end
|
|
|
|
|
|
|
|
--- The first selected tag.
|
|
|
|
-- @property selected_tag
|
|
|
|
-- @param table
|
|
|
|
-- @treturn ?tag The first selected tag or nil
|
|
|
|
-- @see tag.selected
|
|
|
|
-- @see selected_tags
|
|
|
|
|
|
|
|
function screen.object.get_selected_tag(s)
|
|
|
|
return screen.object.get_selected_tags(s)[1]
|
|
|
|
end
|
|
|
|
|
|
|
|
function screen.object.set_selected_tag() end
|
|
|
|
|
|
|
|
|
2016-04-12 04:53:22 +02:00
|
|
|
--- When the tag history changed.
|
|
|
|
-- @signal tag::history::update
|
|
|
|
|
2014-03-30 16:37:19 +02:00
|
|
|
capi.screen.add_signal("padding")
|
2010-08-25 23:00:36 +02:00
|
|
|
|
2016-03-13 08:44:27 +01:00
|
|
|
-- Extend the luaobject
|
2016-04-05 05:35:03 +02:00
|
|
|
object.properties(capi.screen, {
|
|
|
|
getter_class = screen.object,
|
|
|
|
setter_class = screen.object,
|
|
|
|
auto_emit = true,
|
|
|
|
})
|
2016-03-13 08:44:27 +01:00
|
|
|
|
2012-06-12 20:13:09 +02:00
|
|
|
return screen
|
|
|
|
|
2011-09-11 16:50:01 +02:00
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|