summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-08-27 00:55:25 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-08-27 00:55:25 +0000
commit3cfd8b016170e0f560bffe4e7ea6bd741becefeb (patch)
tree6492d7b8be402d7c684d88534a86ed1598cb6668
parent33e22982882d10b7767c2994595a86437873cc6a (diff)
downloadmpv-3cfd8b016170e0f560bffe4e7ea6bd741becefeb.tar.bz2
mpv-3cfd8b016170e0f560bffe4e7ea6bd741becefeb.tar.xz
GUI integration, step 1
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1710 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--Gui/mplayer/mplayer.c8
-rw-r--r--Gui/wm/ws.c10
-rw-r--r--cfg-mplayer.h2
-rw-r--r--mplayer.c56
4 files changed, 61 insertions, 15 deletions
diff --git a/Gui/mplayer/mplayer.c b/Gui/mplayer/mplayer.c
index 66bff1f521..52d04ea665 100644
--- a/Gui/mplayer/mplayer.c
+++ b/Gui/mplayer/mplayer.c
@@ -108,7 +108,11 @@ void mplInit( int argc,char* argv[], char *envp[] )
// timerSetHandler( mplTimerHandler ); // various timer hacks
// timerInit();
- wsMainLoop(); // X event handler (calls mplTimerHandler periodically!)
+// wsMainLoop(); // X event handler (calls mplTimerHandler periodically!)
+
+}
+
+void mplDone(){
dbprintf( 1,"[mplayer] exit.\n" );
@@ -116,4 +120,6 @@ void mplInit( int argc,char* argv[], char *envp[] )
// timerDone();
gtkDone(); // kills the gtkThreadProc() process
wsXDone();
+
}
+
diff --git a/Gui/wm/ws.c b/Gui/wm/ws.c
index 32d27687cf..4922d8998a 100644
--- a/Gui/wm/ws.c
+++ b/Gui/wm/ws.c
@@ -631,6 +631,16 @@ buttonreleased:
Bool wsDummyEvents( Display * display,XEvent * Event,XPointer arg )
{ return True; }
+// mplTimerHandler(0); // handle timer event
+void wsHandleEvents(){
+ // handle pending events
+ while ( XPending(wsDisplay) ){
+ XNextEvent( wsDisplay,&wsEvent );
+// printf("### X event: %d [%d]\n",wsEvent.type,delay);
+ wsEvents( wsDisplay,&wsEvent,NULL );
+ }
+}
+
void wsMainLoop( void )
{
int delay=20;
diff --git a/cfg-mplayer.h b/cfg-mplayer.h
index cba21d8215..4128081ca0 100644
--- a/cfg-mplayer.h
+++ b/cfg-mplayer.h
@@ -230,6 +230,8 @@ struct config conf[]={
{"aa*", vo_aa_parseoption, CONF_TYPE_FUNC_FULL, 0, 0, 0 },
#endif
+ {"gui", &use_gui, CONF_TYPE_FLAG, 0, 0, 1},
+ {"nogui", &use_gui, CONF_TYPE_FLAG, 0, 1, 0},
{"noidx", &index_mode, CONF_TYPE_FLAG, 0, -1, 0},
{"idx", &index_mode, CONF_TYPE_FLAG, 0, -1, 1},
diff --git a/mplayer.c b/mplayer.c
index 09864612fc..6118eada28 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -200,6 +200,8 @@ int divx_quality=0;
static int auto_quality=0;
static int output_quality=0;
+int use_gui=0;
+
int osd_level=2;
char *seek_to_sec=NULL;
off_t seek_to_byte=0;
@@ -462,22 +464,25 @@ int use_stdin=0; //int f; // filedes
mp_msg(MSGT_CPLAYER,MSGL_INFO,"%s",banner_text);
-#ifdef HAVE_NEW_GUI
// this one segfaults if running 'mplayer' (without path containing '/')
// if ( !strcmp( strrchr( argv[0],'/' ),"/gmplayer" ) ) appInit( argc,argv,envp );
- if ( strstr( argv[0],"gmplayer" ) ) appInit( argc,argv,envp );
-
-#endif
-
-
-#ifdef HAVE_GUI
- if ( nogui ) {
-#endif
+ if ( argv[0] )
+ if(!strcmp(argv[0],"gmplayer") ||
+ (strrchr(argv[0],'/') && !strcmp(strrchr(argv[0],'/'),"/gmplayer") ) )
+ use_gui=1;
parse_cfgfiles();
num_filenames=parse_command_line(conf, argc, argv, envp, &filenames);
if(num_filenames<0) exit(1); // error parsing cmdline
+#ifndef HAVE_NEW_GUI
+ if(use_gui){
+ mp_msg(MSGT_CPLAYER,MSGL_WARN,"MPlayer was compiled WITHOUT GUI support!\n");
+ use_gui=0;
+ }
+#endif
+
+
#ifndef USE_LIBVO2
if(video_driver && strcmp(video_driver,"help")==0){
printf("Available video output drivers:\n");
@@ -501,7 +506,7 @@ int use_stdin=0; //int f; // filedes
exit(0);
}
- if(!num_filenames && !vcd_track && !dvd_title){
+ if(!num_filenames && !vcd_track && !dvd_title && !use_gui){
// no file/vcd/dvd -> show HELP:
printf("%s",help_text);
exit(0);
@@ -515,10 +520,6 @@ int use_stdin=0; //int f; // filedes
printf("num_filenames: %d\n",num_filenames);
}
-#ifdef HAVE_GUI
- }
-#endif
-
mp_msg_init(verbose+MSGL_STATUS);
//------ load global data first ------
@@ -556,6 +557,12 @@ if(!parse_codec_cfg(get_path("codecs.conf"))){
}
#endif
+ // It's time to init the GUI code: (and fork() the GTK process)
+#ifdef HAVE_NEW_GUI
+ if(use_gui){
+ appInit( argc,argv,envp );
+ }
+#endif
#ifdef HAVE_LIRC
#ifdef HAVE_GUI
@@ -1288,6 +1295,11 @@ if(1)
}
}
video_out->check_events(); // check events AST
+#ifdef HAVE_NEW_GUI
+ if(use_gui){
+ wsHandleEvents();mplTimerHandler(0); // handle GUI timer events
+ }
+#endif
} else {
// It's time to sleep...
current_module="sleep";
@@ -1319,6 +1331,12 @@ if(1)
// if(verbose>1)printf("sleep: %5.3f a:%6.3f v:%6.3f \n",time_frame,sh_audio->timer,sh_video->timer);
aq_sleep_time+=time_frame;
+
+#ifdef HAVE_NEW_GUI
+ if(use_gui){
+ wsHandleEvents();mplTimerHandler(0); // handle GUI timer events
+ }
+#endif
while(time_frame>0.005){
if(time_frame<=0.020)
@@ -1326,6 +1344,11 @@ if(1)
usec_sleep(0); // sleeps 1 clock tick (10ms)!
else
usec_sleep(1000000*(time_frame-0.002));
+#ifdef HAVE_NEW_GUI
+ if(use_gui){
+ wsHandleEvents();mplTimerHandler(0); // handle GUI timer events
+ }
+#endif
time_frame-=GetRelativeTime();
}
@@ -1493,6 +1516,11 @@ if(auto_quality>0){
#ifndef USE_LIBVO2
video_out->check_events();
#endif
+#ifdef HAVE_NEW_GUI
+ if(use_gui){
+ wsHandleEvents();mplTimerHandler(0); // handle GUI timer events
+ }
+#endif
if(use_stdin) usec_sleep(1000); // do not eat the CPU
}
osd_function=OSD_PLAY;