parent
5bf8499bf8
commit
1091771455
|
@ -50,8 +50,42 @@ function Scratchpad:turn_on()
|
||||||
if self.reapply then self:apply(c) end
|
if self.reapply then self:apply(c) end
|
||||||
-- c.sticky was set to false in turn_off so it has to be reapplied anyway
|
-- c.sticky was set to false in turn_off so it has to be reapplied anyway
|
||||||
c.sticky = self.sticky
|
c.sticky = self.sticky
|
||||||
|
local new_y = c.y
|
||||||
|
local new_x = c.x
|
||||||
|
|
||||||
|
-- Get the tweens
|
||||||
|
local anim_x = self.awestore.x
|
||||||
|
local anim_y = self.awestore.y
|
||||||
|
|
||||||
|
-- Subscribe
|
||||||
|
if anim_x then
|
||||||
|
anim_x:subscribe(function(x) if c then c.x = x end end)
|
||||||
|
end
|
||||||
|
if anim_y then
|
||||||
|
anim_y:subscribe(function(y) if c then c.y = y end end)
|
||||||
|
end
|
||||||
|
|
||||||
helpers.client.turn_on(c)
|
helpers.client.turn_on(c)
|
||||||
|
|
||||||
|
-- Unsubscribe
|
||||||
|
if anim_x then
|
||||||
|
anim_x:set(new_x)
|
||||||
|
local unsub
|
||||||
|
unsub = anim_x.ended:subscribe(
|
||||||
|
function()
|
||||||
|
unsub()
|
||||||
return
|
return
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
if anim_y then
|
||||||
|
anim_y:set(new_y)
|
||||||
|
local unsub_y
|
||||||
|
unsub_y = anim_y.ended:subscribe(
|
||||||
|
function()
|
||||||
|
unsub_y()
|
||||||
|
return
|
||||||
|
end)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
-- if no client was found, spawn one, find the corresponding window,
|
-- if no client was found, spawn one, find the corresponding window,
|
||||||
-- apply the properties only once (until the next closing)
|
-- apply the properties only once (until the next closing)
|
||||||
|
@ -71,7 +105,39 @@ function Scratchpad:turn_off()
|
||||||
local c = matches[1]
|
local c = matches[1]
|
||||||
if c then
|
if c then
|
||||||
c.sticky = false
|
c.sticky = false
|
||||||
|
|
||||||
|
-- Get the tweens
|
||||||
|
local anim_x = self.awestore.x
|
||||||
|
local anim_y = self.awestore.y
|
||||||
|
|
||||||
|
-- Subscribe
|
||||||
|
if anim_x then
|
||||||
|
anim_x:subscribe(function(x) if c then c.x = x end end)
|
||||||
|
end
|
||||||
|
if anim_y then
|
||||||
|
anim_y:subscribe(function(y) if c then c.y = y end end)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Unsubscribe
|
||||||
|
if anim_x then
|
||||||
|
anim_x:set(anim_x:initial())
|
||||||
|
local unsub
|
||||||
|
unsub = anim_x.ended:subscribe(
|
||||||
|
function()
|
||||||
helpers.client.turn_off(c)
|
helpers.client.turn_off(c)
|
||||||
|
unsub()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
if anim_y then
|
||||||
|
anim_y:set(anim_y:initial())
|
||||||
|
|
||||||
|
local unsub
|
||||||
|
unsub = anim_y.ended:subscribe(
|
||||||
|
function()
|
||||||
|
helpers.client.turn_off(c)
|
||||||
|
unsub()
|
||||||
|
end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue