[vlc-devel] [PATCH] qt: fix initial scale/size of video when autoresize gui is disabled
Darrell Walisser
darrell.walisser at gmail.com
Sun Feb 28 20:01:22 CET 2016
---
modules/gui/qt/components/interface_widgets.cpp | 10 ++++++++++
modules/gui/qt/main_interface.cpp | 19 +++++++++++++++----
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/modules/gui/qt/components/interface_widgets.cpp b/modules/gui/qt/components/interface_widgets.cpp
index 920bf68..b6c37e5 100644
--- a/modules/gui/qt/components/interface_widgets.cpp
+++ b/modules/gui/qt/components/interface_widgets.cpp
@@ -183,6 +183,16 @@ WId VideoWidget::request( struct vout_window_t *p_wnd, unsigned int *pi_width,
Parent has to care about resizing itself */
void VideoWidget::setSize( unsigned int w, unsigned int h )
{
+ /* If the size changed, resizeEvent will be called, otherwise not,
+ * in which case we need to tell the vout what the size actually is
+ */
+ if( (unsigned)size().width() == w && (unsigned)size().height() == h )
+ {
+ if( p_window != NULL )
+ vout_window_ReportSize( p_window, w, h );
+ return;
+ }
+
resize( w, h );
emit sizeChanged( w, h );
/* Work-around a bug?misconception? that would happen when vout core resize
diff --git a/modules/gui/qt/main_interface.cpp b/modules/gui/qt/main_interface.cpp
index 90f941c..08ab7c7 100644
--- a/modules/gui/qt/main_interface.cpp
+++ b/modules/gui/qt/main_interface.cpp
@@ -215,11 +215,13 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
{
if( b_autoresize )
{
- CONNECT( this, askVideoToResize( unsigned int, unsigned int ),
- this, setVideoSize( unsigned int, unsigned int ) );
CONNECT( videoWidget, sizeChanged( int, int ),
this, videoSizeChanged( int, int ) );
}
+
+ CONNECT( this, askVideoToResize( unsigned int, unsigned int ),
+ this, setVideoSize( unsigned int, unsigned int ) );
+
CONNECT( this, askVideoSetFullScreen( bool ),
this, setVideoFullScreen( bool ) );
}
@@ -777,8 +779,17 @@ void MainInterface::releaseVideoSlot( void )
void MainInterface::setVideoSize( unsigned int w, unsigned int h )
{
- if( !isFullScreen() && !isMaximized() )
- videoWidget->setSize( w, h );
+ if (!isFullScreen() && !isMaximized() )
+ {
+ /* Resize video widget to video size, or keep it at the same
+ * size. Call setSize() either way so that vout_window_ReportSize
+ * will always get called.
+ */
+ if (b_autoresize)
+ videoWidget->setSize( w, h );
+ else
+ videoWidget->setSize( videoWidget->width(), videoWidget->height() );
+ }
}
void MainInterface::videoSizeChanged( int w, int h )
--
2.5.0
More information about the vlc-devel
mailing list