mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 02:15:34 +00:00
ui/app: introduce DestroyEvent for ending the event loop
Replace the StageDead stage with DestroyEvent dedicated to ending the event loop and, for premature window closes, the error. Drop the error return from NewWindow; any errors in window creation will appear as an immediate DestroyEvent with its Err field set. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+16
-8
@@ -17,6 +17,8 @@ type Event interface {
|
||||
ImplementsEvent()
|
||||
}
|
||||
|
||||
// DrawEvent is sent when a Window's Draw
|
||||
// method must be called.
|
||||
type DrawEvent struct {
|
||||
Config Config
|
||||
Size image.Point
|
||||
@@ -27,6 +29,14 @@ type DrawEvent struct {
|
||||
sync bool
|
||||
}
|
||||
|
||||
// DestroyEvent is the last event sent through
|
||||
// a window event channel.
|
||||
type DestroyEvent struct {
|
||||
// Err is nil for normal window closures. If a
|
||||
// window is prematurely closed, Err is the cause.
|
||||
Err error
|
||||
}
|
||||
|
||||
// Insets is the space taken up by
|
||||
// system decoration such as translucent
|
||||
// system bars and software keyboards.
|
||||
@@ -60,8 +70,7 @@ type windowAndOptions struct {
|
||||
}
|
||||
|
||||
const (
|
||||
StageDead Stage = iota
|
||||
StagePaused
|
||||
StagePaused Stage = iota
|
||||
StageRunning
|
||||
)
|
||||
|
||||
@@ -93,8 +102,6 @@ var extraArgs string
|
||||
|
||||
func (l Stage) String() string {
|
||||
switch l {
|
||||
case StageDead:
|
||||
return "StageDead"
|
||||
case StagePaused:
|
||||
return "StagePaused"
|
||||
case StageRunning:
|
||||
@@ -104,10 +111,6 @@ func (l Stage) String() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (_ DrawEvent) ImplementsEvent() {}
|
||||
func (_ StageEvent) ImplementsEvent() {}
|
||||
func (_ *CommandEvent) ImplementsEvent() {}
|
||||
|
||||
func init() {
|
||||
args := strings.Split(extraArgs, "|")
|
||||
os.Args = append(os.Args, args...)
|
||||
@@ -178,3 +181,8 @@ func newWindowRendezvous() *windowRendezvous {
|
||||
}()
|
||||
return wr
|
||||
}
|
||||
|
||||
func (_ DrawEvent) ImplementsEvent() {}
|
||||
func (_ StageEvent) ImplementsEvent() {}
|
||||
func (_ *CommandEvent) ImplementsEvent() {}
|
||||
func (_ DestroyEvent) ImplementsEvent() {}
|
||||
|
||||
Reference in New Issue
Block a user