# HG changeset patch # User Sean E. Russell # Date 1588617578 18000 # Mon May 04 13:39:38 2020 -0500 # Node ID 891e5322d122f5692ff039b762cd082b239e2f63 # Parent 8e718360c2425fbe6560d07f6ec6e04091e84d3c Created windows may not fit cleanly in the requested dimensions and might size themselves larger so that they fit; this change ensures that if this happens, the window is shrunken so that it fits on the screen. diff --git a/.build.yml b/.build.yml --- a/.build.yml +++ b/.build.yml @@ -17,7 +17,7 @@ cd ${PROJ} VERSION=`hg log -r tip --template '{bookmarks}'` [[ $VERSION == "" ]] && VERSION=dev - BUILDDATE=`date +%Y-%m-%dT%H%M%S` + BUILDDATE=`date +%Y%m%dT%H%M%S` for T in linux:amd64 linux:arm64 linux:arm5 linux:arm6 linux:arm7 ; do GOOS=$(echo $T | cut -d: -f1) GOARCH=$(echo $T | cut -d: -f2) diff --git a/main.go b/main.go --- a/main.go +++ b/main.go @@ -7,6 +7,8 @@ // TODO: AUR // TODO: https://github.com/joshuarubin/go-sway // TODO: Can we dynamically map bindsym using the API? +// TODO: Adjust height so isn't bigger than screen +// TODO: Not all screens are the same height import ( "flag" @@ -213,11 +215,12 @@ height = ws.Rect.Height width = wwidth } + mn := NAME + mark cmd := fmt.Sprintf(`[con_mark="%s"], resize set %d px %d px, move absolute position %dpx %dpx, move scratchpad, - scratchpad show`, NAME+mark, width, height, posx, posy) + scratchpad show`, mn, width, height, posx, posy) suc := false var retries int var err error @@ -230,6 +233,25 @@ } retries++ } + t, e := c.GetTree() + if e != nil { + panic(e) + } + w := t.FindMarked(mn) + if w.Rect.Height > height { + cmd = fmt.Sprintf(`[con_mark="%s"] resize shrink height`, mn) + suc = false + retries = 0 + for suc == false { + suc, err = c.Command(cmd) + if retries > 10 { + if err != nil { + panic(err) + } + } + retries++ + } + } } func (c con) getCurrentWorkspace() i3ipc.Workspace {