Reputation: 23479
So I'm working on developing some code that uses the X11 library to work with X-Windows on Linux. I've found some simple tutorials, but they don't go into many details about best practices for more practical use-cases.
One thing I'm wondering is, should I be making one call to XOpenDisplay per application and passing around the pointer to the Display, or is it okay to call this function for each top-level window?
Upvotes: 0
Views: 1661
Reputation: 25456
While you can use more than one connection to X server in your appilcation, there is a good reason not to do this: every connection is assigned range of resource IDs (even if your client does not create its own resources), and resource id is 32bit number, thus total number of connection is limited in X11 (and is usually as low as 256 to 512 on most systems)
Upvotes: 2
Reputation: 29266
You should only need XOpenDisplay
once. One Display can have many windows.
Upvotes: 2