#include "saverwidget.h" #include #include #include #include #include #include #include #include #include //#include #include "vroot.h" static pid_t childId; static void __attribute((noreturn)) sh(int) { // Clean up if xscreensaver kills us (relay to forked child) kill(childId, SIGTERM); exit(0); } int main(int argc, char **argv) { // Fork once and wait for child so SIGSTOP won't affect us and the counter keeps going // while the auth dialog is up childId = fork(); if (childId != 0) { signal(SIGTERM, sh); signal(SIGINT, sh); int status; for (;;) { pid_t ret = waitpid(childId, &status, 0); if (ret == childId) return 0; if (errno == EINTR) continue; fprintf(stderr, "errno=%d, bye\n", errno); return 1; } } for (int i = 0; i < argc; ++i) { qDebug() << "Argument" << i << "=" << argv[i]; } QApplication app(argc, argv); Display *dpy = QX11Info::display(); if (dpy == nullptr) { fprintf(stderr, "No display"); return 1; } Window win = DefaultRootWindow(dpy); QWindow *xwin = QWindow::fromWinId(win); qDebug() << "Foreign window id is" << win << "pointer is" << xwin; //QWindow *qwin = new QWindow(xwin); //QWidget *w = QWidget::createWindowContainer(qwin); SaverWidget *w = new SaverWidget(win); w->winId(); qDebug() << "New Qt window is" << w << "window handle is" << w->windowHandle(); w->windowHandle()->setParent(xwin); XWindowAttributes attr; // Because QWindow is broken and doesn't report any geometry for foreign windows if (XGetWindowAttributes(dpy, win, &attr)) { qDebug() << "Query:" << attr.width << attr.height; w->setGeometry(0, 0, attr.width, attr.height); } w->show(); app.exec(); return 0; }