コード例 #1
0
ファイル: plasmaeffects.cpp プロジェクト: hbarve1/greenisland
void PlasmaEffects::effects_slide(Resource *resource,
                                  wl_resource *outputResource,
                                  wl_resource *surfaceResource,
                                  uint32_t from,
                                  int32_t x, int32_t y)
{
    Q_UNUSED(resource);

    QWaylandOutput *output = QWaylandOutput::fromResource(outputResource);
    if (!output) {
        qCWarning(PLASMA_EFFECTS_PROTOCOL) << "Couldn't get output from resource";
        return;
    }

    QWaylandSurface *surface = QWaylandSurface::fromResource(surfaceResource);
    if (!surface) {
        qCWarning(PLASMA_EFFECTS_PROTOCOL) << "Couldn't get surface from resource";
        return;
    }

    QPointF ptFrom;
    QPointF ptTo(x, y);

    switch (from) {
    case location_none:
        ptFrom.setX(output->geometry().width() / 2);
        ptFrom.setY(output->geometry().height() / 2);
        break;
    case location_left:
        ptFrom = QPointF(-surface->size().width(), 0);
        break;
    case location_top:
        ptFrom = QPointF(0, -surface->size().height());
        break;
    case location_right:
        ptFrom = QPointF(output->geometry().width() +
                         surface->size().width(), 0);
        break;
    case location_bottom:
        ptFrom = QPointF(0, output->geometry().height() +
                         surface->size().height());
        break;
    }

    for (const PlasmaSurface *plasmaSurface: m_shell->surfaces()) {
        if (plasmaSurface->surface() == surface)
            Q_EMIT plasmaSurface->window()->moveRequested(ptFrom, ptTo);
    }
}
コード例 #2
0
void QWindowCompositor::paintChildren(QWaylandSurface *surface, QWaylandSurface *window, const QSize &windowSize) {

    if (surface->subSurfaces().size() == 0)
        return;

    QLinkedListIterator<QWaylandSurface *> i(surface->subSurfaces());
    while (i.hasNext()) {
        QWaylandSurface *subSurface = i.next();
        QPointF p = subSurface->mapTo(window,QPointF(0,0));
        QSize subSize = subSurface->size();
        subSurface->advanceBufferQueue();
        if (subSize.isValid()) {
            GLuint texture = 0;
            if (subSurface->type() == QWaylandSurface::Texture) {
                texture = subSurface->texture(QOpenGLContext::currentContext());
            } else if (surface->type() == QWaylandSurface::Shm ) {
                texture = m_textureCache->bindTexture(QOpenGLContext::currentContext(),surface->image());
            }
            QRect geo(p.toPoint(),subSize);
            if (texture > 0)
                m_textureBlitter->drawTexture(texture,geo,windowSize,0,window->isYInverted(),subSurface->isYInverted());
            if (surface->type() == QWaylandSurface::Shm)
                glDeleteTextures(1, &texture);
        }
        paintChildren(subSurface,window,windowSize);
    }
}
コード例 #3
0
ファイル: compositor.cpp プロジェクト: webOS-ports/luna-next
void Compositor::onXdgToplevelCreated(QWaylandXdgToplevel *toplevel, QWaylandXdgSurface *shellSurface)
//void Compositor::onXdgSurfaceCreated(QWaylandXdgSurface *shellSurface)
{
    unsigned int windowId = mNextWindowId++;
    QWaylandSurface *surface = shellSurface->surface();

    qDebug() << Q_FUNC_INFO << "windowId" << windowId << surface;

    QQuickWindow *defaultOutputWindow = static_cast<QQuickWindow*>(defaultOutput()->window());
    CompositorWindow *window = new CompositorWindow(windowId, defaultOutputWindow->contentItem());

    window->setOutput(defaultOutput()); //useful ?
    window->setFlag(QQuickItem::ItemIsFocusScope, true);
    // window->setUseTextureAlpha(true);

    window->initialize(shellSurface);
    window->setSize(surface->size());
    window->setTouchEventsEnabled(true);

    mWindows.insert(windowId, window);

    connect(window, &CompositorWindow::readyChanged, this, &Compositor::windowIsReady);
    connect(window, &QWaylandQuickItem::surfaceDestroyed, this, &Compositor::onSurfaceDestroyed);

    window->sendWindowIdToClient();
}
コード例 #4
0
void LipstickCompositor::surfaceMapped()
{
    QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender());
    //Ignore surface if it's not a window surface
    if (!surface->hasShellSurface())
        return;

    QVariantMap properties = surface->windowProperties();
    QString category = properties.value("CATEGORY").toString();

    if (surface->surfaceItem())
        return;

    // The surface was mapped for the first time
    int id = m_nextWindowId++;
    LipstickCompositorWindow *item = new LipstickCompositorWindow(id, category, surface, contentItem());
    item->setSize(surface->size());
    QObject::connect(item, SIGNAL(destroyed(QObject*)), this, SLOT(windowDestroyed()));
    m_totalWindowCount++;
    m_mappedSurfaces.insert(id, item);

    item->setTouchEventsEnabled(true);

    emit windowCountChanged();
    emit windowAdded(item);

    windowAdded(id);

    emit availableWinIdsChanged();
}
コード例 #5
0
void LipstickCompositor::surfaceSizeChanged()
{
    QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender());

    LipstickCompositorWindow *window = static_cast<LipstickCompositorWindow *>(surface->surfaceItem());
    if (window)
        window->setSize(surface->size());
}
コード例 #6
0
QWaylandSurface *QWindowCompositor::surfaceAt(const QPointF &point, QPointF *local)
{
    for (int i = m_surfaces.size() - 1; i >= 0; --i) {
        QWaylandSurface *surface = m_surfaces.at(i);
        QRectF geo(surface->pos(), surface->size());
        if (geo.contains(point)) {
            if (local)
                *local = toSurface(surface, point);
            return surface;
        }
    }
    return 0;
}
コード例 #7
0
void QtwaylandSurfaceNode::paintChildren(QWaylandSurface *surface, QWaylandSurface *window, OpenGLData *glData) {

    if (surface->subSurfaces().size() == 0)
        return;

    QLinkedListIterator<QWaylandSurface *> i(surface->subSurfaces());
    while (i.hasNext()) {
        QWaylandSurface *subSurface = i.next();
        QPointF p = subSurface->mapTo(window,QPointF(0,0));
        if (subSurface->size().isValid()) {
            GLuint texture = 0;
            if (subSurface->type() == QWaylandSurface::Texture) {
                texture = subSurface->texture(QOpenGLContext::currentContext());
            } else if (surface->type() == QWaylandSurface::Shm ) {
                texture = glData->m_textureCache->bindTexture(QOpenGLContext::currentContext(),surface->image());
            }
            QRect geo(p.toPoint(),subSurface->size());
            glData->m_textureBlitter->drawTexture(texture,geo,window->size(),0,window->isYInverted(),subSurface->isYInverted());
        }
        paintChildren(subSurface,window, glData);
    }
}
コード例 #8
0
void QWindowCompositor::surfaceMapped()
{
    QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender());
    QPoint pos;
    if (!m_surfaces.contains(surface)) {
        uint px = 0;
        uint py = 0;
        if (!QCoreApplication::arguments().contains(QLatin1String("-stickytopleft"))) {
            px = 1 + (qrand() % (m_window->width() - surface->size().width() - 2));
            py = 1 + (qrand() % (m_window->height() - surface->size().height() - 2));
        }
        pos = QPoint(px, py);
        surface->setPos(pos);
    } else {
        m_surfaces.removeOne(surface);
    }
    //Sometimes surfaces dont have shell_surfaces, so don't render them
    if (surface->hasShellSurface()) {
        m_surfaces.append(surface);
        defaultInputDevice()->setKeyboardFocus(surface);
    }
    m_renderScheduler.start(0);
}