How does X Server assign Window ID?
Glynn Clements
glynn at gclements.plus.com
Wed Mar 4 20:04:09 PST 2009
Sheng Yu wrote:
> I have been tracking for a bug that makes my program crashing when
> calling function glXMakeCurrent.
> My program runs with multi-displays, ':0.0', ':1.0', ':1.1', ':2.0',
> ':2.1'. When glXMakeCurrent() is called
> to switch rendering context from ':0.0' to either ':1.0', ':1.1' or
> ':2.0', ':2.1', the program runs fine.
> However, if the rendering context is switch from ':1.1' to ':2.0',
> the program crashes with with a
> segmentation fault.
>
> The interesting thing I found when debugging is the window ID and
> root window ID for each display:
> display:':0.0',screen: 0, root window id: 315, window id: 71303171
> display:':1.0',screen: 0, root window id: 595, window id: 2097156
> display:':1.1',screen: 1, root window id: 597, window id: 4194308
> display:':2.0',screen: 0, root window id: 595, window id: 2097156
> display:':2.1',screen: 1, root window id: 597, window id: 4194308
>
> It seems that X Server 1 and 2 assign window ID with the same
> strategy, which is different from X Server 0.
> I am wondering whether it is causing the crashing, which indicates
> problems in X Server settings. I have
> been digging into the source of X Server and I cannot find how the
> window ID is assigned. Could someone
> tell me which file I should look into? Thanks a lot!
The X server doesn't assign individual XIDs (except for resources
which are created internally by the server, e.g. the root window).
Each client is assigned a block of XIDs upon connection, and the
client (i.e. Xlib) allocates XIDs from this block.
It would be more clear if you print the XIDs in hexadecimal:
display:':0.0',screen: 0, root window id: 13b, window id: 4400003
display:':1.0',screen: 0, root window id: 253, window id: 200004
display:':1.1',screen: 1, root window id: 255, window id: 400004
display:':2.0',screen: 0, root window id: 253, window id: 200004
display:':2.1',screen: 1, root window id: 255, window id: 400004
The most significant 11 bits of the XID indicate the client, leaving
21 bits for each client, giving each client 2^21 (= 2,097,152) XIDs.
In any case, I doubt that this has anything to do with your problems
with OpenGL.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the xorg
mailing list