fix scratchpad closeing issue (#63)

* Add an option to disable client floating state when closing the scratchpad

* Fix an issue where a scratchpad can't be toggled with dont_focus_before_close unless doing so from the first tag
This commit is contained in:
Kasper 2021-06-18 15:49:45 +03:00 committed by GitHub
parent 8b245f7ef3
commit 75ff07a47e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 5 deletions

View File

@ -163,10 +163,18 @@ end
--- Turns the scratchpad off if it is focused otherwise it raises the scratchpad
function Scratchpad:toggle()
local is_turn_off = false
if self.dont_focus_before_close then
local matches = self:find()
if matches[1] and matches[1].first_tag then
is_turn_off = matches[1].first_tag.selected
if self.dont_focus_before_close then
if matches[1] then
local current_tag = matches[1].screen.selected_tag
for k, tag in pairs(matches[1]:tags()) do
if tag == current_tag then
is_turn_off = true
break
else
is_turn_off = false
end
end
end
else
is_turn_off = client.focus and
@ -174,6 +182,9 @@ function Scratchpad:toggle()
end
if is_turn_off then
if self.disable_floating_on_close and matches[1].floating == true then
matches[1].floating = false
end
self:turn_off()
else
self:turn_on()