LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to hide a program's GUI? (https://www.linuxquestions.org/questions/programming-9/how-to-hide-a-programs-gui-878291/)

Neoh2009 05-02-2011 05:17 AM

How to hide a program's GUI?
 
Hello everyone! Firstly, I will apologize if this question has been asked. I have googled for nearly a week, and did not gain a lot. I am not green to both linux or programming, but I found this is a tough question for me. I hope anyone of you can help me. I will be very thankful.
Now I am going to descrip the question in detail.(Sorry for my poor English, because it's not my mother tongue)
I want to implement a software that can show other programs in mine. Consequently, I shoud firstly let the program hide when running, and then I get the screen shot of it. I know this sounds incredible. But someone has already implemented it, such as VNC. The VNC can open another display(display is a word used in X Window), and the VNC can take a screen shot and show it to the client.
I will be appreciate if anyone can give me some guidances. Thanks again.

Sergei Steshenko 05-02-2011 05:29 AM

Quote:

Originally Posted by Neoh2009 (Post 4343699)
Hello everyone! Firstly, I will apologize if this question has been asked. I have googled for nearly a week, and did not gain a lot. I am not green to both linux or programming, but I found this is a tough question for me. I hope anyone of you can help me. I will be very thankful.
Now I am going to descrip the question in detail.(Sorry for my poor English, because it's not my mother tongue)
I want to implement a software that can show other programs in mine. Consequently, I shoud firstly let the program hide when running, and then I get the screen shot of it. I know this sounds incredible. But someone has already implemented it, such as VNC. The VNC can open another display(display is a word used in X Window), and the VNC can take a screen shot and show it to the client.
I will be appreciate if anyone can give me some guidances. Thanks again.

I am not sure I understand your question/problem; various GUI toolkits consist of widgets, and the widgets typically have 'show' and 'hide' functions. so, when 'hide' function is called, the widget is hidden. Actually, typically initially widgets are hidden, and 'show' must be called in order to make the widget visible.

Neoh2009 05-02-2011 07:12 AM

Quote:

Originally Posted by Sergei Steshenko (Post 4343704)
I am not sure I understand your question/problem; various GUI toolkits consist of widgets, and the widgets typically have 'show' and 'hide' functions. so, when 'hide' function is called, the widget is hidden. Actually, typically initially widgets are hidden, and 'show' must be called in order to make the widget visible.

Thank you for your answer.
I am sorry if I am not make the question clear. I know there are some libs for GUI programming and they have the functions to hide a Widget. For example, it's easy to make a window, which you designed, to hide with Qt. But the window that I want to hide is not designed by me. It is created by an application that has already been compiled and linked to a binary file. And I want to run this binary file but hide the GUI.
I have two ways in my mind.
1.redirect the GUI output to another virtual device.
2.open another display to paint the GUI.
I think the second way is more possible to implement. Because it's the way the VNC uses.

MTK358 05-02-2011 11:39 AM

I think that intead of thinking about hiding the original GUI and taking screenshots, you should think about integrating the existing GUI into a widget of your application. There are many existing X11 apps that do that.

Neoh2009 05-03-2011 06:13 AM

Quote:

Originally Posted by MTK358 (Post 4344068)
I think that intead of thinking about hiding the original GUI and taking screenshots, you should think about integrating the existing GUI into a widget of your application. There are many existing X11 apps that do that.

Hello, MTK358.
Yes, that's a good idea! But I have no idea about the Xlib or X11. Can you give me an example? For example, give me a function to implement this or the X11 apps' names. Now, I am going to do some research in the X11 and Xlib.
And thank you for your idea which help me a lot.

theNbomr 05-04-2011 09:25 AM

Quote:

Originally Posted by MTK358 (Post 4344068)
integrating the existing GUI into a widget of your application. There are many existing X11 apps that do that.

Cool. Please cite some examples.

To the OP: if your GUI applications are known to use X, then one method that can be used to conceal an application's GUI is to run it with a virtual X server. The standard for this is Xvfb (X virtual frame buffer). It is an X server that provides no visual output, and no keyboard or pointer, but allows client applications to use X services. It's screen representation is stored in a specified disk file, and the file format can be captured as a bitmap image, should you need it for some visualization or analysis (or embedding, perhaps).

--- rod.

MTK358 05-04-2011 10:04 AM

Quote:

Originally Posted by theNbomr (Post 4346271)
Cool. Please cite some examples.

FVWM's "FvwmButtons" lets you embed X applications into it.

I also heard that Qt can do it with something called "QX11Embed", but I can't find any docs, just some forum and mailing list dicsussions about it.

EDIT: http://doc.trolltech.com/solutions/qtxembed/

Neoh2009 05-05-2011 07:54 AM

Quote:

Originally Posted by MTK358 (Post 4346303)
FVWM's "FvwmButtons" lets you embed X applications into it.

I also heard that Qt can do it with something called "QX11Embed", but I can't find any docs, just some forum and mailing list dicsussions about it.

EDIT: http://doc.trolltech.com/solutions/qtxembed/

I am now using Qt to implement my application. I find the docs in Qt4 Assistant. This is a example below, and I hope that will help more people.
#include <QtGui>
#include <QApplication>
#include <QX11EmbedContainer>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);

if (app.arguments().count() != 2) {
qFatal("Error - expected executable path as argument");
return 1;
}

QX11EmbedContainer container;
container.show();

QProcess process(&container);
QString executable(app.arguments()[1]);
QStringList arguments;
arguments << QString::number(container.winId());
process.start(executable, arguments);

int status = app.exec();
process.close();
return status;
}
// you try execute "./main $path/$myAppName" to see whether it works or not.
There's a limitation for QX11EmbedContainer according to the Assistant. The QX11EmbedContainer can only embed the XEmbed widgets. "XEmbed is an X11 protocol that supports the embedding of a widget from one application into another application." But how can I know which application follow the XEmbed proticol? I am still working on it.

MTK358 05-05-2011 08:02 AM

Maybe XEmbed isn't what you're looking for.

I don't really know much about this, I just know that there are applications that can embed other X applications.

Neoh2009 05-06-2011 10:34 AM

Quote:

Originally Posted by MTK358 (Post 4347334)
Maybe XEmbed isn't what you're looking for.

I don't really know much about this, I just know that there are applications that can embed other X applications.

Anyway, it's a very cool idea. And thank you for your time.
I've found it is possible to open another display on linux platform. And I think I am close to the answer. Now, the task for me is to setup configurations to the X window. This task may not be about programming. I will do the research by myself.

ThomasAdam 05-08-2011 09:38 AM

Quote:

Originally Posted by MTK358 (Post 4346303)
FVWM's "FvwmButtons" lets you embed X applications into it.

No -- be careful with the word "embed" here. It *does not* use Xembed, which most people might assume. Instead, it simply reparents applications based on whichever hangon it's told to look for. This has the advantage of not having to rely on applications not being Xembed aware. That, and FvwmButtons was written long before that half-broken spec. came about.

-- Thomas Adam


All times are GMT -5. The time now is 01:12 AM.