[vlc-devel] [PATCH 3/4] Qt: refactor vout resize
Jean-Baptiste Kempf
jb at videolan.org
Sun Aug 7 10:54:14 CEST 2016
I don't see how this is:
- related to HiDPI,
- can be correct...
On 07 Aug, Anatoliy Anischovich wrote :
> VideoWidget::VideoWidget( intf_thread_t *_p_i )
> - : QFrame( NULL ) , p_intf( _p_i )
> + : QFrame( NULL ) , p_intf( _p_i ) , i_width( 0 ), i_height( 0 )
> {
> /* Set the policy to expand in both directions */
> - // setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
> + setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
Changing the policy? Why?
> -WId VideoWidget::request( struct vout_window_t *p_wnd, unsigned int *pi_width,
> - unsigned int *pi_height, bool b_keep_size )
> +WId VideoWidget::request( struct vout_window_t *p_wnd )
This will break "keep-size" option.
> -void VideoWidget::setSize( unsigned int w, unsigned int h )
> +void VideoWidget::setSize( int w, int h )
Why?
> {
> - /* 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;
> - }
> + i_width = w;
> + i_height = h;
>
> - resize( w, h );
> emit sizeChanged( w, h );
> - /* Work-around a bug?misconception? that would happen when vout core resize
> - twice to the same size and would make the vout not centered.
> - This cause a small flicker.
> - See #3621
> - */
> - if( (unsigned)size().width() == w && (unsigned)size().height() == h )
> - updateGeometry();
> +
> sync();
> }
How can you remove all that and not break everything?
> +void MainInterface::setVideoSize( int w, int h )
> {
> - if (!isFullScreen() && !isMaximized() )
> + if( isFullScreen() || isMaximized() )
> + return;
> +
> + QRect screen = QApplication::desktop()->availableGeometry();
> + if( h > screen.height() )
> {
> - /* 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 the video size is too large for the screen, resize it
> - * to the screen size.
> - */
> - if (b_autoresize)
> + w = screen.width();
> + h = screen.height();
> + if( !b_minimalView )
> {
> - QRect screen = QApplication::desktop()->availableGeometry();
> - if( h > screen.height() )
> - {
> - w = screen.width();
> - h = screen.height();
> - if( !b_minimalView )
> - {
> - if( menuBar()->isVisible() )
> - h -= menuBar()->height();
> - if( controls->isVisible() )
> - h -= controls->height();
> - if( statusBar()->isVisible() )
> - h -= statusBar()->height();
> - if( inputC->isVisible() )
> - h -= inputC->height();
> - }
> - h -= style()->pixelMetric(QStyle::PM_TitleBarHeight);
> - h -= style()->pixelMetric(QStyle::PM_LayoutBottomMargin);
> - h -= 2 * style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
> - }
> - videoWidget->setSize( w, h );
> + if( menuBar()->isVisible() )
> + h -= menuBar()->height();
> + if( controls->isVisible() )
> + h -= controls->height();
> + if( statusBar()->isVisible() )
> + h -= statusBar()->height();
> + if( inputC->isVisible() )
> + h -= inputC->height();
> }
> - else
> - videoWidget->setSize( videoWidget->width(), videoWidget->height() );
> + h -= style()->pixelMetric(QStyle::PM_TitleBarHeight);
> + h -= style()->pixelMetric(QStyle::PM_LayoutBottomMargin);
> + h -= 2 * style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
> }
> + videoWidget->setSize( w, h );
> }
>
> void MainInterface::videoSizeChanged( int w, int h )
> diff --git a/modules/gui/qt/main_interface.hpp b/modules/gui/qt/main_interface.hpp
> index 18ab8ce..e4cf8e9 100644
> --- a/modules/gui/qt/main_interface.hpp
> +++ b/modules/gui/qt/main_interface.hpp
> @@ -252,7 +252,7 @@ private slots:
> debug();
> }
>
> - void setVideoSize( unsigned int, unsigned int );
> + void setVideoSize( int, int );
> void videoSizeChanged( int, int );
> void setVideoFullScreen( bool );
> void setVideoOnTop( bool );
> @@ -267,7 +267,7 @@ signals:
> void askGetVideo( WId *, struct vout_window_t *, unsigned *, unsigned *,
> bool );
> void askReleaseVideo( );
> - void askVideoToResize( unsigned int, unsigned int );
> + void askVideoToResize( int, int );
> void askVideoSetFullScreen( bool );
> void askVideoOnTop( bool );
> void minimalViewToggled( bool );
> --
> 2.7.3
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
--
With my kindest regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
More information about the vlc-devel
mailing list