Commit 0d3c7767 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

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
parent 7df36400
......@@ -65,6 +65,7 @@ static const char* psz_introspection_xml =
" <property name=\"CanQuit\" type=\"b\" access=\"read\" />\n"
" <property name=\"CanRaise\" type=\"b\" access=\"read\" />\n"
" <method name=\"Quit\" />\n"
" <method name=\"Raise\" />\n"
" </interface>\n"
" <interface name=\"org.mpris.MediaPlayer2.Player\">\n"
" <property name=\"Metadata\" type=\"a{sv}\" access=\"read\" />\n"
......
......@@ -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
}
......
......@@ -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.
*****************************************************************************/
......
......@@ -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();
};
......
......@@ -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 );
......
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