mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-08 02:45:38 +00:00
app{,/internal/window}: make app.Main blocking on desktop platforms
This CL implements the app.Main function as a blocking-forever function for JS, Wayland, Windows and X11. This works better for applications that can now programmatically close windows.
This commit is contained in:
committed by
Elias Naur
parent
facf5cbb9d
commit
6a9a870462
@@ -57,10 +57,6 @@ type window struct {
|
||||
|
||||
const _WM_REDRAW = windows.WM_USER + 0
|
||||
|
||||
// windowCounter keeps track of the number of windows.
|
||||
// A send of +1 or -1 represents a change in window count.
|
||||
var windowCounter = make(chan int)
|
||||
|
||||
type gpuAPI struct {
|
||||
priority int
|
||||
initializer func(w *window) (Context, error)
|
||||
@@ -84,11 +80,7 @@ var resources struct {
|
||||
}
|
||||
|
||||
func Main() {
|
||||
// Wait for first window
|
||||
count := <-windowCounter
|
||||
for count > 0 {
|
||||
count += <-windowCounter
|
||||
}
|
||||
select {}
|
||||
}
|
||||
|
||||
func NewWindow(window Callbacks, opts *Options) error {
|
||||
@@ -104,11 +96,7 @@ func NewWindow(window Callbacks, opts *Options) error {
|
||||
defer w.destroy()
|
||||
cerr <- nil
|
||||
winMap.Store(w.hwnd, w)
|
||||
windowCounter <- +1
|
||||
defer func() {
|
||||
winMap.Delete(w.hwnd)
|
||||
windowCounter <- -1
|
||||
}()
|
||||
defer winMap.Delete(w.hwnd)
|
||||
w.w = window
|
||||
w.w.SetDriver(w)
|
||||
defer w.w.Event(system.DestroyEvent{})
|
||||
|
||||
Reference in New Issue
Block a user