Mercurial > mplayer.hg
annotate gui/win32/interface.c @ 33737:71c29e8ec68f
Move string functions from interface.c to string.c.
Additionally, change char parameter of gstrchr() to const and
rename parameter size of gstrncmp() n.
The Win32 GUI now needs gstrdup() defined before its first usage.
author | ib |
---|---|
date | Thu, 07 Jul 2011 08:32:10 +0000 |
parents | 1fbe7adc4eaf |
children | 2c02269701bd |
rev | line source |
---|---|
23077 | 1 /* |
23079 | 2 * MPlayer GUI for Win32 |
3 * Copyright (C) 2003 Sascha Sommer <saschasommer@freenet.de> | |
4 * Copyright (C) 2006 Erik Augustson <erik_27can@yahoo.com> | |
5 * Copyright (C) 2006 Gianluigi Tiesi <sherpya@netfarm.it> | |
6 * | |
7 * This file is part of MPlayer. | |
8 * | |
9 * MPlayer is free software; you can redistribute it and/or modify | |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * MPlayer is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
26457 | 19 * You should have received a copy of the GNU General Public License along |
20 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
23079 | 22 */ |
23077 | 23 |
24 #include <windows.h> | |
33358 | 25 |
26 #if defined(__CYGWIN__) | |
27 #define _beginthreadex CreateThread | |
28 #else | |
29 #include <process.h> | |
30 #endif | |
31 | |
30901 | 32 #include "path.h" |
26372
76413880bfad
Update include paths to account for build system changes.
diego
parents:
26193
diff
changeset
|
33 #include "gui/interface.h" |
23091
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
34 #include "m_option.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
35 #include "mixer.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
36 #include "mp_msg.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
37 #include "help_mp.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
38 #include "codec-cfg.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
39 #include "stream/stream.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
40 #include "libmpdemux/demuxer.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
41 #include "libmpdemux/stheader.h" |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
42 #ifdef CONFIG_DVDREAD |
23091
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
43 #include "stream/stream_dvd.h" |
23077 | 44 #endif |
23091
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
45 #include "input/input.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
46 #include "libvo/video_out.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
47 #include "libao2/audio_out.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
48 #include "access_mpcontext.h" |
30558 | 49 #include "libmpcodecs/vd.h" |
31425
2392ad3cec9c
Move af_cfg extern variable declaration to dec_audio.h.
diego
parents:
31312
diff
changeset
|
50 #include "libmpcodecs/dec_audio.h" |
33557 | 51 #include "gui/ui/gmplayer.h" |
30558 | 52 #include "mp_core.h" |
32093 | 53 #include "mpcommon.h" |
23077 | 54 #include "gui.h" |
55 #include "dialogs.h" | |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
27341
diff
changeset
|
56 #ifdef CONFIG_LIBCDIO |
23077 | 57 #include <cdio/cdio.h> |
58 #endif | |
59 | |
60 int guiWinID = 0; | |
61 | |
62 char *skinName = NULL; | |
63 char *codecname = NULL; | |
33555 | 64 int uiGotoTheNext = 1; |
23077 | 65 static gui_t *mygui = NULL; |
66 static int update_subwindow(void); | |
67 static RECT old_rect; | |
68 static DWORD style; | |
24992 | 69 static HANDLE hThread; |
70 static unsigned threadId; | |
25765
304fc0bbefe1
audio_out / video_out structs should be treated as const
reimar
parents:
24992
diff
changeset
|
71 const ao_functions_t *audio_out = NULL; |
304fc0bbefe1
audio_out / video_out structs should be treated as const
reimar
parents:
24992
diff
changeset
|
72 const vo_functions_t *video_out = NULL; |
23077 | 73 mixer_t *mixer = NULL; |
74 | |
75 /* test for playlist files, no need to specify -playlist on the commandline. | |
76 * add any conceivable playlist extensions here. | |
77 * - Erik | |
78 */ | |
79 int parse_filename(char *file, play_tree_t *playtree, m_config_t *mconfig, int clear) | |
80 { | |
81 if(clear) | |
82 mygui->playlist->clear_playlist(mygui->playlist); | |
83 | |
84 if(strstr(file, ".m3u") || strstr(file, ".pls")) | |
85 { | |
86 playtree = parse_playlist_file(file); | |
33734 | 87 guiAddPlaylist(playtree, mconfig); |
23077 | 88 return 1; |
89 } | |
90 return 0; | |
91 } | |
92 | |
33737 | 93 char *gstrdup(const char *str) |
94 { | |
95 if (!str) return NULL; | |
96 return strdup(str); | |
97 } | |
98 | |
23077 | 99 /** |
100 * \brief this actually creates a new list containing only one element... | |
101 */ | |
102 void gaddlist( char ***list, const char *entry) | |
103 { | |
104 int i; | |
105 | |
106 if (*list) | |
107 { | |
108 for (i=0; (*list)[i]; i++) free((*list)[i]); | |
109 free(*list); | |
110 } | |
111 | |
112 *list = malloc(2 * sizeof(char **)); | |
113 (*list)[0] = gstrdup(entry); | |
114 (*list)[1] = NULL; | |
115 } | |
116 | |
117 /** | |
118 * \brief this replaces a string starting with search by replace. | |
119 * If not found, replace is appended. | |
120 */ | |
33579 | 121 static void greplace(char ***list, char *search, char *replace) |
23077 | 122 { |
123 int i = 0; | |
124 int len = (search) ? strlen(search) : 0; | |
125 | |
126 if (*list) | |
127 { | |
128 for (i = 0; (*list)[i]; i++) | |
129 { | |
130 if (search && (!strncmp((*list)[i], search, len))) | |
131 { | |
132 free((*list)[i]); | |
133 (*list)[i] = gstrdup(replace); | |
134 return; | |
135 } | |
136 } | |
137 *list = realloc(*list, (i + 2) * sizeof(char *)); | |
138 } | |
139 else | |
140 *list = malloc(2 * sizeof(char *)); | |
141 | |
142 (*list)[i] = gstrdup(replace); | |
143 (*list)[i + 1] = NULL; | |
144 } | |
145 | |
146 /* this function gets called by the gui to update mplayer */ | |
147 static void guiSetEvent(int event) | |
148 { | |
33555 | 149 if(guiInfo.mpcontext) |
150 mixer = mpctx_get_mixer(guiInfo.mpcontext); | |
23077 | 151 |
152 switch(event) | |
153 { | |
154 case evPlay: | |
155 case evPlaySwitchToPause: | |
23148
71efd1fc20c8
add missing case value, fixes functionality when using some skins.
vayne
parents:
23147
diff
changeset
|
156 case evPauseSwitchToPlay: |
33555 | 157 uiPlay(); |
23077 | 158 break; |
159 case evPause: | |
33555 | 160 uiPause(); |
23077 | 161 break; |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
162 #ifdef CONFIG_DVDREAD |
23077 | 163 case evPlayDVD: |
164 { | |
165 static char dvdname[MAX_PATH]; | |
33555 | 166 guiInfo.DVD.current_title = dvd_title; |
167 guiInfo.DVD.current_chapter = dvd_chapter; | |
168 guiInfo.DVD.current_angle = dvd_angle; | |
169 guiInfo.DiskChanged = 1; | |
23077 | 170 |
33555 | 171 uiSetFileName(NULL, dvd_device, STREAMTYPE_DVD); |
23077 | 172 dvdname[0] = 0; |
173 strcat(dvdname, "DVD Movie"); | |
174 GetVolumeInformation(dvd_device, dvdname, MAX_PATH, NULL, NULL, NULL, NULL, 0); | |
175 capitalize(dvdname); | |
176 mp_msg(MSGT_GPLAYER, MSGL_V, "Opening DVD %s -> %s\n", dvd_device, dvdname); | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
177 gui(GUI_PREPARE, (void *) STREAMTYPE_DVD); |
23077 | 178 mygui->playlist->clear_playlist(mygui->playlist); |
179 mygui->playlist->add_track(mygui->playlist, filename, NULL, dvdname, 0); | |
180 mygui->startplay(mygui); | |
181 break; | |
182 } | |
183 #endif | |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
27341
diff
changeset
|
184 #ifdef CONFIG_LIBCDIO |
23077 | 185 case evPlayCD: |
186 { | |
187 int i; | |
188 char track[10]; | |
189 char trackname[10]; | |
190 CdIo_t *p_cdio = cdio_open(NULL, DRIVER_UNKNOWN); | |
191 track_t i_tracks; | |
192 | |
193 if(p_cdio == NULL) printf("Couldn't find a driver.\n"); | |
194 i_tracks = cdio_get_num_tracks(p_cdio); | |
195 | |
196 mygui->playlist->clear_playlist(mygui->playlist); | |
197 for(i=0;i<i_tracks;i++) | |
198 { | |
199 sprintf(track, "cdda://%d", i+1); | |
200 sprintf(trackname, "Track %d", i+1); | |
201 mygui->playlist->add_track(mygui->playlist, track, NULL, trackname, 0); | |
202 } | |
203 cdio_destroy(p_cdio); | |
204 mygui->startplay(mygui); | |
205 break; | |
206 } | |
207 #endif | |
208 case evFullScreen: | |
209 mp_input_queue_cmd(mp_input_parse_cmd("vo_fullscreen")); | |
210 break; | |
211 case evExit: | |
212 { | |
213 /* We are asking mplayer to exit, later it will ask us after uninit is made | |
214 this should be the only safe way to quit */ | |
215 mygui->activewidget = NULL; | |
216 mp_input_queue_cmd(mp_input_parse_cmd("quit")); | |
217 break; | |
218 } | |
219 case evStop: | |
33555 | 220 if(guiInfo.Playing) |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
221 gui(GUI_SET_STATE, (void *) GUI_STOP); |
23077 | 222 break; |
223 case evSetMoviePosition: | |
224 { | |
33555 | 225 rel_seek_secs = guiInfo.Position / 100.0f; |
23077 | 226 abs_seek_pos = 3; |
227 break; | |
228 } | |
229 case evForward10sec: | |
230 { | |
231 rel_seek_secs = 10.0f; | |
232 abs_seek_pos = 0; | |
233 break; | |
234 } | |
235 case evBackward10sec: | |
236 { | |
237 rel_seek_secs = -10.0f; | |
238 abs_seek_pos = 0; | |
239 break; | |
240 } | |
241 case evSetBalance: | |
242 case evSetVolume: | |
243 { | |
244 float l,r; | |
245 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
246 if (guiInfo.Playing == GUI_STOP) |
23077 | 247 break; |
248 | |
33555 | 249 if (guiInfo.Balance == 50.0f) |
250 mixer_setvolume(mixer, guiInfo.Volume, guiInfo.Volume); | |
23077 | 251 |
33555 | 252 l = guiInfo.Volume * ((100.0f - guiInfo.Balance) / 50.0f); |
253 r = guiInfo.Volume * ((guiInfo.Balance) / 50.0f); | |
23077 | 254 |
33555 | 255 if (l > guiInfo.Volume) l=guiInfo.Volume; |
256 if (r > guiInfo.Volume) r=guiInfo.Volume; | |
23077 | 257 mixer_setvolume(mixer, l, r); |
258 /* Check for balance support on mixer - there is a better way ?? */ | |
259 if (r != l) | |
260 { | |
261 mixer_getvolume(mixer, &l, &r); | |
262 if (r == l) | |
263 { | |
264 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Mixer doesn't support balanced audio\n"); | |
33555 | 265 mixer_setvolume(mixer, guiInfo.Volume, guiInfo.Volume); |
266 guiInfo.Balance = 50.0f; | |
23077 | 267 } |
268 } | |
269 break; | |
270 } | |
271 case evMute: | |
272 { | |
273 mp_cmd_t * cmd = calloc(1, sizeof(*cmd)); | |
274 cmd->id=MP_CMD_MUTE; | |
275 cmd->name=strdup("mute"); | |
276 mp_input_queue_cmd(cmd); | |
277 break; | |
278 } | |
279 case evDropFile: | |
280 case evLoadPlay: | |
281 { | |
33555 | 282 switch(guiInfo.StreamType) |
23077 | 283 { |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
284 #ifdef CONFIG_DVDREAD |
23077 | 285 case STREAMTYPE_DVD: |
286 { | |
33555 | 287 guiInfo.Title = guiInfo.DVD.current_title; |
288 guiInfo.Chapter = guiInfo.DVD.current_chapter; | |
289 guiInfo.Angle = guiInfo.DVD.current_angle; | |
290 guiInfo.DiskChanged = 1; | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
291 gui(GUI_SET_STATE, (void *) GUI_PLAY); |
23077 | 292 break; |
293 } | |
23147
21c35763b178
compilation fix for disabling dvd functionality, patch by <bangbangbear at gmail dot com>, slightly modified by me.
vayne
parents:
23123
diff
changeset
|
294 #endif |
23077 | 295 default: |
296 { | |
33555 | 297 guiInfo.FilenameChanged = guiInfo.NewPlay = 1; |
23077 | 298 update_playlistwindow(); |
33555 | 299 uiGotoTheNext = guiInfo.Playing? 0 : 1; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
300 gui(GUI_SET_STATE, (void *) GUI_STOP); |
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
301 gui(GUI_SET_STATE, (void *) GUI_PLAY); |
23077 | 302 break; |
303 } | |
304 } | |
305 break; | |
306 } | |
307 case evNext: | |
33555 | 308 uiNext(); |
23077 | 309 break; |
310 case evPrev: | |
33555 | 311 uiPrev(); |
23077 | 312 break; |
313 } | |
314 } | |
315 | |
33555 | 316 void uiPlay( void ) |
23077 | 317 { |
33555 | 318 if((!guiInfo.Filename ) || (guiInfo.Filename[0] == 0)) |
23077 | 319 return; |
320 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
321 if(guiInfo.Playing > GUI_STOP) |
23077 | 322 { |
33555 | 323 uiPause(); |
23077 | 324 return; |
325 } | |
33555 | 326 guiInfo.NewPlay = 1; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
327 gui(GUI_SET_STATE, (void *) GUI_PLAY); |
23077 | 328 } |
329 | |
33555 | 330 void uiPause( void ) |
23077 | 331 { |
33555 | 332 if(!guiInfo.Playing) return; |
23077 | 333 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
334 if(guiInfo.Playing == GUI_PLAY) |
23077 | 335 { |
336 mp_cmd_t * cmd = calloc(1, sizeof(*cmd)); | |
337 cmd->id=MP_CMD_PAUSE; | |
338 cmd->name=strdup("pause"); | |
339 mp_input_queue_cmd(cmd); | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
340 } else guiInfo.Playing = GUI_PLAY; |
23077 | 341 } |
342 | |
33555 | 343 void uiNext(void) |
23077 | 344 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
345 if(guiInfo.Playing == GUI_PAUSE) return; |
33555 | 346 switch(guiInfo.StreamType) |
23077 | 347 { |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
348 #ifdef CONFIG_DVDREAD |
23077 | 349 case STREAMTYPE_DVD: |
33555 | 350 if(guiInfo.DVD.current_chapter == (guiInfo.DVD.chapters - 1)) |
23077 | 351 return; |
33555 | 352 guiInfo.DVD.current_chapter++; |
23077 | 353 break; |
354 #endif | |
355 default: | |
356 if(mygui->playlist->current == (mygui->playlist->trackcount - 1)) | |
357 return; | |
33555 | 358 uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)++]->filename, |
23077 | 359 STREAMTYPE_STREAM); |
360 break; | |
361 } | |
362 mygui->startplay(mygui); | |
363 } | |
364 | |
33555 | 365 void uiPrev(void) |
23077 | 366 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
367 if(guiInfo.Playing == GUI_PAUSE) return; |
33555 | 368 switch(guiInfo.StreamType) |
23077 | 369 { |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
370 #ifdef CONFIG_DVDREAD |
23077 | 371 case STREAMTYPE_DVD: |
33555 | 372 if(guiInfo.DVD.current_chapter == 1) |
23077 | 373 return; |
33555 | 374 guiInfo.DVD.current_chapter--; |
23077 | 375 break; |
376 #endif | |
377 default: | |
378 if(mygui->playlist->current == 0) | |
379 return; | |
33555 | 380 uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)--]->filename, |
23077 | 381 STREAMTYPE_STREAM); |
382 break; | |
383 } | |
384 mygui->startplay(mygui); | |
385 } | |
386 | |
33555 | 387 void uiSetFileName(char *dir, char *name, int type) |
23077 | 388 { |
389 if(!name) return; | |
390 if(!dir) | |
33555 | 391 guiSetFilename(guiInfo.Filename, name) |
23077 | 392 else |
33555 | 393 guiSetDF(guiInfo.Filename, dir, name); |
23077 | 394 |
33555 | 395 guiInfo.StreamType = type; |
396 free(guiInfo.AudioFile); | |
397 guiInfo.AudioFile = NULL; | |
398 free(guiInfo.Subtitlename); | |
399 guiInfo.Subtitlename = NULL; | |
23077 | 400 } |
401 | |
33555 | 402 void uiFullScreen( void ) |
23077 | 403 { |
33555 | 404 if(!guiInfo.sh_video) return; |
23077 | 405 |
406 if(sub_window) | |
407 { | |
408 if(!fullscreen && IsWindowVisible(mygui->subwindow) && !IsIconic(mygui->subwindow)) | |
409 GetWindowRect(mygui->subwindow, &old_rect); | |
410 | |
411 if(fullscreen) | |
412 { | |
413 fullscreen = 0; | |
414 style = WS_OVERLAPPEDWINDOW | WS_SIZEBOX; | |
415 } else { | |
416 fullscreen = 1; | |
417 style = WS_VISIBLE | WS_POPUP; | |
418 } | |
419 SetWindowLong(mygui->subwindow, GWL_STYLE, style); | |
420 update_subwindow(); | |
421 } | |
422 video_out->control(VOCTRL_FULLSCREEN, 0); | |
423 if(sub_window) ShowWindow(mygui->subwindow, SW_SHOW); | |
424 } | |
425 | |
24992 | 426 static unsigned __stdcall GuiThread(void* param) |
23077 | 427 { |
428 MSG msg; | |
429 | |
430 if(!skinName) skinName = strdup("Blue"); | |
431 if(!mygui) mygui = create_gui(get_path("skins"), skinName, guiSetEvent); | |
30558 | 432 if(!mygui) exit_player(EXIT_ERROR); |
23077 | 433 |
434 if(autosync && autosync != gtkAutoSync) | |
435 { | |
436 gtkAutoSyncOn = 1; | |
437 gtkAutoSync = autosync; | |
438 } | |
439 | |
24992 | 440 while(GetMessage(&msg, NULL, 0, 0)) |
23077 | 441 { |
442 TranslateMessage(&msg); | |
443 DispatchMessage(&msg); | |
444 } | |
23078 | 445 fprintf(stderr, "[GUI] GUI thread terminated.\n"); |
23077 | 446 fflush(stderr); |
447 return 0; | |
448 } | |
449 | |
450 void guiInit(void) | |
451 { | |
33555 | 452 memset(&guiInfo, 0, sizeof(guiInfo)); |
23077 | 453 /* Create The gui thread */ |
454 if (!mygui) | |
455 { | |
33358 | 456 hThread = _beginthreadex(NULL, 0, GuiThread, NULL, 0, &threadId); |
23077 | 457 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Creating GUI Thread 0x%04x\n", threadId); |
458 } | |
459 | |
460 /* Wait until the gui is created */ | |
461 while(!mygui) Sleep(100); | |
23078 | 462 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] GUI thread started.\n"); |
23077 | 463 } |
464 | |
465 void guiDone(void) | |
466 { | |
467 if(mygui) | |
468 { | |
469 fprintf(stderr, "[GUI] Closed by main mplayer window\n"); | |
470 fflush(stderr); | |
24992 | 471 PostThreadMessage(threadId, WM_QUIT, 0, 0); |
472 WaitForSingleObject(hThread, INFINITE); | |
473 CloseHandle(hThread); | |
23077 | 474 mygui->uninit(mygui); |
475 free(mygui); | |
476 mygui = NULL; | |
477 } | |
478 /* Remove tray icon */ | |
479 Shell_NotifyIcon(NIM_DELETE, &nid); | |
480 cfg_write(); | |
481 } | |
482 | |
483 /* this function gets called by mplayer to update the gui */ | |
33726 | 484 int gui(int what, void *arg) |
23077 | 485 { |
30722
b0342ca7ea61
Fix windows Gui compilation and remove some related typecasts.
reimar
parents:
30558
diff
changeset
|
486 stream_t *stream = arg; |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
487 #ifdef CONFIG_DVDREAD |
33730 | 488 dvd_priv_t *dvdp; |
23077 | 489 #endif |
490 if(!mygui || !mygui->skin) return 0; | |
491 | |
33555 | 492 if(guiInfo.mpcontext) |
23077 | 493 { |
33555 | 494 audio_out = mpctx_get_audio_out(guiInfo.mpcontext); |
495 video_out = mpctx_get_video_out(guiInfo.mpcontext); | |
496 mixer = mpctx_get_mixer(guiInfo.mpcontext); | |
497 playtree = mpctx_get_playtree_iter(guiInfo.mpcontext); | |
23077 | 498 } |
499 | |
33726 | 500 switch (what) |
23077 | 501 { |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
502 case GUI_PREPARE: |
23077 | 503 { |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
504 gui(GUI_SET_FILE, 0); |
33555 | 505 guiInfo.DiskChanged = 0; |
506 guiInfo.FilenameChanged = 0; | |
507 guiInfo.NewPlay = 0; | |
508 switch(guiInfo.StreamType) | |
23077 | 509 { |
510 case STREAMTYPE_PLAYLIST: | |
511 break; | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
512 #ifdef CONFIG_DVDREAD |
23077 | 513 case STREAMTYPE_DVD: |
514 { | |
515 char tmp[512]; | |
33555 | 516 dvd_title = guiInfo.DVD.current_title; |
517 dvd_chapter = guiInfo.DVD.current_chapter; | |
518 dvd_angle = guiInfo.DVD.current_angle; | |
519 sprintf(tmp,"dvd://%d", guiInfo.Title); | |
520 guiSetFilename(guiInfo.Filename, tmp); | |
23077 | 521 break; |
522 } | |
523 #endif | |
524 } | |
33555 | 525 if(guiInfo.Filename) |
526 filename = strdup(guiInfo.Filename); | |
23077 | 527 else if(filename) |
33555 | 528 strcpy(guiInfo.Filename, filename); |
23077 | 529 break; |
530 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
531 case GUI_SET_AUDIO: |
23077 | 532 { |
33679 | 533 guiInfo.MovieWindow = (arg && !guiInfo.sh_video); |
33661 | 534 // NOTE: This type doesn't mean (and never meant) that we have |
535 // *just* audio, so there probably should be a check before | |
536 // hiding (see gui/interface.c). | |
23077 | 537 if(IsWindowVisible(mygui->subwindow)) |
538 ShowWindow(mygui->subwindow, SW_HIDE); | |
539 break; | |
540 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
541 case GUI_SET_CONTEXT: |
33555 | 542 guiInfo.mpcontext = arg; |
23077 | 543 break; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
544 case GUI_SET_VIDEO: |
23077 | 545 { |
33555 | 546 guiInfo.sh_video = arg; |
23077 | 547 if (arg) |
548 { | |
30722
b0342ca7ea61
Fix windows Gui compilation and remove some related typecasts.
reimar
parents:
30558
diff
changeset
|
549 sh_video_t *sh = arg; |
23077 | 550 codecname = sh->codec->name; |
33555 | 551 guiInfo.FPS = sh->fps; |
23077 | 552 |
553 /* we have video, show the subwindow */ | |
554 if(!IsWindowVisible(mygui->subwindow) || IsIconic(mygui->subwindow)) | |
555 ShowWindow(mygui->subwindow, SW_SHOWNORMAL); | |
556 if(WinID == -1) | |
557 update_subwindow(); | |
558 | |
559 } | |
560 break; | |
561 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
562 case GUI_SETUP_VIDEO_WINDOW: |
23077 | 563 { |
33555 | 564 guiInfo.MovieWidth = vo_dwidth; |
565 guiInfo.MovieHeight = vo_dheight; | |
23077 | 566 |
33555 | 567 sub_aspect = (float)guiInfo.MovieWidth/guiInfo.MovieHeight; |
23077 | 568 if(WinID != -1) |
569 update_subwindow(); | |
570 break; | |
571 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
572 case GUI_SET_STREAM: |
23077 | 573 { |
33555 | 574 guiInfo.StreamType = stream->type; |
23077 | 575 switch(stream->type) |
576 { | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
577 #ifdef CONFIG_DVDREAD |
23077 | 578 case STREAMTYPE_DVD: |
33730 | 579 dvdp = stream->priv; |
580 guiInfo.DVD.titles = dvdp->vmg_file->tt_srpt->nr_of_srpts; | |
581 guiInfo.DVD.chapters = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts; | |
582 guiInfo.DVD.angles = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; | |
583 guiInfo.DVD.nr_of_audio_channels = dvdp->nr_of_channels; | |
584 memcpy(guiInfo.DVD.audio_streams, dvdp->audio_streams, sizeof(dvdp->audio_streams)); | |
585 guiInfo.DVD.nr_of_subtitles = dvdp->nr_of_subtitles; | |
586 memcpy(guiInfo.DVD.subtitles, dvdp->subtitles, sizeof(dvdp->subtitles)); | |
587 guiInfo.DVD.current_title = dvd_title + 1; | |
588 guiInfo.DVD.current_chapter = dvd_chapter + 1; | |
589 guiInfo.DVD.current_angle = dvd_angle + 1; | |
590 guiInfo.Track = dvd_title + 1; | |
23077 | 591 break; |
592 #endif | |
593 } | |
594 break; | |
595 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
596 case GUI_REDRAW: |
23077 | 597 mygui->updatedisplay(mygui, mygui->mainwindow); |
598 break; | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
599 case GUI_SET_AFILTER: |
33555 | 600 guiInfo.afilter = arg; |
23077 | 601 break; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
602 case GUI_SET_STATE: |
23077 | 603 { |
33555 | 604 guiInfo.Playing = (int) arg; |
605 switch (guiInfo.Playing) | |
23077 | 606 { |
33614 | 607 case GUI_PLAY: |
23077 | 608 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
609 guiInfo.Playing = GUI_PLAY; |
23077 | 610 break; |
611 } | |
33614 | 612 case GUI_STOP: |
23077 | 613 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
614 guiInfo.Playing = GUI_STOP; |
23077 | 615 if(movie_aspect >= 0) |
616 movie_aspect = -1; | |
617 update_subwindow(); | |
618 break; | |
619 } | |
33614 | 620 case GUI_PAUSE: |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
621 guiInfo.Playing = GUI_PAUSE; |
23077 | 622 break; |
623 } | |
624 break; | |
625 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
626 case GUI_RUN_COMMAND: |
23077 | 627 { |
628 mp_msg(MSGT_GPLAYER,MSGL_V, "cmd: %d\n", (int) arg); | |
629 /* MPlayer asks us to quit */ | |
630 switch((int) arg) | |
631 { | |
31312
0b7792622c88
Remove Gui-specific slave commands and associated key-bindings and other code.
reimar
parents:
30901
diff
changeset
|
632 case MP_CMD_VO_FULLSCREEN: |
33555 | 633 uiFullScreen(); |
23077 | 634 break; |
635 case MP_CMD_QUIT: | |
636 { | |
637 mygui->uninit(mygui); | |
638 free(mygui); | |
639 mygui = NULL; | |
30558 | 640 exit_player(EXIT_QUIT); |
33666
0f592e8530f1
Change return code of guiGetEvent() to indicate success.
ib
parents:
33661
diff
changeset
|
641 return 1; |
23077 | 642 } |
33696
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
643 case MP_CMD_PLAY_TREE_STEP: |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
644 guiSetEvent(evNext); |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
645 break; |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
646 case -MP_CMD_PLAY_TREE_STEP: |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
647 guiSetEvent(evPrev); |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
648 break; |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
649 case MP_CMD_STOP: |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
650 guiSetEvent(evStop); |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
651 break; |
23077 | 652 default: |
653 break; | |
654 } | |
655 break; | |
656 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
657 case GUI_SET_FILE: |
23077 | 658 { |
659 audio_id = -1; | |
660 video_id = -1; | |
661 dvdsub_id = -1; | |
662 vobsub_id = -1; | |
663 stream_cache_size = -1; | |
664 autosync = 0; | |
665 dvd_title = 0; | |
666 force_fps = 0; | |
667 if(!mygui->playlist->tracks) return 0; | |
33555 | 668 filename = guiInfo.Filename = mygui->playlist->tracks[mygui->playlist->current]->filename; |
669 guiInfo.Track = mygui->playlist->current + 1; | |
23077 | 670 if(gtkAONorm) greplace(&af_cfg.list, "volnorm", "volnorm"); |
671 if(gtkAOExtraStereo) | |
672 { | |
673 char *name = malloc(12 + 20 + 1); | |
674 snprintf(name, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul); | |
675 name[12 + 20] = 0; | |
676 greplace(&af_cfg.list, "extrastereo", name); | |
677 free(name); | |
678 } | |
679 if(gtkCacheOn) stream_cache_size = gtkCacheSize; | |
680 if(gtkAutoSyncOn) autosync = gtkAutoSync; | |
681 break; | |
682 } | |
33732 | 683 case GUI_HANDLE_EVENTS: |
684 break; | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
685 case GUI_SET_MIXER: |
23077 | 686 { |
687 if(audio_out) | |
688 { | |
689 /* Some audio_out drivers do not support balance e.g. dsound */ | |
690 /* FIXME this algo is not correct */ | |
691 float l, r; | |
692 mixer_getvolume(mixer, &l, &r); | |
33555 | 693 guiInfo.Volume = (r > l ? r : l); /* max(r,l) */ |
23077 | 694 if (r != l) |
33555 | 695 guiInfo.Balance = ((r-l) + 100.0f) * 0.5f; |
23077 | 696 else |
33555 | 697 guiInfo.Balance = 50.0f; |
23077 | 698 } |
699 break; | |
700 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
701 case GUI_END_FILE: |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
702 { |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
703 if(!uiGotoTheNext && guiInfo.Playing) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
704 { |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
705 uiGotoTheNext = 1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
706 break; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
707 } |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
708 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
709 if(uiGotoTheNext && guiInfo.Playing && |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
710 (mygui->playlist->current < (mygui->playlist->trackcount - 1)) && |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
711 guiInfo.StreamType != STREAMTYPE_DVD && |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
712 guiInfo.StreamType != STREAMTYPE_DVDNAV) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
713 { |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
714 /* we've finished this file, reset the aspect */ |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
715 if(movie_aspect >= 0) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
716 movie_aspect = -1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
717 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
718 uiGotoTheNext = guiInfo.FilenameChanged = guiInfo.NewPlay = 1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
719 uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)++]->filename, STREAMTYPE_STREAM); |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
720 //sprintf(guiInfo.Filename, mygui->playlist->tracks[(mygui->playlist->current)++]->filename); |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
721 } |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
722 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
723 if(guiInfo.FilenameChanged && guiInfo.NewPlay) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
724 break; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
725 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
726 guiInfo.TimeSec = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
727 guiInfo.Position = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
728 guiInfo.AudioChannels = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
729 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
730 #ifdef CONFIG_DVDREAD |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
731 guiInfo.DVD.current_title = 1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
732 guiInfo.DVD.current_chapter = 1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
733 guiInfo.DVD.current_angle = 1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
734 #endif |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
735 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
736 if (mygui->playlist->current == (mygui->playlist->trackcount - 1)) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
737 mygui->playlist->current = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
738 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
739 fullscreen = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
740 if(style == WS_VISIBLE | WS_POPUP) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
741 { |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
742 style = WS_OVERLAPPEDWINDOW | WS_SIZEBOX; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
743 SetWindowLong(mygui->subwindow, GWL_STYLE, style); |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
744 } |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
745 gui(GUI_SET_STATE, (void *) GUI_STOP); |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
746 break; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
747 } |
23077 | 748 default: |
33726 | 749 mp_msg(MSGT_GPLAYER, MSGL_ERR, "[GUI] GOT UNHANDLED EVENT %i\n", what); |
23077 | 750 } |
33666
0f592e8530f1
Change return code of guiGetEvent() to indicate success.
ib
parents:
33661
diff
changeset
|
751 return 1; |
23077 | 752 } |
753 | |
754 /* This function adds/inserts one file into the gui playlist */ | |
33579 | 755 static int import_file_into_gui(char *pathname, int insert) |
23077 | 756 { |
757 char filename[MAX_PATH]; | |
758 char *filepart = filename; | |
759 | |
760 if (strstr(pathname, "://")) | |
761 { | |
762 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding special %s\n", pathname); | |
763 mygui->playlist->add_track(mygui->playlist, pathname, NULL, NULL, 0); | |
764 return 1; | |
765 } | |
766 if (GetFullPathName(pathname, MAX_PATH, filename, &filepart)) | |
767 { | |
768 if (!(GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY)) | |
769 { | |
770 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding filename: %s - fullpath: %s\n", filepart, filename); | |
771 mygui->playlist->add_track(mygui->playlist, filename, NULL, filepart, 0); | |
772 return 1; | |
773 } | |
774 else | |
775 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Cannot add %s\n", filename); | |
776 } | |
777 | |
778 return 0; | |
779 } | |
780 | |
781 /* This function imports the initial playtree (based on cmd-line files) into the gui playlist | |
782 by either: | |
783 - overwriting gui pl (enqueue=0) */ | |
784 | |
33734 | 785 int guiInitializePlaylist(play_tree_t *my_playtree, m_config_t *config, int enqueue) |
23077 | 786 { |
787 play_tree_iter_t *my_pt_iter = NULL; | |
788 int result = 0; | |
789 | |
790 if(!mygui) guiInit(); | |
791 | |
792 if((my_pt_iter = pt_iter_create(&my_playtree, config))) | |
793 { | |
794 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
795 { | |
796 if (parse_filename(filename, my_playtree, config, 0)) | |
797 result = 1; | |
798 else if (import_file_into_gui(filename, 0)) /* Add it to end of list */ | |
799 result = 1; | |
800 } | |
801 } | |
33555 | 802 uiGotoTheNext = 1; |
23077 | 803 |
804 if (result) | |
805 { | |
806 mygui->playlist->current = 0; | |
807 filename = mygui->playlist->tracks[0]->filename; | |
808 } | |
809 return result; | |
810 } | |
811 | |
812 /* This function imports and inserts an playtree, that is created "on the fly", for example by | |
813 parsing some MOV-Reference-File; or by loading an playlist with "File Open" | |
814 The file which contained the playlist is thereby replaced with it's contents. */ | |
815 | |
33734 | 816 int guiAddPlaylist(play_tree_t *my_playtree, m_config_t *config) |
23077 | 817 { |
818 play_tree_iter_t *my_pt_iter = NULL; | |
819 int result = 0; | |
820 | |
821 if((my_pt_iter = pt_iter_create(&my_playtree, config))) | |
822 { | |
823 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
824 if (import_file_into_gui(filename, 1)) /* insert it into the list and set plCurrent = new item */ | |
825 result = 1; | |
826 pt_iter_destroy(&my_pt_iter); | |
827 } | |
828 filename = NULL; | |
829 return result; | |
830 } | |
831 | |
33579 | 832 static inline void gtkMessageBox(int type, const char *str) |
23077 | 833 { |
834 if (type & GTK_MB_FATAL) | |
835 MessageBox(NULL, str, "MPlayer GUI for Windows Error", MB_OK | MB_ICONERROR); | |
836 | |
837 fprintf(stderr, "[GUI] MessageBox: %s\n", str); | |
838 fflush(stderr); | |
839 } | |
840 | |
841 static int update_subwindow(void) | |
842 { | |
843 int x,y; | |
844 RECT rd; | |
845 WINDOWPOS wp; | |
846 | |
847 if(!sub_window) | |
848 { | |
33567 | 849 WinID = -1; |
23077 | 850 |
33555 | 851 if(IsWindowVisible(mygui->subwindow) && guiInfo.sh_video && guiInfo.Playing) |
23077 | 852 { |
853 ShowWindow(mygui->subwindow, SW_HIDE); | |
854 return 0; | |
855 } | |
33679 | 856 else if(!guiInfo.MovieWindow) |
23077 | 857 return 0; |
858 else ShowWindow(mygui->subwindow, SW_SHOW); | |
859 } | |
860 | |
861 /* we've come out of fullscreen at the end of file */ | |
33679 | 862 if((!IsWindowVisible(mygui->subwindow) || IsIconic(mygui->subwindow)) && guiInfo.MovieWindow) |
23077 | 863 ShowWindow(mygui->subwindow, SW_SHOWNORMAL); |
864 | |
865 /* get our current window coordinates */ | |
866 GetWindowRect(mygui->subwindow, &rd); | |
867 | |
868 x = rd.left; | |
869 y = rd.top; | |
870 | |
871 /* restore sub window position when coming out of fullscreen */ | |
872 if(x <= 0) x = old_rect.left; | |
873 if(y <= 0) y = old_rect.top; | |
874 | |
33555 | 875 if(!guiInfo.Playing) |
23077 | 876 { |
877 window *desc = NULL; | |
878 int i; | |
879 | |
880 for (i=0; i<mygui->skin->windowcount; i++) | |
881 if(mygui->skin->windows[i]->type == wiSub) | |
882 desc = mygui->skin->windows[i]; | |
883 | |
884 rd.right = rd.left+desc->base->bitmap[0]->width; | |
885 rd.bottom = rd.top+desc->base->bitmap[0]->height; | |
886 sub_aspect = (float)(rd.right-rd.left)/(rd.bottom-rd.top); | |
887 } | |
888 else | |
889 { | |
33555 | 890 rd.right = rd.left+guiInfo.MovieWidth; |
891 rd.bottom = rd.top+guiInfo.MovieHeight; | |
23077 | 892 |
893 if (movie_aspect > 0.0) // forced aspect from the cmdline | |
894 sub_aspect = movie_aspect; | |
895 } | |
896 | |
897 | |
898 AdjustWindowRect(&rd, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, 0); | |
899 SetWindowPos(mygui->subwindow, 0, x, y, rd.right-rd.left, rd.bottom-rd.top, SWP_NOOWNERZORDER); | |
900 | |
901 wp.hwnd = mygui->subwindow; | |
902 wp.x = rd.left; | |
903 wp.y = rd.top; | |
904 wp.cx = rd.right-rd.left; | |
905 wp.cy = rd.bottom-rd.top; | |
906 wp.flags = SWP_NOOWNERZORDER | SWP_SHOWWINDOW; | |
907 | |
908 /* erase the bitmap image if there's video */ | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
909 if(guiInfo.Playing != GUI_STOP && guiInfo.sh_video) |
23077 | 910 SendMessage(mygui->subwindow, WM_ERASEBKGND, (WPARAM)GetDC(mygui->subwindow), 0); |
911 | |
912 /* reset the window aspect */ | |
913 SendMessage(mygui->subwindow, WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp); | |
914 return 0; | |
915 } |