Commit 35b1ad89 authored by Hugo Beauzée-Luyssen's avatar 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
parent ac9ad115
......@@ -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\>
......
......@@ -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();
}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment