Set minimum window dimensions

This commit is contained in:
Sasha Koshka 2022-11-13 15:39:33 -05:00
parent 636e5ce7e7
commit 5a0e0cd49b

View File

@ -14,6 +14,7 @@ import "golang.org/x/image/font/basicfont"
import "github.com/jezek/xgbutil"
import "github.com/jezek/xgb/xproto"
import "github.com/jezek/xgbutil/ewmh"
import "github.com/jezek/xgbutil/icccm"
import "github.com/jezek/xgbutil/xevent"
import "github.com/jezek/xgbutil/xwindow"
import "github.com/jezek/xgbutil/xgraphics"
@ -404,6 +405,22 @@ func factory (application *stone.Application) (output stone.Backend, err error)
)
backend.SetTitle(application.Title())
backend.SetIcon(application.Icon())
if err != nil { return }
// set minimum dimensions
minWidth :=
backend.metrics.cellWidth + backend.metrics.padding * 2
minHeight :=
backend.metrics.cellHeight + backend.metrics.padding * 2
err = icccm.WmNormalHintsSet (
backend.connection,
backend.window.Id,
&icccm.NormalHints {
Flags: icccm.SizeHintPMinSize,
MinWidth: uint(minWidth),
MinHeight: uint(minHeight),
})
if err != nil { return }
// create a canvas
backend.reallocateCanvas()