introducing awful.client.jumpto

I simply moved out the code to 'jumpto' a client from
`awful.client.urgent.jumpto` into a separate function of its own so that it can
be reused.

Signed-off-by: Anurag Priyam <anurag08priyam@gmail.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Anurag Priyam 2012-03-07 03:39:45 +05:30 committed by Uli Schlachter
parent f9dd1c3389
commit 55cbbac45b
1 changed files with 27 additions and 19 deletions

View File

@ -39,6 +39,32 @@ floating = {}
dockable = {} dockable = {}
property = {} property = {}
---
-- Jump to the given client. Takes care of focussing the screen, the right tag,
-- etc.
-- @param merge If true then merge tags when clients are not visible.
function jumpto(c, merge)
local s = capi.client.focus and capi.client.focus.screen or capi.mouse.screen
-- focus the screen
if s ~= c.screen then
capi.mouse.screen = c.screen
end
-- Try to make client visible, this also covers e.g. sticky
local t = c:tags()[1]
if t and not c:isvisible() then
if merge then
t.selected = true
else
tag.viewonly(t)
end
end
-- focus the client
capi.client.focus = c
c:raise()
end
--- Get the first client that got the urgent hint. --- Get the first client that got the urgent hint.
-- @return The first urgent client. -- @return The first urgent client.
function urgent.get() function urgent.get()
@ -60,25 +86,7 @@ end
function urgent.jumpto(merge) function urgent.jumpto(merge)
local c = urgent.get() local c = urgent.get()
if c then if c then
local s = capi.client.focus and capi.client.focus.screen or capi.mouse.screen jumpto(c, merge)
-- focus the screen
if s ~= c.screen then
capi.mouse.screen = c.screen
end
-- Try to make client visible, this also covers e.g. sticky
local t = c:tags()[1]
if t and not c:isvisible() then
if merge then
t.selected = true
else
tag.viewonly(t)
end
end
-- focus the client
capi.client.focus = c
c:raise()
end end
end end