Skip to content

Commit

Permalink
Fall back to default dimensions if layout is unconfigured
Browse files Browse the repository at this point in the history
  • Loading branch information
numirias committed Mar 1, 2018
1 parent 51af9ae commit 88f83dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 5 additions & 2 deletions plasma/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ class Plasma(Layout):
('border_width_single', 0, 'Border width for single window'),
('margin', 0, 'Layout margin'),
]
# If windows are added before configure() was called, the screen size is
# still unknown, so we need to set some arbitrary initial root dimensions
default_dimensions = (0, 0, 1000, 1000)

def __init__(self, **config):
Layout.__init__(self, **config)
self.add_defaults(Plasma.defaults)
self.root = Node()
self.root = Node(None, *self.default_dimensions)
self.focused = None
self.add_mode = None

Expand All @@ -52,7 +55,7 @@ def info(self):
def clone(self, group):
clone = copy.copy(self)
clone.group = group
clone.root = Node()
clone.root = Node(None, *self.default_dimensions)
clone.focused = None
clone.add_mode = None
return clone
Expand Down
10 changes: 9 additions & 1 deletion tests/test_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# We borrow Qtile's testing framework. That's not elegant but the best option.
sys.path.insert(0, str(Path(__file__).parents[1] / 'lib')) # noqa: E402
from qtile.libqtile import config
from qtile.libqtile.layout.floating import Floating
from qtile.libqtile.layout import Floating
from qtile.test.conftest import no_xinerama, qtile, xephyr, xvfb # noqa: F401
from qtile.test.layouts.layout_utils import assertFocused

Expand Down Expand Up @@ -217,3 +217,11 @@ def test_recent(self, qtile):
assertFocused(qtile, 'a')
qtile.c.layout.recent()
assertFocused(qtile, 'c')

def test_bug_10(self):
"""Adding nodes when the correct root dimensions are still unknown
should not raise an error.
"""
layout = Plasma()
layout.add(object())
layout.add(object())

0 comments on commit 88f83dc

Please sign in to comment.