Support setting an initial window position

This commit is contained in:
Friedrich Große 2020-05-03 19:38:54 +02:00
parent d7884ac96a
commit b7d5e41486
1 changed files with 12 additions and 0 deletions

View File

@ -36,6 +36,9 @@ type WindowConfig struct {
// Bounds specify the bounds of the Window in pixels.
Bounds pixel.Rect
// Initial window position
Position pixel.Vec
// If set to nil, the Window will be windowed. Otherwise it will be fullscreen on the
// specified Monitor.
Monitor *Monitor
@ -113,6 +116,10 @@ func NewWindow(cfg WindowConfig) (*Window, error) {
glfw.WindowHint(glfw.Floating, bool2int[cfg.AlwaysOnTop])
glfw.WindowHint(glfw.AutoIconify, bool2int[!cfg.NoIconify])
if cfg.Position.X != 0 || cfg.Position.Y != 0 {
glfw.WindowHint(glfw.Visible, glfw.False)
}
var share *glfw.Window
if currWin != nil {
share = currWin.window
@ -129,6 +136,11 @@ func NewWindow(cfg WindowConfig) (*Window, error) {
return err
}
if cfg.Position.X != 0 || cfg.Position.Y != 0 {
w.window.SetPos(int(cfg.Position.X), int(cfg.Position.Y))
w.window.Show()
}
// enter the OpenGL context
w.begin()
glhf.Init()