XOpenDisplay, XCloseDisplay − connect or disconnect to X server


Display *XOpenDisplay(char *display_name);

int XCloseDisplay(Display *display);



Specifies the connection to the X server.


Specifies the hardware display name, which determines the display and communications domain to be used. On a POSIX-conformant system, if the display_name is NULL, it defaults to the value of the DISPLAY environment variable.


The XOpenDisplay function returns a Display structure that serves as the connection to the X server and that contains all the information about that X server. XOpenDisplay connects your application to the X server through TCP or DECnet communications protocols, or through some local inter-process communication protocol. If the hostname is a host machine name and a single colon (:) separates the hostname and display number, XOpenDisplay connects using TCP streams. If the hostname is not specified, Xlib uses whatever it believes is the fastest transport. If the hostname is a host machine name and a double colon (::) separates the hostname and display number, XOpenDisplay connects using DECnet. A single X server can support any or all of these transport mechanisms simultaneously. A particular Xlib implementation can support many more of these transport mechanisms.

If successful, XOpenDisplay returns a pointer to a Display structure, which is defined in <X11/Xlib.h>. If XOpenDisplay does not succeed, it returns NULL. After a successful call to XOpenDisplay, all of the screens in the display can be used by the client. The screen number specified in the display_name argument is returned by the DefaultScreen macro (or the XDefaultScreen function). You can access elements of the Display and Screen structures only by using the information macros or functions. For information about using macros and functions to obtain information from the Display structure, see section 2.2.1.

The XCloseDisplay function closes the connection to the X server for the display specified in the Display structure and destroys all windows, resource IDs (Window, Font, Pixmap, Colormap, Cursor, and GContext), or other resources that the client has created on this display, unless the close-down mode of the resource has been changed (see XSetCloseDownMode). Therefore, these windows, resource IDs, and other resources should never be referenced again or an error will be generated. Before exiting, you should call XCloseDisplay explicitly so that any pending errors are reported as XCloseDisplay performs a final XSync operation.

XCloseDisplay can generate a BadGC error.


AllPlanes(3), XFlush(3), XSetCloseDownMode(3)
Xlib − C Language X Interface

More Linux Commands

snmptrapd(8) - Receive and log SNMP trap messages. (ManPage)
snmptrapd is an SNMP application that receives and logs SNMP TRAP and INFORM messages. Note: the default is to listen on UDP port 162 on all IPv4 interfaces. Si

perlivp(1) - Perl Installation Verification Procedure.......
The perlivp program is set up at Perl source code build time to test the Perl version it was built under. It can be used after running: make install (or your pl

svnrdump(1) Subversion remote repository dumper and loader
svnrdump.1 - Subversion is a version control system, which allows you to keep old versions of files and directories (usually source code), keep a log of who, wh

X(7) - a portable, network-transparent window system........
X Window System servers run on computers with bitmap displays. The server distributes user input to and accepts output requests from various client programs thr

sane-apple(5) - SANE backend for Apple flatbed scanners.....
The sane-apple library implements a SANE (Scanner Access Now Easy) backend that provides access to Apple flatbed scanners. At present, the following scanners ar

tracepath(8) - traces path to a network host discovering MTU
It traces path to destination discovering MTU along this path. It uses UDP port port or some random port. It is similar to traceroute, only does not require sup

gnutls_x509_privkey_import_rsa_raw2(3) - API function.......
gnutls_x509_privkey_import_rsa_raw2.3 - This function will convert the given RSA raw parameters to the native gnutls_x509_privkey_t format. The output will be s

vswprintf(3) - formatted wide-character output conversion...
The wprintf() family of functions is the wide-character equivalent of the printf(3) family of functions. It performs formatted output of wide characters. The wp

htobe64(3) - convert values between host and big-/little-end
These functions convert the byte encoding of integer values from the byte order that the current CPU (the host) uses, to and from little-endian and big-endian b

pam_set_data(3) - set module internal data - Linux man page
The pam_set_data function associates a pointer to an object with the (hopefully) unique string module_data_name in the PAM context specified by the pamh argumen

mvwaddchstr(3ncurses) - add a string of characters (and attr
These functions copy the (null-terminated) chstr array into the window image structure starting at the current cursor position. The four functions with n as the

gitdiffcore(7) - Tweaking diff output - Linux manual page...
The diff commands git diff-index, git diff-files, and git diff-tree can be told to manipulate differences they find in unconventional ways before showing diff o

We can't live, work or learn in freedom unless the software we use is free.