diff --git a/awesomerc.lua b/awesomerc.lua index dff4265e..d8b90042 100755 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -161,11 +161,9 @@ mytasklist.buttons = awful.util.table.join( end), awful.button({ }, 4, function () awful.client.focus.byidx(1) - if client.focus then client.focus:raise() end end), awful.button({ }, 5, function () awful.client.focus.byidx(-1) - if client.focus then client.focus:raise() end end)) for s = 1, screen.count() do @@ -229,12 +227,10 @@ globalkeys = awful.util.table.join( awful.key({ modkey, }, "j", function () awful.client.focus.byidx( 1) - if client.focus then client.focus:raise() end end), awful.key({ modkey, }, "k", function () awful.client.focus.byidx(-1) - if client.focus then client.focus:raise() end end), awful.key({ modkey, }, "w", function () mymainmenu:show() end), diff --git a/docs/config.ld b/docs/config.ld index c47faf55..08679918 100644 --- a/docs/config.ld +++ b/docs/config.ld @@ -55,7 +55,6 @@ file = { -- documentation '../lib/awful/autofocus.lua', '../lib/awful/dbus.lua', - '../lib/awful/ewmh.lua', '../lib/awful/init.lua', '../lib/awful/remote.lua', '../lib/awful/startup_notification.lua', diff --git a/ewmh.c b/ewmh.c index 0a4a7b7c..730edc18 100755 --- a/ewmh.c +++ b/ewmh.c @@ -430,7 +430,14 @@ 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); + + /* Create table argument with raise=true. */ + lua_newtable(L); + lua_pushstring(L, "raise"); + lua_pushboolean(L, true); + lua_settable(L, -3); + + 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 325acb36..066c9f71 100644 --- a/lib/awful/autofocus.lua +++ b/lib/awful/autofocus.lua @@ -24,7 +24,8 @@ 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::activate', "autofocus.check_focus") + c:emit_signal("request::activate", "autofocus.check_focus", + {raise=false}) end end end @@ -45,7 +46,8 @@ 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::activate', "autofocus.check_focus_tag") + c:emit_signal("request::activate", "autofocus.check_focus_tag", + {raise=false}) end end end diff --git a/lib/awful/client.lua b/lib/awful/client.lua index 6f206f1c..52eab6a7 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 - capi.client.focus = c - c:raise() + c:emit_signal("request::activate", "client.jumpto", {raise=true}) end --- Get the first client that got the urgent hint. @@ -213,7 +211,10 @@ 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::activate", "client.focus.history.previous", + {raise=false}) + end end --- Get visible clients from a screen. @@ -303,7 +304,8 @@ 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::activate", + "client.focus.bydirection", {raise=false}) end end end @@ -335,7 +337,9 @@ 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::activate", + "client.focus.global_bydirection", + {raise=false}) end end end @@ -348,7 +352,8 @@ end function client.focus.byidx(i, c) local target = client.next(i, c) if target then - capi.client.focus = target + target:emit_signal("request::activate", "client.focus.byidx", + {raise=true}) end end @@ -396,14 +401,15 @@ function client.swap.global_bydirection(dir, c) elseif sel.screen ~= c.screen and sel == c then client.movetoscreen(sel, capi.mouse.screen) - --swapping to a nonempty screen + -- swapping to a nonempty screen elseif sel.screen ~= c.screen and sel ~= c then client.movetoscreen(sel, c.screen) client.movetoscreen(c, scr) end screen.focus(sel.screen) - capi.client.focus = sel + sel:emit_signal("request::activate", "client.swap.global_bydirection", + {raise=false}) end end diff --git a/lib/awful/ewmh.lua b/lib/awful/ewmh.lua index 6d542dbc..d00e07c7 100644 --- a/lib/awful/ewmh.lua +++ b/lib/awful/ewmh.lua @@ -156,12 +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 +-- @tparam string context The context where this signal was used. +-- @tparam table hints A table with additional hints: +-- @tparam boolean hints.raise should the client be raised? (default false) +function ewmh.activate(c, context, hints) + client.focus = c + if raise then + if awesome.startup or c:isvisible() then + c:raise() + else + c.urgent = true + end end end diff --git a/lib/awful/layout/init.lua b/lib/awful/layout/init.lua index cf55cfd5..97b94a74 100755 --- a/lib/awful/layout/init.lua +++ b/lib/awful/layout/init.lua @@ -178,7 +178,10 @@ 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::activate", "layout.arrange_on_tagged", + {raise=false}) + end end end local function arrange_tag(t) diff --git a/lib/awful/menu.lua b/lib/awful/menu.lua index 821db869..ab8d73ec 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 - capi.client.focus = c - c:raise() + c:emit_signal("request::activate", "menu.clients", {raise=true}) end, c.icon } if item_args then diff --git a/lib/awful/rules.lua b/lib/awful/rules.lua index a9df3a34..cba2644e 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", {raise=false}) end end diff --git a/lib/awful/screen.lua b/lib/awful/screen.lua index 1414d39b..58f1cc4e 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::activate", "screen.focus", {raise=false}) + end end --- Give the focus to a screen, and move pointer, by physical position relative to current screen.