From ed09d8ed4ff73bd70b05802d52864d5ccacb7d13 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 13 May 2015 22:11:07 +0200 Subject: [PATCH] Use request::activate with raise=false instead Ref: https://github.com/awesomeWM/awesome/pull/224#issuecomment-101790416 --- ewmh.c | 3 ++- lib/awful/autofocus.lua | 4 ++-- lib/awful/client.lua | 14 ++++++-------- lib/awful/ewmh.lua | 23 +++++++++-------------- lib/awful/layout/init.lua | 2 +- lib/awful/menu.lua | 3 +-- lib/awful/rules.lua | 2 +- lib/awful/screen.lua | 2 +- 8 files changed, 23 insertions(+), 30 deletions(-) diff --git a/ewmh.c b/ewmh.c index 0a4a7b7c..c58dbbd6 100755 --- a/ewmh.c +++ b/ewmh.c @@ -430,7 +430,8 @@ ewmh_process_client_message(xcb_client_message_event_t *ev) lua_State *L = globalconf_get_lua_State(); luaA_object_push(L, c); lua_pushstring(L, "ewmh"); - luaA_object_emit_signal(L, -2, "request::activate", 1); + lua_pushboolean(L, true); + luaA_object_emit_signal(L, -3, "request::activate", 2); lua_pop(L, 1); } } diff --git a/lib/awful/autofocus.lua b/lib/awful/autofocus.lua index 2f0c89f8..0e2556ff 100644 --- a/lib/awful/autofocus.lua +++ b/lib/awful/autofocus.lua @@ -24,7 +24,7 @@ local function check_focus(obj) if not client.focus or not client.focus:isvisible() then local c = aclient.focus.history.get(obj.screen, 0, aclient.focus.filter) if c then - c:emit_signal("request::focus", "autofocus.check_focus") + c:emit_signal("request::activate", "autofocus.check_focus", false) end end end @@ -45,7 +45,7 @@ local function check_focus_tag(t) if client.focus and client.focus.screen ~= s then local c = aclient.focus.history.get(s, 0, aclient.focus.filter) if c then - c:emit_signal("request::focus", "autofocus.check_focus_tag") + c:emit_signal("request::activate", "autofocus.check_focus_tag", false) end end end diff --git a/lib/awful/client.lua b/lib/awful/client.lua index a698a984..b0914788 100644 --- a/lib/awful/client.lua +++ b/lib/awful/client.lua @@ -70,9 +70,7 @@ function client.jumpto(c, merge) end end - -- focus the client - c:emit_signal("request::focus", "client.jumpto") - c:raise() + c:emit_signal("request::activate", "client.jumpto", true) end --- Get the first client that got the urgent hint. @@ -214,7 +212,7 @@ function client.focus.history.previous() end local c = client.focus.history.get(s, 1) if c then - c:emit_signal("request::focus", "client.focus.history.previous") + c:emit_signal("request::activate", "client.focus.history.previous", false) end end @@ -305,7 +303,7 @@ function client.focus.bydirection(dir, c) -- If we found a client to focus, then do it. if target then - cltbl[target]:emit_signal("request::focus", "client.focus.bydirection") + cltbl[target]:emit_signal("request::activate", "client.focus.bydirection", false) end end end @@ -337,7 +335,7 @@ function client.focus.global_bydirection(dir, c) local target = util.get_rectangle_in_direction(dir, geomtbl, capi.screen[scr].geometry) if target then - cltbl[target]:emit_signal("request::focus", "client.focus.global_bydirection") + cltbl[target]:emit_signal("request::activate", "client.focus.global_bydirection", false) end end end @@ -350,7 +348,7 @@ end function client.focus.byidx(i, c) local target = client.next(i, c) if target then - target:emit_signal("request::focus", "client.focus.byidx") + target:emit_signal("request::activate", "client.focus.byidx", false) end end @@ -405,7 +403,7 @@ function client.swap.global_bydirection(dir, c) end screen.focus(sel.screen) - sel:emit_signal("request::focus", "client.swap.global_bydirection") + sel:emit_signal("request::activate", "client.swap.global_bydirection", false) end end diff --git a/lib/awful/ewmh.lua b/lib/awful/ewmh.lua index d7551fdf..da05fc5d 100644 --- a/lib/awful/ewmh.lua +++ b/lib/awful/ewmh.lua @@ -156,21 +156,17 @@ end --- Activate a window -- -- @client c A client to use -function ewmh.activate(c) - if awesome.startup or c:isvisible() then - client.focus = c - c:raise() - else - c.urgent = true - end -end - ---- Focus a window. --- --- @client c The client. -- @tparam string context The context where this signal was used. -function ewmh.focus(c, context) +-- @tparam boolean raise Should the client be raised? +function ewmh.activate(c, context, raise) client.focus = c + if raise then + if awesome.startup or c:isvisible() then + c:raise() + else + c.urgent = true + end + end end --- Tag a window with its requested tag @@ -193,7 +189,6 @@ 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 10faa9f9..924a4098 100755 --- a/lib/awful/layout/init.lua +++ b/lib/awful/layout/init.lua @@ -179,7 +179,7 @@ local function arrange_on_tagged(c, tag) if not capi.client.focus or not capi.client.focus:isvisible() then local c = client.focus.history.get(tag.screen, 0) if c then - c:emit_signal("request::focus", "layout.arrange_on_tagged") + c:emit_signal("request::activate", "layout.arrange_on_tagged", false) end end end diff --git a/lib/awful/menu.lua b/lib/awful/menu.lua index bc9bcb38..5aca0cb3 100644 --- a/lib/awful/menu.lua +++ b/lib/awful/menu.lua @@ -476,8 +476,7 @@ function menu.clients(args, item_args) if not c:isvisible() then tags.viewmore(c:tags(), c.screen) end - c:emit_signal("request::focus", "menu.clients") - c:raise() + c:emit_signal("request::activate", "menu.clients", true) end, c.icon } if item_args then diff --git a/lib/awful/rules.lua b/lib/awful/rules.lua index a9df3a34..d87f20e9 100644 --- a/lib/awful/rules.lua +++ b/lib/awful/rules.lua @@ -217,7 +217,7 @@ function rules.execute(c, props, callbacks) -- Do this at last so we do not erase things done by the focus -- signal. if props.focus and (type(props.focus) ~= "function" or props.focus(c)) then - c:emit_signal('request::activate',"rules") + c:emit_signal('request::activate', "rules", false) end end diff --git a/lib/awful/screen.lua b/lib/awful/screen.lua index 0b5e3483..d19bc3da 100644 --- a/lib/awful/screen.lua +++ b/lib/awful/screen.lua @@ -67,7 +67,7 @@ function screen.focus(_screen) local c = client.focus.history.get(_screen, 0) if c then - c:emit_signal("request::focus", "screen.focus") + c:emit_signal("request::activate", "screen.focus", false) end end