awful: filter focus by type

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-09-08 00:09:50 +02:00
parent d439c5660e
commit 320ac68fb7
2 changed files with 31 additions and 7 deletions

View File

@ -359,7 +359,8 @@ end)
-- Hook function to execute when the mouse is over a client.
awful.hooks.mouse_over.register(function (c)
-- Sloppy focus, but disabled for magnifier layout
if awful.layout.get(c.screen) ~= "magnifier" then
if awful.layout.get(c.screen) ~= "magnifier"
and awful.client.focus.filter(c) then
client.focus = c
end
end)
@ -422,7 +423,8 @@ awful.hooks.arrange.register(function (screen)
mylayoutbox[screen].text = "No layout."
end
-- If no window has focus, give focus to the latest in history
-- Give focus to the latest client in history if no window has focus
-- or if the current window is a desktop or a dock one.
if not client.focus then
local c = awful.client.focus.history.get(screen, 0)
if c then client.focus = c end

View File

@ -161,13 +161,29 @@ function client.focus.history.delete(c)
end
end
--- Filter out window that we do not want handled by focus.
-- This usually means that desktop, dock and splash windows are
-- not registered and cannot get focus.
-- @param c A client.
-- @return The same client if it's ok, nil otherwise.
function client.focus.filter(c)
if c.type == "desktop"
or c.type == "dock"
or c.type == "splash" then
return nil
end
return c
end
--- Update client focus history.
-- @param c The client that has been focused.
function client.focus.history.add(c)
-- Remove the client if its in stack
client.focus.history.delete(c)
-- Record the client has latest focused
table.insert(client.focus.history.data, 1, c)
if client.focus.filter(c) then
-- Remove the client if its in stack
client.focus.history.delete(c)
-- Record the client has latest focused
table.insert(client.focus.history.data, 1, c)
end
end
--- Get the latest focused client for a screen in history.
@ -223,11 +239,17 @@ function client.next(i, c)
if sel then
-- Get all visible clients
local cls = capi.client.visible_get(sel.screen)
-- Remove all no-normal clients
for idx, c in ipairs(cls) do
if not client.focus.filter(c) then
table.remove(cls, idx)
end
end
-- Loop upon each client
for idx, c in ipairs(cls) do
if c == sel then
-- Cycle
return cls[cycle(#cls, idx +i)]
return cls[cycle(#cls, idx + i)]
end
end
end