yuyichao
yuyichao

Reputation: 776

How does compositor work on X?

I am trying to understand how compositors work on X (well basically because neither xcompmgr nor cairo-compmgr can draw shadow properly for my awesome wm~~~)

I have read part of the source code both xcompmgr and cairo-compmgr but I still don't really understand how they do that.

I want to know how they know where the shadow should be (well, arround the window for sure, but the shadow might be under other window and don't need to be drawn.), as well as where (on which layer/window) do they draw the shadow. Probably also how all those X extension are used (and what's for) and how cairo-compmgr use cairo to deal with low level X stuff.

It's a little hard for me to learn these from the source code because a lot of stuff (especially X extensions) is poor documented. It will also be helpful just to point out where I should look at.

Upvotes: 4

Views: 2944

Answers (1)

moongoal
moongoal

Reputation: 2956

The simpler you code it, the best it will work.

  • Get a list of the visible windows
  • Sort them by inverse z-order (from the bottom-most to the top-most)
  • Draw the shadow and then the window itself for each window

You need no black magic.

If you are wondering how it works, it's straightforward: you have to use the 'composite' X extension. It enables the overlay window, which is the only visible window on the screen once it is enabled, then you have to draw all the windows on it as you will be provided with a Pixmap for each window.

EDIT: If you are seeking for documentation, you can use the linux manual (the man command), and the header files, they're the main (also best and perhaps the only real) source of documentation, as all the other sources/websites rely on them afaik.

Upvotes: 4

Related Questions