[vlc-devel] [PATCH] qt: Use native events to notify of a video widget resize
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Thu Apr 27 18:02:27 CEST 2017
On Thu, Apr 27, 2017, at 06:00 PM, Rémi Denis-Courmont wrote:
> Le torstaina 27. huhtikuuta 2017, 15.59.28 EEST Hugo Beauzée-Luyssen a
> écrit :
> > This method can't be used for Wayland as Qt won't invoke
> > QWidget::nativeEvent when Wayland is used.
> > Fix #18211
> > ---
> > modules/gui/qt/Makefile.am | 3 +++
> > modules/gui/qt/components/interface_widgets.cpp | 28
> > +++++++++++++++++++++++++ modules/gui/qt/components/interface_widgets.hpp |
> > 10 +++++++++
> > 3 files changed, 41 insertions(+)
> >
> > diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
> > index a5a428d36c..22e2b54697 100644
> > --- a/modules/gui/qt/Makefile.am
> > +++ b/modules/gui/qt/Makefile.am
> > @@ -25,6 +25,9 @@ if HAVE_QT5_X11
> > libqt_plugin_la_CXXFLAGS += $(QT5_X11_CFLAGS) -DQT5_HAS_X11
> > libqt_plugin_la_LIBADD += $(QT5_X11_LIBS) $(X_LIBS) $(X_PRE_LIB) -lX11
> > endif
> > +if HAVE_XCB
> > +libqt_plugin_la_CXXFLAGS += -DQT5_HAS_XCB
> > +endif
> > if HAVE_WAYLAND
> > libqt_plugin_la_CPPFLAGS += -DQT5_HAS_WAYLAND \
> > -DQPNI_HEADER=\<$(QT_VERSION)/QtGui/qpa/qplatformnativeinterface.h\>
> > diff --git a/modules/gui/qt/components/interface_widgets.cpp
> > b/modules/gui/qt/components/interface_widgets.cpp index
> > 081985dc2c..a8f996eb94 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 defined(QT5_HAS_XCB)
> > +# include <xcb/xproto.h>
> > +# endif
> > #endif
> > #ifdef QT5_HAS_WAYLAND
> > # include QPNI_HEADER
> > @@ -257,12 +260,37 @@ 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 defined(QT5_HAS_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 )
> > + reportSize();
> > + }
> > +#endif
> > +#ifdef _WIN32
> > + if ( eventType == "windows_generic_MSG" )
> > + {
> > + MSG* msg = static_cast<MSG*>( message );
> > + if ( msg->message == WM_SIZE )
> > + reportSize();
> > + }
> > +#endif
> > + // Let Qt handle that event in any case
> > + return false;
> > +}
> > +#else
> > void VideoWidget::resizeEvent( QResizeEvent *event )
> > {
> > QWidget::resizeEvent( event );
> >
> > reportSize();
> > }
> > +#endif
>
> Doesn´t that mean that we never report a size if XCB is present at
> compile-
> time but not used at run-time?
>
> --
> 雷米‧德尼-库尔蒙
> https://www.remlab.net/
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
Yeah that seem like a very valid point. I'll keep both method and
discriminate at runtime I suppose.
--
Hugo Beauzée-Luyssen
hugo at beauzee.fr
More information about the vlc-devel
mailing list