-
Notifications
You must be signed in to change notification settings - Fork 50
Improved swallowing #140
Improved swallowing #140
Changes from 1 commit
32a528a
f28ee92
9765637
6a6e61f
5f0d3c4
ab5f44e
8670856
455aa82
2c5f7dd
3e9c4a1
54fbe76
4465035
8a87381
ec5cc22
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,10 +16,17 @@ local parent_filter_list = beautiful.parent_filter_list | |
or { "firefox", "Gimp", "Google-chrome" } | ||
local child_filter_list = beautiful.child_filter_list | ||
or beautiful.dont_swallow_classname_list or { } | ||
local swallowing_filter = beautiful.swallowing_filter | ||
or beautiful.dont_swallow_filter_activated or true | ||
|
||
-- for boolean values the or chain way to set the values breaks with 2 vars | ||
-- and always defaults to true so i had to do this to se the right value... | ||
local swallowing_filter = true | ||
local filter_vars = { beautiful.swallowing_filter, beautiful.dont_swallow_filter_activated } | ||
for _, var in pairs(filter_vars) do | ||
swallowing_filter = var | ||
end | ||
|
||
-- check if element exist in table | ||
-- returns true if it is | ||
local function is_in_table(element, table) | ||
local res = false | ||
for _, value in pairs(table) do | ||
|
@@ -31,13 +38,16 @@ local function is_in_table(element, table) | |
return res | ||
end | ||
|
||
-- checks if parent's classname can be swallowed | ||
local function check_swallow(class, list) | ||
if not swallowing_filter then | ||
return true | ||
else | ||
return not is_in_table(class, list) | ||
-- if the swallowing filter is active checks the child and parent classes | ||
-- against their filters | ||
local function check_swallow(parent, child) | ||
local res = true | ||
if swallowing_filter then | ||
local prnt = not is_in_table(parent, parent_filter_list) | ||
local chld = not is_in_table(child, child_filter_list) | ||
res = ( prnt and chld ) | ||
end | ||
return res | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the function returns false when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from what i can tell no, since 105 local function start()
106 client.connect_signal("manage", manage_clientspawn)
107 window_swallowing_activated = true
108 end
109
110 local function stop()
111 client.disconnect_signal("manage", manage_clientspawn)
112 window_swallowing_activated = false
113 end
114
115 local function toggle()
116 if window_swallowing_activated then
117 stop()
118 else
119 start()
120 end
121 end however if you meant the boolean value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right. I have forgotten the use of this variable and thought it has what the user change to activate the module... My bad. |
||
end | ||
|
||
-- the function that will be connected to / disconnected from the spawn client signal | ||
|
@@ -57,8 +67,7 @@ local function manage_clientspawn(c) | |
if | ||
-- will search for "(parent_client.pid)" inside the parent_pid string | ||
( tostring(parent_pid):find("("..tostring(parent_client.pid)..")") ) | ||
and check_swallow(parent_client.class, parent_filter_list) | ||
and check_swallow(c.class, child_filter_list) | ||
and check_swallow(parent_client.class, c.class) | ||
then | ||
c:connect_signal("unmanage", function() | ||
helpers.client.turn_on(parent_client) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a thought I have reading this : There is a corner case where the user can require the module before calling
beautiful.init
. In this situation, the user defined lists in their theme will be ignored because these variables here are global to the module and initialized only here, at the module first load.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is a corner case with all of bling and the docs specify requiring bling after beautiful.init
https://blingcorp.github.io/bling/#/?id=installation