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:
Elias Naur
2019-07-12 19:21:02 +02:00
parent 46cee54dd6
commit a3b9c7818f
8 changed files with 116 additions and 79 deletions
+4 -6
View File
@@ -155,11 +155,11 @@ func Main() {
<-mainDone
}
func createWindow(opts *WindowOptions) error {
func createWindow(window *Window, opts *WindowOptions) error {
connMu.Lock()
defer connMu.Unlock()
if len(winMap) > 0 {
panic("multiple windows are not supported")
return errors.New("multiple windows are not supported")
}
if err := waylandConnect(); err != nil {
return err
@@ -169,13 +169,13 @@ func createWindow(opts *WindowOptions) error {
conn.destroy()
return err
}
w.w = window
go func() {
windows <- w.w
w.w.setDriver(w)
w.setStage(StageRunning)
w.loop()
w.destroy()
conn.destroy()
close(windows)
close(mainDone)
}()
return nil
@@ -250,8 +250,6 @@ func createNativeWindow(opts *WindowOptions) (*window, error) {
}
w.updateOpaqueRegion()
C.wl_surface_commit(w.surf)
ow := newWindow(w)
w.w = ow
winMap[w.topLvl] = w
winMap[w.surf] = w
winMap[w.wmSurf] = w