From 1aa1c8052db101744735d7f2d8788dd045bb7b28 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 29 Mar 2015 20:18:29 +0200 Subject: [PATCH] Add client.get_transient_for_matching and .is_transient_for --- lib/awful/client.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/awful/client.lua b/lib/awful/client.lua index 098545d6e..ca32b0cfc 100644 --- a/lib/awful/client.lua +++ b/lib/awful/client.lua @@ -1030,6 +1030,37 @@ function client.run_or_raise(cmd, matcher, merge) util.spawn(cmd) end +--- Get a matching transient_for client (if any). +-- @client c The client. +-- @tparam function matcher A function that should return true, if +-- a matching parent client is found. +-- @treturn client.client|nil The matching parent client or nil. +function client.get_transient_for_matching(c, matcher) + local tc = c.transient_for + while tc do + if matcher(tc) then + return tc + end + tc = tc.transient_for + end + return nil +end + +--- Is a client transient for another one? +-- @client c The child client (having transient_for). +-- @client c2 The parent client to check. +-- @treturn client.client|nil The parent client or nil. +function client.is_transient_for(c, c2) + local tc = c + while tc.transient_for do + if tc.transient_for == c2 then + return tc + end + tc = tc.transient_for + end + return nil +end + -- Register standards signals capi.client.add_signal("property::floating_geometry") capi.client.add_signal("property::floating")