For xlib, how to create a child window with the background pixel or pixmap of its parent window?

47 views Asked by At

I want to create a child window with the background pixel or pixmap of its parent window. But i can not find refer Xlib API. The workaround I can think of is this: create a child window first, and then use XCopyArea to copy part of parent window. Is there a more direct method?

I searched this question on search engines such as Bing, but couldn't find an answer. Asked this question on chatgpt, and the answer was to use the background_pixel member of XWindowAttributes, or use XQueryColor. This is obviously nonsense.

1

There are 1 answers

2
Erdal Küçük On BEST ANSWER

According to Xlib - C Language X Interface: Background Attribute

  • You can set the background-pixel of a window to any pixel value (no default). If you specify a background-pixel, it overrides either the default background-pixmap or any value you may have set in the background-pixmap.

  • If you set the background-pixmap, it overrides the default.

  • If you set the background-pixmap to ParentRelative:

    • The parent window's background-pixmap is used.
    • If the parent window has a background-pixmap of None, the window also has a background-pixmap of None.
  • Setting a new background, whether by setting background-pixmap or background-pixel, overrides any previous background.

Edit:

According to Window Attributes, the default value for background-pixmap is None and for background-pixel the value is undefined.