From 0f9fbd4d89fbf0fab4d375f0b318ed2ab78e6a79 Mon Sep 17 00:00:00 2001 From: kitty piapiac Date: Thu, 30 Jul 2020 11:13:19 -0700 Subject: =?UTF-8?q?(/=E3=83=BB=E3=83=BB)=E3=83=8E=20spawnCustom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit alt+enter on default opens xterm --- src/windowmanager.nim | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/windowmanager.nim') diff --git a/src/windowmanager.nim b/src/windowmanager.nim index 04636a3..5c7fd2c 100644 --- a/src/windowmanager.nim +++ b/src/windowmanager.nim @@ -2,7 +2,7 @@ import x11/[x, xlib], config, /keys, logging, /logger, - tables, os + tables, os, posix type WindowManager* = ref object @@ -12,7 +12,7 @@ type root: Window clients: seq[Window] - keys: Table[cuint, Key] + keys: Table[cuint, keys.Key] # Initialiazation stuff proc initKeybindings (wm: WindowManager) @@ -60,7 +60,7 @@ proc createWindowManager*: WindowManager = root: display.DefaultRootWindow(), clients: @[], - keys: initTable[cuint, Key](1)) + keys: initTable[cuint, keys.Key](1)) # Run window manager proc run* (wm: WindowManager) = @@ -135,7 +135,10 @@ proc initCommands (wm: WindowManager) = proc λcloseWindow (wm: WindowManager) = return proc λnextWindow (wm: WindowManager) = return -proc λspawnCustom (wm: WindowManager, key: Key) = return +proc λspawnCustom (wm: WindowManager, key: keys.Key) = + if fork() == 0: + discard execvp(key.command, nil) + quit QuitSuccess # Error Handlers proc onWMDetected (display: PDisplay, e: PXErrorEvent): cint{.cdecl.} = @@ -217,6 +220,7 @@ proc onButtonPress (wm: WindowManager, e: PXButtonEvent) = return proc onButtonRelease (wm: WindowManager, e: PXButtonEvent) = return proc onMotionNotify (wm: WindowManager, e: PXMotionEvent) = return proc onKeyPress (wm: WindowManager, e: PXKeyEvent) = + lvlDebug.log "key event " & $e.keycode let key = wm.keys[e.keycode] case key.keyfunc: of closeWindow: wm.λcloseWindow() -- cgit v1.2.3