mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 22:55:48 +01:00
[windows] Use msWebView2BrowserHitTransparent for non working NC area clicks on unfocused window
Without this patch there's a really strange behaviour if there are multiple windows. Having two windows with a webview open with an input field. Focusing the input field on one window, then focusing the input field on the second one. Then clicking directly on the non client area of the first one, e.g. to trigger a minimze, the minimize is not executed until the mouse is getting moved. As long as the mouse is not moved the event for the click is blocked and not executed. Using this new mode fixes that problem, but we need to handle ‘alt+f4’ on our own.
This commit is contained in:
parent
b37d0f1cf4
commit
2f3eb70a4d
3 changed files with 30 additions and 22 deletions
|
|
@ -767,8 +767,7 @@ func (a *App) runOrDeferToAppRun(r runnable) {
|
|||
}
|
||||
|
||||
func (a *App) processKeyBinding(acceleratorString string, window *WebviewWindow) bool {
|
||||
|
||||
if a.keyBindings == nil {
|
||||
if len(a.keyBindings) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1096,20 +1096,17 @@ func (w *WebviewWindow) SetAbsolutePosition(x int, y int) {
|
|||
}
|
||||
|
||||
func (w *WebviewWindow) processKeyBinding(acceleratorString string) bool {
|
||||
|
||||
if w.keyBindings == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check key bindings
|
||||
callback, ok := w.keyBindings[acceleratorString]
|
||||
if !ok {
|
||||
return globalApplication.processKeyBinding(acceleratorString, w)
|
||||
}
|
||||
// Execute callback
|
||||
go callback(w)
|
||||
if w.keyBindings != nil {
|
||||
if callback := w.keyBindings[acceleratorString]; callback != nil {
|
||||
// Execute callback
|
||||
go callback(w)
|
||||
|
||||
return true
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return globalApplication.processKeyBinding(acceleratorString, w)
|
||||
}
|
||||
|
||||
func (w *WebviewWindow) HandleKeyEvent(acceleratorString string) {
|
||||
|
|
|
|||
|
|
@ -1289,14 +1289,9 @@ func (w *windowsWebviewWindow) setupChromium() {
|
|||
globalApplication.capabilities = capabilities.NewCapabilities(webview2version)
|
||||
|
||||
disableFeatues := []string{}
|
||||
|
||||
if !opts.EnableFraudulentWebsiteWarnings {
|
||||
disableFeatues = append(disableFeatues, "msSmartScreenProtection")
|
||||
}
|
||||
|
||||
chromium.DataPath = globalApplication.options.Windows.WebviewUserDataPath
|
||||
chromium.BrowserPath = globalApplication.options.Windows.WebviewBrowserPath
|
||||
|
||||
if opts.WebviewGpuIsDisabled {
|
||||
chromium.AdditionalBrowserArgs = append(chromium.AdditionalBrowserArgs, "--disable-gpu")
|
||||
}
|
||||
|
|
@ -1306,6 +1301,15 @@ func (w *windowsWebviewWindow) setupChromium() {
|
|||
chromium.AdditionalBrowserArgs = append(chromium.AdditionalBrowserArgs, arg)
|
||||
}
|
||||
|
||||
enableFeatures := []string{"msWebView2BrowserHitTransparent"}
|
||||
if len(enableFeatures) > 0 {
|
||||
arg := fmt.Sprintf("--enable-features=%s", strings.Join(enableFeatures, ","))
|
||||
chromium.AdditionalBrowserArgs = append(chromium.AdditionalBrowserArgs, arg)
|
||||
}
|
||||
|
||||
chromium.DataPath = globalApplication.options.Windows.WebviewUserDataPath
|
||||
chromium.BrowserPath = globalApplication.options.Windows.WebviewBrowserPath
|
||||
|
||||
if opts.Permissions != nil {
|
||||
for permission, state := range opts.Permissions {
|
||||
chromium.SetPermission(edge.CoreWebView2PermissionKind(permission),
|
||||
|
|
@ -1547,9 +1551,6 @@ func (w *windowsWebviewWindow) processKeyBinding(vkey uint) bool {
|
|||
|
||||
globalApplication.debug("Processing key binding", "vkey", vkey)
|
||||
|
||||
if len(w.parent.keyBindings) == 0 {
|
||||
return false
|
||||
}
|
||||
// Get the keyboard state and convert to an accelerator
|
||||
var keyState [256]byte
|
||||
if !w32.GetKeyboardState(keyState[:]) {
|
||||
|
|
@ -1584,9 +1585,20 @@ func (w *windowsWebviewWindow) processKeyBinding(vkey uint) bool {
|
|||
acc.Key = accKey
|
||||
}
|
||||
|
||||
// Process the key binding
|
||||
return w.parent.processKeyBinding(acc.String())
|
||||
accKey := acc.String()
|
||||
globalApplication.debug("Processing key binding", "vkey", vkey, "acc", accKey)
|
||||
|
||||
// Process the key binding
|
||||
if w.parent.processKeyBinding(accKey) {
|
||||
return true
|
||||
}
|
||||
|
||||
if accKey == "alt+f4" {
|
||||
w32.PostMessage(w.hwnd, w32.WM_CLOSE, 0, 0)
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (w *windowsWebviewWindow) processMessageWithAdditionalObjects(message string, sender *edge.ICoreWebView2, args *edge.ICoreWebView2WebMessageReceivedEventArgs) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue