sidorares/node-x11

Bad mapping for event 17 : "DestroyNotify"

izanagi1995 opened this issue · 3 comments

I'm creating a Window Manager with your awesome module.

I had a bug with the "DestroyNotify" event. The event_consumer of the window was never triggered. It's because the real wid is in the field event. I don't know why but the wid in this case is the same as the "MapNotify" event but when I try X.DestroyWindow(ev.wid), it's yield a "BadWindow" error. But when I do X.DestroyWIndow(ev.event), the window is destroyed successfully.

According to the spec:

This event is reported to clients selecting StructureNotify on the window and to clients selecting SubstructureNotify on the parent. It is generated when the window is destroyed. The event is the window on which the event was generated, and the window is the window that is destroyed.

My understanding of this is:

  • event: can be either the destroyed window or its parent depending on whether StructureNotify or SubstructureNotify was used.
  • window: is the actual destroyed window.

IIUC what you're doing, when you call X.DestroyWindow(ev.wid) you're trying to destroy an already destroyed window while when you call X.DestroyWIndow(ev.event) you're trying to destroy its parent and that probably works ok.

Ok then... There is still a bug somewhere in the windowmanager example and the core in general. The DestroyNotify event is not passed to the event_consumer. Without the trick X.DestroyWIndow(ev.event), the window is still there without content and to close it, I have to call the destroy with ev.event...

IMO, this should be changed to allow the event_consumer to destroy the window.

EDIT : To give you the full context, I'm launching an app through terminal and then kill it with Ctrl-C and try to get the window closed.

hi @izanagi1995 I'm in 'holiday mode' currently and read notifications diagonally. Can you post code snippet with "what's expected" vs "what's happening"? If you strongly believe your expectations are correct, maybe even create PR which adds your assertion as test case ( obviously currently failing)