[SOLVED] Can I create an Xwin Window from a Console App when Xwin is running?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Can I create an Xwin Window from a Console App when Xwin is running?
I'm not new to linux but am fairly new to Xwin. I have a well structured console application to which I'd like to add graphics output. I could port it to Xwin, but that's a pain, I just want to display some graphics. Is this doable? I seem to be able to make the calls, but the window never appears. If I do the same calls (which seem to return the same valid values) from a Xwin application it all works fine. What's going on?
Is it as simple as configuring my console to a different mode? I find I can't execute this application from an X browser either, and I thought I used to be able to do that. IE click on a console application and have it open a console box and run the application.
You're being caught out by X' security (most likely) ...
To make it work on your local machine you'll need to do two things:
a) in the active X11 session (as the user owning the session) permit
local X11 programs to display:
Code:
xhost +localhost
b) from your console:
Code:
export DISPLAY=:0.0
If that doesn't resolve your problem, try running your program under
strace control, and see whether that gives you insight as to why it's
failing to do your bidding.
thanks for the tips, afraid I still don't get a) above.
b) I understand, but where would I enter/do config for a)?
I am currently running a KDE style front end to Xwin. I looked at the console configuration options, and see nothing like that.
Can you hold my hand a little more and tell me where to go to set this up?
Again, thanks for the helping hand, it would be much easier if I can get it to work this way...
Maybe we need to clarify terms first. When you say 'console', are
you talking about a full-screen ASCII terminal outside the GUI, or
an xterm llook-alike like konsole?
What *I* thought you meant was that you have a program that you
want to be able to run as any user from any console (the full screen
one) and display on the same machines X11 graphical subsystem.
The a) above grants any process from the local machine to display
graphical content in the current X11 session (or the first one, to
be pedantic - you could obviously have more than one X session going
at the same time). The "xhost +localhost" needs to be issued in
the running X session.
Unfortunately you are confusing me more rather than less.
The first question I am trying to ask is where/how am I to
issue the command you suggest:
"The "xhost +localhost" needs to be issued in
the running X session."
Ok I have the KDE desktop up and running, where am I supposed to do this? Its a GUI not a command line interface, puzzled.
Is there a configuration window/screen I should be in, if so where?
Oh wait, maybe I get it, 'xhost' is a program I run in console mode. I'll try that.
Further in my experience, If I run the Xserver with the KDE, or
any other front end, I can not at the same time have any 'real full fledged consoles' at all. All I can have are emulated console boxes which I open from the start menu. These act much like the full screen consoles I can open if X is not running, but are X aware. Its one of these console boxes under Xwin that I want to use to run my text mode application. I think it probably is a kconsole.
Last edited by will_kranz; 06-20-2010 at 07:37 PM.
Unfortunately you are confusing me more rather than less.
The first question I am trying to ask is where/how am I to
issue the command you suggest:
"The "xhost +localhost" needs to be issued in
the running X session."
Ok I have the KDE desktop up and running, where am I supposed to do this? Its a GUI not a command line interface, puzzled.
Is there a configuration window/screen I should be in, if so where?
Open any terminal (konsole, xterm, rxvt, ... ) and enter
xhost +localhost
Quote:
Originally Posted by will_kranz
Further in my experience, If I run the Xserver with the KDE, or
any other front end, I can not at the same time have any 'real full fledged consoles' at all. All I can have are emulated console boxes which I open from the start menu. These act much like the full screen consoles I can open if X is not running, but are X aware. Its one of these console boxes under Xwin that I want to use to run my text mode application. I think it probably is a kconsole.
That should just work then. If you're running your app
as the user who owns the X-session, and it doesn't change
privileges after you start it it should actually "just work".
Tinkster seems to be the only one watching this, but just in case someone else comes along, I was making a big newbie mistake. The xhost and security issue is interesting, but was not my problem.
It was more fundmental. I had not read the manual carefully and did not realize that Xwin queues requests to the server. I did all my setup,
including an XMapRaised() call. But I never called XNextEvent() which has the side effect of sending all the pending requests to the server! Sigh.
Live and learn.
I now have a new problem, namely the new window I have created seems to
have control now and I can't get it to go back to the original console window for input processing which is what I need. But lets consider this solved and I will read the Xlib Ref further before asking more questions!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.