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

Add option to disable window re-focus when go app reloads #2272

Conversation

birdmanmandbir
Copy link

@birdmanmandbir birdmanmandbir commented Jan 5, 2023

This PR adds option to disable window re-focus when go app reloads. #1495

Application options

I created a new property in the App options, It defaults to false

How to test

  • with NoDesktopOnDev: true, run wails dev not open the desktop app and http://localhost:34115 have normal behavior
  • with NoDesktopOnDev: true, run wails build, the executable have normal behavior
  • with NoDesktopOnDev: false, run wails dev open the desktop app

Current functionality is working. I also wrote the documentation for En and Zh-Hans.

Below is an example main.go file that can be used as a test in a clean wails project

package main

import (
	"embed"

	"github.com/wailsapp/wails/v2"
	"github.com/wailsapp/wails/v2/pkg/options"
	"github.com/wailsapp/wails/v2/pkg/options/assetserver"
)

//go:embed all:frontend/dist
var assets embed.FS

func main() {
	// Create an instance of the app structure
	app := NewApp()

	// Create application with options
	err := wails.Run(&options.App{
		Title:  "wails-vue",
		Width:  1024,
		Height: 768,
		AssetServer: &assetserver.Options{
			Assets: assets,
		},
		BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
		OnStartup:        app.startup,
		Bind: []interface{}{
			app,
		},
		Debug: options.Debug{
			StartHiddenOnDev: true,
		},
	})

	if err != nil {
		println("Error1:", err.Error())
	}
}

@leaanthony

@birdmanmandbir birdmanmandbir force-pushed the feature/1495_Option_to_disable_window_re-focus branch 3 times, most recently from ab0633d to b40895c Compare January 6, 2023 14:41
@birdmanmandbir birdmanmandbir force-pushed the feature/1495_Option_to_disable_window_re-focus branch from b40895c to 8172dea Compare January 6, 2023 14:57
@birdmanmandbir birdmanmandbir marked this pull request as ready for review January 6, 2023 15:08
@leaanthony
Copy link
Member

You may be able to get the same functionality if you set StartHidden: true in your application options?

@birdmanmandbir
Copy link
Author

You may be able to get the same functionality if you set StartHidden: true in your application options?

I have try it, but with StartHidden: true, The window will also hidden in production mode after wails build, but I only want to hidden in dev mode, and It's easy to forget to remove the option when wails build

@stffabi
Copy link
Collaborator

stffabi commented Jan 16, 2023

Maybe you could add a flag that overrides the 'StartHidden' to the debug options in the appoptions?

@birdmanmandbir
Copy link
Author

Maybe you could add a flag that overrides the 'StartHidden' to the debug options in the appoptions?

You are right, I have moved it to Debug.StartHiddenOnDev

@leaanthony
Copy link
Member

I see this as more a cli flag because as you said, it's easy to forget it when you build. I'm going to add this to v3. Feel free to use a fork of v2 with this patch until it's released.

@leaanthony leaanthony closed this Feb 26, 2023
@birdmanmandbir
Copy link
Author

I see this as more a cli flag because as you said, it's easy to forget it when you build. I'm going to add this to v3. Feel free to use a fork of v2 with this patch until it's released.

okay, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants