|
@ -24,6 +24,12 @@ template HandleKey(key : TKeySym, body : untyped) : untyped = |
|
|
if (XLookupKeySym(cast[PXKeyEvent](ev.xkey.addr), 0) == key.cuint): |
|
|
if (XLookupKeySym(cast[PXKeyEvent](ev.xkey.addr), 0) == key.cuint): |
|
|
body |
|
|
body |
|
|
|
|
|
|
|
|
|
|
|
template RunProcess(procedure : untyped) : untyped = |
|
|
|
|
|
block: |
|
|
|
|
|
let p = procedure() |
|
|
|
|
|
openProcesses[p.processID] = p |
|
|
|
|
|
spawn handleProcess(p) |
|
|
|
|
|
|
|
|
type |
|
|
type |
|
|
WinPropKind = enum pkString, pkCardinal, pkAtom |
|
|
WinPropKind = enum pkString, pkCardinal, pkAtom |
|
|
WinProp = ref object of RootObj |
|
|
WinProp = ref object of RootObj |
|
@ -412,10 +418,14 @@ when isMainModule: |
|
|
# For spawning, e.g. a terminal we also want events for the root window |
|
|
# For spawning, e.g. a terminal we also want events for the root window |
|
|
|
|
|
|
|
|
if ev.theType == KeyPress: |
|
|
if ev.theType == KeyPress: |
|
|
|
|
|
|
|
|
|
|
|
# ctrl+mod+shift runs terminal |
|
|
HandleKey(XK_Return): |
|
|
HandleKey(XK_Return): |
|
|
let p = startTerminal() |
|
|
RunProcess(startTerminal) |
|
|
openProcesses[p.processID] = p |
|
|
|
|
|
spawn handleProcess(p) |
|
|
HandleKey(XK_P): |
|
|
|
|
|
# mod+p runs the launcher |
|
|
|
|
|
RunProcess(launcher) |
|
|
|
|
|
|
|
|
HandleKey(XK_C): |
|
|
HandleKey(XK_C): |
|
|
let windowStack = toSeq(getChildren(display)) |
|
|
let windowStack = toSeq(getChildren(display)) |
|
@ -434,11 +444,6 @@ when isMainModule: |
|
|
discard display.XSetInputFocus(windowStack[0].win, RevertToPointerRoot, CurrentTime) |
|
|
discard display.XSetInputFocus(windowStack[0].win, RevertToPointerRoot, CurrentTime) |
|
|
discard display.XRaiseWindow(windowStack[0].win) |
|
|
discard display.XRaiseWindow(windowStack[0].win) |
|
|
|
|
|
|
|
|
HandleKey(XK_P): |
|
|
|
|
|
let p = launcher() |
|
|
|
|
|
openProcesses[p.processID] = p |
|
|
|
|
|
spawn handleProcess(p) |
|
|
|
|
|
|
|
|
|
|
|
HandleKey(XK_Q): |
|
|
HandleKey(XK_Q): |
|
|
let currentPath = getAppDir() |
|
|
let currentPath = getAppDir() |
|
|
|
|
|
|
|
|