A question about XCompositeRedirectSubwindows

Jasper St. Pierre jstpierre at mecheye.net
Tue Jun 19 14:52:58 UTC 2018


Hi,

(Re-adding xorg-devel. Please make sure to keep the list CC'd in the future)

It is possible for a window to set "no background color", in which case the
existing window contents are used for the pixmap. xclock likely sets no
background color. You can check an individual window's properties with
xwininfo.

Redrawing the screen every frame isn't a bad idea for a simple compositor
to get started. For a more fancy, complete redraw loop, you can track when
windows get drawn to with with the Damage extension, and schedule a repaint
when that happens. Bonus points if you use the damage rectangles to be more
accurate with your redraw. Also, helpful hint that windows get their
backing pixmaps thrown away when resized -- you need to pay attention to
ConfigureNotify and regrab the backing pixmap with
XCompositeNameWindowPixmap, and that whole jazz.

I don't recommend synthesizing input events -- a lot of things are likely
to break or just not work well. Set an empty input shape on the COW, and
make sure to draw windows where they want to be. Pay attention to
MotionNotify events from windows that are moving.

I'm unaware of any beginner-level documentation or tutorials. The number of
people that have written a compositing manager from scratch can be counted
on one hand, and a lot of them had a hand in designing the architecture to
begin with. https://magcius.github.io/xplain/article/composite.html has
some ideas of the broader concepts, but none of the details.

Good luck.

On Tue, Jun 19, 2018 at 2:01 AM Egil Möller <egil at innovationgarage.no>
wrote:

> Hi!
>
> Thanks for answering a noob question :) Ha! That's so not documented (in
> an obvious way)! I was assuming that I could get the initial window
> content, as already drawn (obviously clipped to whatever is visible on
> screen) directly... So why does xclock "work" then? I just haven't gotten
> around to event handling yet, wanted to learn the drawing/copying methods
> themselves first...
>
> Two follow up questions:
>
>   * How should I redraw the screen? As often as I can, or waiting for some
> event for all redirected windows (which event)?
>   * Can I capture input events (key, mouse) for the overlay window and
> then somehow synthesize them for whatever window / subwindow my window
> manager thinks it has drawn in that position? Some docs I read sounded like
> this is impossible, and you should turn of input for the overlay, and
> position the real window underneath in a "strategic position"...
>
> Also, is there any good documentation and/or tutorials around this
> anywhere?
>
> /Egil
>
> On 19. juni 2018 08:42, Jasper St. Pierre wrote:
>
> Hi,
>
> What you're seeing here is a fun little side effect of composite. As you
> might be aware, unredirected X windows don't have any backing storage
> beyond the front buffer -- the full window contents are not really there.
> That means that when the X server first goes to redirect these windows, it
> decides that it should let the window paint again, and sends the window an
> Expose event to let it know it should repaint. A side effect of this is
> that the X server redraws the background for the window. This is the
> semantics for what an Expose event means -- an area that is "Exposed" is
> the background color until the client paints over it.
>
> The client will eventually paint its window contents, but since your CM
> does not appear to have a frame loop, and it only paints once, you do not
> see the updated frame contents.
>
> On Sun, Jun 17, 2018 at 1:28 PM Egil Möller <egil at innovationgarage.no>
> wrote:
>
>> Hi!
>>
>> I'm trying to write a new compositing window manager, and finding the
>> documentation for the API:s I need quite spread out.
>>
>> The particular problem I'm having right now is that copying some windows
>> (xclock) using
>> XCompositeRedirectSubwindows and e.g. XRenderComposite works fine, while
>> other windows (xterm, xlock) leaves me we a square with only their
>> background color. This seems to be true for both XRenderComposite and
>> glXBindTexImageEXT. Any ideas what's different between them, and what I
>> need to do differently?
>>
>> My code is here: https://github.com/redhog/InfiniteGlass
>> (main code is in wm.c; running "make" ahould give you an Xephyr nested X
>> session that shows the problem).
>>
>> Thanks in advance,
>>
>> Egil Möller
>>
>>
>>
>> _______________________________________________
>> xorg-devel at lists.x.org: X.Org development
>> Archives: http://lists.x.org/archives/xorg-devel
>> Info: https://lists.x.org/mailman/listinfo/xorg-devel
>
>
>
> --
>   Jasper
>
>
>

-- 
  Jasper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.x.org/archives/xorg-devel/attachments/20180619/1f6238a9/attachment.html>


More information about the xorg-devel mailing list