2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include "libvo/x11_common.h"
30 #include "libvo/video_out.h"
31 #include "input/input.h"
33 #include "gui/wm/ws.h"
34 #include "gui/wm/wsxdnd.h"
37 #include "gui/wm/wskeys.h"
38 #include "gui/interface.h"
44 #include "gui/skin/skin.h"
45 #include "gui/skin/font.h"
47 #include "stream/stream.h"
49 extern float rel_seek_secs
;
50 extern int abs_seek_pos
;
52 int mplGotoTheNext
= 1;
54 void mplFullScreen( void )
56 if ( guiIntfStruct
.NoWindow
&& guiIntfStruct
.Playing
) return;
58 if ( ( guiIntfStruct
.Playing
)&&( appMPlayer
.subWindow
.isFullScreen
) )
60 appMPlayer
.subWindow
.OldWidth
=guiIntfStruct
.MovieWidth
; appMPlayer
.subWindow
.OldHeight
=guiIntfStruct
.MovieHeight
;
61 switch ( appMPlayer
.sub
.x
)
63 case -1: appMPlayer
.subWindow
.OldX
=( wsMaxX
/ 2 ) - ( appMPlayer
.subWindow
.OldWidth
/ 2 ) + wsOrgX
; break;
64 case -2: appMPlayer
.subWindow
.OldX
=wsMaxX
- appMPlayer
.subWindow
.OldWidth
+ wsOrgX
; break;
65 default: appMPlayer
.subWindow
.OldX
=appMPlayer
.sub
.x
; break;
67 switch ( appMPlayer
.sub
.y
)
69 case -1: appMPlayer
.subWindow
.OldY
=( wsMaxY
/ 2 ) - ( appMPlayer
.subWindow
.OldHeight
/ 2 ) + wsOrgY
; break;
70 case -2: appMPlayer
.subWindow
.OldY
=wsMaxY
- appMPlayer
.subWindow
.OldHeight
+ wsOrgY
; break;
71 default: appMPlayer
.subWindow
.OldY
=appMPlayer
.sub
.y
; break;
74 if ( guiIntfStruct
.Playing
|| gtkShowVideoWindow
) wsFullScreen( &appMPlayer
.subWindow
);
75 fullscreen
=vo_fs
=appMPlayer
.subWindow
.isFullScreen
;
76 wsSetLayer( wsDisplay
,appMPlayer
.mainWindow
.WindowID
,appMPlayer
.subWindow
.isFullScreen
);
77 if ( appMPlayer
.menuIsPresent
) wsSetLayer( wsDisplay
,appMPlayer
.menuWindow
.WindowID
,appMPlayer
.subWindow
.isFullScreen
);
79 if ( guiIntfStruct
.Playing
) wsSetBackgroundRGB( &appMPlayer
.subWindow
,0,0,0 );
80 else wsSetBackgroundRGB( &appMPlayer
.subWindow
,appMPlayer
.sub
.R
,appMPlayer
.sub
.G
,appMPlayer
.sub
.B
);
87 if ( !mplGotoTheNext
&& guiIntfStruct
.Playing
) { mplGotoTheNext
=1; return; }
89 if ( guiIntfStruct
.Playing
&& (next
=gtkSet( gtkGetNextPlItem
,0,NULL
)) && plLastPlayed
!= next
)
92 guiSetDF( guiIntfStruct
.Filename
,next
->path
,next
->name
);
93 guiIntfStruct
.StreamType
=STREAMTYPE_FILE
;
94 guiIntfStruct
.FilenameChanged
=guiIntfStruct
.NewPlay
=1;
95 gfree( (void **)&guiIntfStruct
.AudioFile
);
96 gfree( (void **)&guiIntfStruct
.Subtitlename
);
100 if ( guiIntfStruct
.FilenameChanged
|| guiIntfStruct
.NewPlay
) return;
102 guiIntfStruct
.TimeSec
=0;
103 guiIntfStruct
.Position
=0;
104 guiIntfStruct
.AudioType
=0;
105 guiIntfStruct
.NoWindow
=False
;
107 #ifdef CONFIG_DVDREAD
108 guiIntfStruct
.DVD
.current_title
=1;
109 guiIntfStruct
.DVD
.current_chapter
=1;
110 guiIntfStruct
.DVD
.current_angle
=1;
113 if ( !appMPlayer
.subWindow
.isFullScreen
&& gtkShowVideoWindow
)
115 wsResizeWindow( &appMPlayer
.subWindow
,appMPlayer
.sub
.width
,appMPlayer
.sub
.height
);
116 wsMoveWindow( &appMPlayer
.subWindow
,True
,appMPlayer
.sub
.x
,appMPlayer
.sub
.y
);
118 else wsVisibleWindow( &appMPlayer
.subWindow
,wsHideWindow
);
119 guiGetEvent( guiCEvent
,guiSetStop
);
121 wsSetBackgroundRGB( &appMPlayer
.subWindow
,appMPlayer
.sub
.R
,appMPlayer
.sub
.G
,appMPlayer
.sub
.B
);
122 wsClearWindow( appMPlayer
.subWindow
);
123 wsPostRedisplay( &appMPlayer
.subWindow
);
129 if ( ( !guiIntfStruct
.Filename
)||
130 ( guiIntfStruct
.Filename
[0] == 0 )||
131 ( guiIntfStruct
.Playing
== 1 ) ) return;
132 if ( guiIntfStruct
.Playing
== 2 ) { mplPause(); return; }
133 guiGetEvent( guiCEvent
,(void *)guiSetPlay
);
135 wsSetBackgroundRGB( &appMPlayer
.subWindow
,0,0,0 );
136 wsClearWindow( appMPlayer
.subWindow
);
139 void mplPause( void )
141 if ( !guiIntfStruct
.Playing
) return;
142 if ( guiIntfStruct
.Playing
== 1 )
144 mp_cmd_t
* cmd
= calloc( 1,sizeof( *cmd
) );
145 cmd
->id
=MP_CMD_PAUSE
;
146 cmd
->name
=strdup("pause");
147 mp_input_queue_cmd(cmd
);
148 } else guiIntfStruct
.Playing
=1;
151 void mplState( void )
153 if ( ( guiIntfStruct
.Playing
== 0 )||( guiIntfStruct
.Playing
== 2 ) )
155 btnModify( evPlaySwitchToPause
,btnReleased
);
156 btnModify( evPauseSwitchToPlay
,btnDisabled
);
160 btnModify( evPlaySwitchToPause
,btnDisabled
);
161 btnModify( evPauseSwitchToPlay
,btnReleased
);
165 float mplGetPosition( void )
166 { // return 0.0 ... 100.0
167 return guiIntfStruct
.Position
;
170 void mplRelSeek( float s
)
172 rel_seek_secs
=s
; abs_seek_pos
=0;
175 void mplAbsSeek( float s
)
177 if ( guiIntfStruct
.StreamType
== STREAMTYPE_STREAM
) return;
178 rel_seek_secs
=0.01*s
; abs_seek_pos
=3;
183 void ChangeSkin( char * name
)
186 int prev
= appMPlayer
.menuIsPresent
;
187 int bprev
= appMPlayer
.barIsPresent
;
191 appInitStruct( &tmpList
);
192 skinAppMPlayer
=&tmpList
;
194 ret
=skinRead( name
);
196 appInitStruct( &tmpList
);
197 skinAppMPlayer
=&appMPlayer
;
198 appInitStruct( &appMPlayer
);
199 if ( ret
) name
=skinName
;
200 if ( skinRead( name
) )
206 // --- reload menu window
208 if ( prev
&& appMPlayer
.menuIsPresent
)
210 if ( mplMenuDrawBuffer
) free( mplMenuDrawBuffer
);
211 if ( ( mplMenuDrawBuffer
= calloc( 1,appMPlayer
.menuBase
.Bitmap
.ImageSize
) ) == NULL
)
212 { mp_msg( MSGT_GPLAYER
,MSGL_STATUS
,MSGTR_NEMDB
); return; }
213 wsResizeWindow( &appMPlayer
.menuWindow
,appMPlayer
.menuBase
.width
,appMPlayer
.menuBase
.height
);
214 wsResizeImage( &appMPlayer
.menuWindow
,appMPlayer
.menuBase
.width
,appMPlayer
.menuBase
.height
);
215 wsSetShape( &appMPlayer
.menuWindow
,appMPlayer
.menuBase
.Mask
.Image
);
216 wsVisibleWindow( &appMPlayer
.menuWindow
,wsHideWindow
);
217 } else { mplMenuInit(); }
219 // --- reload sub window
220 if ( appMPlayer
.sub
.Bitmap
.Image
) wsResizeImage( &appMPlayer
.subWindow
,appMPlayer
.sub
.Bitmap
.Width
,appMPlayer
.sub
.Bitmap
.Height
);
221 if ( ( !appMPlayer
.subWindow
.isFullScreen
)&&( !guiIntfStruct
.Playing
) )
223 wsResizeWindow( &appMPlayer
.subWindow
,appMPlayer
.sub
.width
,appMPlayer
.sub
.height
);
224 wsMoveWindow( &appMPlayer
.subWindow
,True
,appMPlayer
.sub
.x
,appMPlayer
.sub
.y
);
226 if ( appMPlayer
.sub
.Bitmap
.Image
) wsConvert( &appMPlayer
.subWindow
,appMPlayer
.sub
.Bitmap
.Image
,appMPlayer
.sub
.Bitmap
.ImageSize
);
227 if ( !guiIntfStruct
.Playing
)
230 wsSetBackgroundRGB( &appMPlayer
.subWindow
,appMPlayer
.sub
.R
,appMPlayer
.sub
.G
,appMPlayer
.sub
.B
);
231 wsClearWindow( appMPlayer
.subWindow
);
232 wsPostRedisplay( &appMPlayer
.subWindow
);
235 // --- reload play bar
236 if ( bprev
) wsDestroyWindow( &appMPlayer
.barWindow
);
239 // --- reload main window
240 if ( mplDrawBuffer
) free( mplDrawBuffer
);
241 if ( ( mplDrawBuffer
= calloc( 1,appMPlayer
.main
.Bitmap
.ImageSize
) ) == NULL
)
242 { mp_msg( MSGT_GPLAYER
,MSGL_STATUS
,MSGTR_NEMDB
); return; }
244 wsDestroyWindow( &appMPlayer
.mainWindow
);
246 wsCreateWindow( &appMPlayer
.mainWindow
,
247 appMPlayer
.main
.x
,appMPlayer
.main
.y
,appMPlayer
.main
.width
,appMPlayer
.main
.height
,
248 wsNoBorder
,wsShowMouseCursor
|wsHandleMouseButton
|wsHandleMouseMove
,wsShowFrame
|wsMaxSize
|wsHideWindow
,"MPlayer" );
249 wsCreateImage( &appMPlayer
.mainWindow
,appMPlayer
.main
.Bitmap
.Width
,appMPlayer
.main
.Bitmap
.Height
);
250 wsSetShape( &appMPlayer
.mainWindow
,appMPlayer
.main
.Mask
.Image
);
251 wsSetIcon( wsDisplay
,appMPlayer
.mainWindow
.WindowID
,guiIcon
,guiIconMask
);
253 appMPlayer
.mainWindow
.ReDraw
=(void *)mplMainDraw
;
254 appMPlayer
.mainWindow
.MouseHandler
=mplMainMouseHandle
;
255 appMPlayer
.mainWindow
.KeyHandler
=mplMainKeyHandle
;
256 appMPlayer
.mainWindow
.DandDHandler
=mplDandDHandler
;
258 wsXDNDMakeAwareness( &appMPlayer
.mainWindow
);
259 if ( !appMPlayer
.mainDecoration
) wsWindowDecoration( &appMPlayer
.mainWindow
,0 );
260 wsVisibleWindow( &appMPlayer
.mainWindow
,wsShowWindow
);
264 btnModify( evSetVolume
,guiIntfStruct
.Volume
);
265 btnModify( evSetBalance
,guiIntfStruct
.Balance
);
266 btnModify( evSetMoviePosition
,guiIntfStruct
.Position
);
267 btnModify( evFullScreen
,!appMPlayer
.subWindow
.isFullScreen
);
269 wsSetLayer( wsDisplay
,appMPlayer
.mainWindow
.WindowID
,appMPlayer
.subWindow
.isFullScreen
);
270 wsSetLayer( wsDisplay
,appMPlayer
.menuWindow
.WindowID
,appMPlayer
.subWindow
.isFullScreen
);
274 void mplSetFileName( char * dir
,char * name
,int type
)
278 if ( !dir
) guiSetFilename( guiIntfStruct
.Filename
,name
)
279 else guiSetDF( guiIntfStruct
.Filename
,dir
,name
);
281 // filename=guiIntfStruct.Filename;
282 guiIntfStruct
.StreamType
=type
;
283 gfree( (void **)&guiIntfStruct
.AudioFile
);
284 gfree( (void **)&guiIntfStruct
.Subtitlename
);
292 if ( guiIntfStruct
.Playing
== 2 ) return;
293 switch ( guiIntfStruct
.StreamType
)
295 #ifdef CONFIG_DVDREAD
304 if ( (curr
=gtkSet( gtkGetCurrPlItem
,0,NULL
)) )
306 mplSetFileName( curr
->path
,curr
->name
,STREAMTYPE_FILE
);
312 if ( stop
) mplEventHandling( evStop
,0 );
313 if ( guiIntfStruct
.Playing
== 1 ) mplEventHandling( evPlay
,0 );
322 if ( guiIntfStruct
.Playing
== 2 ) return;
323 switch ( guiIntfStruct
.StreamType
)
325 #ifdef CONFIG_DVDREAD
327 if ( --guiIntfStruct
.DVD
.current_chapter
== 0 )
329 guiIntfStruct
.DVD
.current_chapter
=1;
330 if ( --guiIntfStruct
.DVD
.current_title
<= 0 ) { guiIntfStruct
.DVD
.current_title
=1; stop
=1; }
332 guiIntfStruct
.Track
=guiIntfStruct
.DVD
.current_title
;
337 if ( --guiIntfStruct
.Track
== 0 ) { guiIntfStruct
.Track
=1; stop
=1; }
341 if ( (prev
=gtkSet( gtkGetPrevPlItem
,0,NULL
)) )
343 mplSetFileName( prev
->path
,prev
->name
,STREAMTYPE_FILE
);
349 if ( stop
) mplEventHandling( evStop
,0 );
350 if ( guiIntfStruct
.Playing
== 1 ) mplEventHandling( evPlay
,0 );
358 if ( guiIntfStruct
.Playing
== 2 ) return;
359 switch ( guiIntfStruct
.StreamType
)
361 #ifdef CONFIG_DVDREAD
363 if ( guiIntfStruct
.DVD
.current_chapter
++ == guiIntfStruct
.DVD
.chapters
)
365 guiIntfStruct
.DVD
.current_chapter
=1;
366 if ( ++guiIntfStruct
.DVD
.current_title
> guiIntfStruct
.DVD
.titles
) { guiIntfStruct
.DVD
.current_title
=guiIntfStruct
.DVD
.titles
; stop
=1; }
368 guiIntfStruct
.Track
=guiIntfStruct
.DVD
.current_title
;
373 if ( ++guiIntfStruct
.Track
> guiIntfStruct
.VCDTracks
) { guiIntfStruct
.Track
=guiIntfStruct
.VCDTracks
; stop
=1; }
377 if ( (next
=gtkSet( gtkGetNextPlItem
,0,NULL
)) )
379 mplSetFileName( next
->path
,next
->name
,STREAMTYPE_FILE
);
385 if ( stop
) mplEventHandling( evStop
,0 );
386 if ( guiIntfStruct
.Playing
== 1 ) mplEventHandling( evPlay
,0 );