From 0d3c77678763f97f6ebe5aaa3fe63ef60cc679b0 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Fri, 7 Oct 2011 01:00:54 +0200 Subject: [PATCH] dbus: Implement the MPRIS Raise method for the Qt interface * Addd the org.mpris.MediaPlayer2.Raise method in the dbus control module * Define the "intf-show" variable in libvlc * Raise the Qt main window when the value of "intf-show" changes Heavily based on the code from Mirsal, modified by me --- modules/control/dbus/dbus_introspect.h | 1 + modules/control/dbus/dbus_root.c | 8 +++++++ modules/gui/qt4/main_interface.cpp | 30 ++++++++++++++++++++++++++ modules/gui/qt4/main_interface.hpp | 3 +++ src/libvlc.c | 3 +++ 5 files changed, 45 insertions(+) diff --git a/modules/control/dbus/dbus_introspect.h b/modules/control/dbus/dbus_introspect.h index bfdc98e011..ff84c38d2f 100644 --- a/modules/control/dbus/dbus_introspect.h +++ b/modules/control/dbus/dbus_introspect.h @@ -65,6 +65,7 @@ static const char* psz_introspection_xml = " \n" " \n" " \n" +" \n" " \n" " \n" " \n" diff --git a/modules/control/dbus/dbus_root.c b/modules/control/dbus/dbus_root.c index 75b43cbdc0..52a22e9eaf 100644 --- a/modules/control/dbus/dbus_root.c +++ b/modules/control/dbus/dbus_root.c @@ -219,6 +219,13 @@ DBUS_METHOD( Quit ) REPLY_SEND; } +DBUS_METHOD( Raise ) +{/* shows vlc's main window */ + REPLY_INIT; + var_ToggleBool( INTF->p_libvlc, "intf-show" ); + REPLY_SEND; +} + #define PROPERTY_MAPPING_BEGIN if( 0 ) {} #define PROPERTY_FUNC( interface, property, function ) \ else if( !strcmp( psz_interface_name, interface ) && \ @@ -277,6 +284,7 @@ handle_root ( DBusConnection *p_conn, DBusMessage *p_from, void *p_this ) METHOD_MAPPING_BEGIN METHOD_FUNC( DBUS_INTERFACE_PROPERTIES, "Get", GetProperty ); METHOD_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "Quit", Quit ); + METHOD_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "Raise", Raise ); METHOD_MAPPING_END } diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp index 1c2948856d..3b46fc4470 100644 --- a/modules/gui/qt4/main_interface.cpp +++ b/modules/gui/qt4/main_interface.cpp @@ -70,6 +70,9 @@ static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable, vlc_value_t old_val, vlc_value_t new_val, void *param ); static int IntfBossCB( vlc_object_t *p_this, const char *psz_variable, vlc_value_t old_val, vlc_value_t new_val, void *param ); +static int IntfRaiseMainCB( vlc_object_t *p_this, const char *psz_variable, + vlc_value_t old_val, vlc_value_t new_val, + void *param ); MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) { @@ -221,6 +224,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) CONNECT( this, askToQuit(), THEDP, quit() ); CONNECT( this, askBoss(), this, setBoss() ); + CONNECT( this, askRaise(), this, setRaise() ); /** END of CONNECTS**/ @@ -230,6 +234,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ************/ var_AddCallback( p_intf->p_libvlc, "intf-toggle-fscontrol", IntfShowCB, p_intf ); var_AddCallback( p_intf->p_libvlc, "intf-boss", IntfBossCB, p_intf ); + var_AddCallback( p_intf->p_libvlc,"intf-show", IntfRaiseMainCB, p_intf ); /* Register callback for the intf-popupmenu variable */ var_AddCallback( p_intf->p_libvlc, "intf-popupmenu", PopupMenuCB, p_intf ); @@ -1299,6 +1304,16 @@ void MainInterface::setBoss() } } +void MainInterface::emitRaise() +{ + emit askRaise(); +} +void MainInterface::setRaise() +{ + activateWindow(); + raise(); +} + /***************************************************************************** * PopupMenuCB: callback triggered by the intf-popupmenu playlist variable. * We don't show the menu directly here because we don't want the @@ -1336,6 +1351,21 @@ static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable, return VLC_SUCCESS; } +/***************************************************************************** + * IntfRaiseMainCB: callback triggered by the intf-show-main libvlc variable. + *****************************************************************************/ +static int IntfRaiseMainCB( vlc_object_t *p_this, const char *psz_variable, + vlc_value_t old_val, vlc_value_t new_val, void *param ) +{ + VLC_UNUSED( p_this ); VLC_UNUSED( psz_variable ); VLC_UNUSED( old_val ); + VLC_UNUSED( new_val ); + + intf_thread_t *p_intf = (intf_thread_t *)param; + p_intf->p_sys->p_mi->emitRaise(); + + return VLC_SUCCESS; +} + /***************************************************************************** * IntfBossCB: callback triggered by the intf-boss libvlc variable. *****************************************************************************/ diff --git a/modules/gui/qt4/main_interface.hpp b/modules/gui/qt4/main_interface.hpp index fd925c4645..1415bf3421 100644 --- a/modules/gui/qt4/main_interface.hpp +++ b/modules/gui/qt4/main_interface.hpp @@ -205,6 +205,7 @@ public slots: void releaseVideoSlot( void ); void emitBoss(); + void emitRaise(); void reloadPrefs(); @@ -246,6 +247,7 @@ private slots: void setVideoFullScreen( bool ); void setVideoOnTop( bool ); void setBoss(); + void setRaise(); signals: void askGetVideo( WId *p_id, int *pi_x, int *pi_y, @@ -258,6 +260,7 @@ signals: void fullscreenInterfaceToggled( bool ); void askToQuit(); void askBoss(); + void askRaise(); }; diff --git a/src/libvlc.c b/src/libvlc.c index e615f058bd..c8397d63af 100644 --- a/src/libvlc.c +++ b/src/libvlc.c @@ -536,6 +536,9 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, /* Create a variable for the Boss Key */ var_Create( p_libvlc, "intf-boss", VLC_VAR_VOID ); + /* Create a variable for showing the main interface */ + var_Create( p_libvlc, "intf-show", VLC_VAR_BOOL ); + /* Create a variable for showing the right click menu */ var_Create( p_libvlc, "intf-popupmenu", VLC_VAR_BOOL ); -- 2.39.2