Add request::focus signal, with ewmh.focus being the default handler
This still does `client.focus = c` by default, but allows to customize it. This was initially suggested in #194, but by using `request::activate` instead, which would not be the same. Therefore a new signal is being used instead. Helped-by: Samir Benmendil <samir.benmendil@gmail.com>
This commit is contained in:
parent
cec04b2684
commit
401f21f8e2
|
@ -71,7 +71,7 @@ function client.jumpto(c, merge)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- focus the client
|
-- focus the client
|
||||||
capi.client.focus = c
|
c:emit_signal("request::focus", "client.jumpto")
|
||||||
c:raise()
|
c:raise()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -213,7 +213,9 @@ function client.focus.history.previous()
|
||||||
s = capi.mouse.screen
|
s = capi.mouse.screen
|
||||||
end
|
end
|
||||||
local c = client.focus.history.get(s, 1)
|
local c = client.focus.history.get(s, 1)
|
||||||
if c then capi.client.focus = c end
|
if c then
|
||||||
|
c:emit_signal("request::focus", "client.focus.history.previous")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get visible clients from a screen.
|
--- Get visible clients from a screen.
|
||||||
|
@ -303,7 +305,7 @@ function client.focus.bydirection(dir, c)
|
||||||
|
|
||||||
-- If we found a client to focus, then do it.
|
-- If we found a client to focus, then do it.
|
||||||
if target then
|
if target then
|
||||||
capi.client.focus = cltbl[target]
|
cltbl[target]:emit_signal("request::focus", "client.focus.bydirection")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -335,7 +337,7 @@ function client.focus.global_bydirection(dir, c)
|
||||||
local target = util.get_rectangle_in_direction(dir, geomtbl, capi.screen[scr].geometry)
|
local target = util.get_rectangle_in_direction(dir, geomtbl, capi.screen[scr].geometry)
|
||||||
|
|
||||||
if target then
|
if target then
|
||||||
capi.client.focus = cltbl[target]
|
cltbl[target]:emit_signal("request::focus", "client.focus.global_bydirection")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -348,7 +350,7 @@ end
|
||||||
function client.focus.byidx(i, c)
|
function client.focus.byidx(i, c)
|
||||||
local target = client.next(i, c)
|
local target = client.next(i, c)
|
||||||
if target then
|
if target then
|
||||||
capi.client.focus = target
|
target:emit_signal("request::focus", "client.focus.byidx")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -403,7 +405,7 @@ function client.swap.global_bydirection(dir, c)
|
||||||
end
|
end
|
||||||
|
|
||||||
screen.focus(sel.screen)
|
screen.focus(sel.screen)
|
||||||
capi.client.focus = sel
|
sel:emit_signal("request::focus", "client.swap.global_bydirection")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,14 @@ function ewmh.activate(c)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Focus a window.
|
||||||
|
--
|
||||||
|
-- @client c The client.
|
||||||
|
-- @tparam string context The context where this signal was used.
|
||||||
|
function ewmh.focus(c, context)
|
||||||
|
client.focus = c
|
||||||
|
end
|
||||||
|
|
||||||
--- Tag a window with its requested tag
|
--- Tag a window with its requested tag
|
||||||
--
|
--
|
||||||
-- @client c A client to tag
|
-- @client c A client to tag
|
||||||
|
@ -185,6 +193,7 @@ function ewmh.urgent(c, urgent)
|
||||||
end
|
end
|
||||||
|
|
||||||
client.connect_signal("request::activate", ewmh.activate)
|
client.connect_signal("request::activate", ewmh.activate)
|
||||||
|
client.connect_signal("request::focus", ewmh.focus)
|
||||||
client.connect_signal("request::tag", ewmh.tag)
|
client.connect_signal("request::tag", ewmh.tag)
|
||||||
client.connect_signal("request::urgent", ewmh.urgent)
|
client.connect_signal("request::urgent", ewmh.urgent)
|
||||||
client.connect_signal("request::maximized_horizontal", maximized_horizontal)
|
client.connect_signal("request::maximized_horizontal", maximized_horizontal)
|
||||||
|
|
|
@ -178,7 +178,9 @@ local function arrange_on_tagged(c, tag)
|
||||||
layout.arrange(tag.screen)
|
layout.arrange(tag.screen)
|
||||||
if not capi.client.focus or not capi.client.focus:isvisible() then
|
if not capi.client.focus or not capi.client.focus:isvisible() then
|
||||||
local c = client.focus.history.get(tag.screen, 0)
|
local c = client.focus.history.get(tag.screen, 0)
|
||||||
if c then capi.client.focus = c end
|
if c then
|
||||||
|
c:emit_signal("request::focus", "layout.arrange_on_tagged")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function arrange_tag(t)
|
local function arrange_tag(t)
|
||||||
|
|
|
@ -476,7 +476,7 @@ function menu.clients(args, item_args)
|
||||||
if not c:isvisible() then
|
if not c:isvisible() then
|
||||||
tags.viewmore(c:tags(), c.screen)
|
tags.viewmore(c:tags(), c.screen)
|
||||||
end
|
end
|
||||||
capi.client.focus = c
|
c:emit_signal("request::focus", "menu.clients")
|
||||||
c:raise()
|
c:raise()
|
||||||
end,
|
end,
|
||||||
c.icon }
|
c.icon }
|
||||||
|
|
|
@ -66,7 +66,9 @@ function screen.focus(_screen)
|
||||||
capi.mouse.coords(pos, true)
|
capi.mouse.coords(pos, true)
|
||||||
|
|
||||||
local c = client.focus.history.get(_screen, 0)
|
local c = client.focus.history.get(_screen, 0)
|
||||||
if c then capi.client.focus = c end
|
if c then
|
||||||
|
c:emit_signal("request::focus", "screen.focus")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Give the focus to a screen, and move pointer, by physical position relative to current screen.
|
--- Give the focus to a screen, and move pointer, by physical position relative to current screen.
|
||||||
|
|
Loading…
Reference in New Issue