diff options
author | kitty piapiac <kcp@bsd.computer> | 2020-07-30 15:26:41 -0700 |
---|---|---|
committer | kitty piapiac <kcp@bsd.computer> | 2020-07-30 15:26:41 -0700 |
commit | 5e945313f8b88a6d89af1ca317cf478c13865a24 (patch) | |
tree | 879271fef27dd8ab86c6998d93e202ec0f132ed9 | |
parent | 7f96f0f9f30cb310a6bce0686cfcca63fed0eccd (diff) |
(。ヘ°) small 'bugfix'
fixed tiling
-rw-r--r-- | src/windowmanager.nim | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/windowmanager.nim b/src/windowmanager.nim index ef69904..4e5ca26 100644 --- a/src/windowmanager.nim +++ b/src/windowmanager.nim @@ -2,8 +2,7 @@ import x11/[x, xlib], config, /keys, logging, /logger, - tables, os, posix, - strutils + tables, os, posix type WindowManager* = ref object @@ -194,20 +193,33 @@ proc tileWindows (wm: WindowManager) = unfocused = wm.getColor config.colours.unfocused offset = cuint config.frameWidth*2 - if n == 0: - return + if n == 0: return if n == 1: discard wm.display.XMoveResizeWindow(wm.clients[0], 0, 0, w-offset, h-offset) - discard wm.display.XSetWindowBorder(wm.clients[0], wm.getColor(config.colours.focused)) + discard wm.display.XSetWindowBorder(wm.clients[0], focused) + else: # resize master window to take up half the screen discard wm.display.XMoveResizeWindow(wm.clients[0], 0, 0, (w div 2)-offset, h-offset) + c = if wm.focused == 0: focused else: unfocused discard wm.display.XSetWindowBorder(wm.clients[0], c) # maths, sort of explained here: https://i.imgur.com/fGxdfDh.png + var + leftoverPixels = h - ((n-1) * (h div (n-1))) + lastEnd: cint = 0 + for i in 1..wm.clients.len-1: - discard wm.display.XMoveResizeWindow(wm.clients[i], cint w div 2, cint (i-1) * cint (h div (n-1)), (w div 2)-offset, (h div (n-1))-offset) + var height = (h div (n-1)) + if leftoverPixels > 0: + height += 1 + leftoverPixels -= 1 + + discard wm.display.XMoveResizeWindow(wm.clients[i], cint w div 2, lastEnd, (w div 2)-offset, height-offset) + + lastEnd += cint height + c = if wm.focused == i: focused else: unfocused discard wm.display.XSetWindowBorder(wm.clients[i], c) |