vlc | branch: master | Hugo Beauzée-Luyssen <[email protected]> | Tue Apr 25 11:10:16 2017 +0200| [35b1ad8972ffd1a2bae55bc7f30e36e7b0269b2f] | committer: Hugo Beauzée-Luyssen
qt: Use native events to notify of a video widget resize This method can't be used for Wayland as Qt won't invoke QWidget::nativeEvent when Wayland is used. Fix #18211 > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=35b1ad8972ffd1a2bae55bc7f30e36e7b0269b2f --- modules/gui/qt/Makefile.am | 3 +++ modules/gui/qt/components/interface_widgets.cpp | 29 +++++++++++++++++++++++++ modules/gui/qt/components/interface_widgets.hpp | 1 + 3 files changed, 33 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..b3b9b28b25 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,10 +260,36 @@ void VideoWidget::setSize( unsigned int w, unsigned int h ) sync(); } +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; +} + void VideoWidget::resizeEvent( QResizeEvent *event ) { QWidget::resizeEvent( event ); + if ( p_intf->p_sys->voutWindowType == VOUT_WINDOW_TYPE_XID || + p_intf->p_sys->voutWindowType == VOUT_WINDOW_TYPE_HWND ) + return; reportSize(); } diff --git a/modules/gui/qt/components/interface_widgets.hpp b/modules/gui/qt/components/interface_widgets.hpp index ca2926c49c..e56b828021 100644 --- a/modules/gui/qt/components/interface_widgets.hpp +++ b/modules/gui/qt/components/interface_widgets.hpp @@ -69,6 +69,7 @@ protected: return NULL; } + bool nativeEvent(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE; virtual void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE; void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE; _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
