[vlc-devel] [PATCH 3/3] Qt: Set proper vout size on hidpi setups.
Rémi Denis-Courmont
remi at remlab.net
Tue Aug 2 16:47:09 CEST 2016
Le 2016-07-30 15:38, Anatoliy Anischovich a écrit :
> ---
> modules/gui/qt/components/interface_widgets.cpp | 23
> +++++++++++++++++------
> modules/gui/qt/components/interface_widgets.hpp | 3 +++
> 2 files changed, 20 insertions(+), 6 deletions(-)
>
> diff --git a/modules/gui/qt/components/interface_widgets.cpp
> b/modules/gui/qt/components/interface_widgets.cpp
> index db590c5..7ac73b6 100644
> --- a/modules/gui/qt/components/interface_widgets.cpp
> +++ b/modules/gui/qt/components/interface_widgets.cpp
> @@ -178,6 +178,21 @@ WId VideoWidget::request( struct vout_window_t
> *p_wnd, unsigned int *pi_width,
> return stable->winId();
> }
>
> +
> +void VideoWidget::reportSize( unsigned int w, unsigned int h )
> +{
> + if( p_window == NULL )
> + return;
> +
> +#ifdef HAS_QT56
> + qreal ratio = devicePixelRatioF();
> + w *= ratio;
> + h *= ratio;
> +#endif
> +
> + vout_window_ReportSize( p_window, w, h );
> +}
> +
I am not quite clear about what the ratio is, so I do not know if this
is right or wrong. But it seems odd that the conversion is done in
Qt->VLC direction and not in VLC->Qt direction. Is this code path
actually tested?
> /* Set the Widget to the correct Size */
> /* Function has to be called by the parent
> Parent has to care about resizing itself */
> @@ -188,8 +203,7 @@ void VideoWidget::setSize( unsigned int w,
> unsigned int h )
> */
> if( (unsigned)size().width() == w && (unsigned)size().height()
> == h )
> {
> - if( p_window != NULL )
> - vout_window_ReportSize( p_window, w, h );
> + reportSize( w, h );
> return;
> }
>
> @@ -207,10 +221,7 @@ void VideoWidget::setSize( unsigned int w,
> unsigned int h )
>
> void VideoWidget::resizeEvent( QResizeEvent *event )
> {
> - if( p_window != NULL )
> - vout_window_ReportSize( p_window, event->size().width(),
> - event->size().height() );
> -
> + reportSize( event->size().width(), event->size().height() );
> QWidget::resizeEvent( event );
> }
>
> diff --git a/modules/gui/qt/components/interface_widgets.hpp
> b/modules/gui/qt/components/interface_widgets.hpp
> index a07119e..c1ff2d5 100644
> --- a/modules/gui/qt/components/interface_widgets.hpp
> +++ b/modules/gui/qt/components/interface_widgets.hpp
> @@ -77,6 +77,9 @@ private:
>
> QWidget *stable;
> QLayout *layout;
> +
> + void reportSize( unsigned int, unsigned int );
> +
> signals:
> void sizeChanged( int, int );
--
Rémi Denis-Courmont
http://www.remlab.net/
More information about the vlc-devel
mailing list