@@ -157,21 +157,6 @@ func (a *Application) Run() error {
157157
158158 // Create a messenger and init plugins
159159 messenger := newMessenger (a .engine )
160- for _ , p := range a .config .plugins {
161- err = p .InitPlugin (messenger )
162- if err != nil {
163- return errors .Wrap (err , "failed to initialize plugin " + fmt .Sprintf ("%T" , p ))
164- }
165-
166- // Extra init call for plugins that satisfy the PluginGLFW interface.
167- if glfwPlugin , ok := p .(PluginGLFW ); ok {
168- err = glfwPlugin .InitPluginGLFW (a .window )
169- if err != nil {
170- return errors .Wrap (err , "failed to initialize glfw plugin" + fmt .Sprintf ("%T" , p ))
171- }
172- }
173- }
174-
175160 // Create a TextureRegistry
176161 texturer := newTextureRegistry (a .engine , a .window )
177162
@@ -263,17 +248,21 @@ func (a *Application) Run() error {
263248 os .Exit (1 )
264249 }
265250
266- // Setup a new windowManager to handle windows pixel ratio's and pointer
267- // devices.
268- windowManager := newWindowManager (a .config .forcePixelRatio )
269- // force first refresh
270- windowManager .glfwRefreshCallback (a .window )
271- // Attach glfw window callbacks for refresh and position changes
272- a .window .SetRefreshCallback (windowManager .glfwRefreshCallback )
273- a .window .SetPosCallback (windowManager .glfwPosCallback )
274-
275- // TODO: Can this only be done here? Why not in the plugin/glfwPlugin init loop above?
251+ // Register plugins
276252 for _ , p := range a .config .plugins {
253+ err = p .InitPlugin (messenger )
254+ if err != nil {
255+ return errors .Wrap (err , "failed to initialize plugin " + fmt .Sprintf ("%T" , p ))
256+ }
257+
258+ // Extra init call for plugins that satisfy the PluginGLFW interface.
259+ if glfwPlugin , ok := p .(PluginGLFW ); ok {
260+ err = glfwPlugin .InitPluginGLFW (a .window )
261+ if err != nil {
262+ return errors .Wrap (err , "failed to initialize glfw plugin" + fmt .Sprintf ("%T" , p ))
263+ }
264+ }
265+
277266 // Extra init call for plugins that satisfy the PluginTexture interface.
278267 if texturePlugin , ok := p .(PluginTexture ); ok {
279268 err = texturePlugin .InitPluginTexture (texturer )
@@ -283,6 +272,15 @@ func (a *Application) Run() error {
283272 }
284273 }
285274
275+ // Setup a new windowManager to handle windows pixel ratio's and pointer
276+ // devices.
277+ windowManager := newWindowManager (a .config .forcePixelRatio )
278+ // force first refresh
279+ windowManager .glfwRefreshCallback (a .window )
280+ // Attach glfw window callbacks for refresh and position changes
281+ a .window .SetRefreshCallback (windowManager .glfwRefreshCallback )
282+ a .window .SetPosCallback (windowManager .glfwPosCallback )
283+
286284 // Attach glfw window callbacks for text input
287285 a .window .SetKeyCallback (
288286 func (window * glfw.Window , key glfw.Key , scancode int , action glfw.Action , mods glfw.ModifierKey ) {
@@ -313,9 +311,6 @@ func (a *Application) Run() error {
313311 messenger .engineTasker .ExecuteTasks ()
314312 }
315313
316- // TODO: What if the window indicates to stop, but there are tasks left on
317- // the queue?
318-
319314 fmt .Println ("go-flutter: closing application" )
320315
321316 return nil
0 commit comments