Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

comp.windows.x Frequently Asked Questions (FAQ) 7/7
Section - 169) How can my application tell if it is being run under X?

( Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Restaurant inspections ]


Top Document: comp.windows.x Frequently Asked Questions (FAQ) 7/7
Previous Document: 168) Why do I get a BadMatch error when calling XGetImage?
Next Document: 170) How do I make a "busy cursor" while my application is computing?
See reader questions & answers on this topic! - Help others by sharing your knowledge

A number of programs offer X modes but otherwise run in a straight
character-only mode. The easiest way for an application to determine that it
is running on an X display is to attempt to open a connection to the X
server:
	
	display = XOpenDisplay(display_name);
	if (display)
		{ do X stuff }
	else
		{ do curses or something else }

where display_name is either the string specified on the command-line
following -display, by convention, or otherwise is (char*)NULL [in which case
XOpenDisplay uses the value of $DISPLAY, if set].

This is superior to simply checking for the existence a -display command-line 
argument or checking for $DISPLAY set in the environment, neither of which is 
adequate. [5/91]

Note that there is a lengthy delay if $DISPLAY exists but is set to a machine
which is not currently running an X server.

User Contributions:

Comment about this article, ask questions, or add new information about this topic:




Top Document: comp.windows.x Frequently Asked Questions (FAQ) 7/7
Previous Document: 168) Why do I get a BadMatch error when calling XGetImage?
Next Document: 170) How do I make a "busy cursor" while my application is computing?

Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
faq%craft@uunet.uu.net (X FAQ maintenance address)





Last Update March 27 2014 @ 02:12 PM