[vlc-commits] qt: send mouse release events before popping a QMenu to avoid Vout mouse state corruption
Pierre Lamot
git at videolan.org
Tue Oct 31 18:18:45 CET 2017
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Mon Oct 30 18:28:54 2017 +0100| [64e6301a6c4c9a47171c68518351d5879a0bcc05] | committer: Jean-Baptiste Kempf
qt: send mouse release events before popping a QMenu to avoid Vout mouse state corruption
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=64e6301a6c4c9a47171c68518351d5879a0bcc05
---
modules/gui/qt/dialogs_provider.cpp | 5 +++++
modules/gui/qt/dialogs_provider.hpp | 1 +
modules/gui/qt/main_interface.cpp | 25 +++++++++++++++++++++++++
modules/gui/qt/main_interface.hpp | 1 +
4 files changed, 32 insertions(+)
diff --git a/modules/gui/qt/dialogs_provider.cpp b/modules/gui/qt/dialogs_provider.cpp
index ec393b5f4c..92f1e17a3e 100644
--- a/modules/gui/qt/dialogs_provider.cpp
+++ b/modules/gui/qt/dialogs_provider.cpp
@@ -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:
diff --git a/modules/gui/qt/dialogs_provider.hpp b/modules/gui/qt/dialogs_provider.hpp
index 399ac5322f..4d65c7a599 100644
--- a/modules/gui/qt/dialogs_provider.hpp
+++ b/modules/gui/qt/dialogs_provider.hpp
@@ -184,6 +184,7 @@ private slots:
void menuUpdateAction( QObject * );
signals:
void toolBarConfUpdated();
+ void releaseMouseEvents();
};
class DialogEvent : public QEvent
diff --git a/modules/gui/qt/main_interface.cpp b/modules/gui/qt/main_interface.cpp
index e517d6d48d..3bde9e8968 100644
--- a/modules/gui/qt/main_interface.cpp
+++ b/modules/gui/qt/main_interface.cpp
@@ -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
diff --git a/modules/gui/qt/main_interface.hpp b/modules/gui/qt/main_interface.hpp
index c0fe178135..e986c69bae 100644
--- a/modules/gui/qt/main_interface.hpp
+++ b/modules/gui/qt/main_interface.hpp
@@ -253,6 +253,7 @@ protected slots:
void setVideoOnTop( bool );
void setBoss();
void setRaise();
+ void voutReleaseMouseEvents();
void showResumePanel( int64_t);
void hideResumePanel();
More information about the vlc-commits
mailing list