doc: Add a client "sticky" example.

This commit is contained in:
Emmanuel Lepage Vallee 2020-09-05 17:55:34 -07:00
parent 522d628c2c
commit 8fb4e2b721
3 changed files with 74 additions and 3 deletions

View File

@ -815,6 +815,12 @@ lua_class_t client_class;
* @propemits false false
* @request client geometry fullscreen granted When the client must be resized
* because it became (or stop being) fullscreen.
* @see maximized_horizontal
* @see maximized_vertical
* @see immobilized_horizontal
* @see immobilized_vertical
* @see maximized
*/
/**
@ -828,6 +834,11 @@ lua_class_t client_class;
* @request client geometry maximized granted When the client must be resized
* because it became (or stop being) maximized.
* @see request::border
* @see maximized_horizontal
* @see maximized_vertical
* @see fullscreen
* @see immobilized_horizontal
* @see immobilized_vertical
*/
/**
@ -840,6 +851,11 @@ lua_class_t client_class;
* @propemits false false
* @request client geometry maximized_horizontal granted When the client must be resized
* because it became (or stop being) maximized horizontally.
* @see maximized_vertical
* @see fullscreen
* @see immobilized_horizontal
* @see immobilized_vertical
* @see maximized
*/
/**
@ -852,6 +868,11 @@ lua_class_t client_class;
* @propemits false false
* @request client geometry maximized_vertical granted When the client must be resized
* because it became (or stop being) maximized vertically.
* @see maximized_horizontal
* @see fullscreen
* @see immobilized_horizontal
* @see immobilized_vertical
* @see maximized
*/
/**
@ -994,6 +1015,8 @@ lua_class_t client_class;
* per screens rather than globally like some other
* implementations.
*
* @DOC_sequences_client_sticky_EXAMPLE@
*
* @property sticky
* @tparam boolean sticky
* @propemits false false

View File

@ -0,0 +1,31 @@
--DOC_GEN_IMAGE --DOC --DOC_NO_USAGE --DOC_ASTERISK
local module = ... --DOC_HIDE
local awful = {tag = require("awful.tag"), layout = require("awful.layout") } --DOC_HIDE
screen[1]._resize {x = 0, width = 128, height = 96} --DOC_HIDE
function awful.spawn(_, args) --DOC_HIDE
local c = client.gen_fake{x = 10, y = 10, height=50, width=50} --DOC_HIDE
c:tags{screen[1].tags[1]} --DOC_HIDE
end --DOC_HIDE
awful.tag({ "one", "two", "three", "four", "five" }, screen[1]) --DOC_HIDE
module.add_event("Add a client", function() --DOC_HIDE
-- Add a client.
awful.spawn("xterm")
assert(#screen[1].clients == 1) --DOC_HIDE
end) --DOC_HIDE
module.display_tags() --DOC_HIDE
--DOC_NEWLINE
module.add_event("Set sticky = true", function() --DOC_HIDE
-- Set sticky = true
screen[1].clients[1].sticky = true
end) --DOC_HIDE
module.display_tags() --DOC_HIDE
module.execute {show_empty = true} --DOC_HIDE

View File

@ -242,11 +242,28 @@ local function gen_cls(c,results)
return ret
end
local function get_all_tag_clients(t)
local s = t.screen
local clients = gtable.clone(t:clients(), false)
for _, c in ipairs(s.clients) do
if c.sticky then
if not gtable.hasitem(clients, c) then
table.insert(clients, c)
end
end
end
return clients
end
local function fake_arrange(tag)
local cls,results,flt = {},setmetatable({},{__mode="k"}),{}
local _, l = tag.screen, tag.layout
local l = tag.layout
local focus, focus_wrap = capi.client.focus, nil
for _ ,c in ipairs (tag:clients()) do
for _ ,c in ipairs (get_all_tag_clients(tag)) do
-- Handle floating client separately
if not c.minimized then
local floating = c.floating
@ -758,7 +775,7 @@ function module.display_tags()
master_width_factor = t.master_width_factor,
client_geo = fake_arrange(t),
})
assert(#st[#st].client_geo == #t:clients())
assert(#st[#st].client_geo == #get_all_tag_clients(t))
end
table.insert(ret, {tags=st})
end