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