diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | ce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch) | |
tree | 5ac38a06f3dde268dc7927dc155896926aaf7012 /kdeui/tests/qxembedtest.cpp | |
download | tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdeui/tests/qxembedtest.cpp')
-rw-r--r-- | kdeui/tests/qxembedtest.cpp | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/kdeui/tests/qxembedtest.cpp b/kdeui/tests/qxembedtest.cpp new file mode 100644 index 000000000..513231051 --- /dev/null +++ b/kdeui/tests/qxembedtest.cpp @@ -0,0 +1,88 @@ +#include <stdlib.h> +#include <stdio.h> + +#include "qapplication.h" +#include "qpushbutton.h" +#include "qlineedit.h" +#include "qhbox.h" +#include "qvbox.h" +#include "qxembed.h" + +WId windowWithName(const char *); + + +int +main(int argc, char**argv) +{ + if (argc != 2) + { + fprintf(stderr, + "usage: qxembedtest [qtoptions] windowid\n" + " qxembedtest [qtoptions] windowTitle\n"); + exit(10); + } + + + QApplication a(argc,argv); + + QWidget *main = new QVBox(NULL,"main",Qt::WDestructiveClose); + QWidget *top = new QHBox(main); + QPushButton *quit = new QPushButton("Quit", top); + QObject::connect( quit, SIGNAL(clicked()), main, SLOT(close()) ); + QLineEdit *edit = new QLineEdit(top); + edit->setText( "Just to see focus changes"); + QXEmbed *embed = new QXEmbed(main); + embed->setProtocol(QXEmbed::XPLAIN); + a.setMainWidget(main); + main->show(); + + WId wid = strtol(argv[1], NULL, 0); + if (! wid) + wid = windowWithName(argv[1]); + if (! wid) + { + fprintf(stderr,"qxembedtest: window not found\n"); + exit(10); + } + + fprintf(stderr,"qxembedtest: embedding wid=0x%08x\n", (unsigned int)wid); + + embed->embed(wid); + + return a.exec(); +} + + + + + +#include <X11/Xlib.h> +#include <qpaintdevice.h> + +// This is lifted from X11 xprop. + +Window Window_With_Name(Display *dpy, Window top, const char *name) +{ + Window *children, dummy; + unsigned int nchildren; + Window w=0; + char *window_name; + if (XFetchName(dpy, top, &window_name) && !strcmp(window_name, name)) + return(top); + if (!XQueryTree(dpy, top, &dummy, &dummy, &children, &nchildren)) + return(0); + for (unsigned int i=0; i<nchildren; i++) { + w = Window_With_Name(dpy, children[i], name); + if (w) + break; + } + if (children) + XFree ((char *)children); + return(w); +} + + +WId windowWithName(const char *name) +{ + return Window_With_Name(qt_xdisplay(), qt_xrootwin(), name); +} |