From 2ca03e7d446b30c6d15d406a4548b42771b576a0 Mon Sep 17 00:00:00 2001 From: stv Date: Fri, 13 May 2011 06:34:56 +0000 Subject: [PATCH] Bug fix for non opaque dock widget resize mode. --- src/Qtx/QtxMainWindow.cxx | 44 ++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/src/Qtx/QtxMainWindow.cxx b/src/Qtx/QtxMainWindow.cxx index 8546d9668..7ddeff7dd 100644 --- a/src/Qtx/QtxMainWindow.cxx +++ b/src/Qtx/QtxMainWindow.cxx @@ -141,7 +141,7 @@ QtxMainWindow::Resizer::Resizer( const QPoint& p, const Qt::Orientation o, QtxMa setPosition( p ); - myRubber->show(); + myRubber->hide(); }; /*! @@ -170,6 +170,8 @@ void QtxMainWindow::Resizer::setPosition( const QPoint& pos ) r = QRect( p - 1, myMain->mapToGlobal( QPoint( 0, 0 ) ).y(), 3, myMain->height() ); } myRubber->setGeometry( r ); + if ( !myRubber->isVisible() ) + myRubber->show(); } } @@ -560,22 +562,34 @@ void QtxMainWindow::onDestroyed( QObject* obj ) bool QtxMainWindow::event( QEvent* e ) { - if ( myResizer && e->type() == QEvent::MouseButtonRelease ) { - if ( myMouseMove ) { - QMainWindow::event( myMouseMove ); - delete myMouseMove; - myMouseMove = 0; - } + if ( e->type() == QEvent::WindowDeactivate ) { + printf( "----------------> Deactivated\n" ); + } + if ( myResizer ) { QMouseEvent* me = static_cast( e ); - myResizer->setFinalEvent( new QMouseEvent( me->type(), me->pos(), me->globalPos(), - me->button(), me->buttons(), me->modifiers() ) ); - myResizer = 0; - return true; + if ( ( e->type() == QEvent::MouseButtonRelease && me->button() == Qt::LeftButton ) || + ( e->type() == QEvent::MouseButtonPress && me->button() != Qt::LeftButton ) ) { + if ( me->button() == Qt::LeftButton ) { + if ( myMouseMove ) { + QMainWindow::event( myMouseMove ); + delete myMouseMove; + myMouseMove = 0; + } + + QMouseEvent* me = static_cast( e ); + myResizer->setFinalEvent( new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), me->globalPos(), + Qt::LeftButton, me->buttons(), me->modifiers() ) ); + myResizer = 0; + return true; + } + } } if ( myResizer && e->type() == QEvent::MouseMove ) { QMouseEvent* me = static_cast( e ); + if ( myMouseMove ) + delete myMouseMove; myMouseMove = new QMouseEvent( me->type(), me->pos(), me->globalPos(), me->button(), me->buttons(), me->modifiers() ); myResizer->setPosition( me->globalPos() ); @@ -583,8 +597,9 @@ bool QtxMainWindow::event( QEvent* e ) bool ok = QMainWindow::event( e ); - if ( e->type() == QEvent::MouseButtonPress ) { - if ( !isOpaqueResize() && ok && testAttribute( Qt::WA_SetCursor ) ) { + if ( !myResizer && e->type() == QEvent::MouseButtonPress ) { + QMouseEvent* me = static_cast( e ); + if ( !isOpaqueResize() && ok && testAttribute( Qt::WA_SetCursor ) && me->button() == Qt::LeftButton ) { bool status = true; Qt::Orientation o; switch ( cursor().shape() ) @@ -600,8 +615,9 @@ bool QtxMainWindow::event( QEvent* e ) break; } if ( status ) { - QMouseEvent* me = static_cast( e ); myResizer = new Resizer( me->globalPos(), o, this ); + myMouseMove = new QMouseEvent( me->type(), me->pos(), me->globalPos(), + me->button(), me->buttons(), me->modifiers() ); } } } -- 2.39.2