From 2a6cba9c3c2e3d2ea720099b61b39669ff6b7474 Mon Sep 17 00:00:00 2001 From: scrouthtv Date: Mon, 1 Mar 2021 18:28:23 +0100 Subject: Update main.go added example of reading events --- examples/create-window/main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'examples/create-window/main.go') diff --git a/examples/create-window/main.go b/examples/create-window/main.go index 50a9bff..284daef 100644 --- a/examples/create-window/main.go +++ b/examples/create-window/main.go @@ -96,12 +96,22 @@ func main() { fmt.Println("Both event and error are nil. Exiting...") return } - + if ev != nil { fmt.Printf("Event: %s\n", ev) } if xerr != nil { fmt.Printf("Error: %s\n", xerr) } + + // This is how accepting events work: + // The application checks what event we got + // (the event must be registered using either xproto.CreateWindow (see l.35) or + // xproto.ChangeWindowAttributes (see l.50)). + // and reacts to it accordingly. All events are defined in the xproto subpackage. + switch ev.(type) { + case xproto.DestroyNotifyEvent: + return // Exit if we get a DestroyNotifyEvent. + } } } -- cgit v1.2.3