void QtWaylandMotorcarCompositor::surfaceMapped()
{
    QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender());

    std::cout << "mapped surface: " << surface << std::endl;

    QPoint pos;
    //if (!m_surfaces.contains(surface)) {

    //surface->setPos(QPoint(0, 0));
    if (surface->hasShellSurface()) {

        motorcar::WaylandSurface::SurfaceType surfaceType;

        int type = static_cast<int>(surface->windowType());
        float popupZOffset = 0.05;


        if(type == QWaylandSurface::WindowType::Toplevel) {
            surfaceType = motorcar::WaylandSurface::SurfaceType::TOPLEVEL;
        } else if(type == QWaylandSurface::WindowType::Popup) {
            surfaceType = motorcar::WaylandSurface::SurfaceType::POPUP;
        } else if(type == QWaylandSurface::WindowType::Transient) {
            surfaceType = motorcar::WaylandSurface::SurfaceType::TRANSIENT;
        } else {
            surfaceType = motorcar::WaylandSurface::SurfaceType::NA;
        }

        QtWaylandMotorcarSurface *motorsurface = this->getMotorcarSurface(surface);
        if(motorsurface == NULL) {
            //if it is not present for some weird reason just go ahead and create it for good measure
            std::cout << "Warning: qwaylandsurface was mapped but motorcar surface does not exist yet, creating now" <<std::endl;
//                surfaceCreated(surface);
//                surfaceNode = this->getSurfaceNode(surface);
            motorsurface = new QtWaylandMotorcarSurface(surface, this, motorcar::WaylandSurface::SurfaceType::NA);

            m_surfaceMap.insert(std::pair<QWaylandSurface *, QtWaylandMotorcarSurface *>(surface, motorsurface));

        }
//            if((motorsurface->type() == motorcar::WaylandSurface::SurfaceType::CUBOID ||
//                motorsurface->type() == motorcar::WaylandSurface::SurfaceType::PORTAL)
//                 && surfaceType == motorcar::WaylandSurface::SurfaceType::TOPLEVEL){
//                std::cout << "Warning: ignoring request to remap a 3D surface to a top level surface " <<std::endl;
//            }else{
        this->scene()->windowManager()->mapSurface(motorsurface, surfaceType);
//            }





        //defaultInputDevice()->setKeyboardFocus(surface);

    }




    //m_renderScheduler.start(0);
}
예제 #2
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();
}
예제 #3
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);
}
예제 #4
0
void SystemCompositor::surfaceMapped()
{
    QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender());

    //A surface without a shell surface is not a window
    if (!surface->hasShellSurface())
        return;

    QWaylandSurfaceItem *item = surface->surfaceItem();

    // Create a QWaylandSurfaceItem from the surface
    if (!item) {
        item = new QWaylandSurfaceItem(surface, rootObject());
        item->setClientRenderingEnabled(true);
        item->setTouchEventsEnabled(true);
    }

    // Surface items gain focus right after they were mapped
    item->takeFocus();

    // Announce a window was added
    emit windowAdded(QVariant::fromValue(static_cast<QQuickItem *>(item)));
}