From 5e945313f8b88a6d89af1ca317cf478c13865a24 Mon Sep 17 00:00:00 2001 From: kitty piapiac Date: Thu, 30 Jul 2020 15:26:41 -0700 Subject: =?UTF-8?q?(=E3=80=82=E3=83=98=C2=B0)=20small=20'bugfix'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixed tiling --- src/windowmanager.nim | 24 ++++++++++++++++++------ 1 file 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) -- cgit v1.2.3