Mercurial > mplayer.hg
annotate gui/mplayer/mw.c @ 30245:bef93e623403
Make sure that sfence is used after any non temporal stores.
author | zuxy |
---|---|
date | Tue, 12 Jan 2010 02:34:33 +0000 |
parents | 0f1b5b68af32 |
children | f4e017b6921a |
rev | line source |
---|---|
26458 | 1 /* |
2 * main window | |
3 * | |
4 * This file is part of MPlayer. | |
5 * | |
6 * MPlayer is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * MPlayer is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License along | |
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
19 */ | |
23077 | 20 |
21 #include <stdlib.h> | |
22 #include <stdio.h> | |
23 #include <inttypes.h> | |
24 #include <sys/stat.h> | |
25 #include <unistd.h> | |
23305
22d3d12c6dfb
Include string.h for memcpy, fastmemcpy.h alone is not enough.
reimar
parents:
23154
diff
changeset
|
26 #include <string.h> |
23077 | 27 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
28 #include "config.h" |
23154
e564b9cd7290
Fix several implicit declarations of functions warnings.
diego
parents:
23077
diff
changeset
|
29 #include "gmplayer.h" |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
30 #include "gui/app.h" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
31 #include "gui/skin/font.h" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
32 #include "gui/skin/skin.h" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
33 #include "gui/wm/ws.h" |
23077 | 34 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
35 #include "help_mp.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
36 #include "libvo/x11_common.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
37 #include "libvo/fastmemcpy.h" |
23077 | 38 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
39 #include "stream/stream.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
40 #include "stream/url.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
41 #include "mixer.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
42 #include "libvo/sub.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
43 #include "access_mpcontext.h" |
23077 | 44 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
45 #include "libmpdemux/demuxer.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
46 #include "libmpdemux/stheader.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
47 #include "codec-cfg.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
48 #include "m_option.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
49 #include "m_property.h" |
23077 | 50 |
51 #define GUI_REDRAW_WAIT 375 | |
52 | |
53 #include "play.h" | |
54 #include "widgets.h" | |
55 | |
28051 | 56 unsigned int GetTimerMS( void ); |
23077 | 57 |
58 unsigned char * mplDrawBuffer = NULL; | |
59 int mplMainRender = 1; | |
60 | |
61 int mplMainAutoPlay = 0; | |
62 int mplMiddleMenu = 0; | |
63 | |
64 int mainVisible = 1; | |
65 | |
66 int boxMoved = 0; | |
67 int sx = 0,sy = 0; | |
68 int i,pot = 0; | |
69 | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
24113
diff
changeset
|
70 #include "gui_common.h" |
23077 | 71 |
72 void mplMainDraw( void ) | |
73 { | |
74 | |
75 if ( appMPlayer.mainWindow.State == wsWindowClosed ) exit_player( MSGTR_Exit_quit ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
76 |
23077 | 77 if ( appMPlayer.mainWindow.Visible == wsWindowNotVisible || |
78 !mainVisible ) return; | |
79 // !appMPlayer.mainWindow.Mapped ) return; | |
80 | |
81 if ( mplMainRender && appMPlayer.mainWindow.State == wsWindowExpose ) | |
82 { | |
83 btnModify( evSetMoviePosition,guiIntfStruct.Position ); | |
84 btnModify( evSetVolume,guiIntfStruct.Volume ); | |
85 | |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
23305
diff
changeset
|
86 fast_memcpy( mplDrawBuffer,appMPlayer.main.Bitmap.Image,appMPlayer.main.Bitmap.ImageSize ); |
23077 | 87 Render( &appMPlayer.mainWindow,appMPlayer.Items,appMPlayer.NumberOfItems,mplDrawBuffer,appMPlayer.main.Bitmap.ImageSize ); |
88 mplMainRender=0; | |
89 } | |
90 wsPutImage( &appMPlayer.mainWindow ); | |
91 // XFlush( wsDisplay ); | |
92 } | |
93 | |
94 static unsigned last_redraw_time = 0; | |
95 | |
96 void mplEventHandling( int msg,float param ) | |
97 { | |
98 int iparam = (int)param; | |
99 mixer_t *mixer = mpctx_get_mixer(guiIntfStruct.mpcontext); | |
100 | |
101 switch( msg ) | |
102 { | |
103 // --- user events | |
104 case evExit: | |
105 exit_player( "Exit" ); | |
106 break; | |
107 | |
108 case evPlayNetwork: | |
109 gfree( (void **)&guiIntfStruct.Subtitlename ); | |
110 gfree( (void **)&guiIntfStruct.AudioFile ); | |
111 guiIntfStruct.StreamType=STREAMTYPE_STREAM; | |
112 goto play; | |
113 case evSetURL: | |
114 gtkShow( evPlayNetwork,NULL ); | |
115 break; | |
116 | |
117 case evSetAudio: | |
118 if ( !guiIntfStruct.demuxer || audio_id == iparam ) break; | |
119 audio_id=iparam; | |
120 goto play; | |
121 | |
122 case evSetVideo: | |
123 if ( !guiIntfStruct.demuxer || video_id == iparam ) break; | |
124 video_id=iparam; | |
125 goto play; | |
126 | |
127 case evSetSubtitle: | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
128 mp_property_do("sub",M_PROPERTY_SET,&iparam,guiIntfStruct.mpcontext); |
23077 | 129 break; |
130 | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
131 #ifdef CONFIG_VCD |
23077 | 132 case evSetVCDTrack: |
133 guiIntfStruct.Track=iparam; | |
134 case evPlayVCD: | |
135 gtkSet( gtkClearStruct,0,(void *)guiALL ); | |
136 guiIntfStruct.StreamType=STREAMTYPE_VCD; | |
137 goto play; | |
138 #endif | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
139 #ifdef CONFIG_DVDREAD |
23077 | 140 case evPlayDVD: |
141 guiIntfStruct.DVD.current_title=1; | |
142 guiIntfStruct.DVD.current_chapter=1; | |
143 guiIntfStruct.DVD.current_angle=1; | |
144 play_dvd_2: | |
145 gtkSet( gtkClearStruct,0,(void *)(guiALL - guiDVD) ); | |
146 guiIntfStruct.StreamType=STREAMTYPE_DVD; | |
147 goto play; | |
148 #endif | |
149 case evPlay: | |
150 case evPlaySwitchToPause: | |
151 play: | |
152 | |
153 if ( ( msg == evPlaySwitchToPause )&&( guiIntfStruct.Playing == 2 ) ) goto NoPause; | |
154 | |
155 if ( gtkSet( gtkGetCurrPlItem,0,NULL ) &&( guiIntfStruct.StreamType == STREAMTYPE_FILE ) ) | |
156 { | |
157 plItem * next = gtkSet( gtkGetCurrPlItem,0,NULL ); | |
158 plLastPlayed=next; | |
159 mplSetFileName( next->path,next->name,STREAMTYPE_FILE ); | |
160 } | |
161 | |
162 switch ( guiIntfStruct.StreamType ) | |
163 { | |
164 case STREAMTYPE_STREAM: | |
165 case STREAMTYPE_FILE: | |
166 gtkSet( gtkClearStruct,0,(void *)(guiALL - guiFilenames) ); | |
167 break; | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
168 #ifdef CONFIG_VCD |
23077 | 169 case STREAMTYPE_VCD: |
170 gtkSet( gtkClearStruct,0,(void *)(guiALL - guiVCD - guiFilenames) ); | |
171 if ( !cdrom_device ) cdrom_device=gstrdup( DEFAULT_CDROM_DEVICE ); | |
172 mplSetFileName( NULL,cdrom_device,STREAMTYPE_VCD ); | |
173 if ( guiIntfStruct.Playing != 2 ) | |
174 { | |
175 if ( !guiIntfStruct.Track ) | |
176 { | |
177 if ( guiIntfStruct.VCDTracks > 1 ) guiIntfStruct.Track=2; | |
178 else guiIntfStruct.Track=1; | |
179 } | |
180 guiIntfStruct.DiskChanged=1; | |
181 } | |
182 break; | |
183 #endif | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
184 #ifdef CONFIG_DVDREAD |
23077 | 185 case STREAMTYPE_DVD: |
186 gtkSet( gtkClearStruct,0,(void *)(guiALL - guiDVD - guiFilenames) ); | |
187 if ( !dvd_device ) dvd_device=gstrdup( DEFAULT_DVD_DEVICE ); | |
188 mplSetFileName( NULL,dvd_device,STREAMTYPE_DVD ); | |
189 if ( guiIntfStruct.Playing != 2 ) | |
190 { | |
191 guiIntfStruct.Title=guiIntfStruct.DVD.current_title; | |
192 guiIntfStruct.Chapter=guiIntfStruct.DVD.current_chapter; | |
193 guiIntfStruct.Angle=guiIntfStruct.DVD.current_angle; | |
194 guiIntfStruct.DiskChanged=1; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
195 } |
23077 | 196 break; |
197 #endif | |
198 } | |
199 guiIntfStruct.NewPlay=1; | |
200 mplPlay(); | |
201 break; | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
202 #ifdef CONFIG_DVDREAD |
23077 | 203 case evSetDVDSubtitle: |
204 dvdsub_id=iparam; | |
205 goto play_dvd_2; | |
206 break; | |
207 case evSetDVDAudio: | |
208 audio_id=iparam; | |
209 goto play_dvd_2; | |
210 break; | |
211 case evSetDVDChapter: | |
212 guiIntfStruct.DVD.current_chapter=iparam; | |
213 goto play_dvd_2; | |
214 break; | |
215 case evSetDVDTitle: | |
216 guiIntfStruct.DVD.current_title=iparam; | |
217 guiIntfStruct.DVD.current_chapter=1; | |
218 guiIntfStruct.DVD.current_angle=1; | |
219 goto play_dvd_2; | |
220 break; | |
221 #endif | |
222 | |
223 case evPause: | |
224 case evPauseSwitchToPlay: | |
225 NoPause: | |
226 mplPause(); | |
227 break; | |
228 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
229 case evStop: |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
230 guiIntfStruct.Playing=guiSetStop; |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
231 mplState(); |
23077 | 232 guiIntfStruct.NoWindow=False; |
233 break; | |
234 | |
235 case evLoadPlay: | |
236 mplMainAutoPlay=1; | |
237 // guiIntfStruct.StreamType=STREAMTYPE_FILE; | |
238 case evLoad: | |
239 gtkSet( gtkDelPl,0,NULL ); | |
240 gtkShow( evLoad,NULL ); | |
241 break; | |
242 case evLoadSubtitle: gtkShow( evLoadSubtitle,NULL ); break; | |
243 case evDropSubtitle: | |
244 gfree( (void **)&guiIntfStruct.Subtitlename ); | |
245 guiLoadSubtitle( NULL ); | |
246 break; | |
247 case evLoadAudioFile: gtkShow( evLoadAudioFile,NULL ); break; | |
248 case evPrev: mplPrev(); break; | |
249 case evNext: mplNext(); break; | |
250 | |
251 case evPlayList: gtkShow( evPlayList,NULL ); break; | |
252 case evSkinBrowser: gtkShow( evSkinBrowser,skinName ); break; | |
253 case evAbout: gtkShow( evAbout,NULL ); break; | |
254 case evPreferences: gtkShow( evPreferences,NULL ); break; | |
255 case evEqualizer: gtkShow( evEqualizer,NULL ); break; | |
256 | |
257 case evForward10min: mplRelSeek( 600 ); break; | |
258 case evBackward10min: mplRelSeek( -600 );break; | |
259 case evForward1min: mplRelSeek( 60 ); break; | |
260 case evBackward1min: mplRelSeek( -60 ); break; | |
261 case evForward10sec: mplRelSeek( 10 ); break; | |
262 case evBackward10sec: mplRelSeek( -10 ); break; | |
263 case evSetMoviePosition: mplAbsSeek( param ); break; | |
264 | |
265 case evIncVolume: vo_x11_putkey( wsGrayMul ); break; | |
266 case evDecVolume: vo_x11_putkey( wsGrayDiv ); break; | |
267 case evMute: mixer_mute( mixer ); break; | |
268 | |
269 case evSetVolume: | |
270 guiIntfStruct.Volume=param; | |
271 goto set_volume; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
272 case evSetBalance: |
23077 | 273 guiIntfStruct.Balance=param; |
274 set_volume: | |
275 { | |
276 float l = guiIntfStruct.Volume * ( ( 100.0 - guiIntfStruct.Balance ) / 50.0 ); | |
277 float r = guiIntfStruct.Volume * ( ( guiIntfStruct.Balance ) / 50.0 ); | |
278 if ( l > guiIntfStruct.Volume ) l=guiIntfStruct.Volume; | |
279 if ( r > guiIntfStruct.Volume ) r=guiIntfStruct.Volume; | |
280 // printf( "!!! v: %.2f b: %.2f -> %.2f x %.2f\n",guiIntfStruct.Volume,guiIntfStruct.Balance,l,r ); | |
281 mixer_setvolume( mixer,l,r ); | |
282 } | |
283 if ( osd_level ) | |
284 { | |
285 osd_visible=(GetTimerMS() + 1000) | 1; | |
286 vo_osd_progbar_type=OSD_VOLUME; | |
287 vo_osd_progbar_value=( ( guiIntfStruct.Volume ) * 256.0 ) / 100.0; | |
288 vo_osd_changed( OSDTYPE_PROGBAR ); | |
289 } | |
290 break; | |
291 | |
292 | |
293 case evIconify: | |
294 switch ( iparam ) | |
295 { | |
296 case 0: wsIconify( appMPlayer.mainWindow ); break; | |
297 case 1: wsIconify( appMPlayer.subWindow ); break; | |
298 } | |
299 break; | |
300 case evHalfSize: | |
301 btnSet( evFullScreen,btnReleased ); | |
302 if ( guiIntfStruct.Playing ) | |
303 { | |
304 if ( appMPlayer.subWindow.isFullScreen ) | |
305 { | |
306 mplFullScreen(); | |
307 } | |
308 wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth / 2, guiIntfStruct.MovieHeight / 2 ); | |
309 wsMoveWindow( &appMPlayer.subWindow, 0, | |
310 ( wsMaxX - guiIntfStruct.MovieWidth/2 )/2 + wsOrgX, | |
311 ( wsMaxY - guiIntfStruct.MovieHeight/2 )/2 + wsOrgY ); | |
312 } | |
313 break; | |
314 case evDoubleSize: | |
315 btnSet( evFullScreen,btnReleased ); | |
316 if ( guiIntfStruct.Playing ) | |
317 { | |
318 if ( appMPlayer.subWindow.isFullScreen ) | |
319 { | |
320 mplFullScreen(); | |
321 } | |
322 wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth * 2, guiIntfStruct.MovieHeight * 2 ); | |
323 wsMoveWindow( &appMPlayer.subWindow, 0, | |
324 ( wsMaxX - guiIntfStruct.MovieWidth*2 )/2 + wsOrgX, | |
325 ( wsMaxY - guiIntfStruct.MovieHeight*2 )/2 + wsOrgY ); | |
326 } | |
327 break; | |
328 case evNormalSize: | |
329 btnSet( evFullScreen,btnReleased ); | |
330 if ( guiIntfStruct.Playing ) | |
331 { | |
332 if ( appMPlayer.subWindow.isFullScreen ) | |
333 { | |
334 mplFullScreen(); | |
335 } | |
336 wsResizeWindow( &appMPlayer.subWindow, guiIntfStruct.MovieWidth, guiIntfStruct.MovieHeight ); | |
337 wsMoveWindow( &appMPlayer.subWindow, 0, | |
338 ( wsMaxX - guiIntfStruct.MovieWidth )/2 + wsOrgX, | |
339 ( wsMaxY - guiIntfStruct.MovieHeight )/2 + wsOrgY ); | |
340 break; | |
341 } else if ( !appMPlayer.subWindow.isFullScreen ) break; | |
342 case evFullScreen: | |
343 if ( !guiIntfStruct.Playing && !gtkShowVideoWindow ) break; | |
344 mplFullScreen(); | |
345 if ( appMPlayer.subWindow.isFullScreen ) btnSet( evFullScreen,btnPressed ); | |
346 else btnSet( evFullScreen,btnReleased ); | |
347 break; | |
348 | |
349 case evSetAspect: | |
350 switch ( iparam ) | |
351 { | |
352 case 2: movie_aspect=16.0f / 9.0f; break; | |
353 case 3: movie_aspect=4.0f / 3.0f; break; | |
354 case 4: movie_aspect=2.35; break; | |
355 case 1: | |
356 default: movie_aspect=-1; | |
357 } | |
358 wsClearWindow( appMPlayer.subWindow ); | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
359 #ifdef CONFIG_DVDREAD |
23077 | 360 if ( guiIntfStruct.StreamType == STREAMTYPE_DVD || guiIntfStruct.StreamType == STREAMTYPE_VCD ) goto play_dvd_2; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
361 else |
23077 | 362 #endif |
363 guiIntfStruct.NewPlay=1; | |
364 break; | |
365 | |
366 // --- timer events | |
367 case evRedraw: | |
368 { | |
369 unsigned now = GetTimerMS(); | |
370 extern int mplPBFade; | |
371 if ((now > last_redraw_time) && | |
372 (now < last_redraw_time + GUI_REDRAW_WAIT) && | |
373 !mplPBFade) | |
374 break; | |
375 last_redraw_time = now; | |
376 } | |
377 mplMainRender=1; | |
378 wsPostRedisplay( &appMPlayer.mainWindow ); | |
379 wsPostRedisplay( &appMPlayer.barWindow ); | |
380 break; | |
381 // --- system events | |
382 #ifdef MP_DEBUG | |
383 case evNone: | |
384 mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[mw] event none received.\n" ); | |
385 break; | |
386 default: | |
387 mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[mw] unknown event received ( %d,%.2f ).\n",msg,param ); | |
388 break; | |
389 #endif | |
390 } | |
391 } | |
392 | |
393 #define itPLMButton (itNULL - 1) | |
394 #define itPRMButton (itNULL - 2) | |
395 | |
396 void mplMainMouseHandle( int Button,int X,int Y,int RX,int RY ) | |
397 { | |
398 static int itemtype = 0; | |
399 int i; | |
400 wItem * item = NULL; | |
401 float value = 0.0f; | |
402 | |
403 static int SelectedItem = -1; | |
404 int currentselected = -1; | |
405 | |
406 for ( i=0;i < appMPlayer.NumberOfItems + 1;i++ ) | |
407 if ( ( appMPlayer.Items[i].pressed != btnDisabled )&& | |
408 ( 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 ) ) ) | |
409 { currentselected=i; break; } | |
410 | |
411 switch ( Button ) | |
412 { | |
413 case wsPMMouseButton: | |
414 gtkShow( evHidePopUpMenu,NULL ); | |
415 mplShowMenu( RX,RY ); | |
416 itemtype=itPRMButton; | |
417 break; | |
418 case wsRMMouseButton: | |
419 mplHideMenu( RX,RY,0 ); | |
420 break; | |
421 | |
422 case wsPLMouseButton: | |
423 gtkShow( evHidePopUpMenu,NULL ); | |
424 sx=X; sy=Y; boxMoved=1; itemtype=itPLMButton; | |
425 SelectedItem=currentselected; | |
426 if ( SelectedItem == -1 ) break; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
427 boxMoved=0; |
23077 | 428 item=&appMPlayer.Items[SelectedItem]; |
429 itemtype=item->type; | |
430 item->pressed=btnPressed; | |
431 switch( item->type ) | |
432 { | |
433 case itButton: | |
434 if ( ( SelectedItem > -1 ) && | |
435 ( ( ( item->msg == evPlaySwitchToPause && item->msg == evPauseSwitchToPlay ) ) || | |
436 ( ( item->msg == evPauseSwitchToPlay && item->msg == evPlaySwitchToPause ) ) ) ) | |
437 { item->pressed=btnDisabled; } | |
438 break; | |
439 } | |
440 break; | |
441 case wsRLMouseButton: | |
442 boxMoved=0; | |
443 item=&appMPlayer.Items[SelectedItem]; | |
444 item->pressed=btnReleased; | |
445 SelectedItem=-1; | |
446 if ( currentselected == - 1 ) { itemtype=0; break; } | |
447 value=0; | |
448 switch( itemtype ) | |
449 { | |
450 case itPotmeter: | |
451 case itHPotmeter: | |
452 btnModify( item->msg,(float)( X - item->x ) / item->width * 100.0f ); | |
453 mplEventHandling( item->msg,item->value ); | |
454 value=item->value; | |
455 break; | |
456 case itVPotmeter: | |
457 btnModify( item->msg, ( 1. - (float)( Y - item->y ) / item->height) * 100.0f ); | |
458 mplEventHandling( item->msg,item->value ); | |
459 value=item->value; | |
460 break; | |
461 } | |
462 mplEventHandling( item->msg,value ); | |
463 itemtype=0; | |
464 break; | |
465 | |
466 case wsRRMouseButton: | |
467 gtkShow( evShowPopUpMenu,NULL ); | |
468 break; | |
469 | |
470 // --- rolled mouse ... de szar :))) | |
471 case wsP5MouseButton: value=-2.5f; goto rollerhandled; | |
472 case wsP4MouseButton: value= 2.5f; | |
473 rollerhandled: | |
474 item=&appMPlayer.Items[currentselected]; | |
475 if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itPotmeter ) ) | |
476 { | |
477 item->value+=value; | |
478 btnModify( item->msg,item->value ); | |
479 mplEventHandling( item->msg,item->value ); | |
480 } | |
481 break; | |
482 | |
483 // --- moving | |
484 case wsMoveMouse: | |
485 item=&appMPlayer.Items[SelectedItem]; | |
486 switch ( itemtype ) | |
487 { | |
488 case itPLMButton: | |
489 wsMoveWindow( &appMPlayer.mainWindow,False,RX - abs( sx ),RY - abs( sy ) ); | |
490 mplMainRender=0; | |
491 break; | |
492 case itPRMButton: | |
493 mplMenuMouseHandle( X,Y,RX,RY ); | |
494 break; | |
495 case itPotmeter: | |
496 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
497 goto potihandled; | |
498 case itVPotmeter: | |
499 item->value=(1. - (float)( Y - item->y ) / item->height) * 100.0f; | |
500 goto potihandled; | |
501 case itHPotmeter: | |
502 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
503 potihandled: | |
504 if ( item->value > 100.0f ) item->value=100.0f; | |
505 if ( item->value < 0.0f ) item->value=0.0f; | |
506 mplEventHandling( item->msg,item->value ); | |
507 break; | |
508 } | |
509 break; | |
510 } | |
511 } | |
512 | |
513 int keyPressed = 0; | |
514 | |
515 void mplMainKeyHandle( int KeyCode,int Type,int Key ) | |
516 { | |
517 int msg = evNone; | |
518 | |
519 if ( Type != wsKeyPressed ) return; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
520 |
23077 | 521 if ( !Key ) |
522 { | |
523 switch ( KeyCode ) | |
524 { | |
525 case wsXFMMPrev: msg=evPrev; break; | |
526 case wsXFMMStop: msg=evStop; break; | |
527 case wsXFMMPlay: msg=evPlaySwitchToPause; break; | |
528 case wsXFMMNext: msg=evNext; break; | |
529 case wsXFMMVolUp: msg=evIncVolume; break; | |
530 case wsXFMMVolDown: msg=evDecVolume; break; | |
531 case wsXFMMMute: msg=evMute; break; | |
532 } | |
533 } | |
534 else | |
535 { | |
536 switch ( Key ) | |
537 { | |
538 case wsEnter: msg=evPlay; break; | |
539 case wsXF86LowerVolume: msg=evDecVolume; break; | |
540 case wsXF86RaiseVolume: msg=evIncVolume; break; | |
541 case wsXF86Mute: msg=evMute; break; | |
542 case wsXF86Play: msg=evPlaySwitchToPause; break; | |
543 case wsXF86Stop: msg=evStop; break; | |
544 case wsXF86Prev: msg=evPrev; break; | |
545 case wsXF86Next: msg=evNext; break; | |
546 case wsXF86Media: msg=evLoad; break; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
547 case wsEscape: |
23077 | 548 if ( appMPlayer.subWindow.isFullScreen ) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
549 { |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
550 if ( guiIntfStruct.event_struct ) ((XEvent *)guiIntfStruct.event_struct)->type=None; |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
551 mplEventHandling( evNormalSize,0 ); |
23077 | 552 return; |
553 } | |
554 default: vo_x11_putkey( Key ); return; | |
555 } | |
556 } | |
557 if ( msg != evNone ) mplEventHandling( msg,0 ); | |
558 } | |
559 | |
560 /* this will be used to handle Drag&Drop files */ | |
561 void mplDandDHandler(int num,char** files) | |
562 { | |
563 struct stat buf; | |
564 int f = 0; | |
565 | |
566 char* subtitles = NULL; | |
567 char* filename = NULL; | |
568 | |
569 if (num <= 0) | |
570 return; | |
571 | |
572 | |
573 /* now fill it with new items */ | |
574 for(f=0; f < num; f++){ | |
575 char* str = strdup( files[f] ); | |
576 plItem* item; | |
577 | |
24086
f5b32d12b691
remove gconvert_uri_to_filename() and use url_unescape_string() instead.
iive
parents:
23457
diff
changeset
|
578 url_unescape_string(str, files[f]); |
23077 | 579 |
580 if(stat(str,&buf) == 0 && S_ISDIR(buf.st_mode) == 0) { | |
581 /* this is not a directory so try to play it */ | |
582 mp_msg( MSGT_GPLAYER,MSGL_V,"Received D&D %s\n",str ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
583 |
23077 | 584 /* check if it is a subtitle file */ |
585 { | |
586 char* ext = strrchr(str,'.'); | |
587 if (ext) { | |
588 static char supported[] = "utf/sub/srt/smi/rt//txt/ssa/aqt/"; | |
589 char* type; | |
590 int len; | |
591 if((len=strlen(++ext)) && (type=strstr(supported,ext)) &&\ | |
592 (type-supported)%4 == 0 && *(type+len) == '/'){ | |
593 /* handle subtitle file */ | |
594 gfree((void**)&subtitles); | |
595 subtitles = str; | |
596 continue; | |
597 } | |
598 } | |
599 } | |
600 | |
601 /* clear playlist */ | |
602 if (filename == NULL) { | |
603 filename = files[f]; | |
604 gtkSet(gtkDelPl,0,NULL); | |
605 } | |
606 | |
607 item = calloc(1,sizeof(plItem)); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
608 |
23077 | 609 /* FIXME: decompose file name ? */ |
610 /* yes -- Pontscho */ | |
611 if ( strrchr( str,'/' ) ) { | |
612 char * s = strrchr( str,'/' ); *s=0; s++; | |
613 item->name = gstrdup( s ); | |
614 item->path = gstrdup( str ); | |
615 } else { | |
616 item->name = strdup(str); | |
617 item->path = strdup(""); | |
618 } | |
619 gtkSet(gtkAddPlItem,0,(void*)item); | |
620 } else { | |
621 mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_NotAFile,str ); | |
622 } | |
623 free( str ); | |
624 } | |
625 | |
626 if (filename) { | |
627 mplSetFileName( NULL,filename,STREAMTYPE_FILE ); | |
628 if ( guiIntfStruct.Playing == 1 ) mplEventHandling( evStop,0 ); | |
629 mplEventHandling( evPlay,0 ); | |
630 } | |
631 if (subtitles) { | |
632 gfree((void**)&guiIntfStruct.Subtitlename); | |
633 guiIntfStruct.Subtitlename = subtitles; | |
634 guiLoadSubtitle(guiIntfStruct.Subtitlename); | |
635 } | |
636 } |