From 715c3215d7965cbed20c1e44ec9ac09c856d7cd4 Mon Sep 17 00:00:00 2001 From: Quan Guo Date: Mon, 9 May 2016 00:28:38 +0200 Subject: [PATCH 1/7] Fix deprecated functions by introducing new APIs --- init.lua | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 36a99a1..c6c1a4b 100644 --- a/init.lua +++ b/init.lua @@ -36,6 +36,20 @@ local capi = { -- It seems there is not way to pass err handling function into the delayed_call() local delayed_call = (type(timer) ~= 'table' and require("gears.timer").delayed_call) +local view_only_func +local toggle_tag_func +local jump_to_func + +if type(capi.client.view_only) == 'function' then + view_only_func = function (tag) tag:view_only() end + toggle_tag_func = function (t, c) c:toggle_tag(t) end + jump_to_func = function(c) c:jump_to() end +else + view_only_func = function (tag) awful.tag.viewonly(tag) end + toggle_tag_func = function (t, c) awful.client.toggletag(t, c) end + jump_to_func = function(c) awful.client.jumpto(c) end +end + local hintbox = {} -- Table of letter wiboxes with characters as the keys local hintindex = {} -- Table of visible clients with the hint letter as the keys @@ -171,7 +185,7 @@ function revelation.expose(args) match_clients(rule, capi.client.get(scr), t[scr], is_excluded) end - awful.tag.viewonly(t[scr]) + view_only_func(t[scr]) end if type(delayed_call) == 'function' then @@ -283,7 +297,7 @@ function revelation.expose_callback(t, zt, clientlist) c = hintindex[key_char] if not zoomed and c ~= nil then --debuginfo(c.screen) - awful.tag.viewonly(zt[c.screen]) + view_only_func(zt[c.screen]) awful.client.toggletag(zt[c.screen], c) zoomedClient = c key_char_zoomed = key_char @@ -351,7 +365,13 @@ function revelation.expose_callback(t, zt, clientlist) local pressedMiddle = false capi.mousegrabber.run(function(mouse) - local c = awful.mouse.client_under_pointer() + local c + + if type(capi.client.view_only) == 'function' then + c = awful.mouse.client_under_pointer() + else + c = mouse.client_under_pointer() + end local key_char = awful.util.table.hasitem(hintindex, c) if mouse.buttons[1] == true then selectfn(restore, t, zt)(c) @@ -392,7 +412,7 @@ function revelation.expose_callback(t, zt, clientlist) end elseif mouse.buttons[3] == true then if not zoomed and c ~= nil then - awful.tag.viewonly(zt[c.screen]) + view_only_func(zt[c.screen]) awful.client.toggletag(zt[c.screen], c) if key_char ~= nil then hintbox_display_toggle(key_char, false) From 3fa219fc272aacc6a2656dace2f205361dd8429b Mon Sep 17 00:00:00 2001 From: Quan Guo Date: Mon, 9 May 2016 21:16:26 +0200 Subject: [PATCH 2/7] Try to maintain backward-compatibility --- init.lua | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/init.lua b/init.lua index c6c1a4b..72baa6d 100644 --- a/init.lua +++ b/init.lua @@ -40,7 +40,8 @@ local view_only_func local toggle_tag_func local jump_to_func -if type(capi.client.view_only) == 'function' then + +if type(awful.client.object.toggle_tag) == 'function' then view_only_func = function (tag) tag:view_only() end toggle_tag_func = function (t, c) c:toggle_tag(t) end jump_to_func = function(c) c:jump_to() end @@ -116,7 +117,7 @@ local function selectfn(restore, t, zt) c.minimized = false end - awful.client.jumpto(c) + jump_to_func(c) end end end @@ -148,7 +149,7 @@ local function match_clients(rule, _clients, t, is_excluded) c[k] = v end - awful.client.toggletag(t, c) + toggle_tag_func(t, c) if c:isvisible() then table.insert(clients, c) end @@ -280,7 +281,6 @@ function revelation.expose_callback(t, zt, clientlist) hintindex[char] = thisclient hintbox_pos(char) hintbox[char].visible = true - hintbox[char].screen = thisclient.screen end end @@ -298,7 +298,7 @@ function revelation.expose_callback(t, zt, clientlist) if not zoomed and c ~= nil then --debuginfo(c.screen) view_only_func(zt[c.screen]) - awful.client.toggletag(zt[c.screen], c) + toggle_tag_func(zt[c.screen], c) zoomedClient = c key_char_zoomed = key_char zoomed = true @@ -312,7 +312,7 @@ function revelation.expose_callback(t, zt, clientlist) elseif zoomedClient ~= nil then awful.tag.history.restore(zoomedClient.screen) - awful.client.toggletag(zt[zoomedClient.screen], zoomedClient) + toggle_tag_func(zt[zoomedClient.screen], zoomedClient) hintbox_display_toggle(key_char_zoomed, true) if type(delayed_call) == 'function' then capi.awesome.emit_signal("refresh") @@ -341,7 +341,7 @@ function revelation.expose_callback(t, zt, clientlist) if key == "Escape" then if zoomedClient ~= nil then awful.tag.history.restore(zoomedClient.screen) - awful.client.toggletag(zt[zoomedClient.screen], zoomedClient) + toggle_tag_func(zt[zoomedClient.screen], zoomedClient) hintbox_display_toggle(string.lower(key), true) if type(delayed_call) == 'function' then capi.awesome.emit_signal("refresh") @@ -367,10 +367,10 @@ function revelation.expose_callback(t, zt, clientlist) capi.mousegrabber.run(function(mouse) local c - if type(capi.client.view_only) == 'function' then + if type(tag.view_only) == 'function' then c = awful.mouse.client_under_pointer() else - c = mouse.client_under_pointer() + c = mouse.current_client end local key_char = awful.util.table.hasitem(hintindex, c) if mouse.buttons[1] == true then @@ -387,7 +387,7 @@ function revelation.expose_callback(t, zt, clientlist) -- if zoomed == true and zoomedClient ~=nil then awful.tag.history.restore(zoomedClient.screen) - awful.client.toggletag(zt[zoomedClient.screen], zoomedClient) + toggle_tag_func(zt[zoomedClient.screen], zoomedClient) end c:kill() hintbox[key_char].visible = false @@ -413,7 +413,7 @@ function revelation.expose_callback(t, zt, clientlist) elseif mouse.buttons[3] == true then if not zoomed and c ~= nil then view_only_func(zt[c.screen]) - awful.client.toggletag(zt[c.screen], c) + toggle_tag_func(zt[c.screen], c) if key_char ~= nil then hintbox_display_toggle(key_char, false) if type(delayed_call) == 'function' then @@ -426,7 +426,7 @@ function revelation.expose_callback(t, zt, clientlist) key_char_zoomed = key_char elseif zoomedClient ~= nil then awful.tag.history.restore(zoomedClient.screen) - awful.client.toggletag(zt[zoomedClient.screen], zoomedClient) + toggle_tag_func(zt[zoomedClient.screen], zoomedClient) hintbox_display_toggle(key_char_zoomed, true) if type(delayed_call) == 'function' then capi.awesome.emit_signal("refresh") From 79525e92d0812a4a3a088801e6bd4b9c2fcdf919 Mon Sep 17 00:00:00 2001 From: Quan Guo Date: Wed, 18 May 2016 19:19:06 +0200 Subject: [PATCH 3/7] Try to fix the bug in compatibility --- init.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index 72baa6d..3007db4 100644 --- a/init.lua +++ b/init.lua @@ -34,6 +34,12 @@ local capi = { -- disable for now. -- It seems there is not way to pass err handling function into the delayed_call() + +local function debuginfo(message) + message = message or "No information available" + nid = naughty.notify({ text = tostring(message), timeout = 10 }) +end + local delayed_call = (type(timer) ~= 'table' and require("gears.timer").delayed_call) local view_only_func @@ -41,7 +47,7 @@ local toggle_tag_func local jump_to_func -if type(awful.client.object.toggle_tag) == 'function' then +if type(awful.client.object) == 'table' then view_only_func = function (tag) tag:view_only() end toggle_tag_func = function (t, c) c:toggle_tag(t) end jump_to_func = function(c) c:jump_to() end @@ -95,10 +101,6 @@ local revelation = { } -local function debuginfo(message) - message = message or "No information available" - nid = naughty.notify({ text = tostring(message), timeout = 10 }) -end -- Executed when user selects a client from expose view. -- From 4e52b080c5e7792c6acdff232a9e735512270fa7 Mon Sep 17 00:00:00 2001 From: Quan Guo Date: Wed, 13 Jul 2016 16:38:03 +0200 Subject: [PATCH 4/7] Fix the bug: issue #27 --- init.lua | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/init.lua b/init.lua index 3007db4..e8f333b 100644 --- a/init.lua +++ b/init.lua @@ -119,7 +119,8 @@ local function selectfn(restore, t, zt) c.minimized = false end - jump_to_func(c) + --jump_to_func(c) + awful.client.jumpto(c) end end end @@ -372,16 +373,20 @@ function revelation.expose_callback(t, zt, clientlist) if type(tag.view_only) == 'function' then c = awful.mouse.client_under_pointer() else - c = mouse.current_client + c = capi.mouse.current_client end local key_char = awful.util.table.hasitem(hintindex, c) if mouse.buttons[1] == true then - selectfn(restore, t, zt)(c) + if c ~= nil then + selectfn(restore, t, zt)(c) - for i,j in pairs(hintindex) do - hintbox[i].visible = false + for i,j in pairs(hintindex) do + hintbox[i].visible = false + end + return false + else + return true end - return false elseif mouse.buttons[2] == true and pressedMiddle == false and c ~= nil then -- is true whenever the button is down. pressedMiddle = true From fb79d264d4df18cb836f8f3319e2fdd6c2f506c4 Mon Sep 17 00:00:00 2001 From: Quan Guo Date: Wed, 13 Jul 2016 20:30:08 +0200 Subject: [PATCH 5/7] Try to fix issue #27 again --- init.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index e8f333b..1ac9fa1 100644 --- a/init.lua +++ b/init.lua @@ -119,8 +119,7 @@ local function selectfn(restore, t, zt) c.minimized = false end - --jump_to_func(c) - awful.client.jumpto(c) + jump_to_func(c) end end end @@ -370,7 +369,7 @@ function revelation.expose_callback(t, zt, clientlist) capi.mousegrabber.run(function(mouse) local c - if type(tag.view_only) == 'function' then + if type(awful.client.object) == 'table' then c = awful.mouse.client_under_pointer() else c = capi.mouse.current_client From 6edcbb47d23ebe26bee4f3d86e3d9e74fc2c7242 Mon Sep 17 00:00:00 2001 From: Quan Guo Date: Wed, 13 Jul 2016 20:32:46 +0200 Subject: [PATCH 6/7] Try to fix #27 again and again --- init.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 1ac9fa1..8f5605d 100644 --- a/init.lua +++ b/init.lua @@ -153,8 +153,7 @@ local function match_clients(rule, _clients, t, is_excluded) end toggle_tag_func(t, c) if c:isvisible() then - table.insert(clients, c) - end + table.insert(clients, c) end end end @@ -370,9 +369,9 @@ function revelation.expose_callback(t, zt, clientlist) local c if type(awful.client.object) == 'table' then - c = awful.mouse.client_under_pointer() - else c = capi.mouse.current_client + else + c = awful.mouse.client_under_pointer() end local key_char = awful.util.table.hasitem(hintindex, c) if mouse.buttons[1] == true then From e4515134e0c61a4b6040aa44a005070c09e79999 Mon Sep 17 00:00:00 2001 From: Quan Guo Date: Thu, 14 Jul 2016 16:44:18 +0200 Subject: [PATCH 7/7] Fixed the wrong position of 'end' --- init.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 8f5605d..0ff6be0 100644 --- a/init.lua +++ b/init.lua @@ -153,7 +153,8 @@ local function match_clients(rule, _clients, t, is_excluded) end toggle_tag_func(t, c) if c:isvisible() then - table.insert(clients, c) end + table.insert(clients, c) + end end end @@ -187,7 +188,7 @@ function revelation.expose(args) match_clients(rule, capi.client.get(scr), t[scr], is_excluded) end - view_only_func(t[scr]) + view_only_func(t[scr]) end if type(delayed_call) == 'function' then