Add 3 new focus stealing policies

Globals:

* tyrannical.settings.block_children_focus_stealing = true --Block popups ()
* tyrannical.settings.group_children = true --Force popups/dialogs to have the same tags as the parent client

Tags:

* no_focus_stealing --Prevent new clients from selecting the tags (good for chat windows), make the new client "urgent" instead

Also update the documentation to match those additions
This commit is contained in:
Emmanuel Lepage Vallee 2013-06-14 00:24:55 -04:00
parent 8943c63020
commit 926d43842c
2 changed files with 40 additions and 42 deletions

View File

@ -136,22 +136,32 @@ tyrannical.properties.ontop = {
tyrannical.properties.centered = { tyrannical.properties.centered = {
"kcalc" "kcalc"
} }
tyrannical.settings.block_children_focus_stealing = true --Block popups ()
tyrannical.settings.group_children = true --Force popups/dialogs to have the same tags as the parent client
``` ```
Then edit this section to fit your needs. That available tag properties are: Then edit this section to fit your needs. That available tag properties are:
* mwfact
* nmaster | Property | Description | Type |
* ncol | --------------------- | ---------------------------------------------- |:----------------:|
* icon | **mwfact** | Tiled layout master/slave ratio | float(0-1) |
* hide | **nmaster** | Number of master clients | number |
* screen (number or array) | **ncol** | Number of columns | number |
* exclusive | **icon** | Tag icon | path |
* layout | **hide** | Hide this tag from view | boolean |
* init | **screen** | Tag screen(s) | number or array |
* clone_on | **exclusive** | Allow only client from the "class" attributes | boolean |
* class | **layout** | The tag layout | layout |
* exec_once | **init** | Create when awesome launch | boolean |
* selected | **clone_on** | Create a clone on screen(s) | number or array |
| **class** | Match these classes to this tag | array of string |
| **exec_once** | Execute when the tag is first selected | string (command) |
| **selected** | Select when created | boolean |
| **volatile** | Destroy when the last client is closed | boolean |
| **force_screen** | Force a screen | number |
| **no_focus_stealing** | Prevent tag from stealing focus on new clients | boolean |
The available client properties are: The available client properties are:
* floating * floating

View File

@ -7,8 +7,6 @@ local awful = require("awful")
local capi = {client = client , tag = tag , local capi = {client = client , tag = tag ,
screen = screen , mouse = mouse } screen = screen , mouse = mouse }
local module = {}
-------------------------------INIT------------------------------ -------------------------------INIT------------------------------
local signals = { local signals = {
@ -23,7 +21,7 @@ for _,sig in ipairs(signals) do
end end
-------------------------------DATA------------------------------ -------------------------------DATA------------------------------
local class_client,matches_client,tags_hash = {},{},{} local module,class_client,matches_client,tags_hash,settings = {},{},{},{},{}
--------------------------TYRANIC LOGIC-------------------------- --------------------------TYRANIC LOGIC--------------------------
@ -90,7 +88,10 @@ local function match_client(c, startup)
if not c then return end if not c then return end
local low = string.lower(c.class or "N/A") local low = string.lower(c.class or "N/A")
local rules = class_client[low] local rules = class_client[low]
if rules then if c.transient_for and settings.group_children == true then
c.sticky = c.transient_for.sticky or false
return c:tags(c.transient_for:tags())
elseif rules then
--Force floating state if necessary --Force floating state if necessary
if rules.properties.floating ~= nil then if rules.properties.floating ~= nil then
awful.client.floating.set(c, rules.properties.floating) awful.client.floating.set(c, rules.properties.floating)
@ -100,7 +101,7 @@ local function match_client(c, startup)
awful.placement.centered(c, nil) awful.placement.centered(c, nil)
end end
--Focus new client --Focus new client
if rules.properties.focus_new ~= false then if rules.properties.focus_new ~= false and (c.transient_for and not settings.block_transient_for_focus_stealing) then
capi.client.focus = c capi.client.focus = c
end end
--Set other properties --Set other properties
@ -115,8 +116,7 @@ local function match_client(c, startup)
end end
tag = awful.tag.selected(c.screen) tag = awful.tag.selected(c.screen)
if tag then --Can be false if there is no tags if tag then --Can be false if there is no tags
c:tags({tag}) return c:tags({tag})
return
end end
end end
--TODO pre_match --TODO pre_match
@ -137,8 +137,11 @@ local function match_client(c, startup)
end end
if #tags > 0 then if #tags > 0 then
c:tags(tags) c:tags(tags)
if awful.tag.getproperty(tags[1],"focus_new") ~= false then 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]) awful.tag.viewonly(tags[1])
elseif awful.tag.getproperty(tags[1],"no_focus_stealing") then
c.urgent = true
end end
return return
end end
@ -171,7 +174,6 @@ capi.client.connect_signal("untagged", function (c, t)
end end
end) end)
-- awful.tag.withcurrent = function() end --Disable automatic tag insertion
awful.tag.withcurrent,awful.tag._add = function(c, startup) awful.tag.withcurrent,awful.tag._add = function(c, startup)
local tags,old_tags = {},c:tags() local tags,old_tags = {},c:tags()
--Safety to prevent --Safety to prevent
@ -215,6 +217,8 @@ awful.tag.setscreen,awful.tag._viewonly = function(tag,screen) --Why this isn't
end,awful.tag.viewonly end,awful.tag.viewonly
awful.tag.viewonly = function(t) awful.tag.viewonly = function(t)
if not t then return end
if not awful.tag.getscreen(t) then awful.tag.setscreen(1) end
awful.tag._viewonly(t) awful.tag._viewonly(t)
if awful.tag.getproperty(t,"clone_of") then if awful.tag.getproperty(t,"clone_of") then
awful.tag.swap(t,awful.tag.getproperty(t,"clone_of")) awful.tag.swap(t,awful.tag.getproperty(t,"clone_of"))
@ -231,24 +235,8 @@ awful.tag.swap = function(tag1,tag2)
end end
--------------------------OBJECT GEARS--------------------------- --------------------------OBJECT GEARS---------------------------
local properties = setmetatable({}, {__newindex = function(table,k,v) load_property(k,v) end}) local getter = {properties = setmetatable({}, {__newindex = function(table,k,v) load_property(k,v) end}),
settings = settings, tags_by_name = tags_hash} --Getter only, use .tags for setter, see syntax
local setter = {tags = load_tags}
local function getter (table, key) 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})
if key == "properties" then
return properties
elseif key == "tags_by_name" then
return tags_hash --Getter only, use .tags for setter, see syntax
end
end
local function setter (table, key,value)
if key == "tags" then --Setter only, use "tags_by_name" to get
load_tags(value)
elseif key == "properties" then
properties = value
for k,v in pairs(tyrannical_properties) do
load_property(k,v)
end
end
end
return setmetatable(module, { __call = function(_, ...) return end , __index = getter, __newindex = setter})