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