Example #1
0
void Compositor::onSurfaceMappedChanged()
{
    QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender());
    CompositorWindow *window = surfaceWindow(surface);
    if(window && surface) {
        if(surface->hasContent()) {
            qDebug() << __PRETTY_FUNCTION__ << " MAPPED " << window << "appId" << window->appId() << "windowType" << window->windowType();

            // If it was a window created by QtWebProcess, it may be not already in our WindowModel list
            if (!WindowModel::isWindowAlreadyAdded(mWindowModels, window)) {
                qDebug() << Q_FUNC_INFO << "Adding window" << window << "to our models";
                emit windowAdded(QVariant::fromValue(static_cast<QQuickItem*>(window)));
                WindowModel::addWindowForEachModel(mWindowModels, window);
            }
            emit windowShown(QVariant::fromValue(static_cast<QQuickItem*>(window)));
        }
        else {
            qDebug() << __PRETTY_FUNCTION__ << " UNMAPPED " << window << "appId" << window->appId() << "windowType" << window->windowType();

            if (window == mFullscreenWindow)
                setFullscreenWindow(0);

            emit windowHidden(QVariant::fromValue(static_cast<QQuickItem*>(window)));
        }
    }
}
Example #2
0
void WindowBase::close()
{
    // Delete the window implementation
    delete m_impl;
    m_impl = NULL;

    // Update the fullscreen window
    if (this == getFullscreenWindow())
        setFullscreenWindow(NULL);
}
Example #3
0
void WindowBase::create(VideoMode mode, const String& title, Uint32 style)
{
    // Destroy the previous window implementation
    close();

    // Fullscreen style requires some tests
    if (style & Style::Fullscreen)
    {
        // Make sure there's not already a fullscreen window (only one is allowed)
        if (getFullscreenWindow())
        {
            err() << "Creating two fullscreen windows is not allowed, switching to windowed mode" << std::endl;
            style &= ~Style::Fullscreen;
        }
        else
        {
            // Make sure that the chosen video mode is compatible
            if (!mode.isValid())
            {
                err() << "The requested video mode is not available, switching to a valid mode" << std::endl;
                mode = VideoMode::getFullscreenModes()[0];
            }

            // Update the fullscreen window
            setFullscreenWindow(this);
        }
    }

    // Check validity of style according to the underlying platform
    #if defined(SFML_SYSTEM_IOS) || defined(SFML_SYSTEM_ANDROID)
        if (style & Style::Fullscreen)
            style &= ~Style::Titlebar;
        else
            style |= Style::Titlebar;
    #else
        if ((style & Style::Close) || (style & Style::Resize))
            style |= Style::Titlebar;
    #endif

    // Recreate the window implementation
    m_impl = priv::WindowImpl::create(mode, title, style, ContextSettings(0, 0, 0, 0, 0, 0xFFFFFFFF, false));

    // Perform common initializations
    initialize();
}
Example #4
0
void Compositor::onSurfaceDestroyed()
{
    CompositorWindow *window = static_cast<CompositorWindow*>(sender());

    qDebug() << Q_FUNC_INFO << window;

    if (window == mFullscreenWindow)
        setFullscreenWindow(0);

    if (window) {
        if (WindowModel::isWindowAlreadyAdded(mWindowModels, window)) {
            WindowModel::removeWindowForEachModel(mWindowModels, window);
            emit windowRemoved(QVariant::fromValue(static_cast<QQuickItem*>(window)));
        }

        mWindows.remove(window->winId());

        // window->deleteLater(); // not needed: the deletion of the surface will trigger the deletion of its extensions, among which is our CompositorWindow
    }
}