[vlc-devel] [PATCH 3/3] Qt: constrain the position of the FSC within the screen bounds

Ludovic Fauvet etix at videolan.org
Thu Jan 12 16:27:04 CET 2012


On Wed, Dec 21, 2011 at 2:58 PM, Ludovic Fauvet <etix at videolan.org> wrote:
> ---
>  modules/gui/qt4/components/controller.cpp |   30 +++++++++++++++++-----------
>  modules/gui/qt4/components/controller.hpp |    2 +-
>  2 files changed, 19 insertions(+), 13 deletions(-)
>
> diff --git a/modules/gui/qt4/components/controller.cpp b/modules/gui/qt4/components/controller.cpp
> index 3d1bd78..39975e4 100644
> --- a/modules/gui/qt4/components/controller.cpp
> +++ b/modules/gui/qt4/components/controller.cpp
> @@ -707,8 +707,8 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i, QWi
>                            : AbstractController( _p_i, _parent )
>  {
>     RTL_UNAFFECTED_WIDGET
> -    i_mouse_last_x      = -1;
> -    i_mouse_last_y      = -1;
> +    i_mouse_pos_x      = -1;
> +    i_mouse_pos_y      = -1;
>     b_mouse_over        = false;
>     i_mouse_last_move_x = -1;
>     i_mouse_last_move_y = -1;
> @@ -970,16 +970,22 @@ void FullscreenControllerWidget::mouseMoveEvent( QMouseEvent *event )
>  {
>     if( event->buttons() == Qt::LeftButton )
>     {
> -        if( i_mouse_last_x == -1 || i_mouse_last_y == -1 )
> +        if( i_mouse_pos_x == -1 || i_mouse_pos_y == -1 )
>             return;
>
> -        int i_moveX = event->globalX() - i_mouse_last_x;
> -        int i_moveY = event->globalY() - i_mouse_last_y;
> +        int i_targetX = event->globalX() - i_mouse_pos_x;
> +        int i_targetY = event->globalY() - i_mouse_pos_y;
>
> -        move( x() + i_moveX, y() + i_moveY );
> +        QRect screen = QApplication::desktop()->screenGeometry( targetScreen() );
> +        QRect pos = geometry();
>
> -        i_mouse_last_x = event->globalX();
> -        i_mouse_last_y = event->globalY();
> +        pos.moveTo( i_targetX, i_targetY );
> +        if( screen.top()    > pos.top()    )  i_targetY = screen.top();
> +        if( screen.bottom() < pos.bottom() )  i_targetY = screen.bottom() - pos.height();
> +        if( screen.left()   > pos.left()   )  i_targetX = screen.left();
> +        if( screen.right()  < pos.right()  )  i_targetX = screen.right() - pos.width();
> +
> +        move( i_targetX, i_targetY );
>     }
>  }
>
> @@ -990,16 +996,16 @@ void FullscreenControllerWidget::mouseMoveEvent( QMouseEvent *event )
>  void FullscreenControllerWidget::mousePressEvent( QMouseEvent *event )
>  {
>     if( isWideFSC ) return;
> -    i_mouse_last_x = event->globalX();
> -    i_mouse_last_y = event->globalY();
> +    i_mouse_pos_x = event->x();
> +    i_mouse_pos_y = event->y();
>     event->accept();
>  }
>
>  void FullscreenControllerWidget::mouseReleaseEvent( QMouseEvent *event )
>  {
>     if( isWideFSC ) return;
> -    i_mouse_last_x = -1;
> -    i_mouse_last_y = -1;
> +    i_mouse_pos_x = -1;
> +    i_mouse_pos_y = -1;
>     event->accept();
>
>     // Save the new FSC position
> diff --git a/modules/gui/qt4/components/controller.hpp b/modules/gui/qt4/components/controller.hpp
> index 42ce504..70d192b 100644
> --- a/modules/gui/qt4/components/controller.hpp
> +++ b/modules/gui/qt4/components/controller.hpp
> @@ -298,7 +298,7 @@ private:
>     float f_opacity;
>  #endif
>
> -    int i_mouse_last_x, i_mouse_last_y;
> +    int i_mouse_pos_x, i_mouse_pos_y;
>     bool b_mouse_over;
>     int i_screennumber;
>     QRect screenRes;
> --
> 1.7.8
>

Any news regarding this patch?

-- 
Ludovic Fauvet



More information about the vlc-devel mailing list