diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-11-06 15:56:40 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-11-06 15:56:40 -0600 |
commit | e16866e072f94410321d70daedbcb855ea878cac (patch) | |
tree | ee3f52eabde7da1a0e6ca845fb9c2813cf1558cf /tdeui/tests/qxembedtest.cpp | |
parent | a58c20c1a7593631a1b50213c805507ebc16adaf (diff) | |
download | tdelibs-e16866e072f94410321d70daedbcb855ea878cac.tar.gz tdelibs-e16866e072f94410321d70daedbcb855ea878cac.zip |
Actually move the kde files that were renamed in the last commit
Diffstat (limited to 'tdeui/tests/qxembedtest.cpp')
-rw-r--r-- | tdeui/tests/qxembedtest.cpp | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/tdeui/tests/qxembedtest.cpp b/tdeui/tests/qxembedtest.cpp new file mode 100644 index 000000000..5e870ba8f --- /dev/null +++ b/tdeui/tests/qxembedtest.cpp @@ -0,0 +1,88 @@ +#include <stdlib.h> +#include <stdio.h> + +#include "tqapplication.h" +#include "tqpushbutton.h" +#include "tqlineedit.h" +#include "tqhbox.h" +#include "tqvbox.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); + } + + + TQApplication a(argc,argv); + + TQWidget *main = new TQVBox(NULL,"main",Qt::WDestructiveClose); + TQWidget *top = new TQHBox(main); + TQPushButton *quit = new TQPushButton("Quit", top); + TQObject::connect( quit, TQT_SIGNAL(clicked()), main, TQT_SLOT(close()) ); + TQLineEdit *edit = new TQLineEdit(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 <tqpaintdevice.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); +} |