/***************************************************************************** * main loop of qtapplication *****************************************************************************/ static void* RunQtThread( vlc_object_t *p_this ) { event_thread_t *p_event = (event_thread_t *)p_this; int canc = vlc_savecancel (); msg_Dbg( p_event->p_vout, "RunQtThread starting" ); #ifdef NEED_QTE_MAIN if (qApp) { p_event->p_vout->p_sys->p_QApplication = qApp; p_event->p_vout->p_sys->bOwnsQApp = FALSE; p_event->p_vout->p_sys->p_VideoWidget = qApp->mainWidget(); msg_Dbg( p_event->p_vout, "RunQtThread applicaton attached" ); } #else if (qApp==NULL) { int argc = 0; QApplication* pApp = new QApplication(argc, NULL); if(pApp) { p_event->p_vout->p_sys->p_QApplication = pApp; p_event->p_vout->p_sys->bOwnsQApp = TRUE; } QWidget* pWidget = new QWidget(); if (pWidget) { p_event->p_vout->p_sys->p_VideoWidget = pWidget; } } #endif /* signal the creation of the window */ vlc_thread_ready( p_event ); msg_Dbg( p_event->p_vout, "RunQtThread ready" ); if (p_event->p_vout->p_sys->p_QApplication) { /* Set default window width and heigh to exactly preferred size. */ QWidget *desktop = p_event->p_vout->p_sys->p_QApplication->desktop(); p_event->p_vout->p_sys->p_VideoWidget->setMinimumWidth( 10 ); p_event->p_vout->p_sys->p_VideoWidget->setMinimumHeight( 10 ); p_event->p_vout->p_sys->p_VideoWidget->setBaseSize( p_event->p_vout->p_sys->i_width, p_event->p_vout->p_sys->i_height ); p_event->p_vout->p_sys->p_VideoWidget->setMaximumWidth( desktop->width() ); p_event->p_vout->p_sys->p_VideoWidget->setMaximumHeight( desktop->height() ); /* Check on fullscreen */ if (p_event->p_vout->b_fullscreen) p_event->p_vout->p_sys->p_VideoWidget->showFullScreen(); else p_event->p_vout->p_sys->p_VideoWidget->showNormal(); p_event->p_vout->p_sys->p_VideoWidget->show(); p_event->p_vout->p_sys->bRunning = TRUE; #ifdef NEED_QTE_MAIN while(vlc_object_alive (p_event) && p_event->p_vout->p_sys->bRunning) { /* Check if we are asked to exit */ if( !vlc_object_alive (p_event) ) break; msleep(100); } #else // run the main loop of qtapplication until someone says: 'quit' p_event->p_vout->p_sys->pcQApplication->exec(); #endif } #ifndef NEED_QTE_MAIN if(p_event->p_vout->p_sys->p_QApplication) { delete p_event->p_vout->p_sys->p_VideoWidget; p_event->p_vout->p_sys->p_VideoWidget = NULL; delete p_event->p_vout->p_sys->p_QApplication; p_event->p_vout->p_sys->p_QApplication = NULL; } #else p_event->p_vout->p_sys->p_VideoWidget = NULL; #endif msg_Dbg( p_event->p_vout, "RunQtThread terminating" ); vlc_restorecancel (canc); return NULL; }
static void MainLoop( intf_thread_t *p_intf ) { MSG msg; Interface *intf = 0; if( !hInstance ) hInstance = GetModuleHandle(NULL); // Register window class WNDCLASS wc; wc.style = CS_HREDRAW | CS_VREDRAW ; wc.lpfnWndProc = (WNDPROC)CBaseWindow::BaseWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hIcon = NULL; wc.hInstance = hInstance; wc.hCursor = NULL; wc.hbrBackground = (HBRUSH)(COLOR_MENU+1); wc.lpszMenuName = NULL; wc.lpszClassName = _T("VLC WinCE"); RegisterClass( &wc ); #ifndef UNDER_CE /* Initialize OLE/COM */ CoInitialize( 0 ); #endif if( !p_intf->pf_show_dialog ) { /* The module is used in interface mode */ p_intf->p_sys->p_window = intf = new Interface( p_intf, 0, hInstance ); /* Create/Show the interface */ if( !intf->InitInstance() ) goto end; } /* Creates the dialogs provider */ p_intf->p_sys->p_window = CreateDialogsProvider( p_intf, p_intf->pf_show_dialog ? NULL : p_intf->p_sys->p_window, hInstance ); p_intf->p_sys->pf_show_dialog = ShowDialog; /* OK, initialization is over */ vlc_thread_ready( p_intf ); /* Check if we need to start playing */ if( !p_intf->pf_show_dialog && p_intf->b_play ) { playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { playlist_Play( p_playlist ); vlc_object_release( p_playlist ); } } // Main message loop while( GetMessage( &msg, NULL, 0, 0 ) > 0 ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } end: if( intf ) delete intf; #ifndef UNDER_CE /* Uninitialize OLE/COM */ CoUninitialize(); #endif }