diff options
| author | Lenni <[email protected]> | 2021-03-06 17:46:57 +0100 |
|---|---|---|
| committer | Lenni <[email protected]> | 2021-03-06 17:46:57 +0100 |
| commit | 89052459e19439240a5f3a1d3e267650f0d0c554 (patch) | |
| tree | c3eb8751f43f3ca3bbf96f0cc1be99312f967bba | |
| parent | 2825966d27b67b6b0227bcbfcd81f3c995c0f472 (diff) | |
Added explanation to the whole DestroyNotifyEvent thing.
See https://github.com/jezek/xgb/pull/1
| -rw-r--r-- | examples/create-window/main.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/examples/create-window/main.go b/examples/create-window/main.go index d4f6d96..9510f9c 100644 --- a/examples/create-window/main.go +++ b/examples/create-window/main.go @@ -17,6 +17,7 @@ func main() { fmt.Println(err) return } + defer X.Close() // xproto.Setup retrieves the Setup information from the setup bytes // gathered during connection. @@ -122,7 +123,22 @@ func main() { return // exit on q } case xproto.DestroyNotifyEvent: - return // Exit if we get a DestroyNotifyEvent. + // Depending on the user's desktop environment (especially + // window manager), killing a window might close the + // client's X connection (e. g. the default Ubuntu + // desktop environment). + // + // If that's the case for your environment, closing this example's window + // will also call the underlying Go program (because closing the X + // connection gives a nil event and EOF error). + // + // Consider how a single application might have multiple windows + // (e.g. an open popup or dialog, ...) + // + // With other DEs, the X connection will still stay open even after the + // X window is closed. For these DEs (e.g. i3) we have to check whether + // the WM sent us a DestroyNotifyEvent and close our program: + return } } } |
