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
|
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,
|
2016-09-15 22:50:10 +02:00
|
|
|
client = client,
|
|
|
|
awesome = awesome,
|
2019-06-20 00:02:49 +02:00
|
|
|
root = root,
|
2008-09-29 16:49:18 +02:00
|
|
|
}
|
2017-03-15 06:08:40 +01:00
|
|
|
local gdebug = require("gears.debug")
|
2017-03-06 17:15:40 +01:00
|
|
|
local gmath = require("gears.math")
|
2016-03-13 08:44:27 +01:00
|
|
|
local object = require("gears.object")
|
2016-05-16 06:30:44 +02:00
|
|
|
local grect = require("gears.geometry").rectangle
|
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 = {}
|
|
|
|
|
2016-10-02 16:03:11 +02:00
|
|
|
--- Take an input geometry and substract/add a delta.
|
|
|
|
-- @tparam table geo A geometry (width, height, x, y) table.
|
|
|
|
-- @tparam table delta A delta table (top, bottom, x, y).
|
|
|
|
-- @treturn table A geometry (width, height, x, y) table.
|
2016-03-26 08:07:20 +01:00
|
|
|
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-10-02 16:03:11 +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
|
2016-10-02 16:03:11 +02:00
|
|
|
-- @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)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use s:get_square_distance(x, y) instead of awful.screen.getdistance_sq", {deprecated_in=4})
|
2016-04-05 05:35:03 +02:00
|
|
|
return screen.object.get_square_distance(s, x, y)
|
|
|
|
end
|
|
|
|
|
2016-10-02 16:03:11 +02:00
|
|
|
--- Get the square distance between a `screen` and a point.
|
2019-06-06 22:32:53 +02:00
|
|
|
-- @method get_square_distance
|
2016-04-05 05:35:03 +02:00
|
|
|
-- @tparam number x X coordinate of point
|
|
|
|
-- @tparam number y Y coordinate of point
|
2016-10-02 16:03:11 +02:00
|
|
|
-- @treturn number The squared distance of the screen to the provided point.
|
2016-04-05 05:35:03 +02:00
|
|
|
function screen.object.get_square_distance(self, x, y)
|
2016-05-16 06:30:44 +02:00
|
|
|
return grect.get_square_distance(get_screen(self).geometry, x, y)
|
2015-10-10 20:16:49 +02:00
|
|
|
end
|
|
|
|
|
2016-10-02 16:03:11 +02:00
|
|
|
--- Return the screen index 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.
|
2019-06-08 01:08:05 +02:00
|
|
|
-- @staticfct awful.screen.getbycoord
|
2016-05-16 06:30:44 +02:00
|
|
|
-- @tparam number x The x coordinate
|
|
|
|
-- @tparam number y The y coordinate
|
|
|
|
-- @treturn ?number The screen index
|
2015-10-10 20:16:49 +02:00
|
|
|
function screen.getbycoord(x, y)
|
2016-05-16 06:30:44 +02:00
|
|
|
local s, sgeos = capi.screen.primary, {}
|
|
|
|
for scr in capi.screen do
|
|
|
|
sgeos[scr] = scr.geometry
|
2012-01-15 11:28:17 +01:00
|
|
|
end
|
2016-05-16 06:30:44 +02:00
|
|
|
s = grect.get_closest_by_coord(sgeos, x, y) or s
|
2016-05-15 14:43:25 +02:00
|
|
|
return s and s.index
|
2012-01-15 11:28:17 +01:00
|
|
|
end
|
|
|
|
|
2016-10-02 16:03:11 +02:00
|
|
|
--- Move the focus to a screen.
|
|
|
|
--
|
|
|
|
-- This moves the mouse pointer to the last known position on the new screen,
|
|
|
|
-- or keeps its position relative to the current focused screen.
|
2019-06-08 01:08:05 +02:00
|
|
|
-- @staticfct awful.screen.focus
|
2016-10-02 16:03:11 +02:00
|
|
|
-- @screen _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
|
|
|
|
|
2016-10-05 21:00:47 +02:00
|
|
|
if not _screen.mouse_per_screen then
|
2015-10-08 03:52:03 +02:00
|
|
|
-- This is the first time we enter this screen,
|
2016-10-02 16:03:11 +02:00
|
|
|
-- 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
|
2016-10-05 21:00:47 +02:00
|
|
|
pos = _screen.mouse_per_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
|
2016-10-05 21:00:47 +02:00
|
|
|
s.mouse_per_screen = 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
|
|
|
|
|
2017-03-05 04:16:15 +01:00
|
|
|
--- Get the next screen in a specific direction.
|
|
|
|
--
|
|
|
|
-- This gets the next screen relative to this one in
|
|
|
|
-- the specified direction.
|
|
|
|
--
|
2019-06-06 22:32:53 +02:00
|
|
|
-- @method get_next_in_direction
|
2017-03-05 04:16:15 +01:00
|
|
|
-- @param self Screen.
|
|
|
|
-- @param dir The direction, can be either "up", "down", "left" or "right".
|
|
|
|
function screen.object.get_next_in_direction(self, dir)
|
|
|
|
local sel = get_screen(self)
|
|
|
|
if not sel then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local geomtbl = {}
|
|
|
|
for s in capi.screen do
|
|
|
|
geomtbl[s] = s.geometry
|
|
|
|
end
|
|
|
|
|
|
|
|
return grect.get_in_direction(dir, geomtbl, sel.geometry)
|
|
|
|
end
|
|
|
|
|
2016-10-02 16:03:11 +02:00
|
|
|
--- Move the focus to a screen in a specific direction.
|
|
|
|
--
|
|
|
|
-- This moves the mouse pointer to the last known position on the new screen,
|
|
|
|
-- or keeps its position relative to the current focused screen.
|
2019-06-08 01:08:05 +02:00
|
|
|
-- @staticfct 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())
|
2017-03-05 04:16:15 +01:00
|
|
|
local target = sel:get_next_in_direction(dir)
|
|
|
|
|
|
|
|
if target then
|
2017-03-09 06:07:35 +01:00
|
|
|
return screen.focus(target)
|
2012-09-14 21:49:14 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-10-02 16:03:11 +02:00
|
|
|
--- Move the focus to a screen relative to the current one,
|
|
|
|
--
|
|
|
|
-- This moves the mouse pointer to the last known position on the new screen,
|
|
|
|
-- or keeps its position relative to the current focused screen.
|
|
|
|
--
|
2019-06-08 01:08:05 +02:00
|
|
|
-- @staticfct awful.screen.focus_relative
|
2016-10-02 16:03:11 +02:00
|
|
|
-- @tparam int offset Value to add to the current focused screen index. 1 to
|
|
|
|
-- focus the next one, -1 to focus the previous one.
|
|
|
|
function screen.focus_relative(offset)
|
2017-03-06 17:15:40 +01:00
|
|
|
return screen.focus(gmath.cycle(capi.screen.count(),
|
2016-10-02 16:03:11 +02:00
|
|
|
screen.focused().index + offset))
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
2019-08-19 07:31:53 +02:00
|
|
|
--- The area where clients can be tiled.
|
|
|
|
--
|
|
|
|
-- This property holds the (read only) area where clients can be tiled. Use
|
|
|
|
-- the `padding` property, `wibox.struts` and `client.struts` to modify this
|
|
|
|
-- area.
|
|
|
|
--
|
|
|
|
-- @DOC_screen_tiling_area_EXAMPLE@
|
|
|
|
--
|
|
|
|
-- @property tiling_area
|
|
|
|
-- @tparam table tiling_area
|
|
|
|
-- @tparam number tiling_area.x
|
|
|
|
-- @tparam number tiling_area.y
|
|
|
|
-- @tparam number tiling_area.width
|
|
|
|
-- @tparam number tiling_area.height
|
|
|
|
-- @see padding
|
|
|
|
-- @see get_bounding_geometry
|
|
|
|
|
|
|
|
function screen.object.get_tiling_area(s)
|
|
|
|
return s:get_bounding_geometry {
|
|
|
|
honor_padding = true,
|
|
|
|
honor_workarea = true,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2009-05-04 11:09:19 +02:00
|
|
|
--- Get or set the screen padding.
|
2016-10-02 16:03:11 +02:00
|
|
|
--
|
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)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use _screen.padding = value instead of awful.screen.padding", {deprecated_in=4})
|
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-04-05 05:35:03 +02:00
|
|
|
return screen.object.get_padding(_screen)
|
|
|
|
end
|
|
|
|
|
|
|
|
--- The screen padding.
|
2016-10-02 16:03:11 +02:00
|
|
|
--
|
|
|
|
-- This adds a "buffer" section on each side of the screen.
|
2016-04-05 05:35:03 +02:00
|
|
|
--
|
|
|
|
-- **Signal:**
|
|
|
|
--
|
|
|
|
-- * *property::padding*
|
|
|
|
--
|
2019-08-19 07:31:53 +02:00
|
|
|
-- @DOC_screen_padding_EXAMPLE@
|
|
|
|
--
|
2016-04-05 05:35:03 +02:00
|
|
|
-- @property padding
|
|
|
|
-- @param table
|
2016-10-02 16:03:11 +02:00
|
|
|
-- @tfield integer table.left The padding on the left.
|
|
|
|
-- @tfield integer table.right The padding on the right.
|
|
|
|
-- @tfield integer table.top The padding on the top.
|
|
|
|
-- @tfield integer table.bottom The padding on the bottom.
|
2016-04-05 05:35:03 +02:00
|
|
|
|
|
|
|
function screen.object.get_padding(self)
|
|
|
|
local p = data.padding[self] or {}
|
2016-10-02 16:03:11 +02:00
|
|
|
-- Create a copy to avoid accidental mutation and nil values.
|
2016-03-26 08:05:45 +01:00
|
|
|
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
|
|
|
|
|
2019-06-20 00:02:49 +02:00
|
|
|
--- A list of outputs for this screen with their size in mm.
|
|
|
|
--
|
|
|
|
-- Please note that the table content may vary. In some case, it might also be
|
|
|
|
-- empty.
|
|
|
|
--
|
|
|
|
-- An easy way to check if a screen is the laptop screen is usually:
|
|
|
|
--
|
|
|
|
-- if s.outputs["LVDS-1"] then
|
|
|
|
-- -- do something
|
|
|
|
-- end
|
|
|
|
--
|
|
|
|
-- **Signal:**
|
|
|
|
--
|
|
|
|
-- * *property::outputs*
|
|
|
|
--
|
|
|
|
-- **Immutable:** true
|
|
|
|
-- @property outputs
|
|
|
|
-- @param table
|
|
|
|
-- @tfield table table.name A table with the screen name as key (like `eDP1` on a laptop)
|
|
|
|
-- @tfield integer table.mm_width The screen physical width.
|
|
|
|
-- @tfield integer table.mm_height The screen physical height.
|
|
|
|
-- @tfield integer table.name The output name.
|
|
|
|
-- @tfield integer table.viewport_id The identifier of the viewport this output
|
|
|
|
-- corresponds to.
|
|
|
|
|
|
|
|
function screen.object.get_outputs(s)
|
|
|
|
local ret = {}
|
|
|
|
|
|
|
|
local outputs = s._custom_outputs
|
|
|
|
or (s.data.viewport and s.data.viewport.outputs or s._outputs)
|
|
|
|
|
|
|
|
-- The reason this exists is because output with name as keys is very
|
|
|
|
-- convenient for quick name lookup by the users, but inconvenient in
|
|
|
|
-- the lower layers since knowing the output count (using #) is better.
|
|
|
|
for k, v in ipairs(outputs) do
|
|
|
|
ret[v.name or k] = v
|
|
|
|
end
|
|
|
|
|
|
|
|
return ret
|
|
|
|
end
|
|
|
|
|
|
|
|
function screen.object.set_outputs(self, outputs)
|
|
|
|
self._custom_outputs = outputs
|
|
|
|
self:emit_signal("property::outputs", screen.object.get_outputs(self))
|
|
|
|
end
|
|
|
|
|
|
|
|
capi.screen.connect_signal("property::_outputs", function(s)
|
|
|
|
if not s._custom_outputs then
|
|
|
|
s:emit_signal("property::outputs", screen.object.get_outputs(s))
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2016-09-15 22:50:28 +02:00
|
|
|
--- Get the preferred screen in the context of a client.
|
2016-10-02 16:03:11 +02:00
|
|
|
--
|
2016-09-15 22:50:28 +02:00
|
|
|
-- This is exactly the same as `awful.screen.focused` except that it avoids
|
|
|
|
-- clients being moved when Awesome is restarted.
|
|
|
|
-- This is used in the default `rc.lua` to ensure clients get assigned to the
|
|
|
|
-- focused screen by default.
|
|
|
|
-- @tparam client c A client.
|
2016-09-15 22:50:10 +02:00
|
|
|
-- @treturn screen The preferred screen.
|
2019-06-08 01:08:05 +02:00
|
|
|
-- @staticfct awful.screen.preferred
|
2016-09-15 22:50:10 +02:00
|
|
|
function screen.preferred(c)
|
|
|
|
return capi.awesome.startup and c.screen or screen.focused()
|
|
|
|
end
|
|
|
|
|
2016-10-02 16:03:11 +02:00
|
|
|
--- The defaults arguments for `awful.screen.focused`.
|
2019-06-08 06:15:59 +02:00
|
|
|
-- @tfield[opt={}] table awful.screen.default_focused_args
|
2016-04-05 05:34:35 +02:00
|
|
|
|
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.
|
|
|
|
--
|
2019-06-08 01:08:05 +02:00
|
|
|
-- @staticfct 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 {}
|
2016-08-01 21:29:02 +02:00
|
|
|
return get_screen(
|
2016-08-11 19:03:17 +02:00
|
|
|
args.client and capi.client.focus and capi.client.focus.screen or capi.mouse.screen
|
2016-08-01 21:29:02 +02:00
|
|
|
)
|
2015-01-31 16:40:46 +01:00
|
|
|
end
|
|
|
|
|
2016-03-26 08:07:20 +01:00
|
|
|
--- Get a placement bounding geometry.
|
|
|
|
--
|
2016-10-02 16:03:11 +02:00
|
|
|
-- This method computes the different variants of the "usable" screen geometry.
|
2016-03-26 08:07:20 +01:00
|
|
|
--
|
2019-06-08 01:08:05 +02:00
|
|
|
-- @staticfct screen.get_bounding_geometry
|
2016-03-26 08:07:20 +01:00
|
|
|
-- @tparam[opt={}] table args The arguments
|
2016-11-22 02:36:16 +01:00
|
|
|
-- @tparam[opt=false] boolean args.honor_padding Whether to honor the screen's padding.
|
|
|
|
-- @tparam[opt=false] boolean args.honor_workarea Whether to honor the screen's workarea.
|
2016-10-02 16:03:11 +02:00
|
|
|
-- @tparam[opt] int|table args.margins Apply some margins on the output.
|
|
|
|
-- This can either be a number or a table with *left*, *right*, *top*
|
|
|
|
-- and *bottom* keys.
|
|
|
|
-- @tag[opt] args.tag Use this tag's screen.
|
|
|
|
-- @tparam[opt] drawable args.parent A parent drawable to use as base geometry.
|
|
|
|
-- @tab[opt] args.bounding_rect A bounding rectangle. This parameter is
|
|
|
|
-- incompatible with `honor_workarea`.
|
2016-03-26 08:07:20 +01:00
|
|
|
-- @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-12-28 12:41:59 +01:00
|
|
|
--- The list of visible clients for the screen.
|
2016-04-07 06:09:20 +02:00
|
|
|
--
|
|
|
|
-- Minimized and unmanaged clients are not included in this list as they are
|
|
|
|
-- technically not on the screen.
|
|
|
|
--
|
2016-10-02 16:03:11 +02:00
|
|
|
-- The clients on tags that are currently not visible are not part of this list.
|
2016-04-05 09:02:00 +02:00
|
|
|
--
|
2016-12-28 12:41:59 +01:00
|
|
|
-- Clients are returned using the stacking order (from top to bottom).
|
|
|
|
-- See `get_clients` if you want them in the order used in the tasklist by
|
|
|
|
-- default.
|
|
|
|
--
|
2016-04-07 06:09:20 +02:00
|
|
|
-- @property clients
|
2016-10-02 16:03:11 +02:00
|
|
|
-- @param table The clients list, ordered from 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
|
|
|
|
2016-12-28 12:41:59 +01:00
|
|
|
--- Get the list of visible clients for the screen.
|
|
|
|
--
|
|
|
|
-- This is used by `screen.clients` internally (with `stacked=true`).
|
|
|
|
--
|
2019-06-08 01:08:05 +02:00
|
|
|
-- @method get_clients
|
2016-12-28 12:41:59 +01:00
|
|
|
-- @tparam[opt=true] boolean stacked Use stacking order? (top to bottom)
|
|
|
|
-- @treturn table The clients list.
|
|
|
|
function screen.object.get_clients(s, stacked)
|
|
|
|
local cls = capi.client.get(s, stacked == nil and true or stacked)
|
2016-04-07 06:09:20 +02:00
|
|
|
local vcls = {}
|
|
|
|
for _, c in pairs(cls) do
|
|
|
|
if c:isvisible() then
|
|
|
|
table.insert(vcls, c)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return vcls
|
|
|
|
end
|
|
|
|
|
2016-10-02 16:03:11 +02:00
|
|
|
--- Get the list of clients assigned to the screen but not currently visible.
|
2016-04-05 09:02:00 +02:00
|
|
|
--
|
2016-10-02 16:03:11 +02:00
|
|
|
-- This includes minimized clients and clients on hidden tags.
|
2016-04-05 09:02:00 +02:00
|
|
|
--
|
|
|
|
-- @property hidden_clients
|
2016-10-02 16:03:11 +02:00
|
|
|
-- @param table The clients list, ordered from top to bottom.
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @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
|
|
|
|
|
2016-12-28 12:41:59 +01:00
|
|
|
--- All clients assigned to the screen.
|
2016-04-05 09:02:00 +02:00
|
|
|
--
|
|
|
|
-- @property all_clients
|
2016-10-02 16:03:11 +02:00
|
|
|
-- @param table The clients list, ordered from top to bottom.
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @see clients
|
|
|
|
-- @see hidden_clients
|
|
|
|
-- @see client.get
|
|
|
|
|
2016-12-28 12:41:59 +01:00
|
|
|
--- Get all clients assigned to the screen.
|
|
|
|
--
|
|
|
|
-- This is used by `all_clients` internally (with `stacked=true`).
|
|
|
|
--
|
2019-06-06 22:32:53 +02:00
|
|
|
-- @method get_all_clients
|
2016-12-28 12:41:59 +01:00
|
|
|
-- @tparam[opt=true] boolean stacked Use stacking order? (top to bottom)
|
|
|
|
-- @treturn table The clients list.
|
|
|
|
function screen.object.get_all_clients(s, stacked)
|
|
|
|
return capi.client.get(s, stacked == nil and true or stacked)
|
2016-04-05 09:02:00 +02:00
|
|
|
end
|
|
|
|
|
2016-12-28 12:41:59 +01:00
|
|
|
--- Tiled clients for the screen.
|
2016-04-07 06:09:20 +02:00
|
|
|
--
|
2016-10-02 16:03:11 +02:00
|
|
|
-- Same as `clients`, but excluding:
|
2016-04-07 06:09:20 +02:00
|
|
|
--
|
|
|
|
-- * fullscreen clients
|
|
|
|
-- * maximized clients
|
|
|
|
-- * floating clients
|
|
|
|
--
|
|
|
|
-- @property tiled_clients
|
2016-10-02 16:03:11 +02:00
|
|
|
-- @param table The clients list, ordered from top to bottom.
|
2016-04-07 06:09:20 +02:00
|
|
|
|
2016-12-28 12:41:59 +01:00
|
|
|
--- Get tiled clients for the screen.
|
|
|
|
--
|
|
|
|
-- This is used by `tiles_clients` internally (with `stacked=true`).
|
|
|
|
--
|
2019-06-06 22:32:53 +02:00
|
|
|
-- @method get_tiled_clients
|
2016-12-28 12:41:59 +01:00
|
|
|
-- @tparam[opt=true] boolean stacked Use stacking order? (top to bottom)
|
|
|
|
-- @treturn table The clients list.
|
|
|
|
function screen.object.get_tiled_clients(s, stacked)
|
|
|
|
local clients = s:get_clients(stacked)
|
2016-04-07 06:09:20 +02:00
|
|
|
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
|
|
|
|
|
2016-04-05 06:01:31 +02:00
|
|
|
--- Call a function for each existing and created-in-the-future screen.
|
2016-10-02 16:03:11 +02:00
|
|
|
--
|
2019-06-08 01:08:05 +02:00
|
|
|
-- @staticfct awful.screen.connect_for_each_screen
|
2016-04-05 06:01:31 +02:00
|
|
|
-- @tparam function func The function to call.
|
2016-10-02 16:03:11 +02:00
|
|
|
-- @screen func.screen The screen.
|
2016-04-05 06:01:31 +02:00
|
|
|
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.
|
2019-06-08 01:08:05 +02:00
|
|
|
-- @staticfct 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.
|
|
|
|
--
|
2016-10-02 16:03:11 +02:00
|
|
|
-- This property is read only, use `tag.screen`, `awful.tag.add`,
|
|
|
|
-- `awful.tag.new` or `t:delete()` to alter this list.
|
2016-04-05 09:02:00 +02:00
|
|
|
--
|
|
|
|
-- @property tags
|
|
|
|
-- @param table
|
2016-10-02 16:03:11 +02:00
|
|
|
-- @treturn table A table with all available tags.
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
function screen.object.get_tags(s, unordered)
|
|
|
|
local tags = {}
|
|
|
|
|
2019-06-20 00:02:49 +02:00
|
|
|
for _, t in ipairs(capi.root.tags()) do
|
2016-04-05 09:02:00 +02:00
|
|
|
if get_screen(t.screen) == s then
|
|
|
|
table.insert(tags, t)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-10-02 16:03:11 +02:00
|
|
|
-- Avoid infinite loop and save some time.
|
2016-04-05 09:02:00 +02:00
|
|
|
if not unordered then
|
|
|
|
table.sort(tags, function(a, b)
|
2016-08-22 23:27:31 +02:00
|
|
|
return (a.index or math.huge) < (b.index or math.huge)
|
2016-04-05 09:02:00 +02:00
|
|
|
end)
|
|
|
|
end
|
|
|
|
return 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
|
|
|
|
|
|
|
|
--- The first selected tag.
|
|
|
|
-- @property selected_tag
|
2019-01-05 10:32:37 +01:00
|
|
|
-- @param tag
|
2016-10-02 16:03:11 +02:00
|
|
|
-- @treturn ?tag The first selected tag or nil.
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @see tag.selected
|
|
|
|
-- @see selected_tags
|
|
|
|
|
|
|
|
function screen.object.get_selected_tag(s)
|
|
|
|
return screen.object.get_selected_tags(s)[1]
|
|
|
|
end
|
|
|
|
|
2019-06-25 05:11:40 +02:00
|
|
|
local function normalize(ratios, size)
|
|
|
|
local sum = 0
|
|
|
|
|
|
|
|
for _, r in ipairs(ratios) do
|
|
|
|
sum = sum + r
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Avoid to mutate the input.
|
|
|
|
local ret = {}
|
|
|
|
local sum2 = 0
|
|
|
|
|
|
|
|
for k, r in ipairs(ratios) do
|
|
|
|
ret[k] = (r*100)/sum
|
|
|
|
ret[k] = math.floor(size*ret[k]*0.01)
|
|
|
|
sum2 = sum2 + ret[k]
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Ratios are random float number. Pixels cannot be divided. This adds the
|
|
|
|
-- remaining pixels to the end. A better approach would be to redistribute
|
|
|
|
-- them based on the ratios. However, nobody will notice.
|
|
|
|
ret[#ret] = ret[#ret] + (size - sum2)
|
|
|
|
|
|
|
|
return ret
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Split the screen into multiple screens.
|
|
|
|
--
|
|
|
|
-- This is useful to turn ultrawide monitors into something more useful without
|
|
|
|
-- fancy client layouts:
|
|
|
|
--
|
|
|
|
-- @DOC_awful_screen_split1_EXAMPLE@
|
|
|
|
--
|
|
|
|
-- It can also be used to turn a vertical "side" screen into 2 smaller screens:
|
|
|
|
--
|
|
|
|
-- @DOC_awful_screen_split2_EXAMPLE@
|
|
|
|
--
|
|
|
|
-- @tparam[opt] table ratios The different ratios to split into. If none is
|
|
|
|
-- provided, it is split in half.
|
|
|
|
-- @tparam[opt] string mode Either "vertical" or "horizontal". If none is
|
|
|
|
-- specified, it will split along the longest axis.
|
|
|
|
-- @method split
|
|
|
|
function screen.object.split(s, ratios, mode, _geo)
|
|
|
|
s = get_screen(s)
|
|
|
|
|
|
|
|
_geo = _geo or s.geometry
|
|
|
|
ratios = ratios or {50,50}
|
|
|
|
|
|
|
|
-- In practice, this is almost always what the user wants.
|
|
|
|
mode = mode or (
|
|
|
|
_geo.height > _geo.width and "vertical" or "horizontal"
|
|
|
|
)
|
|
|
|
|
|
|
|
assert(mode == "horizontal" or mode == "vertical")
|
|
|
|
|
|
|
|
assert((not s) or s.valid)
|
|
|
|
assert(#ratios >= 2)
|
|
|
|
|
|
|
|
local sizes, ret = normalize(
|
|
|
|
ratios, mode == "horizontal" and _geo.width or _geo.height
|
|
|
|
), {}
|
|
|
|
|
|
|
|
assert(#sizes >=2)
|
|
|
|
|
|
|
|
if s then
|
|
|
|
if mode == "horizontal" then
|
|
|
|
s:fake_resize(_geo.x, _geo.y, sizes[1], _geo.height)
|
|
|
|
else
|
|
|
|
s:fake_resize(_geo.x, _geo.y, _geo.width, sizes[1])
|
|
|
|
end
|
|
|
|
table.insert(ret, s)
|
|
|
|
end
|
|
|
|
|
|
|
|
local pos = _geo[mode == "horizontal" and "x" or "y"]
|
|
|
|
+ (s and sizes[1] or 0)
|
|
|
|
|
|
|
|
for k=2, #sizes do
|
|
|
|
local ns
|
|
|
|
|
|
|
|
if mode == "horizontal" then
|
|
|
|
ns = capi.screen.fake_add(pos, _geo.y, sizes[k], _geo.height)
|
|
|
|
else
|
|
|
|
ns = capi.screen.fake_add(_geo.x, pos, _geo.width, sizes[k])
|
|
|
|
end
|
|
|
|
|
|
|
|
table.insert(ret, ns)
|
|
|
|
|
|
|
|
if s then
|
|
|
|
ns.data.viewport = s.data.viewport
|
|
|
|
|
|
|
|
if not ns.data.viewport then
|
|
|
|
ns.outputs = s.outputs
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
pos = pos + sizes[k]
|
|
|
|
end
|
|
|
|
|
|
|
|
return ret
|
|
|
|
end
|
|
|
|
|
2017-11-19 05:23:24 +01:00
|
|
|
--- Enable the automatic calculation of the screen DPI (experimental).
|
|
|
|
--
|
|
|
|
-- This will cause many elements such as the font and some widgets to be scaled
|
|
|
|
-- so they look the same (physical) size on different devices with different
|
|
|
|
-- pixel density.
|
|
|
|
--
|
|
|
|
-- It is calculated using the information provided from `xrandr`.
|
|
|
|
--
|
|
|
|
-- When enabled, the theme and configuration must avoid using pixel sizes for
|
|
|
|
-- different elements as this will cause misalignment or hidden content on some
|
|
|
|
-- devices.
|
|
|
|
--
|
|
|
|
-- Note that it has to be called early in `rc.lua` and requires restarting
|
|
|
|
-- awesome to take effect. It is disabled by default and changes introduced in
|
|
|
|
-- minor releases of Awesome may slightly break the behavior as more components
|
|
|
|
-- gain support for HiDPI.
|
|
|
|
--
|
|
|
|
-- When disabled the DPI is acquired from the `Xft.dpi` X resource (xrdb),
|
|
|
|
-- defaulting to 96.
|
|
|
|
--
|
|
|
|
-- @tparam boolean enabled Enable or disable automatic DPI support.
|
2019-06-08 01:08:05 +02:00
|
|
|
-- @staticfct awful.screen.set_auto_dpi_enabled
|
2017-11-19 05:23:24 +01:00
|
|
|
function screen.set_auto_dpi_enabled(enabled)
|
|
|
|
for s in capi.screen do
|
|
|
|
s.data.dpi_cache = nil
|
|
|
|
end
|
|
|
|
data.autodpi = enabled
|
|
|
|
end
|
|
|
|
|
2017-10-08 12:30:21 +02:00
|
|
|
--- The number of pixels per inch of the screen.
|
2019-06-20 00:02:49 +02:00
|
|
|
--
|
|
|
|
-- The default DPI comes from the X11 server. In most case, it will be 96. If
|
|
|
|
-- `autodpi` is set to `true` on the screen, it will use the least dense dpi
|
|
|
|
-- from the screen outputs. Most of the time, screens only have a single output,
|
|
|
|
-- however it will have two (or more) when "clone mode" is used (eg, when a
|
|
|
|
-- screen is duplicated on a projector).
|
|
|
|
--
|
2017-10-08 12:30:21 +02:00
|
|
|
-- @property dpi
|
2019-06-08 06:15:59 +02:00
|
|
|
-- @param number the DPI value.
|
2017-10-08 12:30:21 +02:00
|
|
|
|
2019-06-20 00:02:49 +02:00
|
|
|
--- The lowest density DPI from all of the (physical) outputs.
|
|
|
|
-- @property minimum_dpi
|
|
|
|
-- @param number the DPI value.
|
2017-10-08 14:40:20 +02:00
|
|
|
|
2019-06-20 00:02:49 +02:00
|
|
|
--- The highest density DPI from all of the (physical) outputs.
|
|
|
|
-- @property maximum_dpi
|
|
|
|
-- @param number the DPI value.
|
2017-10-08 12:30:21 +02:00
|
|
|
|
2019-06-20 00:02:49 +02:00
|
|
|
--- The preferred DPI from all of the (physical) outputs.
|
|
|
|
--
|
|
|
|
-- This is computed by normalizing all output to fill the area, then picking
|
|
|
|
-- the lowest of the resulting virtual DPIs.
|
|
|
|
--
|
|
|
|
-- @property preferred_dpi
|
|
|
|
-- @param number the DPI value.
|
2017-10-08 12:30:21 +02:00
|
|
|
|
2018-12-27 08:02:52 +01:00
|
|
|
--- Emitted when a new screen is added.
|
|
|
|
--
|
|
|
|
-- The handler(s) of this signal are responsible of adding elements such as
|
|
|
|
-- bars, docks or other elements to a screen. The signal is emitted when a
|
|
|
|
-- screen is added, including during startup.
|
|
|
|
--
|
|
|
|
-- The only default implementation is the one provided by `rc.lua`.
|
|
|
|
--
|
|
|
|
-- @signal request::desktop_decoration
|
|
|
|
-- @tparam screen s The screen object.
|
|
|
|
|
|
|
|
--- Emitted when a new screen needs a wallpaper.
|
|
|
|
--
|
|
|
|
-- The handler(s) of this signal are responsible to set the wallpaper. The
|
|
|
|
-- signal is emitted when a screen is added (including at startup), when its
|
|
|
|
-- DPI changes or when its geometry changes.
|
|
|
|
--
|
|
|
|
-- The only default implementation is the one provided by `rc.lua`.
|
|
|
|
--
|
|
|
|
-- @signal request::wallpaper
|
|
|
|
-- @tparam screen s The screen object.
|
|
|
|
|
2019-06-20 00:02:49 +02:00
|
|
|
--- When a new (physical) screen area has been added.
|
|
|
|
--
|
|
|
|
-- Important: This only exists when Awesome is started with `--screen off`.
|
|
|
|
-- Please also note that this doesn't mean it will appear when a screen is
|
|
|
|
-- physically plugged. Depending on the configuration a tool like `arandr` or
|
|
|
|
-- the `xrandr` command is needed.
|
|
|
|
--
|
|
|
|
-- The default handler will create a screen that fills the area.
|
|
|
|
--
|
|
|
|
-- To disconnect the default handler, use:
|
|
|
|
--
|
|
|
|
-- screen.disconnect_signal(
|
|
|
|
-- "request::create", awful.screen.create_screen_handler
|
|
|
|
-- )
|
|
|
|
--
|
|
|
|
-- @signal request::create
|
|
|
|
-- @tparam table viewport
|
|
|
|
-- @tparam table viewport.geometry A table with `x`, `y`, `width` and `height`
|
|
|
|
-- keys.
|
|
|
|
-- @tparam table viewport.outputs A table with the monitor name and possibly the
|
|
|
|
-- `mm_width` and `mm_height` values if they are available.
|
|
|
|
-- @tparam number viewport.id An identifier for this viewport (by pixel
|
|
|
|
-- resolution). It
|
|
|
|
-- will not change when outputs are modified, but will change when the
|
|
|
|
-- resolution changes. Note that if it fully disappear, the next time an
|
|
|
|
-- viewport with the same resolution appears, it will have a different `id`.
|
|
|
|
-- @tparam number viewport.minimum_dpi The least dense DPI.
|
|
|
|
-- @tparam number viewport.maximum_dpi The most dense DPI.
|
|
|
|
-- @tparam number viewport.preferred_dpi The relative least dense DPI.
|
|
|
|
-- @tparam table args
|
|
|
|
-- @tparam string args.context Why was this signal sent.
|
|
|
|
-- @see outputs
|
|
|
|
-- @see awful.screen.create_screen_handler
|
|
|
|
|
|
|
|
--- When a physical monitor viewport has been removed.
|
|
|
|
--
|
|
|
|
-- Important: This only exists when Awesome is started with `--screen off`.
|
|
|
|
--
|
|
|
|
-- If you replace the default handler, it is up to you to find the screen(s)
|
|
|
|
-- associated with this viewport.
|
|
|
|
--
|
|
|
|
-- To disconnect the default handler, use:
|
|
|
|
--
|
|
|
|
-- screen.disconnect_signal(
|
|
|
|
-- "request::remove", awful.screen.remove_screen_handler
|
|
|
|
-- )
|
|
|
|
--
|
|
|
|
-- @signal request::remove
|
|
|
|
-- @tparam table viewport
|
|
|
|
-- @tparam table viewport.geometry A table with `x`, `y`, `width` and `height`
|
|
|
|
-- keys.
|
|
|
|
-- @tparam table viewport.outputs A table with the monitor name and possibly the
|
|
|
|
-- `mm_width` and `mm_height` values if they are available.
|
|
|
|
-- @tparam number viewport.id An identifier for this viewport (by pixel
|
|
|
|
-- resolution). It will not change when outputs are modified, but will change
|
|
|
|
-- when the resolution changes. Note that if it fully disappear, the next time
|
|
|
|
-- an viewport with the same resolution appears, it will have a different `id`.
|
|
|
|
-- @tparam number viewport.minimum_dpi The least dense DPI.
|
|
|
|
-- @tparam number viewport.maximum_dpi The most dense DPI.
|
|
|
|
-- @tparam number viewport.preferred_dpi The relative least dense DPI.
|
|
|
|
-- @tparam table args
|
|
|
|
-- @tparam string args.context Why was this signal sent.
|
|
|
|
-- @see awful.screen.remove_screen_handler
|
|
|
|
|
|
|
|
--- When a physical viewport resolution has changed or it has been replaced.
|
|
|
|
--
|
|
|
|
-- Important: This only exists when Awesome is started with `--screen off`.
|
|
|
|
--
|
|
|
|
-- Note that given the viewports are not the same, the `id` wont be the same.
|
|
|
|
-- Also note that if multiple new viewports fit within a single "old" viewport,
|
|
|
|
-- the resized screen will be the one with the largest total overlapping
|
|
|
|
-- viewport (`intersection.width*intersection.height`), regardless of the
|
|
|
|
-- outputs names.
|
|
|
|
--
|
|
|
|
-- To disconnect the default handler, use:
|
|
|
|
--
|
|
|
|
-- screen.disconnect_signal(
|
|
|
|
-- "request::resize", awful.screen.resize_screen_handler
|
|
|
|
-- )
|
|
|
|
--
|
|
|
|
-- @signal request::resize
|
|
|
|
-- @tparam table old_viewport
|
|
|
|
-- @tparam table old_viewport.geometry A table with `x`, `y`, `width` and
|
|
|
|
-- `height` keys.
|
|
|
|
-- @tparam table old_viewport.outputs A table with the monitor name and
|
|
|
|
-- possibly the `mm_width` and `mm_height` values if they are available.
|
|
|
|
-- @tparam number old_viewport.id An identifier for this viewport (by pixel
|
|
|
|
-- resolution). It will not change when outputs are modified, but will change
|
|
|
|
-- when the resolution changes. Note that if it fully disappear, the next
|
|
|
|
-- time an viewport with the same resolution appears, it will have a different
|
|
|
|
-- `id`.
|
|
|
|
-- @tparam number old_viewport.minimum_dpi The least dense DPI.
|
|
|
|
-- @tparam number old_viewport.maximum_dpi The most dense DPI.
|
|
|
|
-- @tparam number old_viewport.preferred_dpi The relative least dense DPI.
|
|
|
|
-- @tparam table new_viewport
|
|
|
|
-- @tparam table new_viewport.geometry A table with `x`, `y`, `width` and
|
|
|
|
-- `height` keys.
|
|
|
|
-- @tparam table new_viewport.outputs A table with the monitor name and
|
|
|
|
-- possibly the
|
|
|
|
-- `mm_width` and `mm_height` values if they are available.
|
|
|
|
-- @tparam number new_viewport.id An identifier for this viewport (by pixel
|
|
|
|
-- resolution). It will not change when outputs are modified, but will change
|
|
|
|
-- when the resolution changes. Note that if it fully disappear, the next time
|
|
|
|
-- an viewport with the same resolution appears, it will have a different `id`.
|
|
|
|
-- @tparam number new_viewport.minimum_dpi The least dense DPI.
|
|
|
|
-- @tparam number new_viewport.maximum_dpi The most dense DPI.
|
|
|
|
-- @tparam number new_viewport.preferred_dpi The relative least dense DPI.
|
|
|
|
-- @tparam table args
|
|
|
|
-- @tparam string args.context Why was this signal sent.
|
|
|
|
-- @see awful.screen.resize_screen_handler
|
|
|
|
|
|
|
|
--- Default handler for `request::create`.
|
|
|
|
--
|
|
|
|
-- Important: This only exists when Awesome is started with `--screen off`.
|
|
|
|
--
|
|
|
|
-- A simplified implementation looks like:
|
|
|
|
--
|
|
|
|
-- function(viewport --[[, args]])
|
|
|
|
-- local geo = viewport.geometry
|
|
|
|
-- local s = screen.fake_add(geo.x, geo.y, geo.width, geo.height)
|
2019-07-10 22:31:36 +02:00
|
|
|
-- s:emit_signal("request::desktop_decoration")
|
|
|
|
-- s:emit_signal("request::wallpaper")
|
2019-06-20 00:02:49 +02:00
|
|
|
-- end
|
|
|
|
--
|
|
|
|
-- If you implement this by hand, you must also implement handler for the
|
|
|
|
-- `request::remove` and `request::resize`.
|
|
|
|
--
|
|
|
|
-- @signalhandler awful.screen.create_screen_handler
|
|
|
|
-- @see request::create
|
|
|
|
|
|
|
|
--- Default handler for `request::remove`.
|
|
|
|
--
|
|
|
|
-- Important: This only exists when Awesome is started with `--screen off`.
|
|
|
|
--
|
|
|
|
-- A simplified version of the logic is:
|
|
|
|
--
|
|
|
|
-- function (viewport --[[, args]])
|
|
|
|
-- local geo = viewport.geometry
|
|
|
|
-- for s in screen do
|
|
|
|
-- if gears.geometry.rectangle.are_equal(geo, s.geometry) then
|
|
|
|
-- s:fake_remove()
|
|
|
|
-- return
|
|
|
|
-- end
|
|
|
|
-- end
|
|
|
|
-- end
|
|
|
|
--
|
|
|
|
-- @signalhandler awful.screen.remove_screen_handler
|
|
|
|
-- @see request::remove
|
|
|
|
|
|
|
|
--- Default handler for `request::resize`.
|
|
|
|
--
|
|
|
|
-- Important: This only exists when Awesome is started with `--screen off`.
|
|
|
|
--
|
|
|
|
-- A simplified version of the logic is:
|
|
|
|
--
|
|
|
|
-- function (old_viewport, new_viewport --[[, args]])
|
|
|
|
-- local old_geo, new_geo = old_viewport.geometry, new_viewport.geometry
|
|
|
|
-- for s in screen do
|
|
|
|
-- local sgeo = new_viewport.geometry
|
|
|
|
-- if gears.geometry.rectangle.are_equal(old_geo, s.geometry) then
|
|
|
|
-- s:fake_resize(
|
|
|
|
-- sgeo.x, sgeo.y, sgeo.width, sgeo.height
|
|
|
|
-- )
|
|
|
|
-- end
|
|
|
|
-- end
|
|
|
|
-- end
|
|
|
|
--
|
|
|
|
-- @signalhandler awful.screen.resize_screen_handler
|
|
|
|
-- @see request::resize
|
|
|
|
|
|
|
|
-- Add the DPI properties.
|
|
|
|
require("awful.screen.dpi")(screen, data)
|
|
|
|
|
2018-12-27 08:02:52 +01:00
|
|
|
-- Set the wallpaper(s) and create the bar(s) for new screens
|
2019-07-10 22:31:36 +02:00
|
|
|
|
2018-12-27 08:02:52 +01:00
|
|
|
capi.screen.connect_signal("added", function(s)
|
2019-07-10 22:31:36 +02:00
|
|
|
-- If it was emited from here when screens are created with fake_add,
|
|
|
|
-- the Lua code would not have an opportunity to polutate the screen
|
|
|
|
-- metadata. Thus, the DPI may be wrong when setting the wallpaper.
|
2019-07-11 03:03:05 +02:00
|
|
|
if s._managed ~= "Lua" then
|
|
|
|
s:emit_signal("request::desktop_decoration")
|
|
|
|
s:emit_signal("request::wallpaper")
|
|
|
|
end
|
2018-12-27 08:02:52 +01:00
|
|
|
end)
|
|
|
|
|
|
|
|
-- Resize the wallpaper(s)
|
|
|
|
for _, prop in ipairs {"geometry", "dpi" } do
|
|
|
|
capi.screen.connect_signal("property::"..prop, function(s)
|
|
|
|
s:emit_signal("request::wallpaper")
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Create the bar for existing screens when an handler is added
|
|
|
|
capi.screen.connect_signal("request::desktop_decoration::connected", function(new_handler)
|
2019-07-10 22:31:36 +02:00
|
|
|
if capi.screen.automatic_factory then
|
|
|
|
for s in capi.screen do
|
|
|
|
new_handler(s)
|
|
|
|
end
|
2018-12-27 08:02:52 +01:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
-- Set the wallpaper when an handler is added.
|
|
|
|
capi.screen.connect_signal("request::wallpaper::connected", function(new_handler)
|
2019-07-10 22:31:36 +02:00
|
|
|
if capi.screen.automatic_factory then
|
|
|
|
for s in capi.screen do
|
|
|
|
new_handler(s)
|
|
|
|
end
|
2018-12-27 08:02:52 +01:00
|
|
|
end
|
|
|
|
end)
|
2016-04-05 09:02:00 +02:00
|
|
|
|
2016-04-12 04:53:22 +02:00
|
|
|
--- When the tag history changed.
|
|
|
|
-- @signal tag::history::update
|
|
|
|
|
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
|
|
|
|
2019-06-06 22:32:53 +02:00
|
|
|
--@DOC_object_COMMON@
|
|
|
|
|
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
|