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.
2 files changed, 24 insertions(+), 2 deletions(-)

M .build.yml
M main.go
M .build.yml +1 -1
@@ 17,7 17,7 @@ tasks:
         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)

          
M main.go +23 -1
@@ 7,6 7,8 @@ package main
 // 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 @@ func (c con) position(mark string, pos i
 		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 @@ func (c con) position(mark string, pos i
 		}
 		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 {