Browse Source

fix out of bounds error condition

fix-resizing
Wesley Kerfoot 4 years ago
parent
commit
72cff0bab6
  1. 10
      src/nimwin.nim

10
src/nimwin.nim

@ -96,8 +96,11 @@ proc getPropertyValue(display : PDisplay, window : TWindow, property : TAtom) :
if typeName == "STRING": if typeName == "STRING":
var propStrValue = newString(propValue.len) var propStrValue = newString(propValue.len)
copyMem(addr(propStrValue[0]), propValue, propValue.len) if propStrValue.len > 0:
result = some(WinProp(name: atomName, kind: pkString, strProp: propStrValue)) copyMem(addr(propStrValue[0]), propValue, propValue.len)
result = some(WinProp(name: atomName, kind: pkString, strProp: propStrValue))
else:
result = none(WinProp)
elif typeName == "CARDINAL": elif typeName == "CARDINAL":
result = some( result = some(
WinProp( WinProp(
@ -272,7 +275,6 @@ proc handleProcess(p : Process) =
discard p.waitForExit discard p.waitForExit
processChan.send(p.processID) processChan.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):
for prop in win.props: for prop in win.props:
@ -397,7 +399,7 @@ when isMainModule:
discard XMoveResizeWindow(display, discard XMoveResizeWindow(display,
ev.xKey.subWindow, ev.xKey.subWindow,
0, struts.top.cint, 0, struts.top.cint,
screenWidth.cuint, screenHeight.cuint - struts.bottom.cuint - borderWidth) screenWidth.cuint, screenHeight.cuint - struts.bottom.cuint - borderWidth.cuint)
elif (ev.theType == ButtonPress) and (ev.xButton.subWindow != None): elif (ev.theType == ButtonPress) and (ev.xButton.subWindow != None):

Loading…
Cancel
Save