Skip to content

Commit

Permalink
Merge pull request #2829 from andydotxyz/fix/2819
Browse files Browse the repository at this point in the history
Move the fixed size ensuring size to the end of window setup
  • Loading branch information
andydotxyz authored Mar 11, 2022
2 parents dfcb0ea + 02c89ca commit 520867c
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions internal/driver/glfw/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ func (w *window) FixedSize() bool {

func (w *window) SetFixedSize(fixed bool) {
w.fixedSize = fixed
w.ensureFixedHasSize()
if w.view() != nil {
w.runOnMainWhenCreated(w.fitContent)
}
Expand Down Expand Up @@ -501,9 +500,6 @@ func (w *window) SetContent(content fyne.CanvasObject) {
}

w.canvas.SetContent(content)
if !visible {
w.ensureFixedHasSize()
}

// show new canvas element
if content != nil {
Expand Down Expand Up @@ -539,14 +535,6 @@ func (w *window) destroy(d *gLDriver) {
}
}

// ensureFixedHasSize makes sure that if a window is fixed size it has a requested size, or is set to minimum
func (w *window) ensureFixedHasSize() {
if w.FixedSize() && (w.requestedWidth == 0 || w.requestedHeight == 0) {
bigEnough := w.canvas.canvasSize(w.canvas.Content().MinSize())
w.Resize(bigEnough)
}
}

func (w *window) moved(_ *glfw.Window, x, y int) {
if !w.fullScreen { // don't save the move to top left when changing to fullscreen
// save coordinates
Expand Down Expand Up @@ -1502,11 +1490,13 @@ func (w *window) create() {
fn()
}

w.requestedWidth, w.requestedHeight = w.width, w.height

if w.fixedSize { // as the window will not be sized later we may need to pack menus etc
w.canvas.Resize(w.canvas.Size())
if w.FixedSize() && (w.requestedWidth == 0 || w.requestedHeight == 0) {
bigEnough := w.canvas.canvasSize(w.canvas.Content().MinSize())
w.width, w.height = internal.ScaleInt(w.canvas, bigEnough.Width), internal.ScaleInt(w.canvas, bigEnough.Height)
w.shouldWidth, w.shouldHeight = w.width, w.height
}

w.requestedWidth, w.requestedHeight = w.width, w.height
// order of operation matters so we do these last items in order
w.viewport.SetSize(w.shouldWidth, w.shouldHeight) // ensure we requested latest size
})
Expand Down

0 comments on commit 520867c

Please sign in to comment.