@begin(header)
author: ackerman=ag@.ics.uci.edu
show_author: ShowNone
author_organization: Harvard X Class
node_expert: ackerman=ag@ics.uci.edu 
expiration_date: 11/27/93
last_modifier: ackerman=ag@.ics.uci.edu
last_mod_date: 11/27/91
mod_num: 6
@end(header)
-----------------------
Using Server Resources
-----------------------

Outline of this node
  1.  What is a Display?  
  2.  How do you use it?
  3.  What is a Screen?  
  4.  How do you use it?


@begin(1)
What is a Display? 
------------------

The Display struct is created when the connection to the server is
opened.  It is used extensively in Xlib calls.  Sometimes you will
need to use the Display.  For example, you may want to make graphics
calls in the Xlib layer.

You obtain a Display manually if you were just using the Xlib layer
(using a XOpenDisplay call), but is done automatically when you use
the Xt toolkit (with or without the Motif, OpenLook, or any other
widget set).  In Xt, the XtAppInitialize and XtInitialize routines
usually used to begin a program are convenience calls that, among
other things, call XtOpenDisplay.  The XtOpenDisplay, among other
things, calls XOpenDisplay.
@end(1)

@begin(2)
How do you use a Display?
-------------------------
@end(2)

In Xt, you can obtain the Display from any widget id.  You do
this through the XtDisplay call:

	     Display *XtDisplay(the_widget)
	           Widget the_widget;

You can turn around and just use this in an Xlib call.  For
example:

	XDrawLine(XtDisplay(the_widget), some_window, 5,5,100,100);

@begin(3)
What is a Screen?
-----------------
@end(3)

A Screen is another struct that is used primarily with a set of
macros in Xlib.h to obtain the default depth of the screen,
the default colormap, the value for the black pixel on the
screen, and so on.  (These will be detailed below.)

The Screen struct has a back-pointer to the Display struct.

Note, this is *not* the same as "screen" in Xlib.  Small-s 
"screen" is the number of the physical screen attached to
a display; it is an int.  Capital-s "Screen" is a struct.
Use the macros that use Screen.

The most heavily used macros that use Screen are:

	RootWindowOfScreen 
	BlackPixelOfScreen
	WhitePixelOfScreen
	DefaultColormapOfScreen 
	DefaultDepthOfScreen
	DefaultGCOfScreen    
	DefaultVisualOfScreen
	WidthOfScreen
	HeightOfScreen
	WidthMMOfScreen
	HeightMMOfScreen
	DoesBackingStore

See the Xlib documentation for more information.

@begin(4)
How do you use a Screen?
------------------------
@end(4)

To obtain a Screen in an Xt application, use XtScreen with
a widget id:

     Screen *XtScreen(the_widget)
           Widget the_widget;

You can use this straight in a macro:

	RootWindowOfScreen(XtScreen(the_widget))

or
	BlackPixelOfScreen(XtScreen(the_widget))


If you need more information, or this tutorial is incomplete
or wrong, please click the button below and send e-mail.

