Skip to content

Commit

Permalink
modified for HiDPI (192); add find_history function similar to awful.…
Browse files Browse the repository at this point in the history
…focus.history.get
  • Loading branch information
xinhaoyuan committed Dec 14, 2016
1 parent 006f68f commit 017dd0b
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ cyclefocus = {
-- Default callback, which will be applied for all offsets (first).
default = function (preset, args)
-- Default font and icon size (gets overwritten for current/0 index).
preset.font = 'sans 8'
preset.icon_size = 36
preset.font = 'sans 16'
preset.icon_size = 32
preset.text = escape_markup(cyclefocus.get_object_name(args.client))

-- Display the notification on the current screen (mouse).
Expand All @@ -71,7 +71,7 @@ cyclefocus = {

-- Preset for current entry.
["0"] = function (preset, args)
preset.font = 'sans 12'
preset.font = 'sans 20'
preset.icon_size = 48
-- Use get_object_name to handle .name=nil.
preset.text = escape_markup(cyclefocus.get_object_name(args.client))
Expand Down Expand Up @@ -223,6 +223,33 @@ function history.add(c)
-- Record the client has latest focused
table.insert(history.stack, 1, c)
end

function cyclefocus.find_history(idx, filters)
for _, c in ipairs(history.stack) do
local filtered = false

for _, f in pairs(filters) do
if not f(c) then
filtered = true
break
end
end

if not filtered then
if idx <= 0 then
return c
else
idx = idx - 1
end
end
end

if idx >= #history.stack then
return history.stack[#history.stack]
else
return history.stack[idx + 1]
end
end
-- }}}

-- Connect to signals. {{{
Expand Down

1 comment on commit 017dd0b

@blueyed
Copy link

@blueyed blueyed commented on 017dd0b Feb 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @xinhaoyuan!
Check out blueyed#14, which should work better regarding HiDPI with awesome v4 already. Please provide feedback there, and also consider creating a PR for any other changes you made / will make.

Please sign in to comment.