diff --git a/lib/awful/client.lua b/lib/awful/client.lua index 6f206f1c0..a698a9848 100644 --- a/lib/awful/client.lua +++ b/lib/awful/client.lua @@ -71,7 +71,7 @@ function client.jumpto(c, merge) end -- focus the client - capi.client.focus = c + c:emit_signal("request::focus", "client.jumpto") c:raise() end @@ -213,7 +213,9 @@ function client.focus.history.previous() s = capi.mouse.screen end 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 --- 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 target then - capi.client.focus = cltbl[target] + cltbl[target]:emit_signal("request::focus", "client.focus.bydirection") 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) if target then - capi.client.focus = cltbl[target] + cltbl[target]:emit_signal("request::focus", "client.focus.global_bydirection") end end end @@ -348,7 +350,7 @@ end function client.focus.byidx(i, c) local target = client.next(i, c) if target then - capi.client.focus = target + target:emit_signal("request::focus", "client.focus.byidx") end end @@ -403,7 +405,7 @@ function client.swap.global_bydirection(dir, c) end screen.focus(sel.screen) - capi.client.focus = sel + sel:emit_signal("request::focus", "client.swap.global_bydirection") end end diff --git a/lib/awful/ewmh.lua b/lib/awful/ewmh.lua index 6d542dbcb..d7551fdfa 100644 --- a/lib/awful/ewmh.lua +++ b/lib/awful/ewmh.lua @@ -165,6 +165,14 @@ function ewmh.activate(c) 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 -- -- @client c A client to tag @@ -185,6 +193,7 @@ function ewmh.urgent(c, urgent) end 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::urgent", ewmh.urgent) client.connect_signal("request::maximized_horizontal", maximized_horizontal) diff --git a/lib/awful/layout/init.lua b/lib/awful/layout/init.lua index cf55cfd59..10faa9f92 100755 --- a/lib/awful/layout/init.lua +++ b/lib/awful/layout/init.lua @@ -178,7 +178,9 @@ local function arrange_on_tagged(c, tag) layout.arrange(tag.screen) if not capi.client.focus or not capi.client.focus:isvisible() then 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 local function arrange_tag(t) diff --git a/lib/awful/menu.lua b/lib/awful/menu.lua index 821db869a..bc9bcb386 100644 --- a/lib/awful/menu.lua +++ b/lib/awful/menu.lua @@ -476,7 +476,7 @@ function menu.clients(args, item_args) if not c:isvisible() then tags.viewmore(c:tags(), c.screen) end - capi.client.focus = c + c:emit_signal("request::focus", "menu.clients") c:raise() end, c.icon } diff --git a/lib/awful/screen.lua b/lib/awful/screen.lua index 1414d39bc..0b5e3483e 100644 --- a/lib/awful/screen.lua +++ b/lib/awful/screen.lua @@ -66,7 +66,9 @@ function screen.focus(_screen) capi.mouse.coords(pos, true) 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 --- Give the focus to a screen, and move pointer, by physical position relative to current screen.