# HG changeset patch # User arpi # Date 998956604 0 # Node ID 5e4214a7540ef5b60c2e066219c35a288b03efdd # Parent 9e23ceba3f65fac22f0cc71a79ca3d4ca5f8a900 GUI stuff. now seeking works, and xmga renders to video window diff -r 9e23ceba3f65 -r 5e4214a7540e Gui/app.c --- a/Gui/app.c Mon Aug 27 23:56:15 2001 +0000 +++ b/Gui/app.c Mon Aug 27 23:56:44 2001 +0000 @@ -96,7 +96,7 @@ return -1; } -void appInit( int argc,char* argv[], char *envp[] ) +void appInit( int argc,char* argv[], char *envp[], void* disp ) { skinDirInHome=get_path("Skin"); skinMPlayerDir=DATADIR "/Skin"; @@ -124,6 +124,6 @@ case -1: dbprintf( 0,"[app] skin configfile not found.\n" ); exit( 0 ); case -2: dbprintf( 0,"[app] skin configfile read error.\n" ); exit( 0 ); } - mplInit( argc,argv,envp ); // does gtk & ws initialization, create windows + mplInit( argc,argv,envp,disp ); // does gtk & ws initialization, create windows // } } diff -r 9e23ceba3f65 -r 5e4214a7540e Gui/app.h --- a/Gui/app.h Mon Aug 27 23:56:15 2001 +0000 +++ b/Gui/app.h Mon Aug 27 23:56:44 2001 +0000 @@ -79,7 +79,7 @@ extern char * skinDirInHome; extern char * skinMPlayerDir; -extern void appInit( int argc,char* argv[], char *envp[] ); +extern void appInit( int argc,char* argv[], char *envp[], void* disp ); extern void appInitStruct( listItems * item ); extern void appClearItem( wItem * item ); extern void appCopy( listItems * item1,listItems * item2 ); diff -r 9e23ceba3f65 -r 5e4214a7540e Gui/mplayer/mplayer.c --- a/Gui/mplayer/mplayer.c Mon Aug 27 23:56:15 2001 +0000 +++ b/Gui/mplayer/mplayer.c Mon Aug 27 23:56:44 2001 +0000 @@ -48,7 +48,7 @@ if ( mplGeneralTimer == 0 ) mplMsgHandle( evGeneralTimer,0 ); } -void mplInit( int argc,char* argv[], char *envp[] ) +void mplInit( int argc,char* argv[], char *envp[], void* disp ) { // parse_cfgfiles( argc,argv,envp ); @@ -63,7 +63,7 @@ message=mplErrorHandler; // error messagebox drawing function // opens X display, checks for extensions (XShape, DGA etc) - wsXInit(); + wsXInit(disp); if ( ( mplDrawBuffer = (unsigned char *)calloc( 1,appMPlayer.main.Bitmap.ImageSize ) ) == NULL ) { @@ -75,6 +75,9 @@ appMPlayer.sub.x,appMPlayer.sub.y,appMPlayer.sub.width,appMPlayer.sub.height, wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsShowFrame|wsShowWindow,"ViDEO" ); + vo_setwindow(appMPlayer.subWindow.WindowID, appMPlayer.subWindow.wGC); + mplSubRender=0; + wsCreateWindow( &appMPlayer.mainWindow, appMPlayer.main.x,appMPlayer.main.y,appMPlayer.main.width,appMPlayer.main.height, wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsHideFrame|wsMaxSize|wsMinSize|wsShowWindow,"MPlayer" ); @@ -105,6 +108,8 @@ btnModify( evSetBalance,mplShMem->Balance ); btnModify( evSetMoviePosition,mplShMem->Position ); + mplShMem->Playing=0; + // timerSetHandler( mplTimerHandler ); // various timer hacks // timerInit(); diff -r 9e23ceba3f65 -r 5e4214a7540e Gui/mplayer/mplayer.h --- a/Gui/mplayer/mplayer.h Mon Aug 27 23:56:15 2001 +0000 +++ b/Gui/mplayer/mplayer.h Mon Aug 27 23:56:44 2001 +0000 @@ -13,7 +13,7 @@ extern int mplMainAutoPlay; -extern void mplInit( int argc,char* argv[], char *envp[] ); +extern void mplInit( int argc,char* argv[], char *envp[], void* disp ); extern void mplMsgHandle( int msg,float param ); #endif diff -r 9e23ceba3f65 -r 5e4214a7540e Gui/mplayer/mw.h --- a/Gui/mplayer/mw.h Mon Aug 27 23:56:15 2001 +0000 +++ b/Gui/mplayer/mw.h Mon Aug 27 23:56:44 2001 +0000 @@ -178,6 +178,8 @@ XFlush( wsDisplay ); } +#define IZE(x) printf("@@@ " x " @@@\n"); + void mplMsgHandle( int msg,float param ) { int j; @@ -186,12 +188,15 @@ { // --- user events case evExit: - wsDoExit(); + IZE("evExit"); + wsDoExit(); // sets wsTrue=False; break; case evIconify: + IZE("evIcon"); wsIconify( appMPlayer.mainWindow ); break; case evFullScreen: + IZE("evFullS"); for ( j=0;jPause"); if ( Filename ) { btnModify( evPlaySwitchToPause,btnDisabled ); @@ -212,20 +218,24 @@ } if ( mplShMem->Playing == 1 ) goto NoPause; case evPlay: + IZE("evPlay"); mplMainRender=1; mplPlay(); break; case evPauseSwitchToPlay: + IZE("evPause->Play"); btnModify( evPlaySwitchToPause,btnReleased ); btnModify( evPauseSwitchToPlay,btnDisabled ); case evPause: NoPause: + IZE("evPause"); mplMainRender=1; mplPause(); break; case evStop: + IZE("evStop"); btnModify( evPlaySwitchToPause,btnReleased ); btnModify( evPauseSwitchToPlay,btnDisabled ); mplMainRender=1; @@ -233,18 +243,22 @@ break; case evLoadPlay: + IZE("evLoadPlay"); mplMainAutoPlay=1; case evLoad: + IZE("evLoad"); mplMainRender=1; gtkSendMessage( evLoad ); break; case evPrev: + IZE("evPrev"); mplMainRender=1; #ifdef DEBUG dbprintf( 1,"[mw.h] previous stream ...\n" ); #endif break; case evNext: + IZE("evNext"); mplMainRender=1; #ifdef DEBUG dbprintf( 1,"[mw.h] next stream ...\n" ); @@ -252,6 +266,7 @@ break; case evPlayList: + IZE("evPlayList"); mplMainRender=1; if ( gtkVisiblePlayList ) { diff -r 9e23ceba3f65 -r 5e4214a7540e Gui/mplayer/play.c --- a/Gui/mplayer/play.c Mon Aug 27 23:56:15 2001 +0000 +++ b/Gui/mplayer/play.c Mon Aug 27 23:56:44 2001 +0000 @@ -9,6 +9,8 @@ int mplx,mply,mplwidth,mplheight; +float gui_position=-1; + #include "../app.h" #include "../wm/ws.h" @@ -16,6 +18,7 @@ #include "../wm/widget.h" #include "../../config.h" +#include "../../libvo/x11_common.h" #include "widgets.h" #include "./mplayer.h" @@ -25,6 +28,10 @@ mplCommStruct * mplShMem; char * Filename = NULL; +extern float rel_seek_secs; +extern int abs_seek_pos; + + void mplPlayerThread( void ) { // mplayer( 0,NULL,NULL ); @@ -85,6 +92,10 @@ void mplResize( unsigned int X,unsigned int Y,unsigned int width,unsigned int height ) { + +printf("mplResize(%d,%d,%d,%d) \n",X,Y,width,height); + vo_resize=1; + } void mplMPlayerInit( int argc,char* argv[], char *envp[] ) @@ -109,7 +120,7 @@ float mplGetPosition( void ) { // return 0.0 ... 100.0 - return mplShMem->Position; + return (gui_position<0)?(mplShMem->Position):(gui_position*100.0); } void mplRelSeek( float s ) @@ -118,12 +129,14 @@ printf("%%%%%% RelSEEK=%5.3f \n",s); // --- mplShMem->Position=mplGetPosition() + s; + rel_seek_secs=s; abs_seek_pos=0; } void mplAbsSeek( float s ) { // 0.0 ... 100.0 // --- printf("%%%%%% AbsSEEK=%5.3f \n",s); + rel_seek_secs=0.01*s; abs_seek_pos=3; // --- mplShMem->Position=s; mplShMem->TimeSec=s; diff -r 9e23ceba3f65 -r 5e4214a7540e Gui/mplayer/psignal.c --- a/Gui/mplayer/psignal.c Mon Aug 27 23:56:15 2001 +0000 +++ b/Gui/mplayer/psignal.c Mon Aug 27 23:56:44 2001 +0000 @@ -18,6 +18,9 @@ #include "../../config.h" +#include "../../libvo/x11_common.h" +//#include "../../libvo/sub.h" + #include "./mplayer.h" #define gtkShow( w ) gtkShMem->vs.window=w; gtkSendMessage( evShowWindow ); @@ -55,20 +58,21 @@ switch ( mplShMem->message ) { case mplQuit: -// exit_player( "Quit" ); + exit_player( "GUI close" ); break; case mplPauseEvent: // if ( osd_function != OSD_PAUSE ) osd_function=OSD_PAUSE; // else osd_function=OSD_PLAY; break; case mplResizeEvent: -// vo_resize=1; -// vo_expose=1; -// dbprintf( 2,"[psignal] resize.\n" ); + vo_resize=1; + vo_expose=1; + printf( "[psignal] resize.\n" ); // if (video_out != NULL ) video_out->check_events(); break; case mplExposeEvent: -// vo_expose=1; + vo_expose=1; + printf( "[psignal] expose.\n" ); // if (video_out != NULL ) video_out->check_events(); break; case mplSeekEvent: diff -r 9e23ceba3f65 -r 5e4214a7540e Gui/mplayer/sw.h --- a/Gui/mplayer/sw.h Mon Aug 27 23:56:15 2001 +0000 +++ b/Gui/mplayer/sw.h Mon Aug 27 23:56:44 2001 +0000 @@ -18,8 +18,8 @@ wsClearWindow( appMPlayer.subWindow ); if ( appMPlayer.sub.Bitmap.Image ) wsConvert( &appMPlayer.subWindow,appMPlayer.sub.Bitmap.Image,appMPlayer.sub.Bitmap.ImageSize ); mplSubRender=0; + if ( appMPlayer.sub.Bitmap.Image ) wsPutImage( &appMPlayer.subWindow ); } - if ( appMPlayer.sub.Bitmap.Image ) wsPutImage( &appMPlayer.subWindow ); XFlush( wsDisplay ); XSync( wsDisplay,False ); } diff -r 9e23ceba3f65 -r 5e4214a7540e Gui/wm/ws.c --- a/Gui/wm/ws.c Mon Aug 27 23:56:15 2001 +0000 +++ b/Gui/wm/ws.c Mon Aug 27 23:56:44 2001 +0000 @@ -130,12 +130,15 @@ exit( 0 ); } -void wsXInit( void ) +void wsXInit( void* mDisplay ) { - char * DisplayName = ":0.0"; int eventbase; int errorbase; +if(mDisplay){ + wsDisplay=mDisplay; +} else { + char * DisplayName = ":0.0"; if ( getenv( "DISPLAY" ) ) DisplayName=getenv( "DISPLAY" ); wsDisplay=XOpenDisplay( DisplayName ); if ( !wsDisplay ) @@ -143,6 +146,7 @@ fprintf( stderr,"[ws] couldn't open the display !\n" ); exit( 0 ); } +} if ( !XShmQueryExtension( wsDisplay ) ) { diff -r 9e23ceba3f65 -r 5e4214a7540e Gui/wm/ws.h --- a/Gui/wm/ws.h Mon Aug 27 23:56:15 2001 +0000 +++ b/Gui/wm/ws.h Mon Aug 27 23:56:44 2001 +0000 @@ -180,7 +180,7 @@ extern unsigned long wsKeyTable[512]; extern void wsXDone( void ); -extern void wsXInit( void ); +extern void wsXInit( void* disp ); extern int wsGetDepthOnScreen( void ); diff -r 9e23ceba3f65 -r 5e4214a7540e libvo/vo_xmga.c --- a/libvo/vo_xmga.c Mon Aug 27 23:56:15 2001 +0000 +++ b/libvo/vo_xmga.c Mon Aug 27 23:56:44 2001 +0000 @@ -108,7 +108,7 @@ XGetGeometry( mDisplay,mWindow,&mRoot,&drwX,&drwY,&drwWidth,&drwHeight,&drwBorderWidth,&drwDepth ); drwX=0; drwY=0; // drwWidth=wndWidth; drwHeight=wndHeight; XTranslateCoordinates( mDisplay,mWindow,mRoot,0,0,&drwcX,&drwcY,&mRoot ); - //fprintf( stderr,"[xmga] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); + fprintf( stderr,"[xmga] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); #ifdef HAVE_GUI if ( vo_window != None ) @@ -249,7 +249,7 @@ default: printf( "Sorry, this (%d) color depth not supported.\n",vo_depthonscreen ); return -1; } -#ifdef HAVE_GUI +#ifdef HAVE_NEW_GUI if ( vo_window == None ) { #endif @@ -289,7 +289,8 @@ XSetNormalHints( mDisplay,mWindow,&hint ); XStoreName( mDisplay,mWindow,mTitle ); XMapWindow( mDisplay,mWindow ); -#ifdef HAVE_GUI + mGC=XCreateGC( mDisplay,mWindow,GCForeground,&wGCV ); +#ifdef HAVE_NEW_GUI } else { @@ -301,9 +302,9 @@ XResizeWindow( mDisplay,mWindow,d_width,d_height ); } else mFullscreen=1; + mGC=vo_gc; //XCreateGC( mDisplay,mWindow,GCForeground,&wGCV ); } #endif - mGC=XCreateGC( mDisplay,mWindow,GCForeground,&wGCV ); set_window(); @@ -317,16 +318,13 @@ if(mga_init()) return -1; -#ifdef HAVE_GUI +#ifdef HAVE_NEW_GUI if ( vo_window == None ) - { #endif + { XFlush( mDisplay ); XSync( mDisplay,False ); -#ifdef HAVE_GUI - } -#endif - + } saver_off(mDisplay); return 0; diff -r 9e23ceba3f65 -r 5e4214a7540e libvo/x11_common.c --- a/libvo/x11_common.c Mon Aug 27 23:56:15 2001 +0000 +++ b/libvo/x11_common.c Mon Aug 27 23:56:44 2001 +0000 @@ -227,15 +227,17 @@ XSetClassHint(display,window,&wmClass); } -#ifdef HAVE_GUI +#ifdef HAVE_NEW_GUI Window vo_window = None; GC vo_gc; int vo_xeventhandling = 1; int vo_resize = 0; int vo_expose = 0; - void vo_setwindow( Window w,GC g ) - { vo_window=w; vo_gc=g; } + void vo_setwindow( Window w,GC g ) { + vo_window=w; vo_gc=g; + vo_xeventhandling=0; + } #endif int vo_x11_check_events(Display *mydisplay){ @@ -246,7 +248,7 @@ static XComposeStatus stat; // unsigned long vo_KeyTable[512]; -#ifdef HAVE_GUI +#ifdef HAVE_NEW_GUI if ( vo_xeventhandling ) { #endif @@ -270,7 +272,7 @@ break; } } -#ifdef HAVE_GUI +#ifdef HAVE_NEW_GUI } else { diff -r 9e23ceba3f65 -r 5e4214a7540e libvo/x11_common.h --- a/libvo/x11_common.h Mon Aug 27 23:56:15 2001 +0000 +++ b/libvo/x11_common.h Mon Aug 27 23:56:44 2001 +0000 @@ -20,15 +20,16 @@ int vo_x11_check_events(Display *mydisplay); #endif -#ifdef HAVE_GUI +#ifdef HAVE_NEW_GUI extern Window vo_window; - extern Display * vo_display; extern GC vo_gc; + extern void vo_setwindow( Window w,GC g ); extern int vo_xeventhandling; extern int vo_expose; extern int vo_resize; - - extern void vo_setwindow( Window w,GC g ); +#endif +#ifdef HAVE_GUI + extern Display * vo_display; #endif void saver_off( Display * ); diff -r 9e23ceba3f65 -r 5e4214a7540e mplayer.c --- a/mplayer.c Mon Aug 27 23:56:15 2001 +0000 +++ b/mplayer.c Mon Aug 27 23:56:44 2001 +0000 @@ -37,6 +37,7 @@ #include "libvo2/libvo2.h" #else #include "libvo/video_out.h" +void* mDisplay; // Display* mDisplay; #endif //#ifdef USE_OSD @@ -185,6 +186,8 @@ static int play_in_bg=0; +extern float gui_position; + extern void avi_fixate(); #ifdef HAVE_GUI @@ -274,26 +277,41 @@ int sub_auto = 1; /*DSP!!char *dsp=NULL;*/ -//float rel_seek_secs=0; //float initial_pts_delay=0; +float rel_seek_secs=0; +int abs_seek_pos=0; + extern char *vo_subdevice; extern char *ao_subdevice; void exit_player(char* how){ total_time_usage_start=GetTimer()-total_time_usage_start; -#ifdef HAVE_GUI - if ( !nogui ) - { - if ( how != NULL ) - { - if ( !strcmp( how,"Quit" ) ) mplSendMessage( mplEndOfFile ); - if ( !strcmp( how,"End of file" ) ) mplSendMessage( mplEndOfFile ); - if ( !strcmp( how,"audio_init" ) ) mplSendMessage( mplAudioError ); - } - else mplSendMessage( mplUnknowError ); - } + // restore terminal: + #ifdef HAVE_GUI + if ( nogui ) + #endif + getch2_disable(); + +#ifdef USE_LIBVO2 + if(video_out) vo2_close(video_out); +#else + if(video_out) video_out->uninit(); +#endif + +#ifdef HAVE_NEW_GUI + if(use_gui) mplDone(); +#endif + + if(audio_out) audio_out->uninit(); + + if(encode_name) avi_fixate(); +#ifdef HAVE_LIRC + #ifdef HAVE_GUI + if ( nogui ) + #endif + lirc_mp_cleanup(); #endif if(how) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Exiting,how); @@ -312,25 +330,6 @@ 100.0*(total_time_usage-tot)/total_time_usage, 100.0); } - // restore terminal: - #ifdef HAVE_GUI - if ( nogui ) - #endif - getch2_disable(); - -#ifdef USE_LIBVO2 - if(video_out) vo2_close(video_out); -#else - if(video_out) video_out->uninit(); -#endif - if(audio_out) audio_out->uninit(); - if(encode_name) avi_fixate(); -#ifdef HAVE_LIRC - #ifdef HAVE_GUI - if ( nogui ) - #endif - lirc_mp_cleanup(); -#endif exit(1); } @@ -454,9 +453,6 @@ //float a_frame=0; // Audio -float rel_seek_secs=0; -int abs_seek_pos=0; - int i; int use_stdin=0; //int f; // filedes @@ -480,9 +476,13 @@ mp_msg(MSGT_CPLAYER,MSGL_WARN,"MPlayer was compiled WITHOUT GUI support!\n"); use_gui=0; } +#else + if(use_gui && !vo_init()){ + mp_msg(MSGT_CPLAYER,MSGL_WARN,"MPlayer GUI requires X11!\n"); + use_gui=0; + } #endif - #ifndef USE_LIBVO2 if(video_driver && strcmp(video_driver,"help")==0){ printf("Available video output drivers:\n"); @@ -560,7 +560,7 @@ // It's time to init the GUI code: (and fork() the GTK process) #ifdef HAVE_NEW_GUI if(use_gui){ - appInit( argc,argv,envp ); + appInit( argc,argv,envp,(void*)mDisplay ); } #endif @@ -1779,6 +1779,17 @@ current_module=NULL; } +#ifdef HAVE_NEW_GUI + if(use_gui){ + int len=((demuxer->movi_end-demuxer->movi_start)>>8); + if(len>0) + gui_position=(demuxer->filepos-demuxer->movi_start)/len; + else + gui_position=-1; + } +#endif + + //================= Update OSD ==================== #ifdef USE_OSD if(osd_level>=2){