Ejemplo n.º 1
0
// A very simple implementation where we assume that there's only one window and that it's a
// QQuickWindow. Thus the id parameter is irrelevant.
//
// Idea: Make the id contain the objectName of the QQuickWindow once we care about a multi-display
//       compositor?
//       Strictly speaking that could be the actual QWindow::winId(), but that's mostly a
//       meaningless arbitrary number.
QImage WindowScreenshotProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
{
    Q_UNUSED(id);
    Q_UNUSED(requestedSize);

    QWindowList windows = QGuiApplication::topLevelWindows();

    if (windows.count() != 1) {
        size->rwidth() = 0;
        size->rheight() = 0;
        return QImage();
    }

    QQuickWindow *quickWindow = qobject_cast<QQuickWindow *>(windows[0]);

    if (!quickWindow) {
        size->rwidth() = 0;
        size->rheight() = 0;
        return QImage();
    }

    QImage image = quickWindow->grabWindow();
    size->rwidth() = image.width();
    size->rheight() = image.height();
    return image;
}
Ejemplo n.º 2
0
Archivo: Main.cpp Proyecto: Acly/hdrv
void moveToForeground()
{
  QWindowList l = QGuiApplication::allWindows();
  if (l.size() > 0 && l.at(0) != nullptr) {
    QWindow* w = l.at(0);
    w->requestActivate();
    if (w->windowState() & Qt::WindowMinimized) {
      w->showNormal();
    }
  }
}
Ejemplo n.º 3
0
/*!
    Return the given top level window for a given position.

    Default implementation retrieves a list of all top level windows and finds the first window
    which contains point \a pos
*/
QWindow *QPlatformScreen::topLevelAt(const QPoint & pos) const
{
    QWindowList list = QGuiApplication::topLevelWindows();
    for (int i = list.size()-1; i >= 0; --i) {
        QWindow *w = list[i];
        if (w->isVisible() && w->geometry().contains(pos))
            return w;
    }

    return 0;
}
Ejemplo n.º 4
0
QWindow *QWinEventFilter::findWindow(HWND handle)
{
    QWindow *w = 0;
    QWindowList list = qApp->topLevelWindows();
    for (int i = 0; i < list.size(); i++) {
        if (list.at(i)->winId() == reinterpret_cast<WId>(handle)) {
            w = list.at(i);
            break;
        }
    }
    return w;
}
Ejemplo n.º 5
0
QT_BEGIN_NAMESPACE

#ifndef QT_NO_DRAGANDDROP

static QWindow* topLevelAt(const QPoint &pos)
{
    QWindowList list = QGuiApplication::topLevelWindows();
    for (int i = list.count()-1; i >= 0; --i) {
        QWindow *w = list.at(i);
        if (w->isVisible() && w->geometry().contains(pos) && !qobject_cast<QShapedPixmapWindow*>(w))
            return w;
    }
    return 0;
}
QWindow *MouseTouchAdaptor::findQWindowWithXWindowID(WId windowId)
{
    QWindowList windowList = QGuiApplication::topLevelWindows();
    QWindow *foundWindow = nullptr;

    int i = 0;
    while (!foundWindow && i < windowList.count()) {
        QWindow *window = windowList[i];
        if (window->winId() == windowId) {
            foundWindow = window;
        } else {
            ++i;
        }
    }

    Q_ASSERT(foundWindow);
    return foundWindow;
}
Ejemplo n.º 7
0
void Nexus::updateWindowsArg(QWindow* closedWindow)
{
    QWindowList windowList = QApplication::topLevelWindows();
    delete windowActions;
    windowActions = new QActionGroup(this);

    windowMenu->addSeparator();

    QAction* dockLast;
    if (dockMenu->actions().count() != 0)
        dockLast = dockMenu->actions().first();
    else
        dockLast = nullptr;

    QWindow* activeWindow;

    if (QApplication::activeWindow())
        activeWindow = QApplication::activeWindow()->windowHandle();
    else
        activeWindow = nullptr;

    for (int i = 0; i < windowList.size(); ++i)
    {
        if (closedWindow == windowList[i])
            continue;

        QAction* action = windowActions->addAction(windowList[i]->title());
        action->setCheckable(true);
        action->setChecked(windowList[i] == activeWindow);
        connect(action, SIGNAL(triggered()), windowMapper, SLOT(map()));
        windowMapper->setMapping(action, windowList[i]);
        windowMenu->addAction(action);
        dockMenu->insertAction(dockLast, action);
    }

    if (dockLast && !dockLast->isSeparator())
        dockMenu->insertSeparator(dockLast);
}