[vlc-devel] [RFC PATCH] qt: Use XCB events to notify of a video widget resize

Rémi Denis-Courmont remi at remlab.net
Tue Apr 25 18:36:37 CEST 2017


Le tiistaina 25. huhtikuuta 2017, 11.12.10 EEST Hugo Beauzée-Luyssen a écrit :
> This obviously lacks support for wayland,

At least Fedora has switched, so Wayland is no longer merely optional, AFAICT.

> and seems to be unrequired on windows.

That is rather suspicious/dubious. Maybe the Windows video outputs duplicate 
size events internally, which would be another bug.

> Ref #18211
> ---
>  configure.ac                                    |  1 +
>  modules/gui/qt/components/interface_widgets.cpp | 23
> +++++++++++++++++++++++ modules/gui/qt/components/interface_widgets.hpp | 
> 8 ++++++++
>  3 files changed, 32 insertions(+)
> 
> diff --git a/configure.ac b/configure.ac
> index cc54fad48c..696ef77749 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -3010,6 +3010,7 @@ AS_IF([test "${enable_xcb}" != "no"], [
>    PKG_CHECK_MODULES(XCB_KEYSYMS, [xcb-keysyms >= 0.3.4],
> [have_xcb_keysyms="yes"], [ AC_MSG_WARN([${XCB_KEYSYMS_PKG_ERRORS}. Hotkeys
> will not work.]) ])
> +  AC_DEFINE([HAVE_XCB], [1], [Define to 1 if XCB is available.])
>  ])
>  AM_CONDITIONAL([HAVE_XCB], [test "${have_xcb}" = "yes"])
>  AM_CONDITIONAL([HAVE_XCB_KEYSYMS], [test "${have_xcb_keysyms}" = "yes"])

Why clutter configure.ac and config.h when you already have a conditional?

> diff --git a/modules/gui/qt/components/interface_widgets.cpp
> b/modules/gui/qt/components/interface_widgets.cpp index
> 081985dc2c..56869ff87d 100644
> --- a/modules/gui/qt/components/interface_widgets.cpp
> +++ b/modules/gui/qt/components/interface_widgets.cpp
> @@ -53,6 +53,9 @@
>  #if defined (QT5_HAS_X11)
>  # include <X11/Xlib.h>
>  # include <QX11Info>
> +# if HAVE_XCB
> +# include <xcb/xproto.h>
> +#endif
>  #endif
>  #ifdef QT5_HAS_WAYLAND
>  # include QPNI_HEADER
> @@ -257,12 +260,32 @@ void VideoWidget::setSize( unsigned int w, unsigned
> int h ) sync();
>  }
> 
> +#if RESIZE_FROM_NATIVE_EVENTS
> +bool VideoWidget::nativeEvent( const QByteArray& eventType, void* message,
> long* ) +{
> +#if HAVE_XCB
> +    if ( eventType == "xcb_generic_event_t" )
> +    {
> +        const xcb_generic_event_t* xev = reinterpret_cast<const
> xcb_generic_event_t*>( message ); +
> +        if ( xev->response_type == XCB_CONFIGURE_NOTIFY )
> +        {
> +            msg_Err( p_intf, "COUCOU");
> +            reportSize();
> +        }
> +    }
> +#endif
> +    // Let Qt handle that event in any case
> +    return false;
> +}
> +#else
>  void VideoWidget::resizeEvent( QResizeEvent *event )
>  {
>      QWidget::resizeEvent( event );
> 
>      reportSize();
>  }
> +#endif
> 
>  int VideoWidget::qtMouseButton2VLC( Qt::MouseButton qtButton )
>  {
> diff --git a/modules/gui/qt/components/interface_widgets.hpp
> b/modules/gui/qt/components/interface_widgets.hpp index
> ca2926c49c..1a1dbdfe5c 100644
> --- a/modules/gui/qt/components/interface_widgets.hpp
> +++ b/modules/gui/qt/components/interface_widgets.hpp
> @@ -45,6 +45,10 @@
>  #include <QPropertyAnimation>
>  #include <QLinkedList>
> 
> +#if HAVE_XCB
> +# define RESIZE_FROM_NATIVE_EVENTS 1
> +#endif
> +
>  class QMenu;
>  class QSlider;
>  class QWidgetAction;
> @@ -69,7 +73,11 @@ protected:
>          return NULL;
>      }
> 
> +#if RESIZE_FROM_NATIVE_EVENTS
> +    bool nativeEvent(const QByteArray &eventType, void *message, long
> *result) Q_DECL_OVERRIDE; +#else
>      virtual void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
> +#endif
>      void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
>      void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
>      void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;


-- 
雷米‧德尼-库尔蒙
https://www.remlab.net/



More information about the vlc-devel mailing list