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

Avoid visual glitch on launch #38

Open
matthew-carroll opened this issue Sep 11, 2023 · 5 comments
Open

Avoid visual glitch on launch #38

matthew-carroll opened this issue Sep 11, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@matthew-carroll
Copy link

When setting the window size, background, etc, upon launch, there's a visual glitch because the window begins with the standard Flutter configuration and then switches to the desired configuration when the Dart application starts running.

This glitch can be avoided by coding the application delegate to set all of these properties on launch, but writing Swift in the XCode project largely eliminates the value of this package from a window configuration standpoint.

Is there anything that can be done about this initial glitch? Is there a way to avoid showing any window until the Dart app starts up, and therefore the Dart code can set the configuration before any window is visible?

@Adrian-Samoticha
Copy link
Member

I find the glitch isn’t really as noticeable when running the app in release mode (it’s really just a fraction of a second), though it is indeed noticeable at all.

It might be possible how add functionality to hide/unhide the window and document how to make sure the window is hidden during startup by modifying the app’s Swift code. This way you’d still be able to configure your app within Dart, while the only thing you’d need to do in Swift would be making sure the window is hidden during launch.

@Adrian-Samoticha Adrian-Samoticha added the enhancement New feature or request label Sep 11, 2023
@matthew-carroll
Copy link
Author

Is there a Swift and Dart code snippet that does what you described above? Or does this require new Dart APIs in this package?

@Adrian-Samoticha
Copy link
Member

Honestly, I am no longer quite sure if you can even hide the window programmatically, but you can make it invisible by setting its alpha value to 0. So, you could achieve what you’re trying to do like this:

In your MainFlutterWindow.swift file in your Xcode project, add this line to the awakeFromNib method, right above super.awakeFromNib():

self.alphaValue = 0.0

This will ensure that your window is opened with an alpha value of 0.0. Then, use the WindowManipulator’s setWindowAlphaValue method to set it to 1.0 in your Dart code at startup.

@damywise
Copy link

damywise commented Sep 13, 2023

Adding the following line after the function awakeFromNib() also works for hiding the app, though there's no method in this plugin to make it visible again, you need to add one in the plugin.

  override public func order(_ place: NSWindow.OrderingMode, relativeTo otherWin: Int) {
      super.order(place, relativeTo: otherWin)
      super.setIsVisible(false)
  }

(Adapted from window_manager)

@Adrian-Samoticha
Copy link
Member

Oh, you’re right, I somehow missed the setVisible method. Maybe I should expose that.

@Adrian-Samoticha Adrian-Samoticha self-assigned this Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants