vlc_linux/vlc-3.0.16/modules/gui/qt/components/interface_widgets.cpp
/**
 * Request the video to avoid the conflicts
 **/
Request the video to avoid the conflicts
Request the video to avoid the conflicts
bool VideoWidget::request( struct vout_window_t *p_wnd )
{
    if( stable )
    {
        msg_Dbg( p_intf, "embedded video already in use" );
        return false;
    }
    assert( !p_window );
    stable = new QWidget();
    stable->setContextMenuPolicy( Qt::PreventContextMenu );
    QPalette plt = palette();
    plt.setColor( QPalette::Window, Qt::black );
    stable->setPalette( plt );
    stable->setAutoFillBackground(true);
    stable->setAttribute( Qt::WA_NativeWindow, true );
#if !defined (QT5_HAS_X11)
    stable->setAttribute( Qt::WA_PaintOnScreen, true );
#else
    stable->setMouseTracking( true );
    setMouseTracking( true );
#endif
    layout->addWidget( stable );
    sync();
    p_window = p_wnd;
    p_wnd->type = p_intf->p_sys->voutWindowType;
    switch( p_wnd->type )
    {
        case VOUT_WINDOW_TYPE_XID:
            p_wnd->handle.xid = stable->winId();
            p_wnd->display.x11 = NULL;
            break;
        case VOUT_WINDOW_TYPE_HWND:
            p_wnd->handle.hwnd = (void *)stable->winId();
            break;
        case VOUT_WINDOW_TYPE_NSOBJECT:
            p_wnd->handle.nsobject = (void *)stable->winId();
            break;
#ifdef QT5_HAS_WAYLAND
        case VOUT_WINDOW_TYPE_WAYLAND:
        {
            stable->setAttribute( Qt::WA_DontCreateNativeAncestors, true);
            QWindow *window = stable->windowHandle();
            assert(window != NULL);
            window->create();
            QPlatformNativeInterface *qni = qApp->platformNativeInterface();
            assert(qni != NULL);
            p_wnd->handle.wl = static_cast<wl_surface*>(
                qni->nativeResourceForWindow(QByteArrayLiteral("surface"),
                                             window));
            p_wnd->display.wl = static_cast<wl_display*>(
                qni->nativeResourceForIntegration(QByteArrayLiteral("wl_display")));
            break;
        }
#endif
        default:
            vlc_assert_unreachable();
    }
    return true;
}
bool VideoWidget :: request ( struct vout_window_t * p_wnd ) { if ( stable ) { msg_Dbg ( p_intf , " " ) ; return false ; } assert ( ! p_window ) ; stable = new QWidget ( ) ; stable -> setContextMenuPolicy ( Qt :: PreventContextMenu ) ; QPalette plt = palette ( ) ; plt . setColor ( QPalette :: Window , Qt :: black ) ; stable -> setPalette ( plt ) ; stable -> setAutoFillBackground ( true ) ; stable -> setAttribute ( Qt :: WA_NativeWindow , true ) ; #if ! defined ( QT5_HAS_X11 ) stable -> setAttribute ( Qt :: WA_PaintOnScreen , true ) ; #else stable -> setMouseTracking ( true ) ; setMouseTracking ( true ) ; #endif layout -> addWidget ( stable ) ; sync ( ) ; p_window = p_wnd ; p_wnd -> type = p_intf -> p_sys -> voutWindowType ; switch ( p_wnd -> type ) { case VOUT_WINDOW_TYPE_XID : p_wnd -> handle . xid = stable -> winId ( ) ; p_wnd -> display . x11 = NULL ; break ; case VOUT_WINDOW_TYPE_HWND : p_wnd -> handle . hwnd = ( void * ) stable -> winId ( ) ; break ; case VOUT_WINDOW_TYPE_NSOBJECT : p_wnd -> handle . nsobject = ( void * ) stable -> winId ( ) ; break ; #ifdef QT5_HAS_WAYLAND case VOUT_WINDOW_TYPE_WAYLAND : { stable -> setAttribute ( Qt :: WA_DontCreateNativeAncestors , true ) ; QWindow * window = stable -> windowHandle ( ) ; assert ( window != NULL ) ; window -> create ( ) ; QPlatformNativeInterface * qni = qApp -> platformNativeInterface ( ) ; assert ( qni != NULL ) ; p_wnd -> handle . wl = static_cast < wl_surface * > ( qni -> nativeResourceForWindow ( QByteArrayLiteral ( " " ) , window ) ) ; p_wnd -> display . wl = static_cast < wl_display * > ( qni -> nativeResourceForIntegration ( QByteArrayLiteral ( " " ) ) ) ; break ; } #endif default : vlc_assert_unreachable ( ) ; } return true ; }
Request the video to avoid the conflicts
Request the video to avoid the conflicts
/* The owner of the video window needs a stable handle (WinId). Reparenting
     * in Qt4-X11 changes the WinId of the widget, so we need to create another
     * dummy widget that stays within the reparentable widget. */ /* Force the widget to be native so that it gets a winId() */ /* Indicates that the widget wants to draw directly onto the screen.
       Widgets with this attribute set do not participate in composition
       management */ /* This is currently disabled on X11 as it does not seem to improve
     * performance, but causes the video widget to be transparent... */ /* Ensure only the video widget is native (needed for Wayland) */