2015-10-08 14:01:27 +02:00
|
|
|
-- revelation.lua
|
2011-08-23 23:37:11 +02:00
|
|
|
--
|
|
|
|
-- Library that implements Expose like behavior.
|
|
|
|
--
|
|
|
|
-- @author Perry Hargrave resixian@gmail.com
|
|
|
|
-- @author Espen Wiborg espenhw@grumblesmurf.org
|
|
|
|
-- @author Julien Danjou julien@danjou.info
|
2013-08-31 23:54:57 +02:00
|
|
|
-- @auther Quan Guo guotsuan@gmail.com
|
2011-08-23 23:37:11 +02:00
|
|
|
--
|
|
|
|
-- @copyright 2008 Espen Wiborg, Julien Danjou
|
2015-10-08 14:01:27 +02:00
|
|
|
-- @copyright 2015 Quan Guo
|
2011-08-23 23:37:11 +02:00
|
|
|
--
|
|
|
|
|
2013-08-31 23:54:57 +02:00
|
|
|
|
|
|
|
local beautiful = require("beautiful")
|
|
|
|
local wibox = require("wibox")
|
|
|
|
local awful = require('awful')
|
|
|
|
local aw_rules = require('awful.rules')
|
|
|
|
local pairs = pairs
|
2011-08-23 23:37:11 +02:00
|
|
|
local setmetatable = setmetatable
|
2013-08-31 23:54:57 +02:00
|
|
|
local naughty = require("naughty")
|
|
|
|
local table = table
|
2015-07-25 21:42:12 +02:00
|
|
|
local clock = os.clock
|
2013-08-31 23:54:57 +02:00
|
|
|
local tostring = tostring
|
|
|
|
local capi = {
|
2015-09-21 23:09:56 +02:00
|
|
|
awesome = awesome,
|
2013-08-31 23:54:57 +02:00
|
|
|
tag = tag,
|
|
|
|
client = client,
|
|
|
|
keygrabber = keygrabber,
|
|
|
|
mousegrabber = mousegrabber,
|
|
|
|
mouse = mouse,
|
|
|
|
screen = screen
|
2011-08-23 23:37:11 +02:00
|
|
|
}
|
2015-09-25 02:58:34 +02:00
|
|
|
|
2015-09-26 19:44:20 +02:00
|
|
|
-- disable for now.
|
|
|
|
-- It seems there is not way to pass err handling function into the delayed_call()
|
2016-05-18 19:19:06 +02:00
|
|
|
|
|
|
|
local function debuginfo(message)
|
|
|
|
message = message or "No information available"
|
|
|
|
nid = naughty.notify({ text = tostring(message), timeout = 10 })
|
|
|
|
end
|
|
|
|
|
2015-09-25 02:58:34 +02:00
|
|
|
local delayed_call = (type(timer) ~= 'table' and require("gears.timer").delayed_call)
|
2011-08-23 23:37:11 +02:00
|
|
|
|
2016-05-09 00:28:38 +02:00
|
|
|
local view_only_func
|
|
|
|
local toggle_tag_func
|
|
|
|
local jump_to_func
|
|
|
|
|
2016-05-09 21:16:26 +02:00
|
|
|
|
2016-05-18 19:19:06 +02:00
|
|
|
if type(awful.client.object) == 'table' then
|
2016-05-09 00:28:38 +02:00
|
|
|
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
|
|
|
|
|
2011-12-22 17:21:31 +01:00
|
|
|
|
2015-08-21 02:24:01 +02:00
|
|
|
local hintbox = {} -- Table of letter wiboxes with characters as the keys
|
2015-09-26 03:38:54 +02:00
|
|
|
local hintindex = {} -- Table of visible clients with the hint letter as the keys
|
2011-08-23 23:37:11 +02:00
|
|
|
|
2015-10-08 14:01:27 +02:00
|
|
|
local clients = {} --Table of clients to be exposed after fitlering
|
|
|
|
local clientData = {} -- table that holds the positions and sizes of floating clients
|
2011-08-23 23:37:11 +02:00
|
|
|
|
2015-08-21 02:24:01 +02:00
|
|
|
local revelation = {
|
2011-10-21 00:26:37 +02:00
|
|
|
-- Name of expose tag.
|
|
|
|
tag_name = "Revelation",
|
|
|
|
|
2015-11-05 15:47:46 +01:00
|
|
|
charorder = "jkluiopyhnmfdsatgvcewqzx1234567890",
|
|
|
|
|
2011-10-21 00:26:37 +02:00
|
|
|
-- Match function can be defined by user.
|
|
|
|
-- Must accept a `rule` and `client` and return `boolean`.
|
|
|
|
-- The rule forms follow `awful.rules` syntax except we also check the
|
|
|
|
-- special `rule.any` key. If its true, then we use the `match.any` function
|
|
|
|
-- for comparison.
|
|
|
|
match = {
|
|
|
|
exact = aw_rules.match,
|
|
|
|
any = aw_rules.match_any
|
|
|
|
},
|
2014-01-04 02:57:08 +01:00
|
|
|
property_to_watch={
|
|
|
|
minimized = false,
|
|
|
|
fullscreen = false,
|
|
|
|
maximized_horizontal = false,
|
|
|
|
maximized_vertical = false,
|
|
|
|
sticky = false,
|
|
|
|
ontop = false,
|
|
|
|
above = false,
|
|
|
|
below = false,
|
|
|
|
},
|
|
|
|
tags_status = {},
|
|
|
|
is_excluded = false,
|
2015-08-21 02:00:40 +02:00
|
|
|
curr_tag_only = false,
|
|
|
|
font = "monospace 20",
|
2015-09-30 00:25:45 +02:00
|
|
|
fg = beautiful.fg_normal or "#DCDCCC",
|
2016-03-08 16:36:37 +01:00
|
|
|
bg = beautiful.bg_normal or "#000000",
|
|
|
|
border_color=beautiful.border_focus or "#DCDCCC",
|
|
|
|
border_width=beautiful.border_width or 2,
|
2015-09-25 02:58:34 +02:00
|
|
|
hintsize = (type(beautiful.xresources) == 'table' and beautiful.xresources.apply_dpi(50) or 60)
|
2011-10-21 00:26:37 +02:00
|
|
|
}
|
2011-08-23 23:37:11 +02:00
|
|
|
|
2013-08-31 23:54:57 +02:00
|
|
|
|
2015-11-06 08:08:26 +01:00
|
|
|
|
2011-08-23 23:37:11 +02:00
|
|
|
-- Executed when user selects a client from expose view.
|
|
|
|
--
|
|
|
|
-- @param restore Function to reset the current tags view.
|
2015-09-26 03:38:54 +02:00
|
|
|
local function selectfn(restore, t, zt)
|
2011-08-23 23:37:11 +02:00
|
|
|
return function(c)
|
2015-09-26 03:38:54 +02:00
|
|
|
revelation.restore(t, zt)
|
2011-08-23 23:37:11 +02:00
|
|
|
-- Focus and raise
|
2015-10-09 23:22:34 +02:00
|
|
|
--
|
|
|
|
if type(delayed_call) == 'function' then
|
|
|
|
capi.awesome.emit_signal("refresh")
|
|
|
|
end
|
|
|
|
|
2015-09-29 00:57:49 +02:00
|
|
|
if awful.util.table.hasitem(hintindex, c) then
|
|
|
|
if c.minimized then
|
|
|
|
c.minimized = false
|
|
|
|
end
|
|
|
|
|
2016-07-13 16:38:03 +02:00
|
|
|
--jump_to_func(c)
|
|
|
|
awful.client.jumpto(c)
|
2014-01-21 20:09:18 +01:00
|
|
|
end
|
2011-08-23 23:37:11 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-21 00:26:37 +02:00
|
|
|
-- Tags all matching clients with tag t
|
|
|
|
-- @param rule The rule. Conforms to awful.rules syntax.
|
|
|
|
-- @param clients A table of clients to check.
|
|
|
|
-- @param t The tag to give matching clients.
|
2015-10-08 14:01:27 +02:00
|
|
|
local function match_clients(rule, _clients, t, is_excluded)
|
|
|
|
|
2013-12-30 22:42:52 +01:00
|
|
|
local mfc = rule.any and revelation.match.any or revelation.match.exact
|
2015-08-21 02:24:01 +02:00
|
|
|
local mf = is_excluded and function(c,_rule) return not mfc(c,_rule) end or mfc
|
|
|
|
local flt
|
2015-10-08 14:01:27 +02:00
|
|
|
|
|
|
|
for _, c in pairs(_clients) do
|
2011-10-21 00:26:37 +02:00
|
|
|
if mf(c, rule) then
|
2011-12-22 22:49:53 +01:00
|
|
|
-- Store geometry before setting their tags
|
2014-01-04 02:57:08 +01:00
|
|
|
clientData[c] = {}
|
2015-12-31 11:35:39 +01:00
|
|
|
clientData[c]["geometry"] = c:geometry()
|
|
|
|
flt = awful.client.property.get(c, "floating")
|
|
|
|
if flt ~= nil then
|
|
|
|
clientData[c]["floating"] = flt
|
|
|
|
awful.client.property.set(c, "floating", false)
|
2011-12-22 22:49:53 +01:00
|
|
|
end
|
2011-12-22 17:21:31 +01:00
|
|
|
|
2015-12-31 11:35:39 +01:00
|
|
|
|
2014-01-04 02:57:08 +01:00
|
|
|
for k,v in pairs(revelation.property_to_watch) do
|
|
|
|
clientData[c][k] = c[k]
|
|
|
|
c[k] = v
|
2015-02-24 21:48:06 +01:00
|
|
|
|
2014-01-04 02:57:08 +01:00
|
|
|
end
|
2016-05-09 21:16:26 +02:00
|
|
|
toggle_tag_func(t, c)
|
2015-10-17 10:31:58 +02:00
|
|
|
if c:isvisible() then
|
|
|
|
table.insert(clients, c)
|
|
|
|
end
|
2011-10-21 00:26:37 +02:00
|
|
|
end
|
|
|
|
end
|
2015-10-08 14:01:27 +02:00
|
|
|
|
2011-10-21 00:26:37 +02:00
|
|
|
end
|
|
|
|
|
2011-08-23 23:37:11 +02:00
|
|
|
|
|
|
|
-- Implement Exposé (ala Mac OS X).
|
|
|
|
--
|
2011-10-21 00:26:37 +02:00
|
|
|
-- @param rule A table with key and value to match. [{class=""}]
|
2013-12-30 22:50:54 +01:00
|
|
|
function revelation.expose(args)
|
2015-08-21 02:24:01 +02:00
|
|
|
args = args or {}
|
2013-12-30 22:50:54 +01:00
|
|
|
local rule = args.rule or {}
|
2015-11-12 23:47:49 +01:00
|
|
|
local is_excluded = args.is_excluded or revelation.is_excluded
|
|
|
|
local curr_tag_only = args.curr_tag_only or revelation.curr_tag_only
|
2014-01-04 02:57:08 +01:00
|
|
|
|
2013-08-31 23:54:57 +02:00
|
|
|
local t={}
|
|
|
|
local zt={}
|
2013-12-30 23:41:46 +01:00
|
|
|
|
2015-10-08 14:01:27 +02:00
|
|
|
clients = {}
|
|
|
|
clientData = {}
|
2013-08-31 23:54:57 +02:00
|
|
|
|
|
|
|
for scr=1,capi.screen.count() do
|
2013-12-30 22:42:52 +01:00
|
|
|
t[scr] = awful.tag.new({revelation.tag_name},
|
2015-11-16 16:38:02 +01:00
|
|
|
scr, awful.layout.suit.fair)[1]
|
2013-12-30 22:42:52 +01:00
|
|
|
zt[scr] = awful.tag.new({revelation.tag_name.."_zoom"},
|
2015-11-16 16:38:02 +01:00
|
|
|
scr, awful.layout.suit.fair)[1]
|
2013-12-30 22:42:52 +01:00
|
|
|
|
2015-02-24 21:48:06 +01:00
|
|
|
if curr_tag_only then
|
2015-11-16 16:38:02 +01:00
|
|
|
match_clients(rule, awful.client.visible(scr), t[scr], is_excluded)
|
2013-12-30 22:42:52 +01:00
|
|
|
else
|
2013-12-30 22:50:54 +01:00
|
|
|
match_clients(rule, capi.client.get(scr), t[scr], is_excluded)
|
2013-12-30 22:42:52 +01:00
|
|
|
end
|
|
|
|
|
2016-05-09 00:28:38 +02:00
|
|
|
view_only_func(t[scr])
|
2015-02-24 21:48:06 +01:00
|
|
|
end
|
2015-09-25 02:58:34 +02:00
|
|
|
|
|
|
|
if type(delayed_call) == 'function' then
|
2015-09-26 19:44:20 +02:00
|
|
|
capi.awesome.emit_signal("refresh")
|
2015-09-25 02:58:34 +02:00
|
|
|
end
|
2015-09-26 23:55:16 +02:00
|
|
|
-- No need for awesome WM 3.5.6: capi.awesome.emit_signal("refresh")
|
|
|
|
--
|
2015-10-08 14:01:27 +02:00
|
|
|
local status, err=pcall(revelation.expose_callback, t, zt, clients)
|
2013-08-31 23:54:57 +02:00
|
|
|
|
2015-09-26 23:55:16 +02:00
|
|
|
--revelation.expose_callback(t, zt)
|
2015-09-26 19:44:20 +02:00
|
|
|
if not status then
|
|
|
|
debuginfo('Oops!, something is wrong in revelation.expose_callback!')
|
2015-08-21 02:24:01 +02:00
|
|
|
|
2015-09-26 19:44:20 +02:00
|
|
|
if err.msg then
|
|
|
|
debuginfo(err.msg)
|
2013-08-31 23:54:57 +02:00
|
|
|
end
|
2015-11-05 20:42:10 +01:00
|
|
|
|
2015-09-26 19:44:20 +02:00
|
|
|
if err.code then
|
|
|
|
debuginfo('error code is '.. tostring(err.code))
|
2013-08-31 23:54:57 +02:00
|
|
|
end
|
2011-12-22 17:21:31 +01:00
|
|
|
|
2015-09-26 19:44:20 +02:00
|
|
|
revelation.restore(t, zt)
|
2013-08-31 23:54:57 +02:00
|
|
|
|
2015-09-26 19:44:20 +02:00
|
|
|
end
|
2015-08-21 02:00:40 +02:00
|
|
|
end
|
2013-08-31 23:54:57 +02:00
|
|
|
|
2015-07-25 21:42:12 +02:00
|
|
|
|
2015-09-26 03:38:54 +02:00
|
|
|
function revelation.restore(t, zt)
|
|
|
|
for scr=1, capi.screen.count() do
|
|
|
|
awful.tag.history.restore(scr)
|
|
|
|
t[scr].screen = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
capi.keygrabber.stop()
|
|
|
|
capi.mousegrabber.stop()
|
|
|
|
|
2015-10-09 23:30:42 +02:00
|
|
|
for _, c in pairs(clients) do
|
|
|
|
if clientData[c] then
|
|
|
|
for k,v in pairs(clientData[c]) do
|
|
|
|
if v ~= nil then
|
|
|
|
if k== "geometry" then
|
|
|
|
c:geometry(v)
|
|
|
|
elseif k == "floating" then
|
|
|
|
awful.client.property.set(c, "floating", v)
|
|
|
|
else
|
|
|
|
c[k]=v
|
2014-01-04 02:57:08 +01:00
|
|
|
end
|
|
|
|
end
|
2013-08-31 23:54:57 +02:00
|
|
|
end
|
2011-12-22 17:21:31 +01:00
|
|
|
end
|
2015-10-09 23:30:42 +02:00
|
|
|
end
|
|
|
|
|
2015-09-26 03:38:54 +02:00
|
|
|
for scr=1, capi.screen.count() do
|
|
|
|
t[scr].activated = false
|
|
|
|
zt[scr].activated = false
|
|
|
|
end
|
|
|
|
|
|
|
|
for i,j in pairs(hintindex) do
|
|
|
|
hintbox[i].visible = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-09-26 23:55:16 +02:00
|
|
|
local function hintbox_display_toggle(c, show)
|
|
|
|
for char, thisclient in pairs(hintindex) do
|
|
|
|
if char and char ~= c then
|
|
|
|
hintindex[char] = thisclient
|
|
|
|
if show then
|
|
|
|
hintbox[char].visible = true
|
|
|
|
else
|
|
|
|
hintbox[char].visible = false
|
|
|
|
end
|
2013-12-30 23:41:46 +01:00
|
|
|
|
|
|
|
end
|
2015-09-26 23:55:16 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function hintbox_pos(char)
|
|
|
|
local client = hintindex[char]
|
|
|
|
local geom = client:geometry()
|
|
|
|
hintbox[char].x = math.floor(geom.x + geom.width/2 - revelation.hintsize/2)
|
|
|
|
hintbox[char].y = math.floor(geom.y + geom.height/2 - revelation.hintsize/2)
|
|
|
|
end
|
|
|
|
|
2015-09-26 03:38:54 +02:00
|
|
|
|
2015-10-08 14:01:27 +02:00
|
|
|
function revelation.expose_callback(t, zt, clientlist)
|
2013-12-31 22:27:03 +01:00
|
|
|
|
2015-10-08 14:01:27 +02:00
|
|
|
hintindex = {}
|
2015-02-24 21:48:06 +01:00
|
|
|
for i,thisclient in pairs(clientlist) do
|
2013-08-31 23:54:57 +02:00
|
|
|
-- Move wiboxes to center of visible windows and populate hintindex
|
2015-11-06 10:15:02 +01:00
|
|
|
local char = revelation.charorder:sub(i,i)
|
2015-04-21 02:04:37 +02:00
|
|
|
if char and char ~= '' then
|
2015-07-25 21:42:12 +02:00
|
|
|
hintindex[char] = thisclient
|
2015-09-26 23:55:16 +02:00
|
|
|
hintbox_pos(char)
|
2015-07-25 21:42:12 +02:00
|
|
|
hintbox[char].visible = true
|
|
|
|
end
|
2011-08-23 23:37:11 +02:00
|
|
|
end
|
|
|
|
|
2014-03-02 22:13:59 +01:00
|
|
|
local zoomed = false
|
|
|
|
local zoomedClient = nil
|
2015-09-26 23:55:16 +02:00
|
|
|
local key_char_zoomed = nil
|
2014-03-02 22:13:59 +01:00
|
|
|
|
2015-09-26 23:55:16 +02:00
|
|
|
capi.keygrabber.run(function (mod, key, event)
|
2015-08-21 02:24:01 +02:00
|
|
|
local c
|
2013-08-31 23:54:57 +02:00
|
|
|
if event == "release" then return true end
|
2015-02-24 21:48:06 +01:00
|
|
|
|
2014-03-02 22:13:59 +01:00
|
|
|
if awful.util.table.hasitem(mod, "Shift") then
|
2015-09-26 23:55:16 +02:00
|
|
|
key_char = string.lower(key)
|
|
|
|
c = hintindex[key_char]
|
|
|
|
if not zoomed and c ~= nil then
|
2015-11-06 10:18:19 +01:00
|
|
|
--debuginfo(c.screen)
|
2016-05-09 00:28:38 +02:00
|
|
|
view_only_func(zt[c.screen])
|
2016-05-09 21:16:26 +02:00
|
|
|
toggle_tag_func(zt[c.screen], c)
|
2015-09-26 23:55:16 +02:00
|
|
|
zoomedClient = c
|
|
|
|
key_char_zoomed = key_char
|
|
|
|
zoomed = true
|
|
|
|
-- update the position of this hintbox, since it is zoomed
|
|
|
|
if type(delayed_call) == 'function' then
|
|
|
|
capi.awesome.emit_signal("refresh")
|
|
|
|
end
|
|
|
|
hintbox_pos(key_char)
|
|
|
|
hintbox_display_toggle(key_char, false)
|
|
|
|
|
|
|
|
|
|
|
|
elseif zoomedClient ~= nil then
|
2015-09-29 00:57:49 +02:00
|
|
|
awful.tag.history.restore(zoomedClient.screen)
|
2016-05-09 21:16:26 +02:00
|
|
|
toggle_tag_func(zt[zoomedClient.screen], zoomedClient)
|
2015-09-29 00:57:49 +02:00
|
|
|
hintbox_display_toggle(key_char_zoomed, true)
|
2015-09-26 23:55:16 +02:00
|
|
|
if type(delayed_call) == 'function' then
|
|
|
|
capi.awesome.emit_signal("refresh")
|
2014-03-02 22:13:59 +01:00
|
|
|
end
|
2015-09-26 23:55:16 +02:00
|
|
|
hintbox_pos(key_char_zoomed)
|
|
|
|
|
|
|
|
zoomedClient = nil
|
|
|
|
zoomed = false
|
2015-09-29 00:57:49 +02:00
|
|
|
key_char_zoomed = nil
|
2014-03-02 22:13:59 +01:00
|
|
|
end
|
|
|
|
end
|
2013-08-31 23:54:57 +02:00
|
|
|
|
2015-02-24 21:48:06 +01:00
|
|
|
if hintindex[key] then
|
2013-08-31 23:54:57 +02:00
|
|
|
--client.focus = hintindex[key]
|
|
|
|
--hintindex[key]:raise()
|
2015-02-24 21:48:06 +01:00
|
|
|
|
2015-09-26 23:55:16 +02:00
|
|
|
selectfn(restore,t, zt)(hintindex[key])
|
2013-08-31 23:54:57 +02:00
|
|
|
|
|
|
|
for i,j in pairs(hintindex) do
|
|
|
|
hintbox[i].visible = false
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
2015-02-24 21:48:06 +01:00
|
|
|
end
|
2013-08-31 23:54:57 +02:00
|
|
|
|
|
|
|
if key == "Escape" then
|
2015-09-26 23:55:16 +02:00
|
|
|
if zoomedClient ~= nil then
|
2015-09-29 00:57:49 +02:00
|
|
|
awful.tag.history.restore(zoomedClient.screen)
|
2016-05-09 21:16:26 +02:00
|
|
|
toggle_tag_func(zt[zoomedClient.screen], zoomedClient)
|
2015-09-26 23:55:16 +02:00
|
|
|
hintbox_display_toggle(string.lower(key), true)
|
|
|
|
if type(delayed_call) == 'function' then
|
|
|
|
capi.awesome.emit_signal("refresh")
|
|
|
|
end
|
|
|
|
hintbox_pos(key_char_zoomed)
|
|
|
|
|
|
|
|
zoomedClient = nil
|
|
|
|
zoomed = false
|
|
|
|
else
|
|
|
|
for i,j in pairs(hintindex) do
|
|
|
|
hintbox[i].visible = false
|
|
|
|
end
|
|
|
|
revelation.restore(t, zt)
|
|
|
|
return false
|
2013-08-31 23:54:57 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return true
|
2015-09-26 23:55:16 +02:00
|
|
|
end)
|
2011-10-01 23:03:12 +02:00
|
|
|
|
2011-12-21 22:42:20 +01:00
|
|
|
local pressedMiddle = false
|
2013-08-31 23:54:57 +02:00
|
|
|
|
2011-10-01 23:03:12 +02:00
|
|
|
capi.mousegrabber.run(function(mouse)
|
2016-05-09 00:28:38 +02:00
|
|
|
local c
|
|
|
|
|
2016-05-09 21:16:26 +02:00
|
|
|
if type(tag.view_only) == 'function' then
|
2016-05-09 00:28:38 +02:00
|
|
|
c = awful.mouse.client_under_pointer()
|
|
|
|
else
|
2016-07-13 16:38:03 +02:00
|
|
|
c = capi.mouse.current_client
|
2016-05-09 00:28:38 +02:00
|
|
|
end
|
2015-09-26 23:55:16 +02:00
|
|
|
local key_char = awful.util.table.hasitem(hintindex, c)
|
2011-10-21 00:26:37 +02:00
|
|
|
if mouse.buttons[1] == true then
|
2016-07-13 16:38:03 +02:00
|
|
|
if c ~= nil then
|
|
|
|
selectfn(restore, t, zt)(c)
|
2013-08-31 23:54:57 +02:00
|
|
|
|
2016-07-13 16:38:03 +02:00
|
|
|
for i,j in pairs(hintindex) do
|
|
|
|
hintbox[i].visible = false
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
else
|
|
|
|
return true
|
2013-08-31 23:54:57 +02:00
|
|
|
end
|
2015-02-24 21:48:06 +01:00
|
|
|
elseif mouse.buttons[2] == true and pressedMiddle == false and c ~= nil then
|
|
|
|
-- is true whenever the button is down.
|
|
|
|
pressedMiddle = true
|
2013-08-31 23:54:57 +02:00
|
|
|
-- extra variable needed to prevent script from spam-closing windows
|
2015-09-26 23:55:16 +02:00
|
|
|
--
|
|
|
|
if zoomed == true and zoomedClient ~=nil then
|
2015-09-29 00:57:49 +02:00
|
|
|
awful.tag.history.restore(zoomedClient.screen)
|
2016-05-09 21:16:26 +02:00
|
|
|
toggle_tag_func(zt[zoomedClient.screen], zoomedClient)
|
2015-09-26 23:55:16 +02:00
|
|
|
end
|
2011-12-21 22:42:20 +01:00
|
|
|
c:kill()
|
2015-09-26 23:55:16 +02:00
|
|
|
hintbox[key_char].visible = false
|
|
|
|
hintindex[key_char] = nil
|
2015-10-17 10:31:58 +02:00
|
|
|
pos = awful.util.table.hasitem(clients, c)
|
|
|
|
table.remove(clients, pos)
|
2015-09-26 23:55:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
if zoomed == true and zoomedClient ~=nil then
|
|
|
|
hintbox_display_toggle(key_char_zoomed, true)
|
|
|
|
zoomedClient = nil
|
|
|
|
zoomed = false
|
|
|
|
key_char_zoomed = nil
|
|
|
|
end
|
|
|
|
|
2011-12-21 22:42:20 +01:00
|
|
|
return true
|
2015-09-26 23:55:16 +02:00
|
|
|
|
2011-12-21 22:42:20 +01:00
|
|
|
elseif mouse.buttons[2] == false and pressedMiddle == true then
|
|
|
|
pressedMiddle = false
|
2015-09-26 23:55:16 +02:00
|
|
|
for key, _ in pairs(hintindex) do
|
|
|
|
hintbox_pos(key)
|
|
|
|
end
|
|
|
|
elseif mouse.buttons[3] == true then
|
2013-08-31 23:54:57 +02:00
|
|
|
if not zoomed and c ~= nil then
|
2016-05-09 00:28:38 +02:00
|
|
|
view_only_func(zt[c.screen])
|
2016-05-09 21:16:26 +02:00
|
|
|
toggle_tag_func(zt[c.screen], c)
|
2015-09-26 23:55:16 +02:00
|
|
|
if key_char ~= nil then
|
|
|
|
hintbox_display_toggle(key_char, false)
|
|
|
|
if type(delayed_call) == 'function' then
|
|
|
|
capi.awesome.emit_signal("refresh")
|
|
|
|
end
|
|
|
|
hintbox_pos(key_char)
|
|
|
|
end
|
2013-08-31 23:54:57 +02:00
|
|
|
zoomedClient = c
|
|
|
|
zoomed = true
|
2015-09-26 23:55:16 +02:00
|
|
|
key_char_zoomed = key_char
|
2013-08-31 23:54:57 +02:00
|
|
|
elseif zoomedClient ~= nil then
|
2015-09-29 00:57:49 +02:00
|
|
|
awful.tag.history.restore(zoomedClient.screen)
|
2016-05-09 21:16:26 +02:00
|
|
|
toggle_tag_func(zt[zoomedClient.screen], zoomedClient)
|
2015-09-26 23:55:16 +02:00
|
|
|
hintbox_display_toggle(key_char_zoomed, true)
|
|
|
|
if type(delayed_call) == 'function' then
|
|
|
|
capi.awesome.emit_signal("refresh")
|
|
|
|
end
|
|
|
|
hintbox_pos(key_char_zoomed)
|
|
|
|
|
2013-08-31 23:54:57 +02:00
|
|
|
zoomedClient = nil
|
2015-02-24 21:48:06 +01:00
|
|
|
zoomed = false
|
2015-09-29 00:57:49 +02:00
|
|
|
key_char_zoomed = nil
|
2013-08-31 23:54:57 +02:00
|
|
|
end
|
2011-10-01 23:03:12 +02:00
|
|
|
end
|
2011-12-21 22:42:20 +01:00
|
|
|
|
2011-10-01 23:03:12 +02:00
|
|
|
return true
|
2011-10-21 00:26:37 +02:00
|
|
|
--Strange but on my machine only fleur worked as a string.
|
|
|
|
--stole it from
|
2011-10-01 23:03:12 +02:00
|
|
|
--https://github.com/Elv13/awesome-configs/blob/master/widgets/layout/desktopLayout.lua#L175
|
|
|
|
end,"fleur")
|
2015-07-25 21:42:12 +02:00
|
|
|
|
2011-08-23 23:37:11 +02:00
|
|
|
end
|
|
|
|
|
2013-08-31 23:54:57 +02:00
|
|
|
-- Create the wiboxes, but don't show them
|
2014-03-02 22:33:23 +01:00
|
|
|
--
|
2014-01-10 16:04:34 +01:00
|
|
|
function revelation.init(args)
|
2013-08-31 23:54:57 +02:00
|
|
|
local letterbox = {}
|
2013-12-30 22:42:52 +01:00
|
|
|
|
2015-08-21 02:24:01 +02:00
|
|
|
args = args or {}
|
2013-12-30 22:42:52 +01:00
|
|
|
|
|
|
|
revelation.tag_name = args.tag_name or revelation.tag_name
|
2015-02-24 21:48:06 +01:00
|
|
|
if args.match then
|
2013-12-30 22:42:52 +01:00
|
|
|
revelation.match.exact = args.match.exact or revelation.match.exact
|
2014-01-10 16:04:34 +01:00
|
|
|
revelation.match.any = args.match.any or revelation.match.any
|
2013-12-30 22:42:52 +01:00
|
|
|
end
|
|
|
|
|
2015-11-05 15:47:46 +01:00
|
|
|
revelation.charorder = args.charorder or revelation.charorder
|
2013-12-30 22:42:52 +01:00
|
|
|
|
2015-11-05 15:47:46 +01:00
|
|
|
for i = 1, #revelation.charorder do
|
|
|
|
local char = revelation.charorder:sub(i,i)
|
2016-03-08 16:36:37 +01:00
|
|
|
hintbox[char] = wibox({
|
|
|
|
fg=revelation.fg,
|
|
|
|
bg=revelation.bg,
|
|
|
|
border_color=revelation.border_color,
|
|
|
|
border_width=revelation.border_width
|
|
|
|
})
|
2013-08-31 23:54:57 +02:00
|
|
|
hintbox[char].ontop = true
|
2015-08-21 02:24:01 +02:00
|
|
|
hintbox[char].width = revelation.hintsize
|
|
|
|
hintbox[char].height = revelation.hintsize
|
2013-08-31 23:54:57 +02:00
|
|
|
letterbox[char] = wibox.widget.textbox()
|
2016-03-08 16:36:37 +01:00
|
|
|
letterbox[char]:set_markup(char.upper(char))
|
2015-08-21 02:00:40 +02:00
|
|
|
letterbox[char]:set_font(revelation.font)
|
2013-08-31 23:54:57 +02:00
|
|
|
letterbox[char]:set_align("center")
|
|
|
|
hintbox[char]:set_widget(letterbox[char])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
setmetatable(revelation, { __call = function(_, ...) return revelation.expose(...) end })
|
|
|
|
|
|
|
|
return revelation
|