Search code examples
xlib

What are the differences between XDefaultScreen and XDefaultScreenOfDisplay?


What are the differences between XDefaultScreen and XDefaultScreenOfDisplay? I can see they respectively return an integer and a struct pointer, but:

  • What are those return values used for?
  • When would you choose one over the other?
  • Why are there 2 functions anyway?

Solution

    • XDefaultScreen (usually called by the macro DefaultScreen) returns the screen number which is used in most xlib functions where you want to specify a screen e.g. DefaultGC.

    • XDefaultScreenOfDisplay (usually called by the macro DefaultScreenOfDisplay) returns a Screen pointer and is generally used when you want to find out information about a screen e.g. WidthOfScreen.