cxlib

How can I add a custom title bar and decorations to a window using XLib in C for dwm


I want to write a patch for dwm that will add area to border of the window where i can place title and decorations (like close , hide, full screen buttons).

Xlib provides a lot of possible ways to accomplish that, however I'm not sure if some of them even possible.

The simplest of all so far is:

If it's not possible, I would try to create title bars by:

or

If there are multiple solutions to this, the best one would be one that uses least memory and works fastest.


Solution

  • This is done normally (by the window manager, for example) by creating a window a bit bigger than the one you requested, and reparenting your window to become a child of the window in which you are going to draw the frame. You then set a clip region to exclude the area to be occupied by the child in the painting routines, and draw the border, the title, the buttons and everything you like on it. You can avoid painting on the child if you care to specify not to include inferiors in all your painting routines. So the clipping region is automatically created for you.

    Another (not recommended) way is to resize the window to allocate space for the frame, but this requires the inside client code to know the part being used by the frame, which I think is not what you want.