Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mobileDriver.currentWindow should not return hidden windows, fixes #1835 #1986

Merged
merged 1 commit into from Feb 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion internal/driver/gomobile/driver.go
Expand Up @@ -63,7 +63,15 @@ func (d *mobileDriver) currentWindow() fyne.Window {
return nil
}

return d.windows[len(d.windows)-1]
var last fyne.Window
for i := len(d.windows) - 1; i >= 0; i-- {
last = d.windows[i]
if last.(*window).visible {
return last
}
}

return last
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code will return the last hidden window if they are all hidden - is that intended?
Above we return nil if there are no windows, I think we should do that here too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code will return the last hidden window if they are all hidden - is that intended?

Yes, that was intended.

Above we return nil if there are no windows, I think we should do that here too

That was something that I was not sure. In mobile, if all the windows are hidden, what does it mean? 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should not be done - app will be unusable. But not sure that the most recently added window is the right response in this situation... It should never happen, but there is specifically code in their to accommodate it so I figured we should be sure that is what should occur if it can.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But not sure that the most recently added window is the right response in this situation...

Indeed this change is returning the parent window (not the most recently added) because I am looping in reverse. Now I realized I have misread your first comment. It is not the last hidden window but the first one (parent one).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes I see, sorry for misreading the first time

}

func (d *mobileDriver) RenderedTextSize(text string, size float32, style fyne.TextStyle) fyne.Size {
Expand Down