diff options
author | kitty piapiac <kcp@bsd.computer> | 2020-07-31 04:39:41 -0700 |
---|---|---|
committer | kitty piapiac <kcp@bsd.computer> | 2020-07-31 04:39:41 -0700 |
commit | e44f1b2355c61c2c8c7930f5c4b879bf55ec31a3 (patch) | |
tree | 65cbc59db9799c9ca2c10627527f73b96cea21d4 /src/windowmanager.nim | |
parent | 6749e8b5c77cc1f8884dada564d6290e1b9860fd (diff) |
(/・・)ノ closes windows
- small bugfix
- updated readme.md to include config section
- updated .gitignore to ignore config.nim
- added config.def.nim
Diffstat (limited to 'src/windowmanager.nim')
-rw-r--r-- | src/windowmanager.nim | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/windowmanager.nim b/src/windowmanager.nim index 4e5ca26..6053aa0 100644 --- a/src/windowmanager.nim +++ b/src/windowmanager.nim @@ -64,7 +64,7 @@ proc createWindowManager*: WindowManager = root: display.DefaultRootWindow(), clients: @[], - focused: -1, + focused: 0, keys: initTable[cuint, keys.Key](1)) # Run window manager @@ -138,7 +138,11 @@ proc initCommands (wm: WindowManager) = for cmd in config.init: discard execShellCmd cmd -proc λcloseWindow (wm: WindowManager) = return +proc λcloseWindow (wm: WindowManager) = + var n = wm.clients.len + if n > 0: + discard wm.display.XDestroyWindow wm.clients[wm.focused] + proc λnextWindow (wm: WindowManager) = var n = wm.clients.high if n > 0: @@ -230,7 +234,8 @@ proc onReparentNotify (wm: WindowManager, e: PXReparentEvent) = return proc onMapNotify (wm: WindowManager, e: PXMapEvent) = return proc onUnmapNotify (wm: WindowManager, e: PXUnmapEvent) = if wm.focused == wm.clients.high: wm.focused -= 1 - wm.clients.delete wm.clients.find(e.window) + let index = wm.clients.find(e.window) + if index > -1: wm.clients.delete index wm.tileWindows() proc onConfigureNotify (wm: WindowManager, e: PXConfigureEvent) = return |