Path: utzoo!mnetor!tmsoft!torsqnt!hybrid!scifi!bywater!uunet!tdatirv!sarima From: sarima@tdatirv.UUCP (Stanley Friesen) Newsgroups: comp.windows.x Subject: Re: UNIX/X-windows questions Message-ID: <99@tdatirv.UUCP> Date: 25 Jan 91 20:58:25 GMT References: <139@bwilab3.UUCP> <1441@rascal.UUCP> <960@redford.UUCP> Reply-To: sarima@tdatirv.UUCP (Stanley Friesen) Organization: Teradata Corp., Irvine Lines: 25 In article <960@redford.UUCP> bill@redford.UUCP (Bill Poitras(X258)) writes: >>In article <139@bwilab3.UUCP> chris@bwilab3.UUCP (Chris Curtin) writes: >>>Is there a call to see if we are in X? ... >The best way is to try to open the display XOpenDisplay(":0.0"). If it >returns NULL, then you can't connect to the server, whether it is there >or not. The problem with this is that it assumes the application and the X server are on the same machine! A chancy assumption at best, given the design of X. I would try to use something like: dp = getenv(DISPLAY); display = XOpenDisplay(dp); if(display == NULL) { /* use curses or something */ } else { /* Initialize your X toolkit */ } -- --------------- uunet!tdatirv!sarima (Stanley Friesen)