mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-16 17:09:28 +08:00
Ensure key callbacks in window run() are called on the main thread
This commit is contained in:
parent
5445aebe94
commit
2a6e3da30a
@ -20,7 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- [darwin] Ensure `windowDidBecomeKey` callback is running on main thread by [@leaanthony](https://github.com/leaanthony)
|
- [darwin] Ensure `windowDidBecomeKey` callback is running on main thread by [@leaanthony](https://github.com/leaanthony)
|
||||||
|
- Ensure key callbacks in window run() are called on the main thread by [@leaanthony](https://github.com/leaanthony)
|
||||||
|
|
||||||
## v3.0.0-alpha.8.3 - 2024-12-07
|
## v3.0.0-alpha.8.3 - 2024-12-07
|
||||||
|
|
||||||
|
@ -826,16 +826,18 @@ func (w *linuxWebviewWindow) enableDND() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *linuxWebviewWindow) execJS(js string) {
|
func (w *linuxWebviewWindow) execJS(js string) {
|
||||||
value := C.CString(js)
|
InvokeAsync(func() {
|
||||||
C.webkit_web_view_evaluate_javascript(w.webKitWebView(),
|
value := C.CString(js)
|
||||||
value,
|
C.webkit_web_view_evaluate_javascript(w.webKitWebView(),
|
||||||
C.long(len(js)),
|
value,
|
||||||
nil,
|
C.long(len(js)),
|
||||||
C.CString(""),
|
nil,
|
||||||
nil,
|
C.CString(""),
|
||||||
nil,
|
nil,
|
||||||
nil)
|
nil,
|
||||||
C.free(unsafe.Pointer(value))
|
nil)
|
||||||
|
C.free(unsafe.Pointer(value))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMousePosition() (int, int, *Screen) {
|
func getMousePosition() (int, int, *Screen) {
|
||||||
@ -1481,8 +1483,9 @@ func onUriList(extracted **C.char, data unsafe.Pointer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var debounceTimer *time.Timer
|
var debounceTimer *time.Timer
|
||||||
var isDebouncing bool = false
|
var isDebouncing bool = false
|
||||||
|
|
||||||
//export onKeyPressEvent
|
//export onKeyPressEvent
|
||||||
func onKeyPressEvent(_ *C.GtkWidget, event *C.GdkEventKey, userData C.uintptr_t) C.gboolean {
|
func onKeyPressEvent(_ *C.GtkWidget, event *C.GdkEventKey, userData C.uintptr_t) C.gboolean {
|
||||||
// Keypress re-emits if the key is pressed over a certain threshold so we need a debounce
|
// Keypress re-emits if the key is pressed over a certain threshold so we need a debounce
|
||||||
|
@ -321,13 +321,15 @@ func (w *linuxWebviewWindow) run() {
|
|||||||
|
|
||||||
w.setURL(startURL)
|
w.setURL(startURL)
|
||||||
w.parent.OnWindowEvent(events.Linux.WindowLoadChanged, func(_ *WindowEvent) {
|
w.parent.OnWindowEvent(events.Linux.WindowLoadChanged, func(_ *WindowEvent) {
|
||||||
if w.parent.options.JS != "" {
|
InvokeAsync(func() {
|
||||||
w.execJS(w.parent.options.JS)
|
if w.parent.options.JS != "" {
|
||||||
}
|
w.execJS(w.parent.options.JS)
|
||||||
if w.parent.options.CSS != "" {
|
}
|
||||||
js := fmt.Sprintf("(function() { var style = document.createElement('style'); style.appendChild(document.createTextNode('%s')); document.head.appendChild(style); })();", w.parent.options.CSS)
|
if w.parent.options.CSS != "" {
|
||||||
w.execJS(js)
|
js := fmt.Sprintf("(function() { var style = document.createElement('style'); style.appendChild(document.createTextNode('%s')); document.head.appendChild(style); })();", w.parent.options.CSS)
|
||||||
}
|
w.execJS(js)
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
w.parent.OnWindowEvent(events.Linux.WindowFocusIn, func(e *WindowEvent) {
|
w.parent.OnWindowEvent(events.Linux.WindowFocusIn, func(e *WindowEvent) {
|
||||||
w.parent.emit(events.Common.WindowFocus)
|
w.parent.emit(events.Common.WindowFocus)
|
||||||
|
@ -267,7 +267,7 @@ func (w *windowsWebviewWindow) run() {
|
|||||||
nil)
|
nil)
|
||||||
|
|
||||||
if w.hwnd == 0 {
|
if w.hwnd == 0 {
|
||||||
panic("Unable to create window")
|
globalApplication.fatal("Unable to create window")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure correct window size in case the scale factor of current screen is different from the initial one.
|
// Ensure correct window size in case the scale factor of current screen is different from the initial one.
|
||||||
@ -329,7 +329,9 @@ func (w *windowsWebviewWindow) run() {
|
|||||||
case SystemDefault:
|
case SystemDefault:
|
||||||
w.updateTheme(w32.IsCurrentlyDarkMode())
|
w.updateTheme(w32.IsCurrentlyDarkMode())
|
||||||
w.parent.onApplicationEvent(events.Windows.SystemThemeChanged, func(*ApplicationEvent) {
|
w.parent.onApplicationEvent(events.Windows.SystemThemeChanged, func(*ApplicationEvent) {
|
||||||
w.updateTheme(w32.IsCurrentlyDarkMode())
|
InvokeAsync(func() {
|
||||||
|
w.updateTheme(w32.IsCurrentlyDarkMode())
|
||||||
|
})
|
||||||
})
|
})
|
||||||
case Light:
|
case Light:
|
||||||
w.updateTheme(false)
|
w.updateTheme(false)
|
||||||
@ -527,8 +529,7 @@ func (w *windowsWebviewWindow) reload() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) forceReload() {
|
func (w *windowsWebviewWindow) forceReload() {
|
||||||
//TODO implement me
|
// noop
|
||||||
panic("implement me")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) zoomReset() {
|
func (w *windowsWebviewWindow) zoomReset() {
|
||||||
@ -580,8 +581,7 @@ func (w *windowsWebviewWindow) close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) zoom() {
|
func (w *windowsWebviewWindow) zoom() {
|
||||||
//TODO implement me
|
// Noop
|
||||||
panic("implement me")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *windowsWebviewWindow) setHTML(html string) {
|
func (w *windowsWebviewWindow) setHTML(html string) {
|
||||||
@ -1299,7 +1299,7 @@ func (w *windowsWebviewWindow) setWindowMask(imageData []byte) {
|
|||||||
|
|
||||||
data, err := pngToImage(imageData)
|
data, err := pngToImage(imageData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
globalApplication.fatal("Fatal error in callback setWindowMask: " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
bitmap, err := w32.CreateHBITMAPFromImage(data)
|
bitmap, err := w32.CreateHBITMAPFromImage(data)
|
||||||
|
Loading…
Reference in New Issue
Block a user