|
@ -56,6 +56,7 @@ proc unpackPropValue(typeFormat : int, |
|
|
of 16: |
|
|
of 16: |
|
|
byte_stride = (ptr cshort).sizeof.int |
|
|
byte_stride = (ptr cshort).sizeof.int |
|
|
of 32: |
|
|
of 32: |
|
|
|
|
|
# This *is* correct. X treats anything of size '32' as a long for historical / poor design reasons. |
|
|
byte_stride = (ptr clong).sizeof.int |
|
|
byte_stride = (ptr clong).sizeof.int |
|
|
else: |
|
|
else: |
|
|
return @[] |
|
|
return @[] |
|
@ -297,11 +298,11 @@ proc grabKeyCombo(display : PDisplay, |
|
|
# Send a message via channel to the main thread when it's done waiting for it to exit |
|
|
# Send a message via channel to the main thread when it's done waiting for it to exit |
|
|
# Check for events on the current iteration, close the process, remove it from the set of open processes |
|
|
# Check for events on the current iteration, close the process, remove it from the set of open processes |
|
|
|
|
|
|
|
|
# Used to signal when a process has exited |
|
|
# This channel is used to signal when a process has exited |
|
|
# Obviously only used for processes nimwin manages |
|
|
# Obviously only used for processes nimwin manages |
|
|
var processChan : Channel[int] |
|
|
var exitedProcesses : Channel[int] |
|
|
|
|
|
|
|
|
processChan.open(0) |
|
|
exitedProcesses.open(0) |
|
|
|
|
|
|
|
|
proc startTerminal() : Process = |
|
|
proc startTerminal() : Process = |
|
|
let terminal_path = getEnv("NIMWIN_TERMINAL", "/usr/bin/urxvt") |
|
|
let terminal_path = getEnv("NIMWIN_TERMINAL", "/usr/bin/urxvt") |
|
@ -312,8 +313,10 @@ proc launcher() : Process = |
|
|
startProcess(launcher_path) |
|
|
startProcess(launcher_path) |
|
|
|
|
|
|
|
|
proc handleProcess(p : Process) = |
|
|
proc handleProcess(p : Process) = |
|
|
|
|
|
# Wait for a process to exit before broadcasting that it exited |
|
|
|
|
|
# This allows us to call `.close` on it which is necessary to not create zombie processes. |
|
|
discard p.waitForExit |
|
|
discard p.waitForExit |
|
|
processChan.send(p.processID) |
|
|
exitedProcesses.send(p.processID) |
|
|
|
|
|
|
|
|
proc calculateStruts(display : PDisplay) : tuple[top: uint, bottom: uint]= |
|
|
proc calculateStruts(display : PDisplay) : tuple[top: uint, bottom: uint]= |
|
|
for win in getChildren(display): |
|
|
for win in getChildren(display): |
|
@ -395,7 +398,7 @@ when isMainModule: |
|
|
discard XSetIOErrorHandler(handleIOError) |
|
|
discard XSetIOErrorHandler(handleIOError) |
|
|
|
|
|
|
|
|
while true: |
|
|
while true: |
|
|
let processExited = processChan.tryRecv() |
|
|
let processExited = exitedProcesses.tryRecv() |
|
|
|
|
|
|
|
|
if processExited.dataAvailable: |
|
|
if processExited.dataAvailable: |
|
|
openProcesses[processExited.msg].close |
|
|
openProcesses[processExited.msg].close |
|
|