X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmisc%2Fbeos_specific.cpp;h=dab984350afa3587017e9c9b499c517308f1794a;hb=74e8f4f6ac00d56ac3cbc2412fb19fe489ac5218;hp=72ef7c7226ee3b9f1b03a2edfe7a8785706d3570;hpb=7d2f6de57c4def2f33ff81c1f602621255c63a3c;p=vlc diff --git a/src/misc/beos_specific.cpp b/src/misc/beos_specific.cpp index 72ef7c7226..dab984350a 100644 --- a/src/misc/beos_specific.cpp +++ b/src/misc/beos_specific.cpp @@ -2,7 +2,7 @@ * beos_init.cpp: Initialization for BeOS specific features ***************************************************************************** * Copyright (C) 1999-2001 VideoLAN - * $Id: beos_specific.cpp,v 1.25 2002/08/29 23:53:22 massiot Exp $ + * $Id: beos_specific.cpp,v 1.27 2002/10/09 01:14:18 titer Exp $ * * Authors: Jean-Marc Dressler * @@ -24,6 +24,9 @@ #include #include #include +#include +#include + #include #include /* strdup() */ #include /* free() */ @@ -46,6 +49,12 @@ public: virtual void ReadyToRun(); virtual void AboutRequested(); + virtual void RefsReceived(BMessage* message); + virtual void MessageReceived(BMessage* message); + +private: + BWindow* fInterfaceWindow; + BMessage* fRefsMessage; }; /***************************************************************************** @@ -53,6 +62,9 @@ public: *****************************************************************************/ static char * psz_program_path; +//const uint32 INTERFACE_CREATED = 'ifcr'; /* message sent from interface */ +#include "../../modules/gui/beos/MsgVals.h" + extern "C" { @@ -66,11 +78,11 @@ static void AppThread( vlc_object_t *p_appthread ); *****************************************************************************/ void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] ) { - p_this->p_vlc->p_appthread = + p_this->p_libvlc->p_appthread = (vlc_object_t *)vlc_object_create( p_this, sizeof(vlc_object_t) ); /* Create the BApplication thread and wait for initialization */ - vlc_thread_create( p_this->p_vlc->p_appthread, "app thread", AppThread, + vlc_thread_create( p_this->p_libvlc->p_appthread, "app thread", AppThread, VLC_THREAD_PRIORITY_LOW, VLC_TRUE ); } @@ -90,8 +102,8 @@ void system_End( vlc_t *p_this ) /* Tell the BApplication to die */ be_app->PostMessage( B_QUIT_REQUESTED ); - vlc_thread_join( p_this->p_vlc->p_appthread ); - vlc_object_destroy( p_this->p_vlc->p_appthread ); + vlc_thread_join( p_this->p_libvlc->p_appthread ); + vlc_object_destroy( p_this->p_libvlc->p_appthread ); free( psz_program_path ); } @@ -125,7 +137,9 @@ static void AppThread( vlc_object_t * p_this ) * VlcApplication: application constructor *****************************************************************************/ VlcApplication::VlcApplication( char * psz_mimetype ) - :BApplication( psz_mimetype ) + :BApplication( psz_mimetype ), + fInterfaceWindow( NULL ), + fRefsMessage( NULL ) { /* Nothing to do, we use the default constructor */ } @@ -136,6 +150,7 @@ VlcApplication::VlcApplication( char * psz_mimetype ) VlcApplication::~VlcApplication( ) { /* Nothing to do, we use the default destructor */ + delete fRefsMessage; } /***************************************************************************** @@ -168,3 +183,48 @@ void VlcApplication::ReadyToRun( ) /* Tell the main thread we are finished initializing the BApplication */ vlc_thread_ready( p_this ); } + +/***************************************************************************** + * RefsReceived: called when files are sent to our application + * (for example when the user drops fils onto our icon) + *****************************************************************************/ +void VlcApplication::RefsReceived(BMessage* message) +{ + if (fInterfaceWindow) + fInterfaceWindow->PostMessage(message); + else { + delete fRefsMessage; + fRefsMessage = new BMessage(*message); + } +} + +/***************************************************************************** + * MessageReceived: a BeOS applications main message loop + * Since VlcApplication and interface are separated + * in the vlc binary and the interface plugin, + * we use this method to "stick" them together. + * The interface will post a message to the global + * "be_app" pointer when the interface is created + * containing a pointer to the interface window. + * In this way, we can keep a B_REFS_RECEIVED message + * in store for the interface window to handle later. + *****************************************************************************/ +void VlcApplication::MessageReceived(BMessage* message) +{ + switch (message->what) { + case INTERFACE_CREATED: { + BWindow* interfaceWindow; + if (message->FindPointer("window", (void**)&interfaceWindow) == B_OK) { + fInterfaceWindow = interfaceWindow; + if (fRefsMessage) { + fInterfaceWindow->PostMessage(fRefsMessage); + delete fRefsMessage; + fRefsMessage = NULL; + } + } + break; + } + default: + BApplication::MessageReceived(message); + } +}