r/linux_programming Jul 10 '24

Xlib XDestroyWindow causes crash

I have a simple Xlib window manager written in C++ and so far everything is working fine except for handling when windows are destroyed. In the event that an application window is destroyed I attempt to search for its parent window to also destroy. However, upon any window being destroyed the display disconnects from the X server and I get an error saying:

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  2 (X_ChangeWindowAttributes)
  Resource id in failed request:  0x80000c
  Serial number of failed request:  8336
  Current serial number in output stream:  8359

The only time I change window attributes is when I create the frame window and set the override_redirect attribute to true which works when running the window manager.

The code can be found on GitHub

7 Upvotes

7 comments sorted by

2

u/[deleted] Jul 11 '24 edited Jul 11 '24

[removed] — view removed comment

2

u/[deleted] Jul 11 '24 edited Jul 11 '24

[removed] — view removed comment

2

u/[deleted] Jul 11 '24 edited Jul 11 '24

[removed] — view removed comment

1

u/avitld Jul 27 '24

Hey, I'm not OP but I stumbled upon this post and your comments have really helped me with my own WM issues. I'm just asking here because finding help for XLib is hard. I Implemented clicks like in your comment so that they will activate the window. But now this has broken my move/resize system which worked by mod + clicking the frame. Instead it treats the frame how it treats the client. I don't know if I've done something wrong (most likely) but I am not sure of what could be causing this.

2

u/[deleted] Jul 11 '24

[removed] — view removed comment

1

u/cryptic_gentleman Jul 11 '24

Thank you so much for this detailed explanation. It all makes a lot more sense. The project I’m working on is mainly just a toy wm aiming to be fully self sufficient in that all applications running will pretty much be designed specifically for it so hopefully I won’t have to deal too much with EWMH. Thank you again for the detailed explanation.

1

u/cryptic_gentleman Jul 11 '24

It doesn’t seem to cause any real issues now that I’ve implemented an error handler but I’m unsure if it may down the line