4 # include <QtGui/QX11Info>
6 # include <X11/Xatom.h>
9 #include "adopterwindow.h"
12 AdopterWindow::AdopterWindow(QWidget *parent):
13 QMainWindow(parent), grabbingZoomKeys(false), mainChild(0)
16 setAttribute(Qt::WA_Maemo5StackedWindow, true);
17 #endif // Q_WS_MAEMO_5
19 QFrame *frame = new QFrame(this);
20 QVBoxLayout *layout = new QVBoxLayout(frame);
22 frame->setLayout(layout);
23 setCentralWidget(frame);
26 void AdopterWindow::takeChildren(QWidget *main, const QList<QWidget *> &others)
28 Trace t("AdopterWindow::takeChildren");
32 mainChild->setParent(centralWidget());
33 centralWidget()->layout()->addWidget(mainChild);
36 foreach (QWidget *child, others) {
38 child->setParent(this);
43 void AdopterWindow::leaveChildren()
45 Trace t("AdopterWindow::leaveChildren");
47 centralWidget()->layout()->removeWidget(mainChild);
52 void AdopterWindow::grabZoomKeys(bool grab)
54 Trace t("AdopterWindow::grabZoomKeys");
55 grabbingZoomKeys = grab;
59 void AdopterWindow::showEvent(QShowEvent *e)
61 Trace t("AdopterWindow::showEvent");
62 doGrabZoomKeys(grabbingZoomKeys);
63 QMainWindow::showEvent(e);
66 void AdopterWindow::doGrabZoomKeys(bool grab)
68 Trace t("AdopterWindow::doGrabZoomKeys");
71 qDebug() << "Not visible - skipping";
74 qDebug() << "Could not get window ID - skipping";
77 unsigned long val = grab? 1: 0;
78 Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
80 qCritical() << "Unable to obtain _HILDON_ZOOM_KEY_ATOM";
83 XChangeProperty(QX11Info::display(),
89 reinterpret_cast<unsigned char *>(&val),
93 #endif // Q_WS_MAEMO_5