|
@ -1,5 +1,5 @@ |
|
|
import x11/xlib, x11/xutil, x11/x, x11/keysym |
|
|
import x11/xlib, x11/xutil, x11/x, x11/keysym |
|
|
import threadpool, osproc, tables, sequtils, posix, strformat, os, sugar |
|
|
import threadpool, osproc, tables, sequtils, posix, strformat, os, sugar, options |
|
|
|
|
|
|
|
|
var root : TWindow |
|
|
var root : TWindow |
|
|
|
|
|
|
|
@ -51,6 +51,11 @@ iterator getProperties(display : PDisplay, window : TWindow) : string = |
|
|
|
|
|
|
|
|
discard atoms.XFree |
|
|
discard atoms.XFree |
|
|
|
|
|
|
|
|
|
|
|
proc getAttributes(display : PDisplay, window : PWindow) : Option[TXWindowAttributes] = |
|
|
|
|
|
var attrs : TXWindowAttributes |
|
|
|
|
|
if display.XGetWindowAttributes(window[], attrs.addr) == BadWindow: |
|
|
|
|
|
return none(TXWindowAttributes) |
|
|
|
|
|
return some(attrs) |
|
|
|
|
|
|
|
|
iterator getChildren(display : PDisplay, logFile : File) : Window = |
|
|
iterator getChildren(display : PDisplay, logFile : File) : Window = |
|
|
var currentWindow : PWindow |
|
|
var currentWindow : PWindow |
|
@ -68,28 +73,29 @@ iterator getChildren(display : PDisplay, logFile : File) : Window = |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for i in 0..(nChildrenReturn.int - 1): |
|
|
for i in 0..(nChildrenReturn.int - 1): |
|
|
var attr : TXWindowAttributes |
|
|
|
|
|
|
|
|
|
|
|
currentWindow = cast[PWindow]( |
|
|
currentWindow = cast[PWindow]( |
|
|
cast[uint](childrenReturn) + cast[uint](i * currentWindow[].sizeof) |
|
|
cast[uint](childrenReturn) + cast[uint](i * currentWindow[].sizeof) |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
if display.XGetWindowAttributes(currentWindow[], attr.addr) == BadWindow: |
|
|
let attr : Option[TXWindowAttributes] = getAttributes(display, currentWindow) |
|
|
|
|
|
|
|
|
|
|
|
if attr.isNone: |
|
|
continue |
|
|
continue |
|
|
|
|
|
|
|
|
if attr.map_state == IsUnmapped or attr.map_state == IsUnviewable: |
|
|
if attr.get.map_state == IsUnmapped or attr.get.map_state == IsUnviewable: |
|
|
continue |
|
|
continue |
|
|
|
|
|
|
|
|
if attr.override_redirect == 1: |
|
|
if attr.get.override_redirect == 1: |
|
|
continue |
|
|
continue |
|
|
|
|
|
|
|
|
let win = Window( |
|
|
let win = Window( |
|
|
x: attr.x.cint, |
|
|
x: attr.get.x.cint, |
|
|
y: attr.y.cint, |
|
|
y: attr.get.y.cint, |
|
|
width: attr.width, |
|
|
width: attr.get.width, |
|
|
height: attr.height, |
|
|
height: attr.get.height, |
|
|
win: currentWindow[], |
|
|
win: currentWindow[], |
|
|
screen: attr.screen |
|
|
screen: attr.get.screen |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
let ignored = @["_NET_WM_STRUT_PARTIAL", "_NET_WM_STRUT"] |
|
|
let ignored = @["_NET_WM_STRUT_PARTIAL", "_NET_WM_STRUT"] |
|
@ -168,7 +174,8 @@ var processChan : Channel[int] |
|
|
processChan.open(0) |
|
|
processChan.open(0) |
|
|
|
|
|
|
|
|
proc startTerminal() : Process = |
|
|
proc startTerminal() : Process = |
|
|
startProcess("/usr/bin/xterm") |
|
|
let terminal_path = getEnv("NIMWIN_TERMINAL", "/usr/bin/urxvt") |
|
|
|
|
|
startProcess(terminal_path) |
|
|
|
|
|
|
|
|
proc launcher() : Process = |
|
|
proc launcher() : Process = |
|
|
let launcher_path = getEnv("NIMWIN_LAUNCHER", "/usr/bin/dmenu_run") |
|
|
let launcher_path = getEnv("NIMWIN_LAUNCHER", "/usr/bin/dmenu_run") |
|
@ -197,10 +204,11 @@ when isMainModule: |
|
|
|
|
|
|
|
|
display.grabKeyCombo(XK_Return, @[ShiftMask.cuint]) |
|
|
display.grabKeyCombo(XK_Return, @[ShiftMask.cuint]) |
|
|
display.grabKeyCombo(XK_T, @[ShiftMask.cuint]) |
|
|
display.grabKeyCombo(XK_T, @[ShiftMask.cuint]) |
|
|
display.grabKeyCombo(XK_Tab) |
|
|
display.grabKeyCombo(XK_Tab) # Cycle through windows |
|
|
display.grabKeyCombo(XK_Q) |
|
|
display.grabKeyCombo(XK_Q) # Restart window manager |
|
|
display.grabKeyCombo(XK_P) |
|
|
display.grabKeyCombo(XK_P) # Launcher |
|
|
display.grabKeyCombo(XK_C, @[ShiftMask.cuint]) |
|
|
display.grabKeyCombo(XK_F) # Full screen |
|
|
|
|
|
display.grabKeyCombo(XK_C, @[ShiftMask.cuint]) # CLose a window |
|
|
display.grabMouse(1) |
|
|
display.grabMouse(1) |
|
|
display.grabMouse(3) |
|
|
display.grabMouse(3) |
|
|
|
|
|
|
|
@ -266,6 +274,20 @@ when isMainModule: |
|
|
if restartResult == -1: |
|
|
if restartResult == -1: |
|
|
quit("Failed to restart Nimwin") |
|
|
quit("Failed to restart Nimwin") |
|
|
|
|
|
|
|
|
|
|
|
HandleKey(XK_F): |
|
|
|
|
|
if ev.xKey.subWindow != None: |
|
|
|
|
|
let rootAttrs = getAttributes(display, root.addr) |
|
|
|
|
|
|
|
|
|
|
|
if rootAttrs.isSome: |
|
|
|
|
|
let screenHeight = rootAttrs.get.height |
|
|
|
|
|
let screenWidth = rootAttrs.get.width |
|
|
|
|
|
|
|
|
|
|
|
discard XMoveResizeWindow(display, |
|
|
|
|
|
ev.xKey.subWindow, |
|
|
|
|
|
0, 0, |
|
|
|
|
|
screenWidth.cuint, screenHeight.cuint) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) |
|
|
start = ev.xButton |
|
|
start = ev.xButton |
|
|