Debug the suggested changes to lib/awful/screen.lua per the discussion

thread at PR 3448. PR 3448 involves changes to expand the content
(screenshot) API. Originally, I added both root.content() and and
screen.content to the C source, as client.content has always been
handled. However, screen.content in effect takes a root screenshot and
returns a crop of it. This can just as easily be done through Lua.

When this quick update was implemented in github, the code added to
awful.screen.lua was not quite correct. These changes represent the
debugged version. Users can now call s.content for a screen object, s,
and the screenshot will work transparently.

Signed Off: Brian Sobulefsky <brian.sobulefsky@protonmail.com>
This commit is contained in:
poisson-aerohead 2021-09-30 18:13:35 -07:00 committed by Emmanuel Lepage Vallee
parent a9bf812c17
commit b4cb3eae7b
1 changed files with 18 additions and 0 deletions

View File

@ -19,6 +19,8 @@ local gdebug = require("gears.debug")
local gmath = require("gears.math")
local object = require("gears.object")
local grect = require("gears.geometry").rectangle
local gsurf = require("gears.surface")
local cairo = require("lgi").cairo
local function get_screen(s)
return s and capi.screen[s]
@ -201,6 +203,22 @@ function screen.object.get_tiling_area(s)
}
end
--- Take a screenshot of the physical screen.
--
-- Reading this (read only) property returns a screenshot of the physical
-- (Xinerama) screen as a cairo surface.
function screen.object.get_content(s)
local geo = s.geometry
local source = gsurf(root.content())
local target = source:create_similar(cairo.Content.COLOR, geo.width, geo.height)
local cr = cairo.Context(target)
cr:set_source_surface(source, -geo.x, -geo.y)
cr:rectangle(0, 0, geo.width, geo.height)
cr:fill()
return target
end
--- Get or set the screen padding.
--
-- @deprecated awful.screen.padding