comparison libvo/w32_common.c @ 16213:917079aa9fee

Cleanup, move declarations to beginning of block.
author reimar
date Sun, 14 Aug 2005 10:30:18 +0000
parents 519a307e3ccf
children 94bb243636e1
comparison
equal deleted inserted replaced
16212:8ee9633a5e0d 16213:917079aa9fee
30 case WM_SYSCOMMAND: 30 case WM_SYSCOMMAND:
31 switch (wParam) { 31 switch (wParam) {
32 case SC_SCREENSAVE: 32 case SC_SCREENSAVE:
33 case SC_MONITORPOWER: 33 case SC_MONITORPOWER:
34 mp_msg(MSGT_VO, MSGL_V, "vo: win32: killing screensaver\n"); 34 mp_msg(MSGT_VO, MSGL_V, "vo: win32: killing screensaver\n");
35 break; 35 return 0;
36 default:
37 return DefWindowProc(hWnd, message, wParam, lParam);
38 } 36 }
39 break; 37 break;
40 case WM_KEYDOWN: 38 case WM_KEYDOWN:
41 switch (wParam) { 39 switch (wParam) {
42 case VK_LEFT: mplayer_put_key(KEY_LEFT); break; 40 case VK_LEFT: mplayer_put_key(KEY_LEFT); break;
135 if (vo_vm) { 133 if (vo_vm) {
136 int bestMode = -1; 134 int bestMode = -1;
137 int bestScore = INT_MAX; 135 int bestScore = INT_MAX;
138 int i; 136 int i;
139 for (i = 0; EnumDisplaySettings(0, i, &dm); ++i) { 137 for (i = 0; EnumDisplaySettings(0, i, &dm); ++i) {
138 int score = (dm.dmPelsWidth - o_dwidth) * (dm.dmPelsHeight - o_dheight);
140 if (dm.dmBitsPerPel != vo_depthonscreen) continue; 139 if (dm.dmBitsPerPel != vo_depthonscreen) continue;
141 if (dm.dmPelsWidth < o_dwidth) continue; 140 if (dm.dmPelsWidth < o_dwidth) continue;
142 if (dm.dmPelsHeight < o_dheight) continue; 141 if (dm.dmPelsHeight < o_dheight) continue;
143 int score = (dm.dmPelsWidth - o_dwidth) * (dm.dmPelsHeight - o_dheight);
144 142
145 if (score < bestScore) { 143 if (score < bestScore) {
146 bestScore = score; 144 bestScore = score;
147 bestMode = i; 145 bestMode = i;
148 } 146 }
160 ChangeDisplaySettings(0, 0); 158 ChangeDisplaySettings(0, 0);
161 } 159 }
162 160
163 int createRenderingContext(void) { 161 int createRenderingContext(void) {
164 HWND layer = HWND_NOTOPMOST; 162 HWND layer = HWND_NOTOPMOST;
163 PIXELFORMATDESCRIPTOR pfd;
164 int pf;
165 165
166 if (vo_fs || vo_ontop) layer = HWND_TOPMOST; 166 if (vo_fs || vo_ontop) layer = HWND_TOPMOST;
167 if (vo_fs) { 167 if (vo_fs) {
168 changeMode(); 168 changeMode();
169 if (cursor) { 169 if (cursor) {
180 updateScreenProperties(); 180 updateScreenProperties();
181 vo_dwidth = vo_fs ? vo_screenwidth : o_dwidth; 181 vo_dwidth = vo_fs ? vo_screenwidth : o_dwidth;
182 vo_dheight = vo_fs ? vo_screenheight : o_dheight; 182 vo_dheight = vo_fs ? vo_screenheight : o_dheight;
183 SetWindowPos(vo_window, layer, vo_fs ? 0 : vo_dx, vo_fs ? 0 : vo_dy, vo_dwidth, vo_dheight, SWP_SHOWWINDOW); 183 SetWindowPos(vo_window, layer, vo_fs ? 0 : vo_dx, vo_fs ? 0 : vo_dy, vo_dwidth, vo_dheight, SWP_SHOWWINDOW);
184 184
185 PIXELFORMATDESCRIPTOR pfd;
186 memset(&pfd, 0, sizeof pfd); 185 memset(&pfd, 0, sizeof pfd);
187 pfd.nSize = sizeof pfd; 186 pfd.nSize = sizeof pfd;
188 pfd.nVersion = 1; 187 pfd.nVersion = 1;
189 pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; 188 pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
190 pfd.iPixelType = PFD_TYPE_RGBA; 189 pfd.iPixelType = PFD_TYPE_RGBA;
191 pfd.cColorBits = 24; 190 pfd.cColorBits = 24;
192 pfd.iLayerType = PFD_MAIN_PLANE; 191 pfd.iLayerType = PFD_MAIN_PLANE;
193 int pf = ChoosePixelFormat(vo_hdc, &pfd); 192 pf = ChoosePixelFormat(vo_hdc, &pfd);
194 if (!pf) { 193 if (!pf) {
195 mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to select a valid pixel format!\n"); 194 mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to select a valid pixel format!\n");
196 return 0; 195 return 0;
197 } 196 }
198 197
204 } 203 }
205 204
206 int vo_init(void) { 205 int vo_init(void) {
207 HICON mplayerIcon = 0; 206 HICON mplayerIcon = 0;
208 char exedir[MAX_PATH]; 207 char exedir[MAX_PATH];
208 WNDCLASSEX wcex;
209 209
210 if (vo_window) 210 if (vo_window)
211 return 1; 211 return 1;
212 212
213 hInstance = GetModuleHandle(0); 213 hInstance = GetModuleHandle(0);
215 if (GetModuleFileName(0, exedir, MAX_PATH)) 215 if (GetModuleFileName(0, exedir, MAX_PATH))
216 mplayerIcon = ExtractIcon(hInstance, exedir, 0); 216 mplayerIcon = ExtractIcon(hInstance, exedir, 0);
217 if (!mplayerIcon) 217 if (!mplayerIcon)
218 mplayerIcon = LoadIcon(0, IDI_APPLICATION); 218 mplayerIcon = LoadIcon(0, IDI_APPLICATION);
219 219
220 WNDCLASSEX wcex = { sizeof wcex, CS_OWNDC, WndProc, 0, 0, hInstance, mplayerIcon, LoadCursor(0, IDC_ARROW), (HBRUSH)GetStockObject(BLACK_BRUSH), 0, classname, mplayerIcon }; 220 wcex = { sizeof wcex, CS_OWNDC, WndProc, 0, 0, hInstance, mplayerIcon, LoadCursor(0, IDC_ARROW), (HBRUSH)GetStockObject(BLACK_BRUSH), 0, classname, mplayerIcon };
221 221
222 if (!RegisterClassEx(&wcex)) { 222 if (!RegisterClassEx(&wcex)) {
223 mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to register window class!\n"); 223 mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to register window class!\n");
224 return 0; 224 return 0;
225 } 225 }