From f461d0316a8f7e1cc75a232cc66c91f527c21b75 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Fri, 28 Mar 2014 01:25:09 -0400 Subject: [PATCH] Implement tag menu highlight (issue #22) --- impl/common/tag.lua | 14 +++++++++++++- impl/taglist/init.lua | 22 ++++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/impl/common/tag.lua b/impl/common/tag.lua index b0a14f5..65401fb 100644 --- a/impl/common/tag.lua +++ b/impl/common/tag.lua @@ -3,6 +3,7 @@ local capi = { screen = screen, client=client} local awful = require( "awful" ) local beautiful = require("beautiful") local suits = require("awful.layout.suit") +local tag_list = nil local module = {} @@ -22,10 +23,21 @@ local fallback_layouts = { } local function createTagList(aScreen) + if not tag_list then + tag_list = require("radical.impl.taglist") + end local tagList = radical.context({autodiscard = true}) for _, v in ipairs(awful.tag.gettags(aScreen)) do - tagList:add_item({text = v.name,icon=awful.tag.geticon(v)}) + local i = tagList:add_item({text = v.name,icon=awful.tag.geticon(v)}) + i:connect_signal("mouse::enter",function() + tag_list.highlight(v) + end) end + tagList:connect_signal("visible::changed",function() + if not tagList.visible then + tag_list.highlight(nil) + end + end) return tagList end diff --git a/impl/taglist/init.lua b/impl/taglist/init.lua index abc5334..30d9414 100644 --- a/impl/taglist/init.lua +++ b/impl/taglist/init.lua @@ -19,8 +19,10 @@ local tracker = require( "radical.impl.taglist.tracker" ) local tag_menu = require( "radical.impl.taglist.tag_menu" ) local CLONED = 100 +local HIGHLIGHTED = -2 -theme.register_color(CLONED , "cloned" , "taglist_cloned" , true ) +theme.register_color(CLONED , "cloned" , "cloned" , true ) +theme.register_color(HIGHLIGHTED , "highlight" , "highlight" , true ) local module,instances = {},{} @@ -177,6 +179,21 @@ local function init() is_init = true end +local highlighted = nil +function module.highlight(t) + if highlighted and highlighted ~= t then + highlighted.state[HIGHLIGHTED] = nil + highlighted = nil + end + if t then + local item = cache[t] + if item then + highlighted = item + highlighted.state[HIGHLIGHTED] = true + end + end +end + local function new(s) local track = tracker(s) @@ -190,10 +207,11 @@ local function new(s) fg_focus = beautiful.taglist_fg_selected, -- fkeys_prefix = true, } - for k,v in ipairs {"hover","used","urgent","cloned","changed"} do + for k,v in ipairs {"hover","used","urgent","cloned","changed","highlight"} do args["bg_"..v] = beautiful["taglist_bg_"..v] args["fg_"..v] = beautiful["taglist_fg_"..v] end + print("THAT",beautiful.taglist_bg_highlight) instances[s] = radical.bar(args)