Mercurial > mplayer.hg
annotate Gui/win32/gui.c @ 22827:04c6a17fc1df
Clarify -xineramascreen -2 behaviour
author | reimar |
---|---|
date | Fri, 30 Mar 2007 17:10:35 +0000 |
parents | 98eaf29b5dee |
children |
rev | line source |
---|---|
18914 | 1 /* |
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 program is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
9 the Free Software Foundation; either version 2 of the License, or | |
10 (at your option) any later version. | |
11 | |
12 This program is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with this program; if not, write to the Free Software | |
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA | |
20 */ | |
21 | |
22 #include <stdio.h> | |
23 #include <stdlib.h> | |
24 #include <ctype.h> | |
25 #include <fcntl.h> | |
26 #include <windows.h> | |
27 #include <windowsx.h> | |
28 #include <shlobj.h> | |
29 #include <version.h> | |
30 #include <mplayer.h> | |
22823
98eaf29b5dee
Code cleanup: don't include a .c file in mplayer.c and fix a few
rathann
parents:
22487
diff
changeset
|
31 #include <mp_fifo.h> |
18914 | 32 #include <mp_msg.h> |
33 #include <help_mp.h> | |
34 #include <input/input.h> | |
35 #include <input/mouse.h> | |
36 #include <osdep/keycodes.h> | |
19271
64d82a45a05d
introduce new 'stream' directory for all stream layer related components and split them from libmpdemux
ben
parents:
19245
diff
changeset
|
37 #include <stream/stream.h> |
18914 | 38 #include <libvo/video_out.h> |
39 #include <interface.h> | |
40 #include "gui.h" | |
41 #include "wincfg.h" | |
42 #include "dialogs.h" | |
43 | |
18930
d7ab6268e3ea
Some older MinGW versions have a broken INVALID_FILE_ATTRIBUTES, so hack around that for now.
reimar
parents:
18914
diff
changeset
|
44 // HACK around bug in old mingw |
d7ab6268e3ea
Some older MinGW versions have a broken INVALID_FILE_ATTRIBUTES, so hack around that for now.
reimar
parents:
18914
diff
changeset
|
45 #undef INVALID_FILE_ATTRIBUTES |
d7ab6268e3ea
Some older MinGW versions have a broken INVALID_FILE_ATTRIBUTES, so hack around that for now.
reimar
parents:
18914
diff
changeset
|
46 #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) |
d7ab6268e3ea
Some older MinGW versions have a broken INVALID_FILE_ATTRIBUTES, so hack around that for now.
reimar
parents:
18914
diff
changeset
|
47 |
18914 | 48 #ifndef WM_XBUTTONDOWN |
49 # define WM_XBUTTONDOWN 0x020B | |
50 # define WM_XBUTTONUP 0x020C | |
51 # define WM_XBUTTONDBLCLK 0x020D | |
52 #endif | |
53 | |
54 /* Globals / Externs */ | |
55 extern void renderinfobox(skin_t *skin, window_priv_t *priv); | |
56 extern void renderwidget(skin_t *skin, image *dest, widget *item, int state); | |
57 extern void mplayer_put_key(int code); | |
21764 | 58 extern void print_version(void); |
18914 | 59 extern int WinID; |
60 float sub_aspect; | |
61 | |
62 DWORD oldtime; | |
63 NOTIFYICONDATA nid; | |
64 int console_state = 0; | |
22308 | 65 play_tree_t *playtree = NULL; |
18914 | 66 |
19570
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
67 static HBRUSH colorbrush = NULL; //Handle to colorkey brush |
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
68 static COLORREF windowcolor = RGB(255,0,255); //Windowcolor == colorkey |
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
69 |
18914 | 70 void console_toggle(void) |
71 { | |
72 if (console_state) | |
73 { | |
74 FreeConsole(); | |
75 console = 0; | |
76 console_state = 0; | |
77 } | |
78 else | |
79 { | |
80 /* This code comes from: http://dslweb.nwnexus.com/~ast/dload/guicon.htm */ | |
81 CONSOLE_SCREEN_BUFFER_INFO coninfo; | |
82 FILE *fp; | |
83 HWND hwnd = NULL; | |
84 console = 1; | |
85 AllocConsole(); | |
86 SetConsoleTitle(MP_TITLE); | |
87 | |
88 /* disable the close button for now */ | |
89 while (!hwnd) | |
90 { | |
91 hwnd = FindWindow(NULL, MP_TITLE); | |
92 Sleep(100); | |
93 } | |
94 DeleteMenu(GetSystemMenu(hwnd, 0), SC_CLOSE, MF_BYCOMMAND); | |
95 | |
96 GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo); | |
97 coninfo.dwSize.Y = 1000; | |
98 SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize); | |
99 fp = freopen("con", "w", stdout); | |
100 *stdout = *fp; | |
101 setvbuf(stdout, NULL, _IONBF, 0); | |
102 fp = freopen("con", "r", stdin); | |
103 *stdin = *fp; | |
104 setvbuf(stdin, NULL, _IONBF, 0); | |
105 fp = freopen("con", "w", stdout); | |
106 *stderr = *fp; | |
107 setvbuf(stderr, NULL, _IONBF, 0); | |
21764 | 108 print_version(); |
18914 | 109 console_state = 1; |
110 } | |
111 } | |
112 | |
113 void capitalize(char *filename) | |
114 { | |
115 unsigned int i; | |
116 BOOL cap = TRUE; | |
117 for (i=0; i < strlen(filename); i++) | |
118 { | |
119 if (cap) | |
120 { | |
121 cap = FALSE; | |
122 filename[i] = toupper(filename[i]); | |
123 } | |
124 else if (filename[i] == ' ') | |
125 cap = TRUE; | |
126 else | |
127 filename[i] = tolower(filename[i]); | |
128 } | |
129 } | |
130 | |
131 static image *get_drawground(HWND hwnd) | |
132 { | |
133 gui_t * gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
134 unsigned int i; | |
135 if(!gui) return NULL; | |
136 for(i=0; i<gui->window_priv_count; i++) | |
137 if(gui->window_priv[i]->hwnd==hwnd) | |
138 return &gui->window_priv[i]->img; | |
139 return NULL; | |
140 } | |
141 | |
142 static HBITMAP get_bitmap(HWND hwnd) | |
143 { | |
144 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
145 unsigned int i; | |
146 if(!gui) return NULL; | |
147 for(i=0; i<gui->window_priv_count; i++) | |
148 if(gui->window_priv[i]->hwnd == hwnd) | |
149 return gui->window_priv[i]->bitmap; | |
150 return NULL; | |
151 } | |
152 | |
153 static int get_windowtype(HWND hwnd) | |
154 { | |
155 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
156 unsigned int i; | |
157 if(!gui) return -1; | |
158 for(i=0; i<gui->window_priv_count; i++) | |
159 if(gui->window_priv[i]->hwnd == hwnd) | |
160 return gui->window_priv[i]->type; | |
161 return -1; | |
162 } | |
163 | |
164 static void uninit(gui_t *gui) | |
165 { | |
166 if(gui->skin) destroy_window(gui); | |
167 if(gui->playlist) gui->playlist->free_playlist(gui->playlist); | |
168 gui->playlist = NULL; | |
169 } | |
170 | |
171 /* | |
172 the gui message handler | |
173 tries to handle the incoming messages | |
174 and passes them to the player's message handler if it can't handle them | |
175 */ | |
176 static void handlemsg(HWND hWnd, int msg) | |
177 { | |
178 gui_t *gui = (gui_t *) GetWindowLongPtr(hWnd, GWLP_USERDATA); | |
179 if(msg == evNone) return; | |
180 | |
181 switch(msg) | |
182 { | |
183 case evLoadPlay: | |
184 case evLoad: | |
185 if(display_openfilewindow(gui, 0) && (msg == evLoadPlay)) | |
186 handlemsg(hWnd, evDropFile); | |
187 return; | |
188 case evLoadSubtitle: | |
189 display_opensubtitlewindow(gui); | |
190 break; | |
191 case evPreferences: | |
192 display_prefswindow(gui); | |
193 return; | |
194 case evPlayList: | |
195 display_playlistwindow(gui); | |
196 return; | |
197 case evSkinBrowser: | |
198 display_skinbrowser(gui); | |
199 break; | |
200 case evEqualizer: | |
201 display_eqwindow(gui); | |
202 break; | |
203 case evAbout: | |
204 MessageBox(hWnd, COPYRIGHT, "About", MB_OK); | |
205 break; | |
206 case evIconify: | |
207 ShowWindow(hWnd, SW_MINIMIZE); | |
208 break; | |
209 case evIncVolume: | |
210 mplayer_put_key(KEY_VOLUME_UP); | |
211 break; | |
212 case evDecVolume: | |
213 mplayer_put_key(KEY_VOLUME_DOWN); | |
214 break; | |
215 default: | |
216 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] received msg %s (%i)\n", gui->skin->geteventname(msg), msg); | |
217 break; | |
218 } | |
219 gui->playercontrol(msg); | |
220 } | |
221 | |
222 static widget *clickedinsidewidget(gui_t *gui, int window, int x, int y) | |
223 { | |
224 unsigned int i; | |
225 widget *item; | |
226 for(i=0; i<gui->skin->widgetcount; i++) | |
227 { | |
228 item = gui->skin->widgets[i]; | |
229 if((item->window == window) && (item->x <= x) && (item->x + item->width >= x) && | |
230 (item->y <= y) && (item->y + item->height >= y)) | |
231 return item; | |
232 } | |
233 return NULL; | |
234 } | |
235 | |
236 /* updates sliders and the display */ | |
237 static void updatedisplay(gui_t *gui, HWND hwnd) | |
238 { | |
239 unsigned int i; | |
240 window_priv_t *priv = NULL; | |
19718 | 241 DWORD time = timeGetTime(); |
242 | |
243 if(!hwnd) return; | |
18914 | 244 |
245 /* load all potmeters hpotmeters */ | |
246 for(i=0; i<gui->skin->widgetcount; i++) | |
247 { | |
248 if(gui->skin->widgets[i]->type == tyHpotmeter || gui->skin->widgets[i]->type == tyPotmeter) | |
249 { | |
250 if(gui->skin->widgets[i]->msg == evSetVolume) | |
251 gui->skin->widgets[i]->value = guiIntfStruct.Volume; | |
252 else if(gui->skin->widgets[i]->msg == evSetMoviePosition) | |
253 gui->skin->widgets[i]->value = guiIntfStruct.Position; | |
254 else if(gui->skin->widgets[i]->msg == evSetBalance) | |
255 gui->skin->widgets[i]->value = guiIntfStruct.Balance; | |
256 if(gui->skin->widgets[i]->window == get_windowtype(hwnd)) | |
257 renderwidget(gui->skin, get_drawground(hwnd), gui->skin->widgets[i], | |
258 gui->skin->widgets[i]->pressed ? 0 : 1); | |
259 } | |
260 /* update some buttons */ | |
261 if(gui->skin->widgets[i]->type == tyButton && gui->skin->widgets[i]->window == get_windowtype(hwnd)) | |
262 { | |
263 if(gui->skin->widgets[i]->msg == evPlaySwitchToPause) | |
264 { | |
265 gui->skin->widgets[i]->value = guiIntfStruct.Playing; | |
266 renderwidget(gui->skin, get_drawground(hwnd), gui->skin->widgets[i], | |
267 guiIntfStruct.Playing == 1 ? 0 : 1); | |
268 } | |
269 if(gui->skin->widgets[i]->msg == evMute) | |
270 { | |
271 gui->skin->widgets[i]->value = guiIntfStruct.Volume; | |
272 renderwidget(gui->skin, get_drawground(hwnd), gui->skin->widgets[i], | |
273 guiIntfStruct.Volume == 0.0f ? 0 : 1); | |
274 } | |
275 } | |
276 } | |
277 | |
278 /* updating the display once a 100.second is enough imo */ | |
279 if((time - oldtime) < 100) return; | |
280 oldtime=time; | |
281 | |
19535
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
282 /* suppress directx's fullscreen window when using the sub window */ |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
283 if(sub_window && &video_driver_list[0] && strstr("directx", video_driver_list[0])) |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
284 { |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
285 HWND hWndFS = NULL; //handle to directx's fullscreen window |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
286 if(hWndFS == NULL) |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
287 { |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
288 hWndFS = FindWindow(NULL, "MPlayer Fullscreen"); |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
289 if(hWndFS != NULL) DestroyWindow(hWndFS); //sub window handles fullscreen |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
290 } |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
291 } |
69b134c4caea
Further fullscreen switching improvements. Fixes sub window position bug when exiting a file from fullscreen. Fixes sub window position when switching between windows and fullscreen modes.
vayne
parents:
19408
diff
changeset
|
292 |
18914 | 293 for (i=0; i<gui->window_priv_count; i++) |
294 { | |
295 if(gui->window_priv[i]->hwnd == hwnd) | |
296 priv=gui->window_priv[i]; | |
297 }// Sherpya | |
298 /* display the status msgs */ | |
299 renderinfobox(gui->skin, priv); | |
300 RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE); | |
301 } | |
302 | |
303 static LRESULT CALLBACK SubProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) | |
304 { | |
305 gui_t *gui = (gui_t *) GetWindowLongPtr(hWnd, GWLP_USERDATA); | |
306 if (gui && (gui->subwindow != hWnd)) return FALSE; | |
307 | |
308 switch (message) | |
309 { | |
310 case WM_CLOSE: | |
311 handlemsg(hWnd, evExit); | |
312 return 0; | |
313 case WM_DESTROY: | |
314 PostQuitMessage(0); | |
315 return 0; | |
316 case WM_KEYDOWN: | |
317 { | |
318 switch(wParam) | |
319 { | |
320 case VK_LEFT: | |
321 mplayer_put_key(KEY_LEFT); | |
322 break; | |
323 case VK_UP: | |
324 mplayer_put_key(KEY_UP); | |
325 break; | |
326 case VK_RIGHT: | |
327 mplayer_put_key(KEY_RIGHT); | |
328 break; | |
329 case VK_DOWN: | |
330 mplayer_put_key(KEY_DOWN); | |
331 break; | |
332 case VK_TAB: | |
333 mplayer_put_key(KEY_TAB); | |
334 break; | |
335 case VK_BACK: | |
336 mplayer_put_key(KEY_BS); | |
337 break; | |
338 case VK_DELETE: | |
339 mplayer_put_key(KEY_DELETE); | |
340 break; | |
341 case VK_INSERT: | |
342 mplayer_put_key(KEY_INSERT); | |
343 break; | |
344 case VK_HOME: | |
345 mplayer_put_key(KEY_HOME); | |
346 break; | |
347 case VK_END: | |
348 mplayer_put_key(KEY_END); | |
349 break; | |
350 case VK_PRIOR: | |
351 mplayer_put_key(KEY_PAGE_UP); | |
352 break; | |
353 case VK_NEXT: | |
354 mplayer_put_key(KEY_PAGE_DOWN); | |
355 break; | |
356 case VK_ESCAPE: | |
357 mplayer_put_key(KEY_ESC); | |
358 break; | |
359 } | |
360 break; | |
361 } | |
362 case WM_COMMAND: | |
363 { | |
364 switch(LOWORD(wParam)) | |
365 { | |
366 case IDEXIT: | |
367 PostQuitMessage(0); | |
368 handlemsg(hWnd, evExit); | |
369 break; | |
370 case IDFILE_OPEN: | |
371 handlemsg(hWnd, evLoadPlay); | |
372 break; | |
373 case IDURL_OPEN: | |
374 display_openurlwindow(gui, 0); | |
375 break; | |
376 case IDDIR_OPEN: | |
377 { | |
378 static char path[MAX_PATH]; | |
379 BROWSEINFO bi; | |
19718 | 380 LPITEMIDLIST pidl; |
18914 | 381 memset(&bi, 0, sizeof(BROWSEINFO)); |
382 bi.lpszTitle = "Choose a Directory..."; | |
19718 | 383 pidl = SHBrowseForFolder(&bi); |
18914 | 384 if (SHGetPathFromIDList(pidl, path)) |
385 { | |
386 gui->playlist->clear_playlist(gui->playlist); | |
387 adddirtoplaylist(gui->playlist, path, TRUE); | |
388 gui->startplay(gui); | |
389 } | |
390 break; | |
391 } | |
392 case ID_PTRACK: | |
393 handlemsg(hWnd, evPrev); | |
394 break; | |
395 case ID_SEEKB: | |
396 handlemsg(hWnd, evBackward10sec); | |
397 break; | |
398 case ID_PLAY: | |
399 handlemsg(hWnd, evPlaySwitchToPause); | |
400 break; | |
401 case ID_STOP: | |
402 handlemsg(hWnd, evStop); | |
403 break; | |
404 case ID_SEEKF: | |
405 handlemsg(hWnd, evForward10sec); | |
406 break; | |
407 case ID_NTRACK: | |
408 handlemsg(hWnd, evNext); | |
409 break; | |
410 #ifdef USE_DVDREAD | |
411 case ID_CHAPTERSEL: | |
412 display_chapterselwindow(gui); | |
413 break; | |
414 #endif | |
20211
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
415 case ID_FULLSCREEN: |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
416 mp_input_queue_cmd(mp_input_parse_cmd("vo_fullscreen")); |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
417 break; |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
418 case ID_MUTE: |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
419 mp_input_queue_cmd(mp_input_parse_cmd("mute")); |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
420 break; |
18914 | 421 case ID_ASPECT1: |
422 mp_input_queue_cmd(mp_input_parse_cmd("switch_ratio 1.777777")); | |
423 break; | |
424 case ID_ASPECT2: | |
425 mp_input_queue_cmd(mp_input_parse_cmd("switch_ratio 1.333333")); | |
426 break; | |
427 case ID_ASPECT3: | |
428 mp_input_queue_cmd(mp_input_parse_cmd("switch_ratio 2.35")); | |
429 break; | |
430 case ID_ASPECT4: | |
431 mp_input_queue_cmd(mp_input_parse_cmd("switch_ratio 0")); | |
432 break; | |
433 case IDSUB_TOGGLE: | |
434 mp_input_queue_cmd(mp_input_parse_cmd("sub_visibility")); | |
435 break; | |
436 case IDSUB_CYCLE: | |
437 mp_input_queue_cmd(mp_input_parse_cmd("sub_select")); | |
438 break; | |
439 } | |
440 return 0; | |
441 } | |
442 case WM_CHAR: | |
443 mplayer_put_key(wParam); | |
444 break; | |
445 case WM_DROPFILES: | |
446 { | |
447 if(!lParam) | |
448 { | |
449 char file[MAX_PATH]; | |
450 int filecount = DragQueryFile((HDROP) wParam, -1, file, MAX_PATH); | |
451 int i; | |
452 for(i=0; i<filecount; i++) | |
453 { | |
454 DragQueryFile((HDROP) wParam, i, file, MAX_PATH); | |
22487 | 455 mplSetFileName(NULL, file, STREAMTYPE_FILE); |
18914 | 456 if(!parse_filename(file, playtree, mconfig, 1)) |
457 gui->playlist->add_track(gui->playlist, file, NULL, NULL, 0); | |
458 } | |
459 DragFinish((HDROP) wParam); | |
460 handlemsg(hWnd, evDropFile); | |
461 } | |
462 else | |
463 { | |
464 gui->playlist->clear_playlist(gui->playlist); | |
465 gui->playlist->add_track(gui->playlist, (const char *) wParam, NULL, NULL, 0); | |
466 handlemsg(hWnd, evDropFile); | |
467 } | |
468 SetForegroundWindow(gui->subwindow); | |
469 return 0; | |
470 } | |
471 case WM_LBUTTONDOWN: | |
472 { | |
473 if(!vo_nomouse_input) | |
474 mplayer_put_key(MOUSE_BTN0); | |
475 break; | |
476 } | |
477 case WM_MBUTTONDOWN: | |
478 { | |
479 if(!vo_nomouse_input) | |
480 mplayer_put_key(MOUSE_BTN1); | |
481 break; | |
482 } | |
483 case WM_RBUTTONDOWN: | |
484 { | |
485 POINT point; | |
486 point.x = GET_X_LPARAM(lParam); | |
487 point.y = GET_Y_LPARAM(lParam); | |
488 ClientToScreen(hWnd, &point); | |
489 if(guiIntfStruct.StreamType == STREAMTYPE_DVD) | |
490 EnableMenuItem(gui->dvdmenu, ID_CHAPTERSEL, MF_BYCOMMAND | MF_ENABLED); | |
491 TrackPopupMenu(gui->submenu, 0, point.x, point.y, 0, hWnd, NULL); | |
492 return 0; | |
493 } | |
494 case WM_LBUTTONDBLCLK: | |
495 { | |
496 if(!vo_nomouse_input) | |
497 mplayer_put_key(MOUSE_BTN0_DBL); | |
498 break; | |
499 } | |
500 case WM_MBUTTONDBLCLK: | |
501 { | |
502 if(!vo_nomouse_input) | |
503 mplayer_put_key(MOUSE_BTN1_DBL); | |
504 break; | |
505 } | |
506 case WM_RBUTTONDBLCLK: | |
507 { | |
508 if(!vo_nomouse_input) | |
509 mplayer_put_key(MOUSE_BTN2_DBL); | |
510 break; | |
511 } | |
512 case WM_MOUSEWHEEL: | |
513 { | |
19718 | 514 int x = GET_WHEEL_DELTA_WPARAM(wParam); |
18914 | 515 if(vo_nomouse_input) |
516 break; | |
517 if (x > 0) | |
518 mplayer_put_key(MOUSE_BTN3); | |
519 else | |
520 mplayer_put_key(MOUSE_BTN4); | |
521 break; | |
522 } | |
523 case WM_XBUTTONDOWN: | |
524 { | |
525 if(vo_nomouse_input) | |
526 break; | |
527 if(HIWORD(wParam) == 1) | |
528 mplayer_put_key(MOUSE_BTN5); | |
529 else | |
530 mplayer_put_key(MOUSE_BTN6); | |
531 break; | |
532 } | |
533 case WM_XBUTTONDBLCLK: | |
534 { | |
535 if(vo_nomouse_input) | |
536 break; | |
537 if(HIWORD(wParam) == 1) | |
538 mplayer_put_key(MOUSE_BTN5_DBL); | |
539 else | |
540 mplayer_put_key(MOUSE_BTN6_DBL); | |
541 break; | |
542 } | |
20132
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
543 case WM_TIMER: |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
544 { |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
545 if(fullscreen) while(ShowCursor(FALSE) >= 0){} |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
546 KillTimer(hWnd, ID_TIMER); |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
547 return 0; |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
548 } |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
549 case WM_MOUSEMOVE: |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
550 { |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
551 ShowCursor(TRUE); |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
552 SetTimer(hWnd, ID_TIMER, 3000, (TIMERPROC) NULL); |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
553 break; |
a8aa764559fa
added a simple timer to hide the mouse when in fullscreen mode.
vayne
parents:
19897
diff
changeset
|
554 } |
18914 | 555 case WM_WINDOWPOSCHANGED: |
556 { | |
557 int tmpheight=0; | |
558 static uint32_t rect_width; | |
559 static uint32_t rect_height; | |
560 RECT rd; | |
561 POINT pt; | |
562 pt.x = 0; | |
563 pt.y = 0; | |
564 GetClientRect(hWnd, &rd); | |
565 ClientToScreen(hWnd, &pt); | |
566 | |
567 rect_width = rd.right - rd.left; | |
568 rect_height = rd.bottom - rd.top; | |
569 | |
570 /* maintain our aspect ratio */ | |
571 tmpheight = ((float)rect_width/sub_aspect); | |
572 tmpheight += tmpheight % 2; | |
573 if(tmpheight > rect_height) | |
574 { | |
575 rect_width = ((float)rect_height*sub_aspect); | |
576 rect_width += rect_width % 2; | |
577 } | |
578 else rect_height = tmpheight; | |
579 | |
580 rd.right = rd.left + rect_width; | |
581 rd.bottom = rd.top + rect_height; | |
582 | |
19408 | 583 AdjustWindowRect(&rd, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, 0); |
19245 | 584 SetWindowPos(hWnd, 0, fullscreen?0:pt.x+rd.left, fullscreen?0:pt.y+rd.top, |
19408 | 585 fullscreen?vo_screenwidth:rd.right-rd.left, fullscreen?vo_screenheight:rd.bottom-rd.top, SWP_NOOWNERZORDER); |
586 SetForegroundWindow(hWnd); | |
18914 | 587 return 0; |
588 } | |
19897
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
589 case WM_SYSCOMMAND: |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
590 { |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
591 switch(wParam) |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
592 { |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
593 case SC_SCREENSAVE: |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
594 case SC_MONITORPOWER: |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
595 mp_msg(MSGT_VO, MSGL_V ,"<vo_directx><INFO>killing screensaver\n" ); |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
596 return 0; |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
597 } |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
598 break; |
b69d78e8aee8
fix for disabling screensaver when in fullscreen mode while using the sub window.
vayne
parents:
19718
diff
changeset
|
599 } |
18914 | 600 case WM_PAINT: |
601 { | |
602 PAINTSTRUCT ps; | |
603 RECT rect; | |
604 HDC hdc = BeginPaint(hWnd, &ps); | |
605 HDC hMemDC = CreateCompatibleDC(hdc); | |
19570
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
606 HBRUSH blackbrush = (HBRUSH)GetStockObject(BLACK_BRUSH); |
18914 | 607 int width, height; |
608 GetClientRect(hWnd, &rect); | |
609 width = rect.right - rect.left; | |
610 height = rect.bottom - rect.top; | |
611 if(guiIntfStruct.Playing == 0) | |
612 { | |
613 int i; | |
614 window *desc = NULL; | |
615 | |
616 for (i=0; i<gui->skin->windowcount; i++) | |
617 if(gui->skin->windows[i]->type == wiSub) | |
618 desc = gui->skin->windows[i]; | |
619 | |
620 SelectObject(hMemDC, get_bitmap(hWnd)); | |
621 StretchBlt(hdc, 0, 0, width, height, hMemDC, 0, 0, desc->base->bitmap[0]->width, | |
622 desc->base->bitmap[0]->height, SRCCOPY); | |
19570
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
623 } else { |
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
624 FillRect(GetDC(hWnd), &rect, fullscreen?blackbrush:colorbrush); |
18914 | 625 } |
626 DeleteDC(hMemDC); | |
627 EndPaint(hWnd, &ps); | |
628 return 0; | |
629 } | |
630 } | |
631 return DefWindowProc(hWnd, message, wParam, lParam); | |
632 } | |
633 | |
634 /* Window Proc for the gui Window */ | |
635 static LRESULT CALLBACK EventProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) | |
636 { | |
637 gui_t *gui = (gui_t *) GetWindowLongPtr(hWnd, GWLP_USERDATA); | |
638 | |
639 /* Avoid processing when then window doesn't match gui mainwindow */ | |
640 if (gui && (gui->mainwindow != hWnd)) return FALSE; | |
641 | |
642 switch (message) | |
643 { | |
644 case WM_CLOSE: | |
645 handlemsg(hWnd, evExit); | |
646 return 0; | |
647 case WM_DESTROY: | |
648 PostQuitMessage(0); | |
649 return 0; | |
650 case WM_SYSTRAY: | |
651 { | |
652 switch(lParam) | |
653 { | |
654 POINT cursor; | |
655 case WM_RBUTTONDOWN: | |
656 { | |
657 GetCursorPos(&cursor); | |
658 SetForegroundWindow(hWnd); | |
659 TrackPopupMenu(gui->traymenu, 0, cursor.x, cursor.y, 0, hWnd, NULL); | |
660 break; | |
661 } | |
662 case WM_MBUTTONDBLCLK: | |
663 case WM_LBUTTONDBLCLK: | |
664 { | |
665 if(IsWindowVisible(hWnd)) ShowWindow(hWnd, SW_HIDE); | |
666 else { ShowWindow(hWnd, SW_SHOW); SetForegroundWindow(hWnd); } | |
667 break; | |
668 } | |
669 } | |
670 break; | |
671 } | |
672 case WM_KEYDOWN: | |
673 { | |
674 switch(wParam) | |
675 { | |
676 case VK_LEFT: | |
677 mplayer_put_key(KEY_LEFT); | |
678 break; | |
679 case VK_UP: | |
680 mplayer_put_key(KEY_UP); | |
681 break; | |
682 case VK_RIGHT: | |
683 mplayer_put_key(KEY_RIGHT); | |
684 break; | |
685 case VK_DOWN: | |
686 mplayer_put_key(KEY_DOWN); | |
687 break; | |
688 case VK_TAB: | |
689 mplayer_put_key(KEY_TAB); | |
690 break; | |
691 case VK_BACK: | |
692 mplayer_put_key(KEY_BS); | |
693 break; | |
694 case VK_DELETE: | |
695 mplayer_put_key(KEY_DELETE); | |
696 break; | |
697 case VK_INSERT: | |
698 mplayer_put_key(KEY_INSERT); | |
699 break; | |
700 case VK_HOME: | |
701 mplayer_put_key(KEY_HOME); | |
702 break; | |
703 case VK_END: | |
704 mplayer_put_key(KEY_END); | |
705 break; | |
706 case VK_PRIOR: | |
707 mplayer_put_key(KEY_PAGE_UP); | |
708 break; | |
709 case VK_NEXT: | |
710 mplayer_put_key(KEY_PAGE_DOWN); | |
711 break; | |
712 case VK_ESCAPE: | |
713 mplayer_put_key(KEY_ESC); | |
714 break; | |
715 } | |
716 break; | |
717 } | |
718 case WM_CHAR: | |
719 mplayer_put_key(wParam); | |
720 break; | |
721 case WM_COPYDATA: | |
722 { | |
723 if(lParam) | |
724 { | |
725 PCOPYDATASTRUCT cdData; | |
726 cdData = (PCOPYDATASTRUCT) lParam; | |
22487 | 727 mplSetFileName(NULL, cdData->lpData, STREAMTYPE_FILE); |
18914 | 728 if(!parse_filename(cdData->lpData, playtree, mconfig, 1)) |
729 gui->playlist->add_track(gui->playlist, cdData->lpData, NULL, NULL, 0); | |
730 gui->startplay(gui); | |
731 } | |
732 break; | |
733 } | |
734 case WM_DROPFILES: | |
735 { | |
736 if(!lParam) | |
737 { | |
738 char file[MAX_PATH]; | |
739 int filecount = DragQueryFile((HDROP) wParam, -1, file, MAX_PATH); | |
740 int i; | |
741 for(i=0; i<filecount; i++) | |
742 { | |
743 DragQueryFile((HDROP) wParam, i, file, MAX_PATH); | |
22487 | 744 mplSetFileName(NULL, file, STREAMTYPE_FILE); |
18914 | 745 if(!parse_filename(file, playtree, mconfig, 1)) |
746 gui->playlist->add_track(gui->playlist, file, NULL, NULL, 0); | |
747 } | |
748 DragFinish((HDROP) wParam); | |
749 handlemsg(hWnd, evDropFile); | |
750 } | |
751 else | |
752 { | |
753 gui->playlist->clear_playlist(gui->playlist); | |
754 gui->playlist->add_track(gui->playlist, (const char *) wParam, NULL, NULL, 0); | |
755 handlemsg(hWnd, evDropFile); | |
756 } | |
757 SetForegroundWindow(gui->mainwindow); | |
758 return 0; | |
759 } | |
760 case WM_LBUTTONDOWN: | |
761 { | |
762 SetCapture(hWnd); | |
763 gui->mousex = GET_X_LPARAM(lParam); | |
764 gui->mousey = GET_Y_LPARAM(lParam); | |
765 /* inside a widget */ | |
766 gui->activewidget = clickedinsidewidget(gui, get_windowtype(hWnd), gui->mousex, gui->mousey); | |
767 if(gui->activewidget) | |
768 { | |
769 gui->activewidget->pressed = 1; | |
770 gui->mousewx = gui->mousex - gui->activewidget->x; | |
771 gui->mousewy = gui->mousey - gui->activewidget->y; | |
772 renderwidget(gui->skin, get_drawground(hWnd), gui->activewidget, 0); | |
773 RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE); | |
774 handlemsg(hWnd, gui->activewidget->msg); | |
775 } | |
776 break; | |
777 } | |
778 case WM_CAPTURECHANGED: | |
779 { | |
780 if(gui->activewidget) | |
781 { | |
782 gui->activewidget->pressed = 0; | |
783 renderwidget(gui->skin, get_drawground(hWnd), gui->activewidget, 1); | |
784 RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE); | |
785 gui->activewidget = NULL; | |
786 } | |
787 break; | |
788 } | |
789 case WM_LBUTTONUP: | |
790 { | |
791 ReleaseCapture(); | |
792 if(gui->activewidget) | |
793 { | |
794 gui->activewidget->pressed = 0; | |
795 renderwidget(gui->skin, get_drawground(hWnd), gui->activewidget, 1); | |
796 RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE); | |
797 gui->activewidget = NULL; | |
798 } | |
799 break; | |
800 } | |
801 case WM_RBUTTONDOWN: | |
802 { | |
803 POINT point; | |
804 char device[MAX_PATH]; | |
805 char searchpath[MAX_PATH]; | |
806 char searchpath2[MAX_PATH]; | |
807 #ifdef HAVE_LIBCDIO | |
808 char searchpath3[MAX_PATH]; | |
809 #endif | |
810 int len, pos = 0, cdromdrive = 0; | |
20235
c7f580aa091d
Set SetErrorMode to make sure no dialog box will pop up when no disk in CD/DVD drive.
reimar
parents:
20211
diff
changeset
|
811 UINT errmode; |
18914 | 812 point.x = GET_X_LPARAM(lParam); |
813 point.y = GET_Y_LPARAM(lParam); | |
814 ClientToScreen(hWnd, &point); | |
20235
c7f580aa091d
Set SetErrorMode to make sure no dialog box will pop up when no disk in CD/DVD drive.
reimar
parents:
20211
diff
changeset
|
815 errmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); |
20245
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
816 while (GetMenuItemCount(gui->diskmenu) > 0) |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
817 DeleteMenu(gui->diskmenu, 0, MF_BYPOSITION); |
18914 | 818 len = GetLogicalDriveStrings(MAX_PATH, device); |
819 while(pos < len) | |
820 { | |
821 if(GetDriveType(device + pos) == DRIVE_CDROM) | |
822 { | |
20245
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
823 char volname[MAX_PATH]; |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
824 char menuitem[MAX_PATH]; |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
825 int flags = MF_STRING; |
18914 | 826 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] checking %s for CD/VCD/SVCD/DVDs\n", device + pos); |
827 sprintf(searchpath, "%sVIDEO_TS", device + pos); | |
828 sprintf(searchpath2, "%sMpegav", device + pos); | |
829 #ifdef HAVE_LIBCDIO | |
830 sprintf(searchpath3, "%sTrack01.cda", device + pos); | |
831 #endif | |
832 if(GetFileAttributes(searchpath) != INVALID_FILE_ATTRIBUTES) | |
20245
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
833 flags |= MF_ENABLED; |
18914 | 834 else if(GetFileAttributes(searchpath2) != INVALID_FILE_ATTRIBUTES) |
20245
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
835 flags |= MF_ENABLED; |
18914 | 836 #ifdef HAVE_LIBCDIO |
837 else if(GetFileAttributes(searchpath3) != INVALID_FILE_ATTRIBUTES) | |
20245
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
838 flags |= MF_ENABLED; |
18914 | 839 #endif |
20245
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
840 else |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
841 flags |= MF_GRAYED; |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
842 volname[0] = 0; |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
843 strcpy(menuitem, device + pos); |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
844 menuitem[strlen(menuitem) - 1]=0; |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
845 GetVolumeInformation(device + pos, volname, MAX_PATH, NULL, NULL, NULL, NULL, 0); |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
846 if (strlen(volname)) |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
847 { |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
848 capitalize(volname); |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
849 strcat(menuitem, " - "); |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
850 strcat(menuitem, volname); |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
851 } |
dcb263f32986
Move "Play CD/DVD/VCD/SVCD" submenu generation to right-click handling
reimar
parents:
20237
diff
changeset
|
852 AppendMenu(gui->diskmenu, flags, IDPLAYDISK + cdromdrive, menuitem); |
18914 | 853 cdromdrive++; |
854 } | |
855 pos += strlen(device + pos) + 1; | |
856 } | |
20235
c7f580aa091d
Set SetErrorMode to make sure no dialog box will pop up when no disk in CD/DVD drive.
reimar
parents:
20211
diff
changeset
|
857 SetErrorMode(errmode); |
18914 | 858 TrackPopupMenu(gui->menu, 0, point.x, point.y, 0, hWnd, NULL); |
859 return 0; | |
860 } | |
861 case WM_MOUSEMOVE: | |
862 { | |
863 if(wParam & MK_LBUTTON) | |
864 { | |
865 POINT point; | |
866 RECT rect; | |
867 if(gui->activewidget) | |
868 { | |
869 widget *item = gui->activewidget; | |
870 | |
871 if(item->type == tyHpotmeter) | |
872 { | |
873 item->x = GET_X_LPARAM(lParam) - gui->mousewx; | |
874 item->value = (float)((float)((item->x - item->wx) * 100.0f) / (float)(item->wwidth - item->width)); | |
875 } | |
876 if(item->type == tyPotmeter) | |
877 { | |
878 gui->mousewx = GET_X_LPARAM(lParam) - gui->activewidget->x; | |
879 item->value = (float) (gui->mousewx * 100.0f) / (float) item->wwidth; | |
880 } | |
881 | |
882 if((item->type == tyPotmeter) || (item->type == tyHpotmeter) || (item->type == tyVpotmeter)) | |
883 { | |
884 /* Bound checks */ | |
885 if(item->value > 100.0f) | |
886 item->value = 100.0f; | |
887 else if(item->value < 0.0f) | |
888 item->value = 0.0f; | |
889 | |
890 if(item->msg == evSetVolume) | |
891 guiIntfStruct.Volume = (float) item->value; | |
892 else if(item->msg == evSetMoviePosition) | |
893 guiIntfStruct.Position = (float) item->value; | |
894 else if(item->msg == evSetBalance) | |
895 { | |
896 /* make the range for 50% a bit bigger, because the sliders for balance usually suck */ | |
897 if((item->value - 50.0f < 1.5f) && (item->value - 50.0f > -1.5f)) | |
898 item->value = 50.0f; | |
899 guiIntfStruct.Balance = (float) item->value; | |
900 } | |
901 updatedisplay(gui, hWnd); | |
902 handlemsg(hWnd, item->msg); | |
903 } | |
904 break; | |
905 } | |
906 point.x = GET_X_LPARAM(lParam); | |
907 point.y = GET_Y_LPARAM(lParam); | |
908 ClientToScreen(hWnd, &point); | |
909 GetWindowRect(hWnd, &rect); | |
910 MoveWindow(hWnd, point.x - gui->mousex, point.y - gui->mousey, | |
911 rect.right-rect.left,rect.bottom-rect.top,TRUE); | |
912 break; | |
913 } | |
914 break; | |
915 } | |
916 case WM_COMMAND: | |
917 { | |
918 switch(LOWORD(wParam)) | |
919 { | |
920 case IDEXIT: | |
921 PostQuitMessage(0); | |
922 handlemsg(hWnd, evExit); | |
923 break; | |
924 case IDFILE_OPEN: | |
925 handlemsg(hWnd, evLoadPlay); | |
926 break; | |
927 case IDDIR_OPEN: | |
928 { | |
929 static char path[MAX_PATH]; | |
930 BROWSEINFO bi; | |
19718 | 931 LPITEMIDLIST pidl; |
18914 | 932 memset(&bi, 0, sizeof(BROWSEINFO)); |
933 bi.lpszTitle = "Choose a Directory..."; | |
19718 | 934 pidl = SHBrowseForFolder(&bi); |
18914 | 935 if (SHGetPathFromIDList(pidl, path)) |
936 { | |
937 gui->playlist->clear_playlist(gui->playlist); | |
938 adddirtoplaylist(gui->playlist, path, TRUE); | |
939 gui->startplay(gui); | |
940 } | |
941 break; | |
942 } | |
943 case ID_SKINBROWSER: | |
944 handlemsg(hWnd, evSkinBrowser); | |
945 break; | |
946 case IDURL_OPEN: | |
947 display_openurlwindow(gui, 0); | |
948 break; | |
20211
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
949 case ID_MUTE: |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
950 mp_input_queue_cmd(mp_input_parse_cmd("mute")); |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
951 break; |
18914 | 952 case IDSUBTITLE_OPEN: |
953 display_opensubtitlewindow(gui); | |
954 break; | |
955 case ID_PTRACK: | |
956 handlemsg(hWnd, evPrev); | |
957 break; | |
958 case ID_SEEKB: | |
959 handlemsg(hWnd, evBackward10sec); | |
960 break; | |
961 case ID_PLAY: | |
962 handlemsg(hWnd, evPlaySwitchToPause); | |
963 break; | |
964 case ID_STOP: | |
965 handlemsg(hWnd, evStop); | |
966 break; | |
967 case ID_SEEKF: | |
968 handlemsg(hWnd, evForward10sec); | |
969 break; | |
970 case ID_NTRACK: | |
971 handlemsg(hWnd, evNext); | |
972 break; | |
973 case ID_SHOWHIDE: | |
974 { | |
975 if(IsWindowVisible(hWnd)) ShowWindow(hWnd, SW_HIDE); | |
976 else ShowWindow(hWnd, SW_SHOW); | |
977 break; | |
978 } | |
979 case ID_PLAYLIST: | |
980 handlemsg(hWnd, evPlayList); | |
981 break; | |
982 case ID_PREFS: | |
983 handlemsg(hWnd, evPreferences); | |
984 break; | |
985 case ID_CONSOLE: | |
986 console_toggle(); | |
987 break; | |
988 case ID_ONLINEHELP: | |
989 ShellExecute(NULL, "open", ONLINE_HELP_URL, NULL, NULL, SW_SHOWNORMAL); | |
990 break; | |
991 } | |
992 if((IDPLAYDISK <= LOWORD(wParam)) && (LOWORD(wParam) < (IDPLAYDISK + 100))) | |
993 { | |
994 char device[MAX_PATH]; | |
995 char searchpath[MAX_PATH]; | |
996 char filename[MAX_PATH]; | |
997 int len, pos = 0, cdromdrive = 0; | |
998 len = GetLogicalDriveStrings(MAX_PATH, device); | |
999 while(pos < len) | |
1000 { | |
1001 if(GetDriveType(device + pos)==DRIVE_CDROM) | |
1002 { | |
1003 if(LOWORD(wParam) - IDPLAYDISK == cdromdrive) | |
1004 { | |
1005 #ifdef USE_DVDREAD | |
1006 sprintf(searchpath, "%sVIDEO_TS", device + pos); | |
1007 if(GetFileAttributes(searchpath) != INVALID_FILE_ATTRIBUTES) | |
1008 { | |
1009 if (dvd_device) free(dvd_device); | |
1010 dvd_device = strdup(device + pos); | |
1011 dvd_title = dvd_chapter = dvd_angle = 1; | |
1012 handlemsg(hWnd, evPlayDVD); | |
1013 } | |
1014 #endif | |
1015 #ifdef HAVE_LIBCDIO | |
1016 sprintf(searchpath, "%sTrack01.cda", device + pos); | |
1017 if(GetFileAttributes(searchpath) != INVALID_FILE_ATTRIBUTES) | |
1018 { | |
1019 if (cdrom_device) free(cdrom_device); | |
1020 cdrom_device = strdup(device + pos); | |
1021 /* mplayer doesn't seem to like the trailing \ after the device name */ | |
1022 cdrom_device[2]=0; | |
1023 handlemsg(hWnd, evPlayCD); | |
1024 } | |
1025 #endif | |
1026 else | |
1027 { | |
1028 HANDLE searchhndl; | |
1029 WIN32_FIND_DATA finddata; | |
1030 sprintf(searchpath, "%smpegav\\*.dat", device + pos); | |
1031 if((searchhndl=FindFirstFile(searchpath, &finddata)) != INVALID_HANDLE_VALUE) | |
1032 { | |
1033 mp_msg(MSGT_GPLAYER,MSGL_V, "Opening VCD/SVCD\n"); | |
1034 gui->playlist->clear_playlist(gui->playlist); | |
1035 do | |
1036 { | |
1037 sprintf(filename, "%smpegav\\%s", device + pos, finddata.cFileName); | |
1038 gui->playlist->add_track(gui->playlist, filename, NULL, NULL, 0); | |
1039 } | |
1040 while(FindNextFile(searchhndl, &finddata)); | |
1041 FindClose(searchhndl); | |
1042 } | |
1043 gui->startplay(gui); | |
1044 } | |
1045 } | |
1046 cdromdrive++; | |
1047 } | |
1048 pos += strlen(device + pos) + 1; | |
1049 } | |
1050 } | |
1051 break; | |
1052 } | |
1053 case WM_PAINT: | |
1054 { | |
1055 PAINTSTRUCT ps; | |
1056 RECT rd; | |
1057 HDC hdc = BeginPaint(hWnd, &ps); | |
1058 HDC hMemDC = CreateCompatibleDC(hdc); | |
1059 int width, height; | |
1060 GetClientRect(hWnd, &rd); | |
1061 width = rd.right - rd.left; | |
1062 height = rd.bottom - rd.top; | |
1063 SelectObject(hMemDC, get_bitmap(hWnd)); | |
1064 BitBlt(hdc, 0, 0, width, height, hMemDC, 0, 0, SRCCOPY); | |
1065 DeleteDC(hMemDC); | |
1066 EndPaint(hWnd, &ps); | |
1067 return 0; | |
1068 } | |
1069 return 0; | |
1070 } | |
1071 return DefWindowProc(hWnd, message, wParam, lParam); | |
1072 } | |
1073 | |
1074 inline void startplay(gui_t *gui) | |
1075 { | |
1076 handlemsg(gui->mainwindow, evDropFile); | |
1077 } | |
1078 | |
1079 /* returns the bits per pixel of the desktop */ | |
1080 /* the format is always in BGR byte order */ | |
1081 static int GetDesktopBitsPerPixel(void) | |
1082 { | |
1083 HWND desktop=GetDesktopWindow(); | |
1084 HDC dc=GetDC(desktop); | |
1085 int bpp=GetDeviceCaps(dc, BITSPIXEL); | |
1086 ReleaseDC(desktop, dc); | |
1087 return bpp; | |
1088 } | |
1089 | |
1090 /* unloads a skin and destroys its windows */ | |
1091 extern int destroy_window(gui_t *gui) | |
1092 { | |
1093 RECT rd; | |
1094 unsigned int i; | |
1095 | |
1096 /* Save position: MSDN says don't pass workspace coordinates | |
1097 * to CreateWindow() or SetWindowPos(), as both of which expect | |
1098 * screen coordinates; resulting in the window appearing in the | |
1099 * wrong location. | |
1100 * -Erik | |
1101 */ | |
1102 | |
1103 /* main window position */ | |
1104 if(IsIconic(gui->mainwindow)) | |
1105 ShowWindow(gui->mainwindow, SW_SHOWNORMAL); | |
1106 GetWindowRect(gui->mainwindow, &rd); | |
1107 gui_main_pos_x = rd.left; | |
1108 gui_main_pos_y = rd.top; | |
1109 | |
1110 /* sub window position */ | |
1111 if(IsIconic(gui->subwindow)) | |
1112 ShowWindow(gui->subwindow, SW_SHOWNORMAL); | |
1113 GetWindowRect(gui->subwindow, &rd); | |
1114 gui_sub_pos_x = rd.left; | |
1115 gui_sub_pos_y = rd.top; | |
1116 | |
1117 for(i=0; i<gui->window_priv_count; i++) | |
1118 { | |
1119 if(gui->window_priv[i]->bitmap) | |
1120 DeleteObject(gui->window_priv[i]->bitmap); | |
1121 free(gui->window_priv[i]); | |
1122 } | |
1123 free(gui->window_priv); | |
1124 gui->window_priv = NULL; | |
1125 gui->window_priv_count = 0; | |
1126 | |
1127 /* destroy the main window */ | |
1128 if(gui->mainwindow) | |
1129 DestroyWindow(gui->mainwindow); | |
1130 gui->mainwindow = NULL; | |
1131 | |
1132 /* destroy the sub window */ | |
1133 if(gui->subwindow) | |
1134 DestroyWindow(gui->subwindow); | |
1135 gui->subwindow = NULL; | |
1136 | |
1137 UnregisterClass(gui->classname, 0); | |
1138 DestroyIcon(gui->icon); | |
1139 | |
1140 gui->skin->freeskin(gui->skin); | |
1141 gui->skin = NULL; | |
1142 return 0; | |
1143 } | |
1144 | |
1145 static void create_menu(gui_t *gui) | |
1146 { | |
1147 gui->diskmenu = CreatePopupMenu(); | |
1148 gui->menu=CreatePopupMenu(); | |
1149 gui->trayplaymenu = CreatePopupMenu(); | |
1150 AppendMenu(gui->menu, MF_STRING | MF_POPUP, (UINT) gui->trayplaymenu, "Open..."); | |
1151 AppendMenu(gui->trayplaymenu, MF_STRING, IDFILE_OPEN, "File..."); | |
1152 AppendMenu(gui->trayplaymenu, MF_STRING, IDURL_OPEN, "Url..."); | |
1153 AppendMenu(gui->trayplaymenu, MF_STRING, IDDIR_OPEN, "Directory..."); | |
1154 AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); | |
1155 AppendMenu(gui->menu, MF_STRING | MF_POPUP, (UINT) gui->diskmenu, "Play &CD/DVD/VCD/SVCD"); | |
1156 AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); | |
1157 AppendMenu(gui->menu, MF_STRING, IDSUBTITLE_OPEN, "Open Subtitle"); | |
1158 AppendMenu(gui->menu, MF_STRING, ID_SKINBROWSER, "Skin Browser"); | |
1159 AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); | |
1160 AppendMenu(gui->menu, MF_STRING, ID_PREFS, "Preferences"); | |
1161 AppendMenu(gui->menu, MF_STRING, ID_CONSOLE, "Debug Console"); | |
1162 AppendMenu(gui->menu, MF_STRING, ID_ONLINEHELP, "Online Help"); | |
1163 AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); | |
1164 AppendMenu(gui->menu, MF_STRING, IDEXIT, "&Exit"); | |
1165 } | |
1166 | |
1167 static void create_traymenu(gui_t *gui) | |
1168 { | |
1169 gui->traymenu = CreatePopupMenu(); | |
1170 gui->trayplaybackmenu = CreatePopupMenu(); | |
1171 AppendMenu(gui->traymenu, MF_STRING | MF_POPUP, (UINT) gui->trayplaymenu, "Open..."); | |
1172 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); | |
1173 AppendMenu(gui->traymenu, MF_STRING | MF_POPUP, (UINT) gui->trayplaybackmenu, "Playback"); | |
1174 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_SEEKB, "Seek Backwards"); | |
1175 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_PTRACK, "Previous Track"); | |
1176 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_PLAY, "Play/Pause"); | |
1177 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_STOP, "Stop"); | |
1178 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_NTRACK, "Next Track"); | |
1179 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_SEEKF, "Seek Forwards"); | |
1180 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); | |
20211
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
1181 AppendMenu(gui->traymenu, MF_STRING, ID_MUTE, "Toggle Mute"); |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
1182 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); |
18914 | 1183 AppendMenu(gui->traymenu, MF_STRING, IDSUBTITLE_OPEN, "Open Subtitle"); |
1184 AppendMenu(gui->traymenu, MF_STRING, ID_PLAYLIST, "Playlist"); | |
1185 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); | |
1186 AppendMenu(gui->traymenu, MF_STRING, ID_SHOWHIDE, "Show/Hide"); | |
1187 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); | |
1188 AppendMenu(gui->traymenu, MF_STRING, ID_PREFS, "Preferences"); | |
1189 AppendMenu(gui->traymenu, MF_STRING, ID_CONSOLE, "Debug Console"); | |
1190 AppendMenu(gui->traymenu, MF_STRING, ID_ONLINEHELP, "Online Help"); | |
1191 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); | |
1192 AppendMenu(gui->traymenu, MF_STRING, IDEXIT, "&Exit"); | |
1193 } | |
1194 | |
1195 static void create_submenu(gui_t *gui) | |
1196 { | |
1197 gui->submenu = CreatePopupMenu(); | |
1198 gui->dvdmenu = CreatePopupMenu(); | |
1199 gui->aspectmenu = CreatePopupMenu(); | |
1200 gui->subtitlemenu = CreatePopupMenu(); | |
1201 AppendMenu(gui->submenu, MF_STRING | MF_POPUP, (UINT) gui->trayplaymenu, "Open..."); | |
1202 AppendMenu(gui->submenu, MF_SEPARATOR, 0, 0); | |
1203 AppendMenu(gui->submenu, MF_STRING, ID_SEEKB, "Seek Backwards"); | |
1204 AppendMenu(gui->submenu, MF_STRING, ID_PTRACK, "Previous Track"); | |
1205 AppendMenu(gui->submenu, MF_STRING, ID_PLAY, "Play/Pause"); | |
1206 AppendMenu(gui->submenu, MF_STRING, ID_STOP, "Stop"); | |
1207 AppendMenu(gui->submenu, MF_STRING, ID_NTRACK, "Next Track"); | |
1208 AppendMenu(gui->submenu, MF_STRING, ID_SEEKF, "Seek Forwards"); | |
1209 AppendMenu(gui->submenu, MF_SEPARATOR, 0, 0); | |
20211
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
1210 AppendMenu(gui->submenu, MF_STRING, ID_FULLSCREEN, "Toggle Fullscreen"); |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
1211 AppendMenu(gui->submenu, MF_STRING, ID_MUTE, "Toggle Mute"); |
26867dede11c
as per request, fullscreen and mute options have been added to the context menus.
vayne
parents:
20132
diff
changeset
|
1212 AppendMenu(gui->submenu, MF_SEPARATOR, 0, 0); |
18914 | 1213 AppendMenu(gui->submenu, MF_STRING | MF_POPUP, (UINT) gui->aspectmenu, "Aspect Ratio"); |
1214 AppendMenu(gui->submenu, MF_STRING | MF_POPUP, (UINT) gui->subtitlemenu, "Subtitle Options"); | |
1215 AppendMenu(gui->submenu, MF_STRING | MF_POPUP, (UINT) gui->dvdmenu, "DVD Options"); | |
1216 #ifdef USE_DVDREAD | |
1217 AppendMenu(gui->dvdmenu, MF_STRING | MF_GRAYED, ID_CHAPTERSEL, "Select Title/Chapter..."); | |
1218 #endif | |
1219 AppendMenu(gui->subtitlemenu, MF_STRING, IDSUB_TOGGLE, "Subtitle Visibility On/Off"); | |
1220 AppendMenu(gui->subtitlemenu, MF_STRING, IDSUB_CYCLE, "Cycle Subtitle Languages"); | |
1221 AppendMenu(gui->aspectmenu, MF_STRING, ID_ASPECT1, "Set 16:9"); | |
1222 AppendMenu(gui->aspectmenu, MF_STRING, ID_ASPECT2, "Set 4:3"); | |
1223 AppendMenu(gui->aspectmenu, MF_STRING, ID_ASPECT3, "Set 2.35"); | |
1224 AppendMenu(gui->aspectmenu, MF_SEPARATOR, 0, 0); | |
1225 AppendMenu(gui->aspectmenu, MF_STRING, ID_ASPECT4, "Original Aspect"); | |
1226 AppendMenu(gui->submenu, MF_SEPARATOR, 0, 0); | |
1227 AppendMenu(gui->submenu, MF_STRING, IDEXIT, "&Exit"); | |
1228 } | |
1229 | |
1230 static void maketransparent(HWND hwnd, COLORREF crTransparent) | |
1231 { | |
1232 HDC mdc = GetDC(hwnd); | |
1233 RECT rd; | |
1234 HRGN crRgnres, crRgn, crRgnTmp; | |
1235 int iX = 0, iY = 0, iLeftX = 0; | |
1236 int width, height; | |
1237 GetWindowRect(hwnd, &rd); | |
1238 width = rd.right - rd.left; | |
1239 height = rd.bottom - rd.top; | |
1240 | |
1241 /* create an empty region */ | |
1242 crRgn = CreateRectRgn(0, 0, 0, 0); | |
1243 | |
1244 /* Create a region from a bitmap with transparency colour of Purple */ | |
1245 for (iY = -1; iY < height; iY++) | |
1246 { | |
1247 do | |
1248 { | |
1249 /* skip over transparent pixels at start of lines */ | |
1250 while (iX <= width && GetPixel(mdc,iX, iY) == crTransparent) iX++; | |
1251 | |
1252 /* remember this pixel */ | |
1253 iLeftX = iX; | |
1254 | |
1255 /* now find first non transparent pixel */ | |
1256 while (iX <= width && GetPixel(mdc,iX, iY) != crTransparent) ++iX; | |
1257 | |
1258 /* create a temp region on this info */ | |
1259 crRgnTmp = CreateRectRgn(iLeftX, iY, iX, iY+1); | |
1260 | |
1261 /* combine into main region */ | |
1262 crRgnres = crRgn; | |
1263 CombineRgn(crRgnres, crRgn, crRgnTmp, RGN_OR); | |
1264 crRgn = crRgnres; | |
1265 | |
1266 /* delete the temp region for next pass (otherwise you'll get an ASSERT) */ | |
1267 DeleteObject(crRgnTmp); | |
1268 } while (iX < width); | |
1269 iX = 0; | |
1270 } | |
1271 SetWindowRgn(hwnd, crRgn, TRUE); | |
1272 DeleteObject(crRgn); | |
1273 ReleaseDC(hwnd,mdc); | |
1274 } | |
1275 | |
1276 static int window_render(gui_t *gui, HWND hWnd, HDC hdc, window_priv_t *priv, window *desc, BITMAPINFO binfo) | |
1277 { | |
1278 int i; | |
1279 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui); | |
1280 (gui->window_priv_count)++; | |
1281 gui->window_priv = realloc(gui->window_priv, sizeof(window_priv_t *) * gui->window_priv_count); | |
1282 priv = gui->window_priv[gui->window_priv_count - 1] = calloc(1, sizeof(window_priv_t)); | |
1283 priv->hwnd = hWnd; | |
1284 priv->type = desc->type; | |
1285 priv->background = desc->base->bitmap[0]; | |
1286 memcpy(&priv->img, desc->base->bitmap[0], sizeof(image)); | |
1287 hdc = GetDC(hWnd); | |
1288 binfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
1289 binfo.bmiHeader.biWidth = priv->img.width; | |
1290 binfo.bmiHeader.biHeight = -priv->img.height; | |
1291 binfo.bmiHeader.biPlanes = 1; | |
1292 binfo.bmiHeader.biSizeImage = priv->img.width * priv->img.height * (gui->screenbpp / 8); | |
1293 binfo.bmiHeader.biXPelsPerMeter = 0; | |
1294 binfo.bmiHeader.biYPelsPerMeter = 0; | |
1295 binfo.bmiHeader.biClrUsed = 0; | |
1296 binfo.bmiHeader.biClrImportant = 0; | |
1297 binfo.bmiHeader.biBitCount = gui->screenbpp; | |
1298 binfo.bmiHeader.biCompression = BI_RGB; | |
1299 priv->bitmap = CreateDIBSection(hdc, &binfo, DIB_RGB_COLORS, (void **) &priv->img.data, NULL, 0); | |
1300 if(!priv->bitmap) | |
1301 { | |
1302 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "[GUI] unable to create bitmap for skinned window\n"); | |
1303 return 0; | |
1304 } | |
1305 memcpy(priv->img.data, desc->base->bitmap[0]->data, binfo.bmiHeader.biSizeImage); | |
1306 ReleaseDC(hWnd,hdc); | |
1307 | |
1308 for (i=0; i<gui->skin->widgetcount; i++) | |
1309 if(gui->skin->widgets[i]->window == desc->type) | |
1310 renderwidget(gui->skin, &priv->img, gui->skin->widgets[i], 1); | |
1311 | |
1312 return 0; | |
1313 } | |
1314 | |
1315 /* creates the sub (AKA video) window,*/ | |
1316 extern int create_subwindow(gui_t *gui, char *skindir) | |
1317 { | |
1318 HINSTANCE instance = GetModuleHandle(NULL); | |
1319 WNDCLASS wc; | |
1320 RECT rect; | |
1321 HWND hWnd; | |
1322 DWORD style = 0; | |
1323 HDC hdc = NULL; | |
1324 BITMAPINFO binfo; | |
1325 window_priv_t *priv = NULL; | |
1326 window *desc = NULL; | |
1327 int i, x = -1, y = -1; | |
19570
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
1328 vo_colorkey = 0xff00ff; |
18914 | 1329 |
1330 for (i=0; i<gui->skin->windowcount; i++) | |
1331 if(gui->skin->windows[i]->type == wiSub) | |
1332 desc = gui->skin->windows[i]; | |
1333 | |
1334 if(!desc) | |
1335 { | |
1336 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "[GUI] Invalid skin description\n"); | |
1337 return 1; | |
1338 } | |
1339 | |
19570
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
1340 windowcolor = vo_colorkey; |
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
1341 colorbrush = CreateSolidBrush(windowcolor); |
18914 | 1342 wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; |
1343 wc.lpfnWndProc = SubProc; | |
1344 wc.cbClsExtra = 0; | |
1345 wc.cbWndExtra = 0; | |
1346 wc.hInstance = instance; | |
1347 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | |
1348 wc.hIcon = gui->icon; | |
19570
e9ea7852e803
vo_colorkey change to avoid clashes with other black windows
vayne
parents:
19535
diff
changeset
|
1349 wc.hbrBackground = NULL; //WM_PAINT will handle background color switching; |
18914 | 1350 wc.lpszClassName = "MPlayer Sub for Windows"; |
1351 wc.lpszMenuName = NULL; | |
1352 RegisterClass(&wc); | |
1353 | |
1354 /* create the sub window menu */ | |
1355 create_submenu(gui); | |
1356 | |
1357 rect.top = rect.left = 100; | |
1358 rect.bottom = rect.top+desc->base->bitmap[0]->height; | |
1359 rect.right = rect.left+desc->base->bitmap[0]->width; | |
1360 | |
1361 /* our window aspect */ | |
1362 sub_aspect = (float)(rect.right-rect.left)/(rect.bottom-rect.top); | |
1363 | |
19571
a894b3a3d28c
bug fix for starting gmplayer with -fs when using the sub window
vayne
parents:
19570
diff
changeset
|
1364 style = fullscreen?WS_VISIBLE | WS_POPUP:WS_OVERLAPPEDWINDOW | WS_SYSMENU | WS_MINIMIZEBOX; |
18914 | 1365 AdjustWindowRect(&rect, style, 0); |
1366 | |
1367 if (gui_sub_pos_x >= 0) | |
1368 x = gui_sub_pos_x; | |
1369 if (gui_sub_pos_y >= 0) | |
1370 y = gui_sub_pos_y; | |
1371 | |
1372 /* out of bounds check */ | |
1373 if (x <= -1 || (x+(rect.right-rect.left) > GetSystemMetrics(SM_CXSCREEN))) | |
1374 x = CW_USEDEFAULT; | |
1375 if (y <= -1 || (y+(rect.bottom-rect.top) > GetSystemMetrics(SM_CYSCREEN))) | |
1376 y = x; | |
1377 | |
1378 hWnd = CreateWindowEx(0, "MPlayer Sub for Windows", "MPlayer for Windows", style, | |
1379 x, y, rect.right-rect.left, rect.bottom-rect.top, | |
1380 gui->subwindow, NULL, instance, NULL); | |
1381 | |
1382 /* load all the window images */ | |
1383 window_render(gui, hWnd, hdc, priv, desc, binfo); | |
1384 | |
1385 /* enable drag and drop support */ | |
1386 DragAcceptFiles(hWnd, TRUE); | |
1387 | |
1388 gui->subwindow = hWnd; | |
1389 if(sub_window) | |
1390 WinID = gui->subwindow; | |
1391 ShowWindow(gui->subwindow, SW_SHOW); | |
1392 UpdateWindow(gui->subwindow); | |
1393 return 0; | |
1394 } | |
1395 | |
1396 /* loads/updates a skin and creates windows for it */ | |
1397 extern int create_window(gui_t *gui, char *skindir) | |
1398 { | |
1399 HINSTANCE instance = GetModuleHandle(NULL); | |
1400 WNDCLASS wc; | |
1401 RECT rect; | |
1402 DWORD style = 0; | |
1403 HWND hwnd; | |
1404 HDC hdc = NULL; | |
1405 BITMAPINFO binfo; | |
1406 window_priv_t *priv = NULL; | |
1407 window *desc = NULL; | |
1408 char dir[MAX_PATH]; | |
1409 unsigned int i; | |
19718 | 1410 int x = -1, y = -1; |
18914 | 1411 |
1412 /* destroy the current main window */ | |
1413 if(gui->skin) destroy_window(gui); | |
1414 | |
1415 /* get screenproperties */ | |
1416 gui->screenbpp = GetDesktopBitsPerPixel(); | |
1417 gui->screenw = GetSystemMetrics(SM_CXSCREEN); | |
1418 gui->screenh = GetSystemMetrics(SM_CYSCREEN); | |
1419 | |
1420 /* load the new skin */ | |
1421 gui->skin = loadskin(skindir, gui->screenbpp); | |
1422 if(!gui->skin) | |
1423 { | |
1424 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "[GUI] fatal error during skinload\n"); | |
1425 /* Set default Skin */ | |
1426 if (skinName) free(skinName); | |
1427 skinName = strdup("Blue"); | |
1428 /* then force write conf */ | |
1429 cfg_write(); | |
1430 return 1; | |
1431 } | |
1432 | |
1433 /* find the description of the mainwindow */ | |
1434 for (i=0; i<gui->skin->windowcount; i++) | |
1435 if(gui->skin->windows[i]->type == wiMain) | |
1436 desc = gui->skin->windows[i]; | |
1437 | |
1438 if(!desc) | |
1439 { | |
1440 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "[GUI] Invalid skin description\n"); | |
1441 return 1; | |
1442 } | |
1443 | |
1444 /* load the icon from the executable */ | |
1445 GetModuleFileName(NULL, dir, MAX_PATH); | |
1446 gui->icon = ExtractIcon(instance, dir, 0); | |
1447 | |
1448 /* create the window class */ | |
1449 wc.style = CS_HREDRAW | CS_VREDRAW; | |
1450 wc.lpfnWndProc = EventProc; | |
1451 wc.cbClsExtra = 0; | |
1452 wc.cbWndExtra = 0; | |
1453 wc.hInstance = instance; | |
1454 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | |
1455 wc.hIcon = gui->icon; | |
1456 wc.hbrBackground = CreateSolidBrush(RGB(0, 0, 0)); | |
1457 wc.lpszClassName = gui->classname = "MPlayer GUI for Windows"; | |
1458 wc.lpszMenuName = NULL; | |
1459 RegisterClass(&wc); | |
1460 | |
1461 /* create a context menu */ | |
1462 create_menu(gui); | |
1463 /* create the systray menu */ | |
1464 create_traymenu(gui); | |
1465 | |
1466 /* create the mainwindow */ | |
1467 /* TODO implement aligning as described in skin.html */ | |
1468 rect.top = rect.left = 100; | |
1469 rect.bottom = rect.top+desc->base->bitmap[0]->height; | |
1470 rect.right = rect.left+desc->base->bitmap[0]->width; | |
1471 if(desc->decoration) style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; | |
1472 else style = WS_POPUP | WS_SYSMENU; | |
1473 | |
1474 AdjustWindowRect(&rect, style, 0); | |
1475 | |
1476 /* Check if out of screen */ | |
1477 if (gui_main_pos_x >= 0) | |
1478 x = gui_main_pos_x; | |
1479 if (gui_main_pos_y >= 0) | |
1480 y = gui_main_pos_y; | |
1481 | |
1482 if (x <= -1 || (x+(rect.right-rect.left) > GetSystemMetrics(SM_CXFULLSCREEN))) | |
1483 { | |
1484 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - ((rect.right-rect.left) / 2); | |
1485 gui_main_pos_x = x; | |
1486 } | |
1487 if (y <= -1 || (y+(rect.bottom-rect.top) > GetSystemMetrics(SM_CYFULLSCREEN))) | |
1488 { | |
1489 y = ((GetSystemMetrics(SM_CYSCREEN)-40) - (rect.bottom-rect.top)); | |
1490 gui_main_pos_y = y; | |
1491 } | |
1492 | |
1493 hwnd = CreateWindowEx(0, gui->classname, "MPlayer for Windows", style, | |
1494 x, y, rect.right-rect.left, rect.bottom-rect.top, | |
1495 gui->mainwindow, NULL, instance, NULL); | |
1496 | |
1497 /* set the systray icon properties */ | |
1498 nid.cbSize = sizeof(NOTIFYICONDATA); | |
1499 nid.hWnd = hwnd; | |
1500 nid.uID = 1; | |
1501 nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; | |
1502 nid.uCallbackMessage = WM_SYSTRAY; | |
1503 nid.hIcon = gui->icon; | |
1504 strcpy(nid.szTip, "MPlayer for Windows"); | |
1505 | |
1506 /* register the systray icon */ | |
1507 Shell_NotifyIcon(NIM_ADD, &nid); | |
1508 | |
1509 /* load all the window images */ | |
1510 window_render(gui, hwnd, hdc, priv, desc, binfo); | |
1511 | |
1512 /* enable drag and drop support */ | |
1513 DragAcceptFiles(hwnd, TRUE); | |
1514 | |
1515 updatedisplay(gui, hwnd); | |
1516 gui->mainwindow = hwnd; | |
1517 | |
1518 /* display */ | |
1519 ShowWindow(gui->mainwindow, SW_SHOW); | |
1520 UpdateWindow(gui->mainwindow); | |
1521 maketransparent(gui->mainwindow, RGB(255, 0, 255)); | |
1522 return 0; | |
1523 } | |
1524 | |
1525 gui_t *create_gui(char *skindir, char *skinName, void (*playercontrol)(int event)) | |
1526 { | |
1527 gui_t *gui = calloc(1, sizeof(gui_t)); | |
19718 | 1528 char temp[MAX_PATH]; |
1529 HWND runningmplayer = FindWindow("MPlayer GUI for Windows", "MPlayer for Windows"); | |
18914 | 1530 |
1531 if(runningmplayer) | |
1532 { | |
1533 free(gui); | |
1534 return NULL; | |
1535 } | |
1536 | |
1537 gui->startplay = startplay; | |
1538 gui->playercontrol = playercontrol; | |
1539 gui->uninit = uninit; | |
1540 gui->updatedisplay = updatedisplay; | |
1541 | |
1542 /* create playlist */ | |
1543 gui->playlist = create_playlist(); | |
1544 | |
1545 if(!skinName) skinName = strdup("Blue"); | |
1546 sprintf(temp, "%s\\%s", skindir, skinName); | |
1547 if(create_window(gui, temp)) return NULL; | |
1548 if(create_subwindow(gui, temp)) return NULL; | |
1549 if(console) console_toggle(); | |
1550 return gui; | |
1551 } |