mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 02:19:43 +08:00
Move WindowGet* to main thread (#1464)
This commit is contained in:
parent
7cc3652a39
commit
7141c972fd
@ -565,6 +565,7 @@ void SetWindowIcon(GtkWindow* window, const guchar* buf, gsize len) {
|
||||
import "C"
|
||||
import (
|
||||
"strings"
|
||||
"sync"
|
||||
"unsafe"
|
||||
|
||||
"github.com/wailsapp/wails/v2/internal/frontend"
|
||||
@ -707,13 +708,25 @@ func (w *Window) SetPosition(x int, y int) {
|
||||
|
||||
func (w *Window) Size() (int, int) {
|
||||
var width, height C.int
|
||||
C.gtk_window_get_size(w.asGTKWindow(), &width, &height)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
invokeOnMainThread(func() {
|
||||
C.gtk_window_get_size(w.asGTKWindow(), &width, &height)
|
||||
wg.Done()
|
||||
})
|
||||
wg.Wait()
|
||||
return int(width), int(height)
|
||||
}
|
||||
|
||||
func (w *Window) GetPosition() (int, int) {
|
||||
var width, height C.int
|
||||
C.gtk_window_get_position(w.asGTKWindow(), &width, &height)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
invokeOnMainThread(func() {
|
||||
C.gtk_window_get_position(w.asGTKWindow(), &width, &height)
|
||||
wg.Done()
|
||||
})
|
||||
wg.Wait()
|
||||
return int(width), int(height)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user