Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an explanation of how to use events to the create-window example #1

Merged
merged 19 commits into from
Mar 7, 2021
Merged

Added an explanation of how to use events to the create-window example #1

merged 19 commits into from
Mar 7, 2021

Conversation

scrouthtv
Copy link

Hello,

first, I think that the default examples are very helpful and well documented.

However, if you run the create-window example and close the window, the underlying Go Program keeps running.

I think this is a good use case for the DestroyNotifyEvent and demonstrating how reading it / reading events in general works.

So I added these simple lines to the demo.

added example of reading events
Copy link
Owner

@jezek jezek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, if you run the create-window example and close the window, the underlying Go Program keeps running.

How running? On Ubuntu if I close the window, i got the program terminated with output:

XGB: xgb.go:455: A read error is unrecoverable: EOF
Both event and error are nil. Exiting...

examples/create-window/main.go Show resolved Hide resolved
examples/create-window/main.go Outdated Show resolved Hide resolved
examples/create-window/main.go Outdated Show resolved Hide resolved
@scrouthtv
Copy link
Author

I just tried again:
xgb-pr1
(It only ends because I manually C-c)

I am running Arch Linux with xorg-server 1.20.10-3 and xcb-proto 1.14.1-3. My WM is i3-gaps 4.19.1-1.

If I close the window, both UnmapNotify and DestroyNotify are sent, however, no error is sent (which closes the example in your case).

Sorry about the formatting.

@scrouthtv
Copy link
Author

Here is also an example of how to listen to key

@jezek
Copy link
Owner

jezek commented Mar 6, 2021

Now I remember. I've encountered this before. On some (well behaved) DEs the UnmapNotify and DestroyNotify is not sent just the connection is closed, unless you add WM_DELETE_WINDOW to WM_PROTOCOLS property. Could you mention this in comment in the DestoyNotifyEvent, please?

@scrouthtv
Copy link
Author

scrouthtv commented Mar 6, 2021

sure thing. You're using stock ubuntu (so I can mention your DE as an example for closing = killing the X conection)?

I also have an example for drawing coming up which you can consider adding, I just have to add comments for everything.

@scrouthtv
Copy link
Author

Here it is. I think I'm done

@scrouthtv
Copy link
Author

I also added some text drawing in there.

Copy link
Owner

@jezek jezek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks a lot better, but I have a few demands. Thank you for bearing with me and implementing my requests so far.

You're using stock ubuntu (so I can mention your DE as an example for closing = killing the X conection)?

I use Ubuntu MATE right now, but I think, stock ubuntu does the same. I have to test it, but for now let's assume it's happening on stock ubuntu too. 😆
Edit: Tested it on stock Ubuntu 20.04, no DestroyNotifyEvent, like in MATE.

examples/create-window/main.go Show resolved Hide resolved
examples/create-window/main.go Outdated Show resolved Hide resolved
examples/create-window/main.go Outdated Show resolved Hide resolved
examples/create-window/main.go Outdated Show resolved Hide resolved
examples/create-window/main.go Show resolved Hide resolved
examples/shapes/main.go Outdated Show resolved Hide resolved
@scrouthtv
Copy link
Author

Thank you for bearing with me

No worries, I am a perfectionist myself ;)

I think it should all be in there.
Regarding the shapes example, I messed up a bit and will be opening a new PR soon (in case you're interested).

@jezek jezek merged commit b58285d into jezek:master Mar 7, 2021
@jezek
Copy link
Owner

jezek commented Mar 7, 2021

Just added an missing "\n" and merged. Thank you.

Also I'm interested in the shapes example. I myself like to learn from examples, so I think the more examples, the better. ;)
Hint: git rebase -i is useful to trim/modify branches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants