Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/driver/embedded/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ func (w *noosWindow) Show() {
w.d.renderWindow(w)
}

func (w *noosWindow) ShowAtPos(xPos int, yPos int) {
w.Show()
}

func (w *noosWindow) Hide() {}

func (w *noosWindow) Close() {
Expand Down
31 changes: 25 additions & 6 deletions internal/driver/glfw/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (w *window) detectTextureScale() float32 {
return float32(texWidth) / float32(winWidth)
}

func (w *window) Show() {
func (w *window) show(xPos int, yPos int) {
async.EnsureMain(func() {
if w.view() != nil {
w.doShowAgain()
Expand All @@ -154,16 +154,20 @@ func (w *window) Show() {
view := w.view()
view.SetTitle(w.title)

if !build.IsWayland && w.centered {
w.doCenterOnScreen() // lastly center if that was requested
if xPos != 0 || yPos != 0 {
view.SetPos(xPos, yPos)
}
view.Show()

// save coordinates
if !build.IsWayland {
w.xpos, w.ypos = view.GetPos()
if !build.IsWayland || xPos != 0 || yPos != 0 {
w.xpos, w.ypos = xPos, yPos
}

if !build.IsWayland && w.centered {
w.doCenterOnScreen() // lastly center if that was requested
}
view.Show()

if w.fullScreen { // this does not work if called before viewport.Show()
w.doSetFullScreen(true)
}
Expand All @@ -177,6 +181,21 @@ func (w *window) Show() {
})
}

func (w *window) Show() {
xPos, yPos := 0, 0

view := w.view()
if view != nil && !build.IsWayland {
xPos, yPos = view.GetPos()
}

w.show(xPos, yPos)
}

func (w *window) ShowAtPos(xPos int, yPos int) {
w.show(xPos, yPos)
}

func (w *window) Hide() {
async.EnsureMain(func() {
if w.closing || w.viewport == nil {
Expand Down
4 changes: 4 additions & 0 deletions internal/driver/mobile/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ func (w *window) Show() {
}
}

func (w *window) ShowAtPos(xPos int, yPos int) {
w.Show()
}

func (w *window) Hide() {
w.visible = false

Expand Down
4 changes: 4 additions & 0 deletions test/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ func (w *window) Show() {
w.RequestFocus()
}

func (w *window) ShowAtPos(xPos int, yPos int) {
w.Show()
}

func (w *window) ShowAndRun() {
w.Show()
}
Expand Down
3 changes: 3 additions & 0 deletions window.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ type Window interface {

// Show the window on screen.
Show()
// Show the window on screen at a position.
// Since 2.8
ShowAtPos(int, int)
// Hide the window from the user.
// This will not destroy the window or cause the app to exit.
Hide()
Expand Down