Commit 64e6301a authored by Pierre Lamot's avatar Pierre Lamot Committed by Jean-Baptiste Kempf

qt: send mouse release events before popping a QMenu to avoid Vout mouse state corruption

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent d2f73eb9
......@@ -188,7 +188,12 @@ void DialogsProvider::customEvent( QEvent *event )
delete popupMenu; popupMenu = NULL;
bool show = (de->i_arg != 0);
if( show )
{
//popping a QMenu prevents mouse release events to be received,
//this ensures the coherency of the vout mouse state.
emit releaseMouseEvents();
popupMenu = VLCMenuBar::PopupMenu( p_intf, show );
}
break;
}
case INTF_DIALOG_AUDIOPOPUPMENU:
......
......@@ -184,6 +184,7 @@ private slots:
void menuUpdateAction( QObject * );
signals:
void toolBarConfUpdated();
void releaseMouseEvents();
};
class DialogEvent : public QEvent
......
......@@ -229,6 +229,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
CONNECT( this, askBoss(), this, setBoss() );
CONNECT( this, askRaise(), this, setRaise() );
connect( THEDP, &DialogsProvider::releaseMouseEvents, this, &MainInterface::voutReleaseMouseEvents ) ;
/** END of CONNECTS**/
......@@ -1665,6 +1667,29 @@ void MainInterface::setRaise()
raise();
}
void MainInterface::voutReleaseMouseEvents()
{
if (videoWidget)
{
QPoint pos = QCursor::pos();
QPoint localpos = videoWidget->mapFromGlobal(pos);
int buttons = QApplication::mouseButtons();
int i_button = 1;
while (buttons != 0)
{
if ( (buttons & 1) != 0 )
{
QMouseEvent new_e( QEvent::MouseButtonRelease, localpos,
(Qt::MouseButton)i_button, (Qt::MouseButton)i_button, Qt::NoModifier );
QApplication::sendEvent(videoWidget, &new_e);
}
buttons >>= 1;
i_button <<= 1;
}
}
}
/*****************************************************************************
* PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.
* We don't show the menu directly here because we don't want the
......
......@@ -253,6 +253,7 @@ protected slots:
void setVideoOnTop( bool );
void setBoss();
void setRaise();
void voutReleaseMouseEvents();
void showResumePanel( int64_t);
void hideResumePanel();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment