jezek / xgb

The X Go Binding is a low-level API to communicate with the X server. It is modeled on XCB and supports many X extensions.
Other
130 stars 13 forks source link

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

Closed scrouthtv closed 3 years ago

scrouthtv commented 3 years ago

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.

scrouthtv commented 3 years ago

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 commented 3 years ago

Here is also an example of how to listen to key

jezek commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Here it is. I think I'm done

scrouthtv commented 3 years ago

I also added some text drawing in there.

scrouthtv commented 3 years ago

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 commented 3 years ago

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.