feat: wire up buttons for tag list

This commit is contained in:
xeals 2019-01-18 10:30:58 +11:00
parent 4ac05d48a6
commit fdcffa9650
2 changed files with 104 additions and 68 deletions

View File

@ -3,6 +3,36 @@ local dpi = require("beautiful").xresources.apply_dpi
local wibox = require("wibox") local wibox = require("wibox")
local clickable_container = require("widget.clickable-container") local clickable_container = require("widget.clickable-container")
local capi = {button = _G.button}
function create_buttons(buttons, object)
if buttons then
local btns = {}
for _, b in ipairs(buttons) do
-- Create a proxy button object: it will receive the real
-- press and release events, and will propagate them to the
-- button object the user provided, but with the object as
-- argument.
local btn = capi.button {modifiers = b.modifiers, button = b.button}
btn:connect_signal(
'press',
function()
b:emit_signal('press', object)
end
)
btn:connect_signal(
'release',
function()
b:emit_signal('release', object)
end
)
btns[#btns + 1] = btn
end
return btns
end
end
function list_update(w, buttons, label, data, objects) function list_update(w, buttons, label, data, objects)
-- update the widgets, creating them if needed -- update the widgets, creating them if needed
w:reset() w:reset()
@ -35,7 +65,7 @@ function list_update(w, buttons, label, data, objects)
-- bgb:set_widget(l) -- bgb:set_widget(l)
bgb:set_widget(bg_clickable) bgb:set_widget(bg_clickable)
bgb:buttons(common.create_buttons(buttons, o)) bgb:buttons(create_buttons(buttons, o))
data[o] = { data[o] = {
ib = ib, ib = ib,

View File

@ -4,10 +4,12 @@
(local awful (require :awful)) (local awful (require :awful))
(local beautiful (require :beautiful)) (local beautiful (require :beautiful))
(local gears (require :gears))
(local wibox (require :wibox)) (local wibox (require :wibox))
(local common (require :awful.widget.common)) (local common (require :awful.widget.common))
(local dpi (. (require :beautiful) :xresources :apply_dpi)) (local dpi (. (require :beautiful) :xresources :apply_dpi))
(local button (. (require :lib.keys) :button))
(local std (require :lib.std)) (local std (require :lib.std))
;;; ;;;
@ -93,7 +95,11 @@
(awful.widget.taglist (awful.widget.taglist
s s
awful.widget.taglist.filter.all awful.widget.taglist.filter.all
{} (gears.table.join
(button [] 1 (lambda [t] (: t :view_only)))
(button [] 3 (lambda [t] (when _G.client.focus (: _G.client.focus :move_to_tag t))))
(button [] 4 (lambda [t] (awful.tag.viewnext t.screen)))
(button [] 5 (lambda [t] (awful.tag.viewprev t.screen))))
{:font (.. beautiful.font " Bold 10") {:font (.. beautiful.font " Bold 10")
:spacing 2} :spacing 2}
;; update-tag-list ;; update-tag-list