|
@ -1,4 +1,5 @@ |
|
|
import x11/xlib, x11/xutil, x11/x, x11/keysym |
|
|
import x11/xlib, x11/xutil, x11/x, x11/keysym |
|
|
|
|
|
import threadpool, osproc |
|
|
|
|
|
|
|
|
proc getDisplay : PDisplay = |
|
|
proc getDisplay : PDisplay = |
|
|
result = XOpenDisplay(nil) |
|
|
result = XOpenDisplay(nil) |
|
@ -18,16 +19,36 @@ proc grabMouse(display : PDisplay, button : int) = |
|
|
None) |
|
|
None) |
|
|
|
|
|
|
|
|
proc grabKeys(display : PDisplay) = |
|
|
proc grabKeys(display : PDisplay) = |
|
|
let keyModifier = "F1" |
|
|
|
|
|
discard XGrabKey(display, |
|
|
discard XGrabKey(display, |
|
|
XKeySymToKeyCode(display, |
|
|
XKeySymToKeyCode(display, XK_T).cint, |
|
|
XStringToKeySym(keyModifier.cstring)).cint, |
|
|
ControlMask.cuint or Mod1Mask.cuint, |
|
|
Mod1Mask.cuint or Mod2Mask.cuint, |
|
|
DefaultRootWindow(display), |
|
|
|
|
|
1.cint, |
|
|
|
|
|
GrabModeAsync.cint, |
|
|
|
|
|
GrabModeAsync.cint) |
|
|
|
|
|
discard XGrabKey(display, |
|
|
|
|
|
XKeySymToKeyCode(display, XK_T).cint, |
|
|
|
|
|
ControlMask.cuint or Mod1Mask.cuint or Mod2Mask.cuint, |
|
|
|
|
|
DefaultRootWindow(display), |
|
|
|
|
|
1.cint, |
|
|
|
|
|
GrabModeAsync.cint, |
|
|
|
|
|
GrabModeAsync.cint) |
|
|
|
|
|
discard XGrabKey(display, |
|
|
|
|
|
XKeySymToKeyCode(display, XK_T).cint, |
|
|
|
|
|
ControlMask.cuint or Mod1Mask.cuint or LockMask.cuint, |
|
|
|
|
|
DefaultRootWindow(display), |
|
|
|
|
|
1.cint, |
|
|
|
|
|
GrabModeAsync.cint, |
|
|
|
|
|
GrabModeAsync.cint) |
|
|
|
|
|
discard XGrabKey(display, |
|
|
|
|
|
XKeySymToKeyCode(display, XK_T).cint, |
|
|
|
|
|
ControlMask.cuint or Mod1Mask.cuint or LockMask.cuint or Mod2Mask.cuint, |
|
|
DefaultRootWindow(display), |
|
|
DefaultRootWindow(display), |
|
|
1.cint, |
|
|
1.cint, |
|
|
GrabModeAsync.cint, |
|
|
GrabModeAsync.cint, |
|
|
GrabModeAsync.cint) |
|
|
GrabModeAsync.cint) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
when isMainModule: |
|
|
when isMainModule: |
|
|
var start : TXButtonEvent |
|
|
var start : TXButtonEvent |
|
|
var ev : TXEvent |
|
|
var ev : TXEvent |
|
@ -48,8 +69,15 @@ when isMainModule: |
|
|
# subwindow is because we grabbed the root window |
|
|
# subwindow is because we grabbed the root window |
|
|
# and we want events in its children |
|
|
# and we want events in its children |
|
|
|
|
|
|
|
|
if (ev.theType == KeyPress) and (ev.xKey.subWindow != None): |
|
|
# For spawning a terminal we also want events for the root window |
|
|
discard XRaiseWindow(display, ev.xKey.subWindow) |
|
|
if (ev.theType == KeyPress): |
|
|
|
|
|
echo "Executing xterm" |
|
|
|
|
|
discard spawn "xterm".execProcess |
|
|
|
|
|
|
|
|
|
|
|
# TODO have to actually check which keys were pressed, not assume they were the only ones we grabbed |
|
|
|
|
|
# since we're going to want to grab multiple combos soon |
|
|
|
|
|
#if (ev.theType == KeyPress) and (ev.xKey.subWindow != None): |
|
|
|
|
|
#discard XRaiseWindow(display, ev.xKey.subWindow) |
|
|
|
|
|
|
|
|
elif (ev.theType == ButtonPress) and (ev.xButton.subWindow != None): |
|
|
elif (ev.theType == ButtonPress) and (ev.xButton.subWindow != None): |
|
|
discard XGetWindowAttributes(display, ev.xButton.subWindow, attr.addr) |
|
|
discard XGetWindowAttributes(display, ev.xButton.subWindow, attr.addr) |
|
|