Skip to content

Commit

Permalink
Fix position of a window that is re-shown
Browse files Browse the repository at this point in the history
Also we don't have to recreate the window either, waste of CPU
Fixes fyne-io#1116
  • Loading branch information
andydotxyz committed Jun 20, 2020
1 parent 49f5fbb commit fa30f63
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions internal/driver/glfw/window.go
Expand Up @@ -328,6 +328,11 @@ func (w *window) Show() {
}

func (w *window) doShow() {
if w.view() != nil {
w.doShowAgain()
return
}

for !running() {
time.Sleep(time.Millisecond * 10)
}
Expand Down Expand Up @@ -1174,6 +1179,25 @@ func (w *window) create() {
})
}

func (w *window) doShowAgain() {
if w.viewport == nil {
return
}

runOnMain(func() {
// show top canvas element
if w.canvas.Content() != nil {
w.canvas.Content().Show()
}

w.viewport.SetPos(w.xpos, w.ypos)
w.viewport.Show()
w.viewLock.Lock()
w.visible = true
w.viewLock.Unlock()
})
}

func (w *window) view() *glfw.Window {
w.viewLock.RLock()
defer w.viewLock.RUnlock()
Expand Down

0 comments on commit fa30f63

Please sign in to comment.