summaryrefslogtreecommitdiff
path: root/examples/create-window/main.go
diff options
context:
space:
mode:
authorscrouthtv <[email protected]>2021-03-01 18:28:23 +0100
committerGitHub <[email protected]>2021-03-01 18:28:23 +0100
commit2a6cba9c3c2e3d2ea720099b61b39669ff6b7474 (patch)
tree0f439c08822bc1275ff31432e4d394103bac1300 /examples/create-window/main.go
parentcec22bda1ce18b7a75cf028a67ad5f1c71a37831 (diff)
Update main.go
added example of reading events
Diffstat (limited to 'examples/create-window/main.go')
-rw-r--r--examples/create-window/main.go12
1 files changed, 11 insertions, 1 deletions
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.
+ }
}
}