2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
// main window
|
|
|
|
|
2002-11-02 18:57:14 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "../app.h"
|
|
|
|
#include "../skin/font.h"
|
2002-11-10 15:31:26 +00:00
|
|
|
#include "../skin/skin.h"
|
2002-11-02 18:57:14 +00:00
|
|
|
#include "../wm/ws.h"
|
|
|
|
|
|
|
|
#include "../../config.h"
|
|
|
|
#include "../../help_mp.h"
|
|
|
|
#include "../../libvo/x11_common.h"
|
2003-03-20 12:42:16 +00:00
|
|
|
#include "../../libvo/fastmemcpy.h"
|
2002-11-02 18:57:14 +00:00
|
|
|
|
2001-10-24 10:58:18 +00:00
|
|
|
#include "../../libmpdemux/stream.h"
|
2002-06-06 07:13:57 +00:00
|
|
|
#include "../../mixer.h"
|
2002-07-02 13:35:04 +00:00
|
|
|
#include "../../libvo/sub.h"
|
|
|
|
#include "../../mplayer.h"
|
2001-10-24 10:58:18 +00:00
|
|
|
|
2002-11-28 19:01:50 +00:00
|
|
|
#include "../../libmpdemux/demuxer.h"
|
|
|
|
#include "../../libmpdemux/stheader.h"
|
|
|
|
#include "../../codec-cfg.h"
|
|
|
|
|
2004-10-18 18:26:44 +00:00
|
|
|
#define GUI_REDRAW_WAIT 375
|
2002-11-28 19:01:50 +00:00
|
|
|
|
2002-11-02 18:57:14 +00:00
|
|
|
#include "play.h"
|
|
|
|
#include "widgets.h"
|
|
|
|
|
2004-06-26 13:26:11 +00:00
|
|
|
extern mixer_t mixer; // mixer from mplayer.c
|
|
|
|
|
2002-11-02 16:09:05 +00:00
|
|
|
extern unsigned int GetTimerMS( void );
|
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
unsigned char * mplDrawBuffer = NULL;
|
|
|
|
int mplMainRender = 1;
|
2001-11-16 23:17:52 +00:00
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
int mplMainAutoPlay = 0;
|
2002-02-23 15:12:55 +00:00
|
|
|
int mplMiddleMenu = 0;
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
int mainVisible = 1;
|
|
|
|
|
|
|
|
int boxMoved = 0;
|
|
|
|
int sx = 0,sy = 0;
|
|
|
|
int i,pot = 0;
|
|
|
|
|
2003-01-17 22:39:43 +00:00
|
|
|
#include "common.h"
|
2001-08-25 21:04:29 +00:00
|
|
|
|
2002-11-02 20:10:18 +00:00
|
|
|
void mplMainDraw( void )
|
2001-08-25 21:04:29 +00:00
|
|
|
{
|
|
|
|
wItem * item;
|
|
|
|
txSample * image = NULL;
|
2002-11-27 23:11:49 +00:00
|
|
|
int i, type;
|
2001-08-25 21:04:29 +00:00
|
|
|
|
2002-05-11 14:57:41 +00:00
|
|
|
if ( appMPlayer.mainWindow.State == wsWindowClosed ) exit_player( MSGTR_Exit_quit );
|
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
if ( appMPlayer.mainWindow.Visible == wsWindowNotVisible ||
|
2001-08-28 15:55:02 +00:00
|
|
|
!mainVisible ) return;
|
|
|
|
// !appMPlayer.mainWindow.Mapped ) return;
|
|
|
|
|
2002-07-25 20:26:38 +00:00
|
|
|
if ( mplMainRender && appMPlayer.mainWindow.State == wsWindowExpose )
|
2001-08-25 21:04:29 +00:00
|
|
|
{
|
2003-01-17 22:39:43 +00:00
|
|
|
btnModify( evSetMoviePosition,guiIntfStruct.Position );
|
|
|
|
btnModify( evSetVolume,guiIntfStruct.Volume );
|
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
memcpy( mplDrawBuffer,appMPlayer.main.Bitmap.Image,appMPlayer.main.Bitmap.ImageSize );
|
2003-01-17 22:39:43 +00:00
|
|
|
Render( &appMPlayer.mainWindow,appMPlayer.Items,appMPlayer.NumberOfItems,mplDrawBuffer,appMPlayer.main.Bitmap.ImageSize );
|
2001-08-25 21:04:29 +00:00
|
|
|
mplMainRender=0;
|
|
|
|
}
|
|
|
|
wsPutImage( &appMPlayer.mainWindow );
|
2001-11-12 15:16:13 +00:00
|
|
|
// XFlush( wsDisplay );
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
|
2001-08-28 15:55:02 +00:00
|
|
|
extern void exit_player(char* how);
|
2002-06-03 15:06:32 +00:00
|
|
|
extern int vcd_track;
|
2002-07-02 13:35:04 +00:00
|
|
|
extern int osd_visible;
|
2004-10-18 18:26:44 +00:00
|
|
|
static unsigned last_redraw_time = 0;
|
2001-08-28 15:55:02 +00:00
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
void mplEventHandling( int msg,float param )
|
2001-08-25 21:04:29 +00:00
|
|
|
{
|
|
|
|
int j;
|
2002-12-11 01:21:12 +00:00
|
|
|
int iparam = (int)param;
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
switch( msg )
|
|
|
|
{
|
|
|
|
// --- user events
|
|
|
|
case evExit:
|
2001-11-12 12:26:09 +00:00
|
|
|
exit_player( "Exit" );
|
2001-08-25 21:04:29 +00:00
|
|
|
break;
|
|
|
|
|
2002-06-04 16:38:18 +00:00
|
|
|
case evPlayNetwork:
|
2003-01-19 22:46:39 +00:00
|
|
|
gfree( (void **)&guiIntfStruct.Subtitlename );
|
|
|
|
gfree( (void **)&guiIntfStruct.AudioFile );
|
2002-06-04 16:38:18 +00:00
|
|
|
guiIntfStruct.StreamType=STREAMTYPE_STREAM;
|
|
|
|
goto play;
|
|
|
|
case evSetURL:
|
|
|
|
gtkShow( evPlayNetwork,NULL );
|
|
|
|
break;
|
2002-11-29 00:58:25 +00:00
|
|
|
|
|
|
|
case evSetAudio:
|
2002-12-11 01:21:12 +00:00
|
|
|
if ( !guiIntfStruct.demuxer || audio_id == iparam ) break;
|
|
|
|
audio_id=iparam;
|
2002-12-16 22:25:17 +00:00
|
|
|
goto play;
|
2002-12-05 23:54:15 +00:00
|
|
|
|
|
|
|
case evSetVideo:
|
2002-12-11 01:21:12 +00:00
|
|
|
if ( !guiIntfStruct.demuxer || video_id == iparam ) break;
|
|
|
|
video_id=iparam;
|
2002-12-16 22:25:17 +00:00
|
|
|
goto play;
|
2002-12-05 23:54:15 +00:00
|
|
|
|
2002-06-03 15:06:32 +00:00
|
|
|
#ifdef HAVE_VCD
|
|
|
|
case evSetVCDTrack:
|
2002-12-11 01:21:12 +00:00
|
|
|
guiIntfStruct.Track=iparam;
|
2002-06-03 15:06:32 +00:00
|
|
|
case evPlayVCD:
|
2002-08-14 23:02:45 +00:00
|
|
|
gtkSet( gtkClearStruct,0,(void *)guiALL );
|
2002-06-03 15:06:32 +00:00
|
|
|
guiIntfStruct.StreamType=STREAMTYPE_VCD;
|
|
|
|
goto play;
|
|
|
|
#endif
|
2001-11-21 17:43:57 +00:00
|
|
|
#ifdef USE_DVDREAD
|
2001-11-19 09:48:59 +00:00
|
|
|
case evPlayDVD:
|
2002-04-17 21:12:12 +00:00
|
|
|
guiIntfStruct.DVD.current_title=1;
|
|
|
|
guiIntfStruct.DVD.current_chapter=1;
|
|
|
|
guiIntfStruct.DVD.current_angle=1;
|
2001-12-19 16:55:32 +00:00
|
|
|
play_dvd_2:
|
2002-08-14 23:02:45 +00:00
|
|
|
gtkSet( gtkClearStruct,0,(void *)(guiALL - guiDVD) );
|
2002-02-23 15:12:55 +00:00
|
|
|
guiIntfStruct.StreamType=STREAMTYPE_DVD;
|
2002-12-11 01:21:12 +00:00
|
|
|
goto play;
|
2001-11-21 17:43:57 +00:00
|
|
|
#endif
|
2001-11-19 09:48:59 +00:00
|
|
|
case evPlay:
|
2001-08-25 21:04:29 +00:00
|
|
|
case evPlaySwitchToPause:
|
2002-06-03 15:06:32 +00:00
|
|
|
play:
|
2002-07-12 00:53:26 +00:00
|
|
|
|
2002-07-25 20:26:38 +00:00
|
|
|
if ( ( msg == evPlaySwitchToPause )&&( guiIntfStruct.Playing == 2 ) ) goto NoPause;
|
2001-12-19 16:55:32 +00:00
|
|
|
|
2002-08-04 20:44:21 +00:00
|
|
|
if ( gtkSet( gtkGetCurrPlItem,0,NULL ) &&( guiIntfStruct.StreamType == STREAMTYPE_FILE ) )
|
2002-07-12 00:53:26 +00:00
|
|
|
{
|
|
|
|
plItem * next = gtkSet( gtkGetCurrPlItem,0,NULL );
|
|
|
|
plLastPlayed=next;
|
2002-12-11 01:21:12 +00:00
|
|
|
mplSetFileName( next->path,next->name,STREAMTYPE_FILE );
|
2002-07-12 00:53:26 +00:00
|
|
|
}
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
switch ( guiIntfStruct.StreamType )
|
2001-08-25 21:04:29 +00:00
|
|
|
{
|
2002-06-04 16:38:18 +00:00
|
|
|
case STREAMTYPE_STREAM:
|
2002-06-03 15:06:32 +00:00
|
|
|
case STREAMTYPE_FILE:
|
2002-08-14 23:02:45 +00:00
|
|
|
gtkSet( gtkClearStruct,0,(void *)(guiALL - guiFilenames) );
|
2002-06-03 15:06:32 +00:00
|
|
|
break;
|
|
|
|
#ifdef HAVE_VCD
|
2001-11-19 09:56:22 +00:00
|
|
|
case STREAMTYPE_VCD:
|
2002-08-14 23:02:45 +00:00
|
|
|
gtkSet( gtkClearStruct,0,(void *)(guiALL - guiVCD - guiFilenames) );
|
2003-01-12 23:38:55 +00:00
|
|
|
if ( !cdrom_device ) cdrom_device=gstrdup( DEFAULT_CDROM_DEVICE );
|
2002-08-14 23:02:45 +00:00
|
|
|
mplSetFileName( NULL,cdrom_device,STREAMTYPE_VCD );
|
2002-06-03 15:06:32 +00:00
|
|
|
if ( guiIntfStruct.Playing != 2 )
|
|
|
|
{
|
|
|
|
if ( !guiIntfStruct.Track )
|
|
|
|
{
|
2002-12-11 01:21:12 +00:00
|
|
|
if ( guiIntfStruct.VCDTracks > 1 ) guiIntfStruct.Track=2;
|
|
|
|
else guiIntfStruct.Track=1;
|
2002-06-03 15:06:32 +00:00
|
|
|
}
|
|
|
|
guiIntfStruct.DiskChanged=1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
2001-11-21 17:43:57 +00:00
|
|
|
#ifdef USE_DVDREAD
|
2002-02-23 15:12:55 +00:00
|
|
|
case STREAMTYPE_DVD:
|
2002-08-14 23:02:45 +00:00
|
|
|
gtkSet( gtkClearStruct,0,(void *)(guiALL - guiDVD - guiFilenames) );
|
2003-01-12 23:38:55 +00:00
|
|
|
if ( !dvd_device ) dvd_device=gstrdup( DEFAULT_DVD_DEVICE );
|
2002-08-14 23:02:45 +00:00
|
|
|
mplSetFileName( NULL,dvd_device,STREAMTYPE_DVD );
|
2002-04-17 21:38:21 +00:00
|
|
|
if ( guiIntfStruct.Playing != 2 )
|
|
|
|
{
|
2002-12-11 01:21:12 +00:00
|
|
|
guiIntfStruct.Title=guiIntfStruct.DVD.current_title;
|
|
|
|
guiIntfStruct.Chapter=guiIntfStruct.DVD.current_chapter;
|
|
|
|
guiIntfStruct.Angle=guiIntfStruct.DVD.current_angle;
|
2002-06-03 15:06:32 +00:00
|
|
|
guiIntfStruct.DiskChanged=1;
|
2002-04-17 21:38:21 +00:00
|
|
|
}
|
2002-02-23 15:12:55 +00:00
|
|
|
break;
|
2001-11-21 17:43:57 +00:00
|
|
|
#endif
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
2002-12-11 01:21:12 +00:00
|
|
|
guiIntfStruct.NewPlay=1;
|
2001-08-25 21:04:29 +00:00
|
|
|
mplPlay();
|
|
|
|
break;
|
2001-12-19 16:55:32 +00:00
|
|
|
#ifdef USE_DVDREAD
|
2002-02-23 15:12:55 +00:00
|
|
|
case evSetDVDSubtitle:
|
2002-12-11 01:21:12 +00:00
|
|
|
dvdsub_id=iparam;
|
2002-02-23 15:12:55 +00:00
|
|
|
goto play_dvd_2;
|
2001-12-18 23:19:53 +00:00
|
|
|
break;
|
|
|
|
case evSetDVDAudio:
|
2002-12-11 01:21:12 +00:00
|
|
|
audio_id=iparam;
|
2002-02-23 15:12:55 +00:00
|
|
|
goto play_dvd_2;
|
2001-12-18 23:19:53 +00:00
|
|
|
break;
|
|
|
|
case evSetDVDChapter:
|
2002-12-11 01:21:12 +00:00
|
|
|
guiIntfStruct.DVD.current_chapter=iparam;
|
2002-02-23 15:12:55 +00:00
|
|
|
goto play_dvd_2;
|
2001-12-18 23:19:53 +00:00
|
|
|
break;
|
|
|
|
case evSetDVDTitle:
|
2002-12-11 01:21:12 +00:00
|
|
|
guiIntfStruct.DVD.current_title=iparam;
|
2002-04-17 21:12:12 +00:00
|
|
|
guiIntfStruct.DVD.current_chapter=1;
|
|
|
|
guiIntfStruct.DVD.current_angle=1;
|
2002-02-23 15:12:55 +00:00
|
|
|
goto play_dvd_2;
|
2001-12-18 23:19:53 +00:00
|
|
|
break;
|
2002-02-23 15:12:55 +00:00
|
|
|
#endif
|
2001-08-25 21:04:29 +00:00
|
|
|
|
2001-11-19 09:48:59 +00:00
|
|
|
case evPause:
|
2001-08-25 21:04:29 +00:00
|
|
|
case evPauseSwitchToPlay:
|
|
|
|
NoPause:
|
|
|
|
mplPause();
|
|
|
|
break;
|
|
|
|
|
2002-12-11 01:21:12 +00:00
|
|
|
case evStop:
|
|
|
|
guiIntfStruct.Playing=guiSetStop;
|
|
|
|
mplState();
|
|
|
|
guiIntfStruct.NoWindow=False;
|
|
|
|
break;
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
case evLoadPlay:
|
|
|
|
mplMainAutoPlay=1;
|
2002-06-03 15:06:32 +00:00
|
|
|
// guiIntfStruct.StreamType=STREAMTYPE_FILE;
|
2001-08-25 21:04:29 +00:00
|
|
|
case evLoad:
|
2002-07-12 00:53:26 +00:00
|
|
|
gtkSet( gtkDelPl,0,NULL );
|
2002-02-23 15:12:55 +00:00
|
|
|
gtkShow( evLoad,NULL );
|
2001-08-25 21:04:29 +00:00
|
|
|
break;
|
2002-07-25 20:26:38 +00:00
|
|
|
case evLoadSubtitle: gtkShow( evLoadSubtitle,NULL ); break;
|
2002-08-30 19:11:03 +00:00
|
|
|
case evDropSubtitle:
|
|
|
|
gfree( (void **)&guiIntfStruct.Subtitlename );
|
|
|
|
guiLoadSubtitle( NULL );
|
|
|
|
break;
|
2002-07-25 20:26:38 +00:00
|
|
|
case evLoadAudioFile: gtkShow( evLoadAudioFile,NULL ); break;
|
|
|
|
case evPrev: mplPrev(); break;
|
|
|
|
case evNext: mplNext(); break;
|
2001-08-25 21:04:29 +00:00
|
|
|
|
2002-07-12 00:53:26 +00:00
|
|
|
case evPlayList: gtkShow( evPlayList,NULL ); break;
|
2002-02-23 15:12:55 +00:00
|
|
|
case evSkinBrowser: gtkShow( evSkinBrowser,skinName ); break;
|
2002-07-12 00:53:26 +00:00
|
|
|
case evAbout: gtkShow( evAbout,NULL ); break;
|
|
|
|
case evPreferences: gtkShow( evPreferences,NULL ); break;
|
|
|
|
case evEqualizer: gtkShow( evEqualizer,NULL ); break;
|
2001-08-25 21:04:29 +00:00
|
|
|
|
2003-01-02 15:53:21 +00:00
|
|
|
case evForward10min: mplRelSeek( 600 ); break;
|
|
|
|
case evBackward10min: mplRelSeek( -600 );break;
|
2001-08-25 21:04:29 +00:00
|
|
|
case evForward1min: mplRelSeek( 60 ); break;
|
|
|
|
case evBackward1min: mplRelSeek( -60 ); break;
|
|
|
|
case evForward10sec: mplRelSeek( 10 ); break;
|
|
|
|
case evBackward10sec: mplRelSeek( -10 ); break;
|
|
|
|
case evSetMoviePosition: mplAbsSeek( param ); break;
|
|
|
|
|
2001-09-06 09:36:48 +00:00
|
|
|
case evIncVolume: vo_x11_putkey( wsGrayMul ); break;
|
|
|
|
case evDecVolume: vo_x11_putkey( wsGrayDiv ); break;
|
2004-06-26 13:26:11 +00:00
|
|
|
case evMute: mixer_mute( &mixer ); break;
|
2002-07-02 13:35:04 +00:00
|
|
|
|
2001-11-12 12:26:09 +00:00
|
|
|
case evSetVolume:
|
2002-07-02 13:35:04 +00:00
|
|
|
guiIntfStruct.Volume=param;
|
|
|
|
goto set_volume;
|
|
|
|
case evSetBalance:
|
|
|
|
guiIntfStruct.Balance=param;
|
|
|
|
set_volume:
|
|
|
|
{
|
|
|
|
float l = guiIntfStruct.Volume * ( ( 100.0 - guiIntfStruct.Balance ) / 50.0 );
|
|
|
|
float r = guiIntfStruct.Volume * ( ( guiIntfStruct.Balance ) / 50.0 );
|
|
|
|
if ( l > guiIntfStruct.Volume ) l=guiIntfStruct.Volume;
|
|
|
|
if ( r > guiIntfStruct.Volume ) r=guiIntfStruct.Volume;
|
|
|
|
// printf( "!!! v: %.2f b: %.2f -> %.2f x %.2f\n",guiIntfStruct.Volume,guiIntfStruct.Balance,l,r );
|
2004-06-26 13:26:11 +00:00
|
|
|
mixer_setvolume( &mixer,l,r );
|
2002-07-02 13:35:04 +00:00
|
|
|
}
|
|
|
|
#ifdef USE_OSD
|
|
|
|
if ( osd_level )
|
|
|
|
{
|
|
|
|
osd_visible=vo_mouse_timer_const;
|
|
|
|
vo_osd_progbar_type=OSD_VOLUME;
|
|
|
|
vo_osd_progbar_value=( ( guiIntfStruct.Volume ) * 256.0 ) / 100.0;
|
|
|
|
vo_osd_changed( OSDTYPE_PROGBAR );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
break;
|
2001-09-02 21:26:51 +00:00
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
|
2001-11-19 09:48:59 +00:00
|
|
|
case evIconify:
|
2002-12-11 01:21:12 +00:00
|
|
|
switch ( iparam )
|
2001-11-19 09:48:59 +00:00
|
|
|
{
|
|
|
|
case 0: wsIconify( appMPlayer.mainWindow ); break;
|
|
|
|
case 1: wsIconify( appMPlayer.subWindow ); break;
|
|
|
|
}
|
|
|
|
break;
|
2005-01-25 12:44:38 +00:00
|
|
|
case evHalfSize:
|
|
|
|
btnSet( evFullScreen,btnReleased );
|
|
|
|
if ( guiIntfStruct.Playing )
|
|
|
|
{
|
|
|
|
if ( appMPlayer.subWindow.isFullScreen )
|
|
|
|
{
|
|
|
|
mplFullScreen();
|
|
|
|
}
|
|
|
|
wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth / 2, guiIntfStruct.MovieHeight / 2 );
|
|
|
|
wsMoveWindow( &appMPlayer.subWindow, 0,
|
|
|
|
( wsMaxX - guiIntfStruct.MovieWidth/2 )/2 + wsOrgX,
|
|
|
|
( wsMaxY - guiIntfStruct.MovieHeight/2 )/2 + wsOrgY );
|
|
|
|
}
|
|
|
|
break;
|
2002-07-02 22:31:50 +00:00
|
|
|
case evDoubleSize:
|
2003-02-01 16:42:02 +00:00
|
|
|
btnSet( evFullScreen,btnReleased );
|
2002-02-23 15:12:55 +00:00
|
|
|
if ( guiIntfStruct.Playing )
|
2001-11-12 12:26:09 +00:00
|
|
|
{
|
2004-11-21 15:10:37 +00:00
|
|
|
if ( appMPlayer.subWindow.isFullScreen )
|
|
|
|
{
|
|
|
|
mplFullScreen();
|
|
|
|
}
|
|
|
|
wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth * 2, guiIntfStruct.MovieHeight * 2 );
|
|
|
|
wsMoveWindow( &appMPlayer.subWindow, 0,
|
|
|
|
( wsMaxX - guiIntfStruct.MovieWidth*2 )/2 + wsOrgX,
|
|
|
|
( wsMaxY - guiIntfStruct.MovieHeight*2 )/2 + wsOrgY );
|
2001-11-12 12:26:09 +00:00
|
|
|
}
|
|
|
|
break;
|
2002-07-02 22:31:50 +00:00
|
|
|
case evNormalSize:
|
2003-02-01 16:42:02 +00:00
|
|
|
btnSet( evFullScreen,btnReleased );
|
2002-02-23 15:12:55 +00:00
|
|
|
if ( guiIntfStruct.Playing )
|
2001-11-12 12:26:09 +00:00
|
|
|
{
|
2004-11-21 15:10:37 +00:00
|
|
|
if ( appMPlayer.subWindow.isFullScreen )
|
|
|
|
{
|
|
|
|
mplFullScreen();
|
|
|
|
}
|
|
|
|
wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth, guiIntfStruct.MovieHeight );
|
|
|
|
wsMoveWindow( &appMPlayer.subWindow, 0,
|
|
|
|
( wsMaxX - guiIntfStruct.MovieWidth )/2 + wsOrgX,
|
|
|
|
( wsMaxY - guiIntfStruct.MovieHeight )/2 + wsOrgY );
|
2002-07-02 22:31:50 +00:00
|
|
|
break;
|
|
|
|
} else if ( !appMPlayer.subWindow.isFullScreen ) break;
|
2001-11-19 09:48:59 +00:00
|
|
|
case evFullScreen:
|
2003-02-01 16:42:02 +00:00
|
|
|
if ( !guiIntfStruct.Playing && !gtkShowVideoWindow ) break;
|
2001-11-19 09:48:59 +00:00
|
|
|
mplFullScreen();
|
2003-02-01 16:42:02 +00:00
|
|
|
if ( appMPlayer.subWindow.isFullScreen ) btnSet( evFullScreen,btnPressed );
|
|
|
|
else btnSet( evFullScreen,btnReleased );
|
2001-11-19 09:48:59 +00:00
|
|
|
break;
|
2001-08-25 21:04:29 +00:00
|
|
|
|
2002-09-28 21:16:12 +00:00
|
|
|
case evSetAspect:
|
2002-12-11 01:21:12 +00:00
|
|
|
switch ( iparam )
|
2002-09-28 21:16:12 +00:00
|
|
|
{
|
|
|
|
case 2: movie_aspect=16.0f / 9.0f; break;
|
|
|
|
case 3: movie_aspect=4.0f / 3.0f; break;
|
|
|
|
case 4: movie_aspect=2.35; break;
|
|
|
|
case 1:
|
|
|
|
default: movie_aspect=-1;
|
|
|
|
}
|
|
|
|
wsClearWindow( appMPlayer.subWindow );
|
2002-11-02 14:01:41 +00:00
|
|
|
#ifdef USE_DVDREAD
|
2002-12-11 01:21:12 +00:00
|
|
|
if ( guiIntfStruct.StreamType == STREAMTYPE_DVD || guiIntfStruct.StreamType == STREAMTYPE_VCD ) goto play_dvd_2;
|
2002-11-02 14:01:41 +00:00
|
|
|
else
|
|
|
|
#endif
|
2002-12-11 01:21:12 +00:00
|
|
|
guiIntfStruct.NewPlay=1;
|
2002-09-28 21:16:12 +00:00
|
|
|
break;
|
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
// --- timer events
|
|
|
|
case evRedraw:
|
2004-10-18 18:26:44 +00:00
|
|
|
{
|
|
|
|
unsigned now = GetTimerMS();
|
|
|
|
extern int mplPBFade;
|
|
|
|
if ((now > last_redraw_time) &&
|
|
|
|
(now < last_redraw_time + GUI_REDRAW_WAIT) &&
|
|
|
|
!mplPBFade)
|
|
|
|
break;
|
|
|
|
last_redraw_time = now;
|
|
|
|
}
|
2001-08-25 21:04:29 +00:00
|
|
|
mplMainRender=1;
|
|
|
|
wsPostRedisplay( &appMPlayer.mainWindow );
|
2003-01-17 22:39:43 +00:00
|
|
|
wsPostRedisplay( &appMPlayer.barWindow );
|
2001-08-25 21:04:29 +00:00
|
|
|
break;
|
|
|
|
// --- system events
|
2002-05-28 11:55:17 +00:00
|
|
|
#ifdef MP_DEBUG
|
2001-08-25 21:04:29 +00:00
|
|
|
case evNone:
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[mw] event none received.\n" );
|
2001-08-25 21:04:29 +00:00
|
|
|
break;
|
|
|
|
default:
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[mw] unknown event received ( %d,%.2f ).\n",msg,param );
|
2001-08-25 21:04:29 +00:00
|
|
|
break;
|
2002-05-28 11:55:17 +00:00
|
|
|
#endif
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-12 12:26:09 +00:00
|
|
|
#define itPLMButton (itNULL - 1)
|
|
|
|
#define itPRMButton (itNULL - 2)
|
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
void mplMainMouseHandle( int Button,int X,int Y,int RX,int RY )
|
|
|
|
{
|
|
|
|
static int itemtype = 0;
|
2001-11-12 12:26:09 +00:00
|
|
|
int i;
|
2001-08-25 21:04:29 +00:00
|
|
|
wItem * item = NULL;
|
|
|
|
float value = 0.0f;
|
2001-11-12 12:26:09 +00:00
|
|
|
|
|
|
|
static int SelectedItem = -1;
|
|
|
|
int currentselected = -1;
|
|
|
|
|
|
|
|
for ( i=0;i < appMPlayer.NumberOfItems + 1;i++ )
|
|
|
|
if ( ( appMPlayer.Items[i].pressed != btnDisabled )&&
|
|
|
|
( wgIsRect( X,Y,appMPlayer.Items[i].x,appMPlayer.Items[i].y,appMPlayer.Items[i].x+appMPlayer.Items[i].width,appMPlayer.Items[i].y+appMPlayer.Items[i].height ) ) )
|
|
|
|
{ currentselected=i; break; }
|
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
switch ( Button )
|
|
|
|
{
|
2002-07-05 23:47:00 +00:00
|
|
|
case wsPMMouseButton:
|
2002-07-19 20:51:48 +00:00
|
|
|
gtkShow( evHidePopUpMenu,NULL );
|
2001-08-25 21:04:29 +00:00
|
|
|
mplShowMenu( RX,RY );
|
2001-11-12 12:26:09 +00:00
|
|
|
itemtype=itPRMButton;
|
2001-08-25 21:04:29 +00:00
|
|
|
break;
|
2002-07-05 23:47:00 +00:00
|
|
|
case wsRMMouseButton:
|
2002-05-01 09:29:06 +00:00
|
|
|
mplHideMenu( RX,RY,0 );
|
2001-08-25 21:04:29 +00:00
|
|
|
break;
|
2001-11-12 12:26:09 +00:00
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
case wsPLMouseButton:
|
2002-07-19 20:51:48 +00:00
|
|
|
gtkShow( evHidePopUpMenu,NULL );
|
2003-01-17 22:39:43 +00:00
|
|
|
sx=X; sy=Y; boxMoved=1; itemtype=itPLMButton;
|
2001-11-12 12:26:09 +00:00
|
|
|
SelectedItem=currentselected;
|
2003-01-17 22:39:43 +00:00
|
|
|
if ( SelectedItem == -1 ) break;
|
|
|
|
boxMoved=0;
|
2001-11-12 12:26:09 +00:00
|
|
|
item=&appMPlayer.Items[SelectedItem];
|
|
|
|
itemtype=item->type;
|
|
|
|
item->pressed=btnPressed;
|
|
|
|
switch( item->type )
|
|
|
|
{
|
|
|
|
case itButton:
|
|
|
|
if ( ( SelectedItem > -1 ) &&
|
2003-01-17 22:39:43 +00:00
|
|
|
( ( ( item->msg == evPlaySwitchToPause && item->msg == evPauseSwitchToPlay ) ) ||
|
|
|
|
( ( item->msg == evPauseSwitchToPlay && item->msg == evPlaySwitchToPause ) ) ) )
|
|
|
|
{ item->pressed=btnDisabled; }
|
2001-11-12 12:26:09 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case wsRLMouseButton:
|
|
|
|
boxMoved=0;
|
|
|
|
item=&appMPlayer.Items[SelectedItem];
|
|
|
|
item->pressed=btnReleased;
|
|
|
|
SelectedItem=-1;
|
|
|
|
if ( currentselected == - 1 ) { itemtype=0; break; }
|
|
|
|
value=0;
|
|
|
|
switch( itemtype )
|
|
|
|
{
|
|
|
|
case itPotmeter:
|
2003-01-17 23:29:14 +00:00
|
|
|
case itVPotmeter:
|
2001-11-12 12:26:09 +00:00
|
|
|
case itHPotmeter:
|
|
|
|
btnModify( item->msg,(float)( X - item->x ) / item->width * 100.0f );
|
2002-07-02 13:35:04 +00:00
|
|
|
mplEventHandling( item->msg,item->value );
|
2001-11-12 12:26:09 +00:00
|
|
|
value=item->value;
|
|
|
|
break;
|
|
|
|
}
|
2002-02-23 15:12:55 +00:00
|
|
|
mplEventHandling( item->msg,value );
|
2001-11-12 12:26:09 +00:00
|
|
|
itemtype=0;
|
|
|
|
break;
|
2002-02-23 15:12:55 +00:00
|
|
|
|
2002-07-05 23:47:00 +00:00
|
|
|
case wsPRMouseButton:
|
2002-02-23 15:12:55 +00:00
|
|
|
gtkShow( evShowPopUpMenu,NULL );
|
|
|
|
break;
|
2001-11-12 12:26:09 +00:00
|
|
|
|
|
|
|
// --- rolled mouse ... de szar :)))
|
|
|
|
case wsP5MouseButton: value=-2.5f; goto rollerhandled;
|
|
|
|
case wsP4MouseButton: value= 2.5f;
|
|
|
|
rollerhandled:
|
|
|
|
item=&appMPlayer.Items[currentselected];
|
|
|
|
if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itPotmeter ) )
|
2001-08-25 21:04:29 +00:00
|
|
|
{
|
2001-11-12 12:26:09 +00:00
|
|
|
item->value+=value;
|
|
|
|
btnModify( item->msg,item->value );
|
2002-02-23 15:12:55 +00:00
|
|
|
mplEventHandling( item->msg,item->value );
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
break;
|
2001-11-12 12:26:09 +00:00
|
|
|
|
|
|
|
// --- moving
|
2001-08-25 21:04:29 +00:00
|
|
|
case wsMoveMouse:
|
2001-11-12 12:26:09 +00:00
|
|
|
item=&appMPlayer.Items[SelectedItem];
|
|
|
|
switch ( itemtype )
|
2001-08-25 21:04:29 +00:00
|
|
|
{
|
2001-11-12 12:26:09 +00:00
|
|
|
case itPLMButton:
|
2001-11-12 15:16:13 +00:00
|
|
|
wsMoveWindow( &appMPlayer.mainWindow,False,RX - abs( sx ),RY - abs( sy ) );
|
2001-08-25 21:04:29 +00:00
|
|
|
mplMainRender=0;
|
|
|
|
break;
|
2001-11-12 12:26:09 +00:00
|
|
|
case itPRMButton:
|
2001-08-25 21:04:29 +00:00
|
|
|
mplMenuMouseHandle( X,Y,RX,RY );
|
|
|
|
break;
|
|
|
|
case itPotmeter:
|
2001-08-28 15:55:02 +00:00
|
|
|
item->value=(float)( X - item->x ) / item->width * 100.0f;
|
2001-08-25 21:04:29 +00:00
|
|
|
goto potihandled;
|
2003-01-17 22:39:43 +00:00
|
|
|
case itVPotmeter:
|
|
|
|
item->value=(float)( Y - item->y ) / item->height * 100.0f;
|
|
|
|
goto potihandled;
|
2001-08-25 21:04:29 +00:00
|
|
|
case itHPotmeter:
|
2001-08-28 15:55:02 +00:00
|
|
|
item->value=(float)( X - item->x ) / item->width * 100.0f;
|
2001-08-25 21:04:29 +00:00
|
|
|
potihandled:
|
2001-11-12 12:26:09 +00:00
|
|
|
if ( item->value > 100.0f ) item->value=100.0f;
|
|
|
|
if ( item->value < 0.0f ) item->value=0.0f;
|
2002-02-23 15:12:55 +00:00
|
|
|
mplEventHandling( item->msg,item->value );
|
2001-08-25 21:04:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int keyPressed = 0;
|
|
|
|
|
2002-05-25 09:46:37 +00:00
|
|
|
void mplMainKeyHandle( int KeyCode,int Type,int Key )
|
2001-08-25 21:04:29 +00:00
|
|
|
{
|
|
|
|
int msg = evNone;
|
2002-03-06 18:42:56 +00:00
|
|
|
|
2002-01-29 16:35:53 +00:00
|
|
|
if ( Type != wsKeyPressed ) return;
|
2002-05-25 09:46:37 +00:00
|
|
|
|
|
|
|
if ( !Key )
|
2001-08-25 21:04:29 +00:00
|
|
|
{
|
2002-05-25 09:46:37 +00:00
|
|
|
switch ( KeyCode )
|
|
|
|
{
|
|
|
|
case wsXFMMPrev: msg=evPrev; break;
|
|
|
|
case wsXFMMStop: msg=evStop; break;
|
|
|
|
case wsXFMMPlay: msg=evPlaySwitchToPause; break;
|
|
|
|
case wsXFMMNext: msg=evNext; break;
|
|
|
|
case wsXFMMVolUp: msg=evIncVolume; break;
|
|
|
|
case wsXFMMVolDown: msg=evDecVolume; break;
|
|
|
|
case wsXFMMMute: msg=evMute; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch ( Key )
|
|
|
|
{
|
2002-11-28 00:44:24 +00:00
|
|
|
case wsEnter: msg=evPlay; break;
|
2002-05-25 09:46:37 +00:00
|
|
|
case wsXF86LowerVolume: msg=evDecVolume; break;
|
|
|
|
case wsXF86RaiseVolume: msg=evIncVolume; break;
|
|
|
|
case wsXF86Mute: msg=evMute; break;
|
|
|
|
case wsXF86Play: msg=evPlaySwitchToPause; break;
|
|
|
|
case wsXF86Stop: msg=evStop; break;
|
|
|
|
case wsXF86Prev: msg=evPrev; break;
|
|
|
|
case wsXF86Next: msg=evNext; break;
|
|
|
|
case wsXF86Media: msg=evLoad; break;
|
2003-01-17 22:39:43 +00:00
|
|
|
case wsEscape:
|
2002-11-28 00:44:24 +00:00
|
|
|
if ( appMPlayer.subWindow.isFullScreen )
|
|
|
|
{
|
2003-01-17 22:39:43 +00:00
|
|
|
if ( guiIntfStruct.event_struct ) ((XEvent *)guiIntfStruct.event_struct)->type=None;
|
2002-11-28 00:44:24 +00:00
|
|
|
mplEventHandling( evNormalSize,0 );
|
2003-01-17 22:39:43 +00:00
|
|
|
return;
|
2002-11-28 00:44:24 +00:00
|
|
|
}
|
2002-05-25 09:46:37 +00:00
|
|
|
default: vo_x11_putkey( Key ); return;
|
|
|
|
}
|
|
|
|
}
|
2002-02-25 13:14:27 +00:00
|
|
|
if ( msg != evNone ) mplEventHandling( msg,0 );
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
2002-08-11 13:12:38 +00:00
|
|
|
|
|
|
|
/* this will be used to handle Drag&Drop files */
|
2002-08-26 22:20:58 +00:00
|
|
|
void mplDandDHandler(int num,char** files)
|
2002-08-11 13:12:38 +00:00
|
|
|
{
|
|
|
|
struct stat buf;
|
|
|
|
int f = 0;
|
|
|
|
|
2002-12-16 20:16:29 +00:00
|
|
|
char* subtitles = NULL;
|
|
|
|
char* filename = NULL;
|
|
|
|
|
2002-08-11 13:12:38 +00:00
|
|
|
if (num <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
/* now fill it with new items */
|
|
|
|
for(f=0; f < num; f++){
|
2002-08-11 19:12:09 +00:00
|
|
|
char* str = strdup( files[f] );
|
2002-08-11 13:12:38 +00:00
|
|
|
plItem* item;
|
2002-08-11 19:12:09 +00:00
|
|
|
|
2002-08-14 12:17:04 +00:00
|
|
|
#ifdef USE_ICONV
|
2002-08-11 19:12:09 +00:00
|
|
|
if ( strchr( str,'%' ) )
|
|
|
|
{
|
2002-08-14 12:17:04 +00:00
|
|
|
char * tmp=gconvert_uri_to_filename( str );
|
|
|
|
free( str ); str=tmp;
|
2002-08-11 19:12:09 +00:00
|
|
|
}
|
2002-08-14 12:17:04 +00:00
|
|
|
#endif
|
2002-08-11 19:12:09 +00:00
|
|
|
|
2002-08-11 13:12:38 +00:00
|
|
|
if(stat(str,&buf) == 0 && S_ISDIR(buf.st_mode) == 0) {
|
|
|
|
/* this is not a directory so try to play it */
|
2004-12-15 01:22:24 +00:00
|
|
|
mp_msg( MSGT_GPLAYER,MSGL_V,"Received D&D %s\n",str );
|
2002-12-16 20:16:29 +00:00
|
|
|
|
|
|
|
/* check if it is a subtitle file */
|
|
|
|
{
|
|
|
|
char* ext = strrchr(str,'.');
|
|
|
|
if (ext) {
|
|
|
|
static char supported[] = "utf/sub/srt/smi/rt//txt/ssa/aqt/";
|
|
|
|
char* type;
|
|
|
|
int len;
|
|
|
|
if((len=strlen(++ext)) && (type=strstr(supported,ext)) &&\
|
|
|
|
(type-supported)%4 == 0 && *(type+len) == '/'){
|
|
|
|
/* handle subtitle file */
|
|
|
|
gfree((void**)&subtitles);
|
|
|
|
subtitles = str;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clear playlist */
|
|
|
|
if (filename == NULL) {
|
|
|
|
filename = files[f];
|
|
|
|
gtkSet(gtkDelPl,0,NULL);
|
|
|
|
}
|
|
|
|
|
2002-08-11 13:12:38 +00:00
|
|
|
item = calloc(1,sizeof(plItem));
|
2002-08-11 19:12:09 +00:00
|
|
|
|
2002-08-11 13:12:38 +00:00
|
|
|
/* FIXME: decompose file name ? */
|
|
|
|
/* yes -- Pontscho */
|
2002-12-16 20:16:29 +00:00
|
|
|
if ( strrchr( str,'/' ) ) {
|
2002-08-11 19:12:09 +00:00
|
|
|
char * s = strrchr( str,'/' ); *s=0; s++;
|
2002-12-16 20:16:29 +00:00
|
|
|
item->name = gstrdup( s );
|
|
|
|
item->path = gstrdup( str );
|
|
|
|
} else {
|
|
|
|
item->name = strdup(str);
|
|
|
|
item->path = strdup("");
|
|
|
|
}
|
2002-08-11 13:12:38 +00:00
|
|
|
gtkSet(gtkAddPlItem,0,(void*)item);
|
|
|
|
} else {
|
2004-12-15 01:22:24 +00:00
|
|
|
mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_NotAFile,str );
|
2002-08-11 13:12:38 +00:00
|
|
|
}
|
2002-08-11 19:12:09 +00:00
|
|
|
free( str );
|
2002-08-11 13:12:38 +00:00
|
|
|
}
|
|
|
|
|
2002-12-16 20:16:29 +00:00
|
|
|
if (filename) {
|
|
|
|
mplSetFileName( NULL,filename,STREAMTYPE_FILE );
|
|
|
|
if ( guiIntfStruct.Playing == 1 ) mplEventHandling( evStop,0 );
|
|
|
|
mplEventHandling( evPlay,0 );
|
|
|
|
}
|
|
|
|
if (subtitles) {
|
|
|
|
gfree((void**)&guiIntfStruct.Subtitlename);
|
|
|
|
guiIntfStruct.Subtitlename = subtitles;
|
|
|
|
guiLoadSubtitle(guiIntfStruct.Subtitlename);
|
|
|
|
}
|
2002-08-11 13:12:38 +00:00
|
|
|
}
|