Skip to content

Commit

Permalink
fix scratchpad for sway
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Crisci committed Mar 22, 2020
1 parent 64553f2 commit f11e729
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
30 changes: 4 additions & 26 deletions i3ipc/con.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,30 +415,8 @@ def scratchpad(self) -> 'Con':
:returns: The scratchpad container.
:rtype: class:`Con`
"""
root = self.root()
for con in self.root():
if con.type == 'workspace' and con.name == "__i3_scratch":
return con

i3con = None
for c in root.nodes:
if c.name == "__i3":
i3con = c
break

if not i3con:
return None

i3con_content = None
for c in i3con.nodes:
if c.name == "content":
i3con_content = c
break

if not i3con_content:
return None

scratch = None
for c in i3con_content.nodes:
if c.name == "__i3_scratch":
scratch = c
break

return scratch
return None
18 changes: 18 additions & 0 deletions test/aio/test_scratchpad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from .ipctest import IpcTest

import pytest


class TestScratchpad(IpcTest):
@pytest.mark.asyncio
async def test_scratchpad(self, i3):
scratchpad = (await i3.get_tree()).scratchpad()
assert scratchpad is not None
assert scratchpad.name == '__i3_scratch'
assert scratchpad.type == 'workspace'
assert not scratchpad.floating_nodes
win = self.open_window()
await i3.command('move scratchpad')
scratchpad = (await i3.get_tree()).scratchpad()
assert scratchpad is not None
assert scratchpad.floating_nodes

0 comments on commit f11e729

Please sign in to comment.