Merge pull request #224 from blueyed/request-focus-signal
Add 'request::focus' signal, use it with autofocus
This commit is contained in:
commit
33a6ade4d7
|
@ -161,11 +161,9 @@ mytasklist.buttons = awful.util.table.join(
|
||||||
end),
|
end),
|
||||||
awful.button({ }, 4, function ()
|
awful.button({ }, 4, function ()
|
||||||
awful.client.focus.byidx(1)
|
awful.client.focus.byidx(1)
|
||||||
if client.focus then client.focus:raise() end
|
|
||||||
end),
|
end),
|
||||||
awful.button({ }, 5, function ()
|
awful.button({ }, 5, function ()
|
||||||
awful.client.focus.byidx(-1)
|
awful.client.focus.byidx(-1)
|
||||||
if client.focus then client.focus:raise() end
|
|
||||||
end))
|
end))
|
||||||
|
|
||||||
for s = 1, screen.count() do
|
for s = 1, screen.count() do
|
||||||
|
@ -229,12 +227,10 @@ globalkeys = awful.util.table.join(
|
||||||
awful.key({ modkey, }, "j",
|
awful.key({ modkey, }, "j",
|
||||||
function ()
|
function ()
|
||||||
awful.client.focus.byidx( 1)
|
awful.client.focus.byidx( 1)
|
||||||
if client.focus then client.focus:raise() end
|
|
||||||
end),
|
end),
|
||||||
awful.key({ modkey, }, "k",
|
awful.key({ modkey, }, "k",
|
||||||
function ()
|
function ()
|
||||||
awful.client.focus.byidx(-1)
|
awful.client.focus.byidx(-1)
|
||||||
if client.focus then client.focus:raise() end
|
|
||||||
end),
|
end),
|
||||||
awful.key({ modkey, }, "w", function () mymainmenu:show() end),
|
awful.key({ modkey, }, "w", function () mymainmenu:show() end),
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,6 @@ file = {
|
||||||
-- documentation
|
-- documentation
|
||||||
'../lib/awful/autofocus.lua',
|
'../lib/awful/autofocus.lua',
|
||||||
'../lib/awful/dbus.lua',
|
'../lib/awful/dbus.lua',
|
||||||
'../lib/awful/ewmh.lua',
|
|
||||||
'../lib/awful/init.lua',
|
'../lib/awful/init.lua',
|
||||||
'../lib/awful/remote.lua',
|
'../lib/awful/remote.lua',
|
||||||
'../lib/awful/startup_notification.lua',
|
'../lib/awful/startup_notification.lua',
|
||||||
|
|
9
ewmh.c
9
ewmh.c
|
@ -430,7 +430,14 @@ ewmh_process_client_message(xcb_client_message_event_t *ev)
|
||||||
lua_State *L = globalconf_get_lua_State();
|
lua_State *L = globalconf_get_lua_State();
|
||||||
luaA_object_push(L, c);
|
luaA_object_push(L, c);
|
||||||
lua_pushstring(L, "ewmh");
|
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);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,8 @@ local function check_focus(obj)
|
||||||
if not client.focus or not client.focus:isvisible() then
|
if not client.focus or not client.focus:isvisible() then
|
||||||
local c = aclient.focus.history.get(obj.screen, 0, aclient.focus.filter)
|
local c = aclient.focus.history.get(obj.screen, 0, aclient.focus.filter)
|
||||||
if c then
|
if c then
|
||||||
c:emit_signal('request::activate', "autofocus.check_focus")
|
c:emit_signal("request::activate", "autofocus.check_focus",
|
||||||
|
{raise=false})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -45,7 +46,8 @@ local function check_focus_tag(t)
|
||||||
if client.focus and client.focus.screen ~= s then
|
if client.focus and client.focus.screen ~= s then
|
||||||
local c = aclient.focus.history.get(s, 0, aclient.focus.filter)
|
local c = aclient.focus.history.get(s, 0, aclient.focus.filter)
|
||||||
if c then
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -70,9 +70,7 @@ function client.jumpto(c, merge)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- focus the client
|
c:emit_signal("request::activate", "client.jumpto", {raise=true})
|
||||||
capi.client.focus = c
|
|
||||||
c:raise()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get the first client that got the urgent hint.
|
--- Get the first client that got the urgent hint.
|
||||||
|
@ -213,7 +211,10 @@ 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::activate", "client.focus.history.previous",
|
||||||
|
{raise=false})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get visible clients from a screen.
|
--- 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 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::activate",
|
||||||
|
"client.focus.bydirection", {raise=false})
|
||||||
end
|
end
|
||||||
end
|
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)
|
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::activate",
|
||||||
|
"client.focus.global_bydirection",
|
||||||
|
{raise=false})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -348,7 +352,8 @@ 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::activate", "client.focus.byidx",
|
||||||
|
{raise=true})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -396,14 +401,15 @@ function client.swap.global_bydirection(dir, c)
|
||||||
elseif sel.screen ~= c.screen and sel == c then
|
elseif sel.screen ~= c.screen and sel == c then
|
||||||
client.movetoscreen(sel, capi.mouse.screen)
|
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
|
elseif sel.screen ~= c.screen and sel ~= c then
|
||||||
client.movetoscreen(sel, c.screen)
|
client.movetoscreen(sel, c.screen)
|
||||||
client.movetoscreen(c, scr)
|
client.movetoscreen(c, scr)
|
||||||
end
|
end
|
||||||
|
|
||||||
screen.focus(sel.screen)
|
screen.focus(sel.screen)
|
||||||
capi.client.focus = sel
|
sel:emit_signal("request::activate", "client.swap.global_bydirection",
|
||||||
|
{raise=false})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -156,13 +156,18 @@ end
|
||||||
--- Activate a window
|
--- Activate a window
|
||||||
--
|
--
|
||||||
-- @client c A client to use
|
-- @client c A client to use
|
||||||
function ewmh.activate(c)
|
-- @tparam string context The context where this signal was used.
|
||||||
if awesome.startup or c:isvisible() then
|
-- @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
|
client.focus = c
|
||||||
|
if raise then
|
||||||
|
if awesome.startup or c:isvisible() then
|
||||||
c:raise()
|
c:raise()
|
||||||
else
|
else
|
||||||
c.urgent = true
|
c.urgent = true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Tag a window with its requested tag
|
--- Tag a window with its requested tag
|
||||||
|
|
|
@ -178,7 +178,10 @@ 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::activate", "layout.arrange_on_tagged",
|
||||||
|
{raise=false})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function arrange_tag(t)
|
local function arrange_tag(t)
|
||||||
|
|
|
@ -476,8 +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::activate", "menu.clients", {raise=true})
|
||||||
c:raise()
|
|
||||||
end,
|
end,
|
||||||
c.icon }
|
c.icon }
|
||||||
if item_args then
|
if item_args then
|
||||||
|
|
|
@ -217,7 +217,7 @@ function rules.execute(c, props, callbacks)
|
||||||
-- Do this at last so we do not erase things done by the focus
|
-- Do this at last so we do not erase things done by the focus
|
||||||
-- signal.
|
-- signal.
|
||||||
if props.focus and (type(props.focus) ~= "function" or props.focus(c)) then
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -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::activate", "screen.focus", {raise=false})
|
||||||
|
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