From e5e1ec10b9fb723a0ecfcdfe5affe5d43b2dde7d Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 22 Jun 2013 18:12:08 -0400 Subject: [PATCH] Support clients with multiple matches on multiple screens. Honestly, I don't really like this commit, but I do agree that Tyrannical cannot just ignore bugs to keep the code simple forever. I tried this code for 1 week and it doesn't seem to cause regressions, so I commit it. Please report bugs on github if you experience degraded functionalities. --- init.lua | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) mode change 100644 => 100755 init.lua diff --git a/init.lua b/init.lua old mode 100644 new mode 100755 index dbfd9bf..8bde05b --- a/init.lua +++ b/init.lua @@ -1,7 +1,7 @@ local setmetatable = setmetatable local print , pairs = print , pairs local ipairs , type = ipairs , type -local string = string +local string , unpack= string,unpack local awful = require("awful") local capi = {client = client , tag = tag , @@ -121,23 +121,24 @@ local function match_client(c, startup) end --TODO pre_match --Add to matches - local tags = {} + local tags,tags_src,fav_scr,c_src,mouse_s = {},{},false,c.screen,capi.mouse.screen for j=1,#(rules.tags or {}) do - local tag_tmp = rules.tags[j] - tag_tmp.instances = tag_tmp.instances or {} - if not tag_tmp.instances[c.screen or 1] then - local cache = tag_tmp.screen - tag_tmp.screen = tag_tmp.force_screen == true and tag_tmp.screen or c.screen - tag_tmp.screen = (tag_tmp.screen <= capi.screen.count()) and tag_tmp.screen or 1 - c.screen = tag_tmp.screen - awful.tag.add(tag_tmp.name,tag_tmp) - tag_tmp.screen = cache + local tag,cache = rules.tags[j],rules.tags[j].screen + tag.instances,has_screen = tag.instances or {},(type(tag.screen)=="table" and awful.util.table.hasitem(tag.screen,c_src)~=nil) + tag.screen = (tag.force_screen ~= true and c_src) or (has_screen and c_src or type(tag.screen)=="table" and tag.screen[1] or tag.screen) + tag.screen = (tag.screen <= capi.screen.count()) and tag.screen or mouse_s + if not tag.instances[tag.screen] and not (fav_scr == true and mouse_s ~= tag.screen) then + awful.tag.add(tag.name,tag) end - tags[#tags+1] = tag_tmp.instances[(c.screen <= capi.screen.count()) and c.screen or 1] + tags_src[tag.screen],fav_scr = tags_src[tag.screen] or {},fav_scr or (tag.screen == mouse_s) --Reset if a better screen is found + tags_src[tag.screen][#tags_src[tag.screen]+1] = tag.instances[tag.screen] + tag.screen = cache end + tags = tags_src[mouse_s] or tags_src[c_src] or select(2,next(tags_src)) or awful.util.table.join(unpack(tags_src)) + c.screen = tags[1] and awful.tag.getscreen(tags[1]) or c_src if #tags > 0 then c:tags(tags) - if awful.tag.getproperty(tags[1],"focus_new") ~= false and not (c.transient_for and settings.block_transient_for_focus_stealing) + if awful.tag.getproperty(tags[1],"focus_new") ~= false and not (c.transient_for and settings.block_transient_for_focus_stealing) and not awful.tag.getproperty(tags[1],"no_focus_stealing") then awful.tag.viewonly(tags[1]) elseif awful.tag.getproperty(tags[1],"no_focus_stealing") then @@ -241,4 +242,4 @@ local getter = {properties = setmetatable({}, {__newindex = function(table,k,v settings = settings, tags_by_name = tags_hash} --Getter only, use .tags for setter, see syntax local setter = {tags = load_tags} -return setmetatable(module,{__index=function(t,k) return getter[k] end,__newindex=function(t,k,v) if setter[k] then return setter[k](v) end end}) +return setmetatable(module,{__index=function(t,k) return getter[k] end,__newindex=function(t,k,v) if setter[k] then return setter[k](v) end end}) \ No newline at end of file