From 79f538468c79fa4de52ac34465a8077bc0608764 Mon Sep 17 00:00:00 2001 From: Wesley Kerfoot Date: Sun, 28 Jun 2020 19:32:11 -0400 Subject: [PATCH] use mapnotify event for resizing windows --- src/nimwin.nim | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/nimwin.nim b/src/nimwin.nim index f1382ab..fd7bc50 100644 --- a/src/nimwin.nim +++ b/src/nimwin.nim @@ -1,6 +1,7 @@ import x11/xlib, x11/xutil, x11/x, x11/keysym import threadpool, osproc, tables, sequtils, posix, strformat, os, sugar, options, strutils + var root : TWindow proc handleBadWindow(display : PDisplay, ev : PXErrorEvent) : cint {.cdecl.} = @@ -415,25 +416,22 @@ when isMainModule: discard XGetWindowAttributes(display, ev.xButton.subWindow, attr.addr) start = ev.xButton - elif (ev.theType == CreateNotify) and (ev.xcreatewindow.parent == root): + + elif (ev.theType == MapNotify) and (ev.xmap.overrideRedirect == 0): let rootAttrs = getAttributes(display, root.addr) if rootAttrs.isSome: let struts = display.calculateStruts let screenHeight = rootAttrs.get.height let screenWidth = rootAttrs.get.width - let winAttrs : Option[TXWindowAttributes] = getAttributes(display, ev.xcreatewindow.window.addr) - - let depth = winAttrs.get.borderWidth.cuint - let borderWidth = winAttrs.get.depth.cuint + let winAttrs : Option[TXWindowAttributes] = getAttributes(display, ev.xmap.window.addr) if winAttrs.isSome and winAttrs.get.overrideRedirect == 0: discard XMoveResizeWindow(display, - ev.xcreatewindow.window, + ev.xmap.window, 0, struts.top.cint, - screenWidth.cuint, screenHeight.cuint - struts.bottom.cuint - borderWidth.cuint) + screenWidth.cuint, screenHeight.cuint) - elif (ev.theType == MapNotify) and (ev.xmap.overrideRedirect == 0): discard display.XSetInputFocus(ev.xmap.window, RevertToPointerRoot, CurrentTime) elif (ev.theType == MotionNotify) and (start.subWindow != None):