Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a way to increase or decrease the gap between windows #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
# Leave some empty space between windows
gap = 0

# How much should the gap change on increase and decrease
gap_change = 5

# Maximum and minimum gap allowed
gap_max = 200
gap_min = 0

# Whether to send any debug information to stdout
debug = False

10 changes: 8 additions & 2 deletions keybind.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,21 @@
# rotate: shift all windows' positions (clockwise)
# make_master: send active window to the master position

'Control-Mod1-v': tile.cmd('tile'),
# expand_gap: increase the gap between windows
# contract_gap: decrease the gap between windows

'Control-Mod1-v': tile.cmd('tile'),
'Control-Mod1-BackSpace': tile.cmd('untile'),
'Control-Mod1-s': tile.cmd('decrease_master'),
'Control-Mod1-r': tile.cmd('increase_master'),
'Control-Mod1-g': tile.cmd('remove_master'),
'Control-Mod1-d': tile.cmd('add_master'),
'Control-Mod1-c': tile.cmd('rotate'),
'Control-Mod1-c': tile.cmd('rotate'),
'Control-Mod1-h': tile.cmd('cycle'),
'Control-Mod1-f': tile.cmd('toggle_float'),
'Control-Mod1-e': tile.cmd('expand_gap'),
'Control-Mod1-l': tile.cmd('contract_gap'),


# quit pytyle
'Control-Mod1-q': state.quit,
Expand Down
20 changes: 18 additions & 2 deletions pt3/layouts/layout_vert_horz.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def __init__(self, desk):
super(OrientLayout, self).__init__(desk)
self.store = store.Store()
self.proportion = 0.5
self.gap = getattr(config, 'gap', 0)
self.gap_change = getattr(config, 'gap_change', 5)
self.gap_max = getattr(config, 'gap_max', 200)
self.gap_min = getattr(config, 'gap_min', 0)

def add(self, c):
debug('%s being added to %s' % (c, self))
Expand Down Expand Up @@ -78,6 +82,18 @@ def clients(self):

# End abstract methods; begin OrientLayout specific methods

def expand_gap(self):
self.gap = self.gap + self.gap_change
if (self.gap > self.gap_max):
self.gap = self.gap_max
self.tile()

def contract_gap(self):
self.gap = self.gap - self.gap_change
if (self.gap < 0 or self.gap < self.gap_min):
self.gap = self.gap_min
self.tile()

def decrease_master(self):
self.proportion = max(0.0, self.proportion - config.proportion_change)
self.tile()
Expand Down Expand Up @@ -201,7 +217,7 @@ def tile(self, save=True):
mw = int(ww * self.proportion) # width of the master
sx = mx + mw
sw = ww - mw
g = config.gap # Gap between windows
g = self.gap # Gap between windows

if mw <= 0 or mw > ww or sw <= 0 or sw > ww:
return
Expand Down Expand Up @@ -239,7 +255,7 @@ def tile(self, save=True):
mh = int(wh * self.proportion)
sy = my + mh
sh = wh - mh
g = config.gap # Gap between windows
g = self.gap # Gap between windows

if mh <= 0 or mh > wh or sh <= 0 or sh > wh:
return
Expand Down