From 785ca98337c746b87fc7bf5fa35242d25e6e7cae Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Fri, 15 Oct 2021 19:57:11 -0700 Subject: [PATCH] client: Turn client.setslave/setmaster into properties. It also no longer use the master/slave name. In this case, it kinds of make sense since, for example, of the tag `master_count` is greater than the number of clients, calling `client.setslave` move the client to another "master" slot. Closes #626 --- lib/awful/client.lua | 49 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/lib/awful/client.lua b/lib/awful/client.lua index d80ea52d..44b2107a 100644 --- a/lib/awful/client.lua +++ b/lib/awful/client.lua @@ -428,7 +428,7 @@ end --- Get the master window. -- --- @legacylayout awful.client.getmaster +-- @deprecated awful.client.getmaster -- @tparam[opt=awful.screen.focused()] screen s The screen. -- @treturn client The master client. function client.getmaster(s) @@ -438,22 +438,53 @@ end --- Set the client as master: put it at the beginning of other windows. -- --- @legacylayout awful.client.setmaster +-- @deprecated awful.client.setmaster -- @tparam client c The window to set as master. function client.setmaster(c) - local cls = gtable.reverse(capi.client.get(c.screen)) - for _, v in pairs(cls) do - c:swap(v) - end + c:to_primary_section() end --- Set the client as slave: put it at the end of other windows. --- @legacylayout awful.client.setslave +-- @deprecated awful.client.setslave -- @tparam client c The window to set as slave. function client.setslave(c) - local cls = capi.client.get(c.screen) + c:to_secondary_section() +end + +--- Move the client to the most significant layout position. +-- +-- This only affects tiled clients. It will shift all other +-- client to fill the gap caused to by the move. +-- +-- @DOC_sequences_client_to_primary_EXAMPLE@ +-- +-- @method to_primary_section +-- @see swap +-- @see to_secondary_section +function client.object:to_primary_section() + local cls = gtable.reverse(capi.client.get(self.screen)) + for _, v in pairs(cls) do - c:swap(v) + self:swap(v) + end +end + +--- Move the client to the least significant layout position. +-- +-- This only affects tiled clients. It will shift all other +-- client to fill the gap caused to by the move. +-- +-- @DOC_sequences_client_to_secondary_EXAMPLE@ +-- +-- @method to_secondary_section +-- @see swap +-- @see to_primary_section + +function client.object:to_secondary_section() + local cls = capi.client.get(self.screen) + + for _, v in pairs(cls) do + self:swap(v) end end