mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 02:15:34 +00:00
ui/app: create windows directly
Replace CreateWindow with NewWindow that immediately creates a Window ready to use. Drop the Windows channel of windows created by the system. For iOS and Android where the system creates the windows, let them rendezvous with the window created in the first NewWindow call. Android is further changed so that destroying and re-creating the Java Activity simply reconnects with the original Window. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"image"
|
||||
"runtime"
|
||||
@@ -159,11 +160,11 @@ func Main() {
|
||||
<-mainDone
|
||||
}
|
||||
|
||||
func createWindow(opts *WindowOptions) error {
|
||||
func createWindow(window *Window, opts *WindowOptions) error {
|
||||
onceMu.Lock()
|
||||
defer onceMu.Unlock()
|
||||
if len(winMap) > 0 {
|
||||
panic("multiple windows are not supported")
|
||||
return errors.New("multiple windows are not supported")
|
||||
}
|
||||
cerr := make(chan error)
|
||||
go func() {
|
||||
@@ -176,14 +177,14 @@ func createWindow(opts *WindowOptions) error {
|
||||
}
|
||||
defer w.destroy()
|
||||
cerr <- nil
|
||||
windows <- w.w
|
||||
w.w = window
|
||||
w.w.setDriver(w)
|
||||
showWindow(w.hwnd, _SW_SHOWDEFAULT)
|
||||
setForegroundWindow(w.hwnd)
|
||||
setFocus(w.hwnd)
|
||||
if err := w.loop(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
close(windows)
|
||||
close(mainDone)
|
||||
}()
|
||||
return <-cerr
|
||||
@@ -248,7 +249,6 @@ func createNativeWindow(opts *WindowOptions) (*window, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
w.w = newWindow(w)
|
||||
return w, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user