Skip to content
This repository has been archived by the owner on Jul 10, 2022. It is now read-only.

Commit

Permalink
(.づ◡﹏◡)づ. small code cleanup, prepare v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ktiy committed Aug 11, 2020
1 parent 2664ef0 commit 66b8728
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
*.kra*
*.kak*
*.swp*
*/config.nim
Expand Down
2 changes: 1 addition & 1 deletion kauw.nimble
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Package
version = "0.0.1"
version = "0.1.0"
author = "fox-cat"
description = "an expiremental window manager built for x11"
license = "MIT"
Expand Down
3 changes: 1 addition & 2 deletions src/kauw.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import
/windowmanager,
logging, /logger

# 0.0.0 for DOESN'T FUNCTION YET!!
const version = "0.0.0"
const version = "0.1.0"

proc main() =
if paramCount() > 0:
Expand Down
23 changes: 11 additions & 12 deletions src/windowmanager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,23 @@ proc createWindowManager*: WindowManager =
lvlError.log("failed to open X display " & $XDisplayName nil)
quit QuitFailure

var
screen = display.DefaultScreenOfDisplay()
var screen = display.DefaultScreenOfDisplay

return WindowManager(
display: display,
screen: screen,
colormap: screen.DefaultColormapOfScreen(),
root: display.DefaultRootWindow(),
colormap: screen.DefaultColormapOfScreen,
root: display.DefaultRootWindow,

clients: @[],
focused: -1,
keys: initTable[cuint, objects.Key](1))

# Run window manager
proc run* (wm: WindowManager) =
initKeybindings wm
initButtons wm
initCommands wm
wm.initKeybindings
wm.initButtons
wm.initCommands

discard XSetErrorHandler onWMDetected # Temporary error handler if there is another window manager running

Expand All @@ -73,7 +72,7 @@ proc run* (wm: WindowManager) =
var e: XEvent
discard wm.display.XNextEvent(addr e)

tileWindows wm
wm.tileWindows

case e.theType:
of CreateNotify: wm.onCreateNotify addr e.xcreatewindow
Expand Down Expand Up @@ -138,15 +137,15 @@ proc λnextWindow (wm: WindowManager) =
if wm.focused == n: wm.focused = 0
else: wm.focused += 1
discard wm.display.XSetInputFocus(wm.clients[wm.focused], RevertToParent, CurrentTime)
tileWindows wm
wm.tileWindows
lvlDebug.log $wm.focused

proc λsetMaster (wm: WindowManager) =
var n = wm.focused
if n != 0:
swap(wm.clients[n], wm.clients[0])
wm.focused = 0
tileWindows wm
wm.tileWindows
lvlDebug.log $wm.focused

proc λspawnCustom (wm: WindowManager, key: objects.Key) =
Expand Down Expand Up @@ -234,15 +233,15 @@ proc onUnmapNotify (wm: WindowManager, e: PXUnmapEvent) =

let ti = wm.clients.find(e.window)
if ti > -1: wm.clients.delete ti
wm.tileWindows()
wm.tileWindows

proc onConfigureNotify (wm: WindowManager, e: PXConfigureEvent) = return

proc onMapRequest (wm: WindowManager, e: PXMapRequestEvent) =
discard wm.display.XMapWindow e.window
discard wm.display.XSetWindowBorderWidth(e.window, config.frameWidth)
wm.addWindow e.window
wm.tileWindows()
wm.tileWindows

proc onConfigureRequest (wm: WindowManager, e: PXConfigureRequestEvent) =
var changes: XWindowChanges
Expand Down

0 comments on commit 66b8728

Please sign in to comment.