Mercurial > mplayer.hg
annotate libvo/w32_common.c @ 22315:0a0191bc366d
10l, avoid crash on invalid subtitle id
author | reimar |
---|---|
date | Sat, 24 Feb 2007 10:19:41 +0000 |
parents | 2d3fdf94a50c |
children | c36b8d705d08 |
rev | line source |
---|---|
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
1 #include <limits.h> |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
2 #include <windows.h> |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
3 |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12936
diff
changeset
|
4 #include "osdep/keycodes.h" |
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12936
diff
changeset
|
5 #include "input/input.h" |
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12936
diff
changeset
|
6 #include "input/mouse.h" |
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12936
diff
changeset
|
7 #include "mp_msg.h" |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
8 #include "video_out.h" |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
9 #include "aspect.h" |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
10 #include "w32_common.h" |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
11 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
12 extern void mplayer_put_key(int code); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
13 |
18081
192e778f1ba1
define MONITOR_DEFAULTTOPRIMARY if necessary, some mingw version seem to miss it
reimar
parents:
18079
diff
changeset
|
14 #ifndef MONITOR_DEFAULTTOPRIMARY |
192e778f1ba1
define MONITOR_DEFAULTTOPRIMARY if necessary, some mingw version seem to miss it
reimar
parents:
18079
diff
changeset
|
15 #define MONITOR_DEFAULTTOPRIMARY 1 |
192e778f1ba1
define MONITOR_DEFAULTTOPRIMARY if necessary, some mingw version seem to miss it
reimar
parents:
18079
diff
changeset
|
16 #endif |
192e778f1ba1
define MONITOR_DEFAULTTOPRIMARY if necessary, some mingw version seem to miss it
reimar
parents:
18079
diff
changeset
|
17 |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
18 static const char* classname = "MPlayer - Media player for Win32"; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
19 int vo_vm = 0; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
20 HDC vo_hdc = 0; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
21 |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
22 // last non-fullscreen extends |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
23 int prev_width; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
24 int prev_height; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
25 int prev_x; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
26 int prev_y; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
27 |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
28 uint32_t o_dwidth; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
29 uint32_t o_dheight; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
30 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
31 static HINSTANCE hInstance; |
21631 | 32 #define vo_window vo_w32_window |
14142
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
13787
diff
changeset
|
33 HWND vo_window = 0; |
17115 | 34 static int event_flags; |
18116 | 35 static int mon_cnt; |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
36 |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
37 static HMONITOR (WINAPI* myMonitorFromWindow)(HWND, DWORD); |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
38 static BOOL (WINAPI* myGetMonitorInfo)(HMONITOR, LPMONITORINFO); |
18116 | 39 static BOOL (WINAPI* myEnumDisplayMonitors)(HDC, LPCRECT, MONITORENUMPROC, LPARAM); |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
40 |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
41 static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
42 RECT r; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
43 POINT p; |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
44 switch (message) { |
17126 | 45 case WM_PAINT: |
17115 | 46 event_flags |= VO_EVENT_EXPOSE; |
47 break; | |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
48 case WM_MOVE: |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
49 p.x = 0; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
50 p.y = 0; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
51 ClientToScreen(vo_window, &p); |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
52 vo_dx = p.x; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
53 vo_dy = p.y; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
54 break; |
17115 | 55 case WM_SIZE: |
56 event_flags |= VO_EVENT_RESIZE; | |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
57 GetClientRect(vo_window, &r); |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
58 vo_dwidth = r.right; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
59 vo_dheight = r.bottom; |
17115 | 60 break; |
18927
278eaf3ed5d8
Convince windows to allow window sizes > screen size
reimar
parents:
18116
diff
changeset
|
61 case WM_WINDOWPOSCHANGING: |
278eaf3ed5d8
Convince windows to allow window sizes > screen size
reimar
parents:
18116
diff
changeset
|
62 return 0; |
12004
494a93a19242
replace WM_DESTROY with WM_CLOSE to make it possible to play multiple files, patch by Reimar Doeffinger
faust3
parents:
11542
diff
changeset
|
63 case WM_CLOSE: |
16892
3470c810527b
libvo input cleanup: remove the dependency on libinput,
albeu
parents:
16288
diff
changeset
|
64 mplayer_put_key(KEY_CLOSE_WIN); |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
65 break; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
66 case WM_SYSCOMMAND: |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
67 switch (wParam) { |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
68 case SC_SCREENSAVE: |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
69 case SC_MONITORPOWER: |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
70 mp_msg(MSGT_VO, MSGL_V, "vo: win32: killing screensaver\n"); |
16213 | 71 return 0; |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
72 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
73 break; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
74 case WM_KEYDOWN: |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
75 switch (wParam) { |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
76 case VK_LEFT: mplayer_put_key(KEY_LEFT); break; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
77 case VK_UP: mplayer_put_key(KEY_UP); break; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
78 case VK_RIGHT: mplayer_put_key(KEY_RIGHT); break; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
79 case VK_DOWN: mplayer_put_key(KEY_DOWN); break; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
80 case VK_TAB: mplayer_put_key(KEY_TAB); break; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
81 case VK_CONTROL: mplayer_put_key(KEY_CTRL); break; |
20597 | 82 case VK_BACK: mplayer_put_key(KEY_BS); break; |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
83 case VK_DELETE: mplayer_put_key(KEY_DELETE); break; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
84 case VK_INSERT: mplayer_put_key(KEY_INSERT); break; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
85 case VK_HOME: mplayer_put_key(KEY_HOME); break; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
86 case VK_END: mplayer_put_key(KEY_END); break; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
87 case VK_PRIOR: mplayer_put_key(KEY_PAGE_UP); break; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
88 case VK_NEXT: mplayer_put_key(KEY_PAGE_DOWN); break; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
89 case VK_ESCAPE: mplayer_put_key(KEY_ESC); break; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
90 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
91 break; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
92 case WM_CHAR: |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
93 mplayer_put_key(wParam); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
94 break; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
95 case WM_LBUTTONDOWN: |
12927 | 96 if (!vo_nomouse_input && (vo_fs || (wParam & MK_CONTROL))) { |
97 mplayer_put_key(MOUSE_BTN0); | |
98 break; | |
99 } | |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
100 if (!vo_fs) { |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
101 ReleaseCapture(); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
102 SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
103 return 0; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
104 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
105 break; |
12927 | 106 case WM_MBUTTONDOWN: |
107 if (!vo_nomouse_input) | |
108 mplayer_put_key(MOUSE_BTN1); | |
109 break; | |
110 case WM_RBUTTONDOWN: | |
111 if (!vo_nomouse_input) | |
112 mplayer_put_key(MOUSE_BTN2); | |
113 break; | |
114 case WM_MOUSEWHEEL: | |
115 if (!vo_nomouse_input) { | |
116 int x = GET_WHEEL_DELTA_WPARAM(wParam); | |
117 if (x > 0) | |
118 mplayer_put_key(MOUSE_BTN3); | |
119 else | |
120 mplayer_put_key(MOUSE_BTN4); | |
121 break; | |
122 } | |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
123 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
124 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
125 return DefWindowProc(hWnd, message, wParam, lParam); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
126 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
127 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
128 int vo_w32_check_events(void) { |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
129 MSG msg; |
17115 | 130 event_flags = 0; |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
131 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
132 TranslateMessage(&msg); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
133 DispatchMessage(&msg); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
134 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
135 |
17115 | 136 return event_flags; |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
137 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
138 |
18116 | 139 static BOOL CALLBACK mon_enum(HMONITOR hmon, HDC hdc, LPRECT r, LPARAM p) { |
140 // this defaults to the last screen if specified number does not exist | |
141 xinerama_x = r->left; | |
142 xinerama_y = r->top; | |
143 vo_screenwidth = r->right - r->left; | |
144 vo_screenheight = r->bottom - r->top; | |
145 if (mon_cnt == xinerama_screen) | |
146 return FALSE; | |
147 mon_cnt++; | |
148 return TRUE; | |
149 } | |
150 | |
21631 | 151 void w32_update_xinerama_info(void) { |
18116 | 152 xinerama_x = xinerama_y = 0; |
153 if (xinerama_screen < -1) { | |
154 int tmp; | |
155 xinerama_x = GetSystemMetrics(SM_XVIRTUALSCREEN); | |
156 xinerama_y = GetSystemMetrics(SM_YVIRTUALSCREEN); | |
157 tmp = GetSystemMetrics(SM_CXVIRTUALSCREEN); | |
158 if (tmp) vo_screenwidth = tmp; | |
159 tmp = GetSystemMetrics(SM_CYVIRTUALSCREEN); | |
160 if (tmp) vo_screenheight = tmp; | |
161 } else if (xinerama_screen == -1 && myMonitorFromWindow && myGetMonitorInfo) { | |
162 MONITORINFO mi; | |
163 HMONITOR m = myMonitorFromWindow(vo_window, MONITOR_DEFAULTTOPRIMARY); | |
164 mi.cbSize = sizeof(mi); | |
165 myGetMonitorInfo(m, &mi); | |
166 xinerama_x = mi.rcMonitor.left; | |
167 xinerama_y = mi.rcMonitor.top; | |
168 vo_screenwidth = mi.rcMonitor.right - mi.rcMonitor.left; | |
169 vo_screenheight = mi.rcMonitor.bottom - mi.rcMonitor.top; | |
170 } else if (xinerama_screen > 0 && myEnumDisplayMonitors) { | |
171 mon_cnt = 0; | |
172 myEnumDisplayMonitors(NULL, NULL, mon_enum, 0); | |
173 } | |
174 aspect_save_screenres(vo_screenwidth, vo_screenheight); | |
175 } | |
176 | |
14747 | 177 static void updateScreenProperties() { |
178 DEVMODE dm; | |
179 dm.dmSize = sizeof dm; | |
180 dm.dmDriverExtra = 0; | |
181 dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; | |
182 if (!EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &dm)) { | |
183 mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to enumerate display settings!\n"); | |
184 return; | |
185 } | |
186 | |
187 vo_screenwidth = dm.dmPelsWidth; | |
188 vo_screenheight = dm.dmPelsHeight; | |
189 vo_depthonscreen = dm.dmBitsPerPel; | |
21631 | 190 w32_update_xinerama_info(); |
14747 | 191 } |
192 | |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
193 static void changeMode(void) { |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
194 DEVMODE dm; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
195 dm.dmSize = sizeof dm; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
196 dm.dmDriverExtra = 0; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
197 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
198 dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
199 dm.dmBitsPerPel = vo_depthonscreen; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
200 dm.dmPelsWidth = vo_screenwidth; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
201 dm.dmPelsHeight = vo_screenheight; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
202 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
203 if (vo_vm) { |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
204 int bestMode = -1; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
205 int bestScore = INT_MAX; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
206 int i; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
207 for (i = 0; EnumDisplaySettings(0, i, &dm); ++i) { |
16213 | 208 int score = (dm.dmPelsWidth - o_dwidth) * (dm.dmPelsHeight - o_dheight); |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
209 if (dm.dmBitsPerPel != vo_depthonscreen) continue; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
210 if (dm.dmPelsWidth < o_dwidth) continue; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
211 if (dm.dmPelsHeight < o_dheight) continue; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
212 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
213 if (score < bestScore) { |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
214 bestScore = score; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
215 bestMode = i; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
216 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
217 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
218 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
219 if (bestMode != -1) |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
220 EnumDisplaySettings(0, bestMode, &dm); |
14747 | 221 |
222 ChangeDisplaySettings(&dm, CDS_FULLSCREEN); | |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
223 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
224 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
225 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
226 static void resetMode(void) { |
14142
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
13787
diff
changeset
|
227 if (vo_vm) |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
228 ChangeDisplaySettings(0, 0); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
229 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
230 |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
231 static int createRenderingContext(void) { |
11542 | 232 HWND layer = HWND_NOTOPMOST; |
16213 | 233 PIXELFORMATDESCRIPTOR pfd; |
17006
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
234 RECT r; |
16213 | 235 int pf; |
18948
c2aee29c80b6
Do not fiddle (too much) with external (WinID) windows
reimar
parents:
18927
diff
changeset
|
236 if (WinID < 0) { |
17006
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
237 int style = (vo_border && !vo_fs) ? |
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
238 (WS_OVERLAPPEDWINDOW | WS_SIZEBOX) : WS_POPUP; |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
239 |
11542 | 240 if (vo_fs || vo_ontop) layer = HWND_TOPMOST; |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
241 if (vo_fs) { |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
242 changeMode(); |
20972
ef8ac967b43f
Adapt code to annoying ShowCursor semantics (increases/decreases and returns
reimar
parents:
20657
diff
changeset
|
243 while (ShowCursor(0) >= 0) /**/ ; |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
244 } else { |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
245 resetMode(); |
20972
ef8ac967b43f
Adapt code to annoying ShowCursor semantics (increases/decreases and returns
reimar
parents:
20657
diff
changeset
|
246 while (ShowCursor(1) < 0) /**/ ; |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
247 } |
14747 | 248 updateScreenProperties(); |
17006
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
249 ShowWindow(vo_window, SW_HIDE); |
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
250 SetWindowLong(vo_window, GWL_STYLE, style); |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
251 if (vo_fs) { |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
252 prev_width = vo_dwidth; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
253 prev_height = vo_dheight; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
254 prev_x = vo_dx; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
255 prev_y = vo_dy; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
256 vo_dwidth = vo_screenwidth; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
257 vo_dheight = vo_screenheight; |
18116 | 258 vo_dx = xinerama_x; |
259 vo_dy = xinerama_y; | |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
260 } else { |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
261 vo_dwidth = prev_width; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
262 vo_dheight = prev_height; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
263 vo_dx = prev_x; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
264 vo_dy = prev_y; |
20657 | 265 // HACK around what probably is a windows focus bug: |
266 // when pressing 'f' on the console, then 'f' again to | |
267 // return to windowed mode, any input into the video | |
268 // window is lost forever. | |
269 SetFocus(vo_window); | |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
270 } |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
271 r.left = vo_dx; |
17006
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
272 r.right = r.left + vo_dwidth; |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
273 r.top = vo_dy; |
17006
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
274 r.bottom = r.top + vo_dheight; |
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
275 AdjustWindowRect(&r, style, 0); |
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
276 SetWindowPos(vo_window, layer, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_SHOWWINDOW); |
18948
c2aee29c80b6
Do not fiddle (too much) with external (WinID) windows
reimar
parents:
18927
diff
changeset
|
277 } |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
278 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
279 memset(&pfd, 0, sizeof pfd); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
280 pfd.nSize = sizeof pfd; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
281 pfd.nVersion = 1; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
282 pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
283 pfd.iPixelType = PFD_TYPE_RGBA; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
284 pfd.cColorBits = 24; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
285 pfd.iLayerType = PFD_MAIN_PLANE; |
16213 | 286 pf = ChoosePixelFormat(vo_hdc, &pfd); |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
287 if (!pf) { |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
288 mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to select a valid pixel format!\n"); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
289 return 0; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
290 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
291 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
292 SetPixelFormat(vo_hdc, pf, &pfd); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
293 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
294 mp_msg(MSGT_VO, MSGL_V, "vo: win32: running at %dx%d with depth %d\n", vo_screenwidth, vo_screenheight, vo_depthonscreen); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
295 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
296 return 1; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
297 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
298 |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
299 int vo_w32_config(uint32_t width, uint32_t height, uint32_t flags) { |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
300 // store original size for videomode switching |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
301 o_dwidth = width; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
302 o_dheight = height; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
303 |
18987
1f08622dd297
Fix window size bug when starting with -fs and returning
reimar
parents:
18948
diff
changeset
|
304 prev_width = vo_dwidth = width; |
1f08622dd297
Fix window size bug when starting with -fs and returning
reimar
parents:
18948
diff
changeset
|
305 prev_height = vo_dheight = height; |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
306 prev_x = vo_dx; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
307 prev_y = vo_dy; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
308 |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
309 vo_fs = flags & VOFLAG_FULLSCREEN; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
310 vo_vm = flags & VOFLAG_MODESWITCHING; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
311 return createRenderingContext(); |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
312 } |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
313 |
21631 | 314 int vo_w32_init(void) { |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
315 HICON mplayerIcon = 0; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
316 char exedir[MAX_PATH]; |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
317 HINSTANCE user32; |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
318 |
14142
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
13787
diff
changeset
|
319 if (vo_window) |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
320 return 1; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
321 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
322 hInstance = GetModuleHandle(0); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
323 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
324 if (GetModuleFileName(0, exedir, MAX_PATH)) |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
325 mplayerIcon = ExtractIcon(hInstance, exedir, 0); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
326 if (!mplayerIcon) |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
327 mplayerIcon = LoadIcon(0, IDI_APPLICATION); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
328 |
16226
94bb243636e1
10l, initializers don't work without a declaration :-(
reimar
parents:
16213
diff
changeset
|
329 { |
94bb243636e1
10l, initializers don't work without a declaration :-(
reimar
parents:
16213
diff
changeset
|
330 WNDCLASSEX wcex = { sizeof wcex, CS_OWNDC, WndProc, 0, 0, hInstance, mplayerIcon, LoadCursor(0, IDC_ARROW), (HBRUSH)GetStockObject(BLACK_BRUSH), 0, classname, mplayerIcon }; |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
331 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
332 if (!RegisterClassEx(&wcex)) { |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
333 mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to register window class!\n"); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
334 return 0; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
335 } |
16226
94bb243636e1
10l, initializers don't work without a declaration :-(
reimar
parents:
16213
diff
changeset
|
336 } |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
337 |
16282
273d33249c25
-wid support for windows. Not well tested, might still behave a bit weird.
reimar
parents:
16226
diff
changeset
|
338 if (WinID >= 0) |
273d33249c25
-wid support for windows. Not well tested, might still behave a bit weird.
reimar
parents:
16226
diff
changeset
|
339 vo_window = WinID; |
273d33249c25
-wid support for windows. Not well tested, might still behave a bit weird.
reimar
parents:
16226
diff
changeset
|
340 else { |
17006
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
341 vo_window = CreateWindowEx(0, classname, classname, |
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
342 vo_border ? (WS_OVERLAPPEDWINDOW | WS_SIZEBOX) : WS_POPUP, |
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
343 CW_USEDEFAULT, 0, 100, 100, 0, 0, hInstance, 0); |
14142
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
13787
diff
changeset
|
344 if (!vo_window) { |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
345 mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to create window!\n"); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
346 return 0; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
347 } |
16282
273d33249c25
-wid support for windows. Not well tested, might still behave a bit weird.
reimar
parents:
16226
diff
changeset
|
348 } |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
349 |
14142
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
13787
diff
changeset
|
350 vo_hdc = GetDC(vo_window); |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
351 |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
352 myMonitorFromWindow = NULL; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
353 myGetMonitorInfo = NULL; |
18116 | 354 myEnumDisplayMonitors = NULL; |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
355 user32 = GetModuleHandle("user32.dll"); |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
356 if (user32) { |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
357 myMonitorFromWindow = GetProcAddress(user32, "MonitorFromWindow"); |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
358 myGetMonitorInfo = GetProcAddress(user32, "GetMonitorInfoA"); |
18116 | 359 myEnumDisplayMonitors = GetProcAddress(user32, "EnumDisplayMonitors"); |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
360 } |
14747 | 361 updateScreenProperties(); |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
362 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
363 return 1; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
364 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
365 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
366 void vo_w32_fullscreen(void) { |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
367 vo_fs = !vo_fs; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
368 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
369 createRenderingContext(); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
370 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
371 |
17006
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
372 void vo_w32_border() { |
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
373 vo_border = !vo_border; |
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
374 createRenderingContext(); |
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
375 } |
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
376 |
11542 | 377 void vo_w32_ontop( void ) |
378 { | |
379 vo_ontop = !vo_ontop; | |
380 if (!vo_fs) { | |
381 HWND layer = HWND_NOTOPMOST; | |
382 if (vo_ontop) layer = HWND_TOPMOST; | |
14142
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
13787
diff
changeset
|
383 SetWindowPos(vo_window, layer, (vo_screenwidth - vo_dwidth) / 2, (vo_screenheight - vo_dheight) / 2, vo_dwidth, vo_dheight, SWP_SHOWWINDOW); |
11542 | 384 } |
385 } | |
386 | |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
387 void vo_w32_uninit() { |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
388 mp_msg(MSGT_VO, MSGL_V, "vo: win32: uninit\n"); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
389 resetMode(); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
390 ShowCursor(1); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
391 vo_depthonscreen = 0; |
16288
1cb19a114eb8
DestroyWindow must be used when -wid was not given, so for WinID < 0, not >=0
reimar
parents:
16282
diff
changeset
|
392 if (WinID < 0) |
14142
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
13787
diff
changeset
|
393 DestroyWindow(vo_window); |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
13787
diff
changeset
|
394 vo_window = 0; |
11479
5d76d070b44b
change vo_w32_fullscreen to behave like vo_x11_fullscreen patch by Reimar Doeffinger <someone-guy at gmx.de>
faust3
parents:
10880
diff
changeset
|
395 UnregisterClass(classname, 0); |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
396 } |