LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Why I can't get X Display handle? (https://www.linuxquestions.org/questions/programming-9/why-i-cant-get-x-display-handle-698253/)

leeward.xie 01-19-2009 01:03 AM

Why I can't get X Display handle?
 
I call XOpenDisplay to connect to the X server but get a NULL pointer. My client program run in the text terminal, not GUI desktop. I have got the MIT key using the xauth and set the enviroment variable DISPLAY to "localhost/unix:0". My linux distribution is openSUSE 11.1.

I have test our program on Ubuntu, Debian and SLE10-sp2, it's ok. So I am confused. :confused:

SciYro 01-19-2009 02:08 AM

We are all confused, as you havent asked any questions, nore provided any real information. There could be a number of issues, so Ill just list a checklist.

* Does your program work under normal X? (run the program in a xterm or such under a user thats running and using X)
* Can other X programs run under your test conditions? (see if its only your program that has a problem)
* Are you using passing a custom string to XOpenDisplay or are using the normal NULL?
* Try other DISPLAYs, such as ':0' or ':0.0'

leeward.xie 01-19-2009 03:43 AM

Quote:

Originally Posted by SciYro (Post 3413502)
We are all confused, as you havent asked any questions, nore provided any real information. There could be a number of issues, so Ill just list a checklist.

* Does your program work under normal X? (run the program in a xterm or such under a user thats running and using X)
* Can other X programs run under your test conditions? (see if its only your program that has a problem)
* Are you using passing a custom string to XOpenDisplay or are using the normal NULL?
* Try other DISPLAYs, such as ':0' or ':0.0'

Thanks. I'am sorry for my confused question.

>>* Does your program work under normal X? (run the program in a xterm or such under a user thats running and using X)
Yes. All is OK under the GUI desktop enviroment. There is the connection problem under the normal character terminal.

>>* Can other X programs run under your test conditions? (see if its only your program that has a problem)
No. I wrote the program just to test if it's OK to connect to the X server so it's very simple, which just call XOpenDisplay and XCloseDisplay.

>>* Are you using passing a custom string to XOpenDisplay or are using the normal NULL?
>>* Try other DISPLAYs, such as ':0' or ':0.0'
I have tried :0.0, :0, but return error:
No protocol specified
I have tried NULL, localhost/unix:0, localhost:0, localhost/unix:0.0, localhost:0.0, but get NULL Display pointer.

SciYro 01-19-2009 06:27 AM

If the program works under X, then open a xterm and check the DISPLAY ("env | grep DISPLAY"), then set it your terminal according to that.

By any chance did the out was anything useful? If its a permissions error, the output should have something like "connection refused" or somesuch.

wje_lq 01-19-2009 09:53 AM

Quote:

If the program works under X, then open a xterm and check the DISPLAY ("env | grep DISPLAY"), then set it your terminal according to that.
Just the opposite, if I read the situation correctly. The program works when he runs it under X on the local host. But when he wants to run it on the desired X server, it doesn't work. Presumably running xterm on that desired X server doesn't work either. I'm hoping he'll correct me if I'm wrong. :)

leeward.xie 01-19-2009 07:53 PM

Quote:

Originally Posted by SciYro (Post 3413692)
If the program works under X, then open a xterm and check the DISPLAY ("env | grep DISPLAY"), then set it your terminal according to that.

By any chance did the out was anything useful? If its a permissions error, the output should have something like "connection refused" or somesuch.

It's not permission problem. I have tested my program under Ubuntu 8.10, Debian (4.0 and 5.0), SLE10-sp2 and all are OK.

I wonder why there is the problem under openSUSE 11.1.


All times are GMT -5. The time now is 05:16 PM.