annotate libvo/w32_common.c @ 18109:68145aae7349

fallback to USERPROFILE environment variable for caching CSS keys when HOME is not set (for MinGW builds running outside of MinGW).
author reimar
date Sat, 15 Apr 2006 21:45:29 +0000
parents 3e8c2b5c60a5
children d75953576ae4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
28 // top left coordinates of current monitor
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
29 int vo_screenx;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
30 int vo_screeny;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
31
10880
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_dwidth;
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
33 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
34
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
35 static HINSTANCE hInstance;
14142
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 13787
diff changeset
36 HWND vo_window = 0;
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
37 static int cursor = 1;
17115
dbe315450a32 Fix message handling, process resize events
reimar
parents: 17006
diff changeset
38 static int 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
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);
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
42
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
43 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
44 RECT r;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
45 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
46 switch (message) {
17126
e5f2f50744cd WM_PAINT is the "expose" event, not WM_ACTIVATE
reimar
parents: 17115
diff changeset
47 case WM_PAINT:
17115
dbe315450a32 Fix message handling, process resize events
reimar
parents: 17006
diff changeset
48 event_flags |= VO_EVENT_EXPOSE;
dbe315450a32 Fix message handling, process resize events
reimar
parents: 17006
diff changeset
49 break;
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
50 case WM_MOVE:
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
51 p.x = 0;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
52 p.y = 0;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
53 ClientToScreen(vo_window, &p);
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
54 vo_dx = p.x;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
55 vo_dy = p.y;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
56 break;
17115
dbe315450a32 Fix message handling, process resize events
reimar
parents: 17006
diff changeset
57 case WM_SIZE:
dbe315450a32 Fix message handling, process resize events
reimar
parents: 17006
diff changeset
58 event_flags |= VO_EVENT_RESIZE;
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
59 GetClientRect(vo_window, &r);
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
60 vo_dwidth = r.right;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
61 vo_dheight = r.bottom;
17115
dbe315450a32 Fix message handling, process resize events
reimar
parents: 17006
diff changeset
62 break;
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
917079aa9fee Cleanup, move declarations to beginning of block.
reimar
parents: 16109
diff changeset
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;
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
82 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
83 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
84 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
85 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
86 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
87 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
88 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
89 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
90 break;
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
91 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
92 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
93 break;
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
94 case WM_LBUTTONDOWN:
12927
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
95 if (!vo_nomouse_input && (vo_fs || (wParam & MK_CONTROL))) {
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
96 mplayer_put_key(MOUSE_BTN0);
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
97 break;
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
98 }
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
99 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
100 ReleaseCapture();
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
101 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
102 return 0;
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
103 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
104 break;
12927
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
105 case WM_MBUTTONDOWN:
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
106 if (!vo_nomouse_input)
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
107 mplayer_put_key(MOUSE_BTN1);
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
108 break;
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
109 case WM_RBUTTONDOWN:
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
110 if (!vo_nomouse_input)
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
111 mplayer_put_key(MOUSE_BTN2);
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
112 break;
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
113 case WM_MOUSEWHEEL:
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
114 if (!vo_nomouse_input) {
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
115 int x = GET_WHEEL_DELTA_WPARAM(wParam);
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
116 if (x > 0)
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
117 mplayer_put_key(MOUSE_BTN3);
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
118 else
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
119 mplayer_put_key(MOUSE_BTN4);
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
120 break;
ba7d39185cc1 support for passing mouse events on to MPlayer
reimar
parents: 12004
diff changeset
121 }
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
122 }
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 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
125 }
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 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
128 MSG msg;
17115
dbe315450a32 Fix message handling, process resize events
reimar
parents: 17006
diff changeset
129 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
130 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
131 TranslateMessage(&msg);
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
132 DispatchMessage(&msg);
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
133 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
134
17115
dbe315450a32 Fix message handling, process resize events
reimar
parents: 17006
diff changeset
135 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
136 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
137
14747
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
138 static void updateScreenProperties() {
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
139 DEVMODE dm;
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
140 dm.dmSize = sizeof dm;
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
141 dm.dmDriverExtra = 0;
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
142 dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
143 if (!EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &dm)) {
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
144 mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to enumerate display settings!\n");
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
145 return;
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
146 }
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
147
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
148 vo_screenwidth = dm.dmPelsWidth;
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
149 vo_screenheight = dm.dmPelsHeight;
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
150 vo_depthonscreen = dm.dmBitsPerPel;
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
151 vo_screenx = vo_screeny = 0;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
152 if (myMonitorFromWindow && myGetMonitorInfo) {
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
153 MONITORINFO mi;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
154 HMONITOR m = myMonitorFromWindow(vo_window, MONITOR_DEFAULTTOPRIMARY);
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
155 mi.cbSize = sizeof(mi);
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
156 myGetMonitorInfo(m, &mi);
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
157 vo_screenx = mi.rcMonitor.left;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
158 vo_screeny = mi.rcMonitor.top;
18085
cf861a0c08a1 correct fullscreen size
reimar
parents: 18081
diff changeset
159 vo_screenwidth = mi.rcMonitor.right - mi.rcMonitor.left;
cf861a0c08a1 correct fullscreen size
reimar
parents: 18081
diff changeset
160 vo_screenheight = mi.rcMonitor.bottom - mi.rcMonitor.top;
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
161 }
18089
3e8c2b5c60a5 10l, forgot to move aspect_save_screenres in last commit
reimar
parents: 18085
diff changeset
162 aspect_save_screenres(vo_screenwidth, vo_screenheight);
14747
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
163 }
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
164
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
165 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
166 DEVMODE dm;
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
167 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
168 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
169
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
170 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
171 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
172 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
173 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
174
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
175 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
176 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
177 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
178 int i;
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
179 for (i = 0; EnumDisplaySettings(0, i, &dm); ++i) {
16213
917079aa9fee Cleanup, move declarations to beginning of block.
reimar
parents: 16109
diff changeset
180 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
181 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
182 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
183 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
184
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
185 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
186 bestScore = score;
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
187 bestMode = i;
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
188 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
189 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
190
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
191 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
192 EnumDisplaySettings(0, bestMode, &dm);
14747
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
193
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
194 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
195 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
196 }
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 static void resetMode(void) {
14142
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 13787
diff changeset
199 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
200 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
201 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
202
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
203 static int createRenderingContext(void) {
11542
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
diff changeset
204 HWND layer = HWND_NOTOPMOST;
16213
917079aa9fee Cleanup, move declarations to beginning of block.
reimar
parents: 16109
diff changeset
205 PIXELFORMATDESCRIPTOR pfd;
17006
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
206 RECT r;
16213
917079aa9fee Cleanup, move declarations to beginning of block.
reimar
parents: 16109
diff changeset
207 int pf;
17006
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
208 int style = (vo_border && !vo_fs) ?
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
209 (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
210
11542
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
diff changeset
211 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
212 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
213 changeMode();
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
214 if (cursor) {
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
215 ShowCursor(0);
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
216 cursor = 0;
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 } else {
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
219 resetMode();
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
220 if (!cursor) {
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
221 ShowCursor(1);
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
222 cursor = 1;
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 }
14747
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
225 updateScreenProperties();
17006
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
226 ShowWindow(vo_window, SW_HIDE);
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
227 SetWindowLong(vo_window, GWL_STYLE, style);
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
228 if (vo_fs) {
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
229 prev_width = vo_dwidth;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
230 prev_height = vo_dheight;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
231 prev_x = vo_dx;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
232 prev_y = vo_dy;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
233 vo_dwidth = vo_screenwidth;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
234 vo_dheight = vo_screenheight;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
235 vo_dx = vo_screenx;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
236 vo_dy = vo_screeny;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
237 } else {
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
238 vo_dwidth = prev_width;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
239 vo_dheight = prev_height;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
240 vo_dx = prev_x;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
241 vo_dy = prev_y;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
242 }
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
243 r.left = vo_dx;
17006
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
244 r.right = r.left + vo_dwidth;
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
245 r.top = vo_dy;
17006
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
246 r.bottom = r.top + vo_dheight;
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
247 AdjustWindowRect(&r, style, 0);
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
248 SetWindowPos(vo_window, layer, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_SHOWWINDOW);
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
249
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
250 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
251 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
252 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
253 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
254 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
255 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
256 pfd.iLayerType = PFD_MAIN_PLANE;
16213
917079aa9fee Cleanup, move declarations to beginning of block.
reimar
parents: 16109
diff changeset
257 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
258 if (!pf) {
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
259 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
260 return 0;
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
261 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
262
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
263 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
264
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
265 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
266
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
267 return 1;
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
268 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
269
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
270 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
271 // store original size for videomode switching
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
272 o_dwidth = width;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
273 o_dheight = height;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
274
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
275 prev_width = width;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
276 prev_height = height;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
277 prev_x = vo_dx;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
278 prev_y = vo_dy;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
279
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
280 vo_fs = flags & VOFLAG_FULLSCREEN;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
281 vo_vm = flags & VOFLAG_MODESWITCHING;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
282 return createRenderingContext();
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
283 }
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
284
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
285 int vo_init(void) {
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
286 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
287 char exedir[MAX_PATH];
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
288 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
289
14142
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 13787
diff changeset
290 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
291 return 1;
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
292
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
293 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
294
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
295 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
296 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
297 if (!mplayerIcon)
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
298 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
299
16226
94bb243636e1 10l, initializers don't work without a declaration :-(
reimar
parents: 16213
diff changeset
300 {
94bb243636e1 10l, initializers don't work without a declaration :-(
reimar
parents: 16213
diff changeset
301 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
302
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
303 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
304 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
305 return 0;
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
306 }
16226
94bb243636e1 10l, initializers don't work without a declaration :-(
reimar
parents: 16213
diff changeset
307 }
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
308
16282
273d33249c25 -wid support for windows. Not well tested, might still behave a bit weird.
reimar
parents: 16226
diff changeset
309 if (WinID >= 0)
273d33249c25 -wid support for windows. Not well tested, might still behave a bit weird.
reimar
parents: 16226
diff changeset
310 vo_window = WinID;
273d33249c25 -wid support for windows. Not well tested, might still behave a bit weird.
reimar
parents: 16226
diff changeset
311 else {
17006
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
312 vo_window = CreateWindowEx(0, classname, classname,
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
313 vo_border ? (WS_OVERLAPPEDWINDOW | WS_SIZEBOX) : WS_POPUP,
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
314 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
315 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
316 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
317 return 0;
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
318 }
16282
273d33249c25 -wid support for windows. Not well tested, might still behave a bit weird.
reimar
parents: 16226
diff changeset
319 }
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
320
14142
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 13787
diff changeset
321 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
322
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
323 myMonitorFromWindow = NULL;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
324 myGetMonitorInfo = NULL;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
325 user32 = GetModuleHandle("user32.dll");
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
326 if (user32) {
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
327 myMonitorFromWindow = GetProcAddress(user32, "MonitorFromWindow");
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
328 myGetMonitorInfo = GetProcAddress(user32, "GetMonitorInfoA");
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
329 }
14747
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
330 updateScreenProperties();
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 return 1;
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
333 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
334
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
335 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
336 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
337
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
338 createRenderingContext();
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
339 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
340
17006
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
341 void vo_w32_border() {
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
342 vo_border = !vo_border;
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
343 createRenderingContext();
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
344 }
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
345
11542
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
diff changeset
346 void vo_w32_ontop( void )
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
diff changeset
347 {
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
diff changeset
348 vo_ontop = !vo_ontop;
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
diff changeset
349 if (!vo_fs) {
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
diff changeset
350 HWND layer = HWND_NOTOPMOST;
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
diff changeset
351 if (vo_ontop) layer = HWND_TOPMOST;
14142
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 13787
diff changeset
352 SetWindowPos(vo_window, layer, (vo_screenwidth - vo_dwidth) / 2, (vo_screenheight - vo_dheight) / 2, vo_dwidth, vo_dheight, SWP_SHOWWINDOW);
11542
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
diff changeset
353 }
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
diff changeset
354 }
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
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 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
357 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
358 resetMode();
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
359 ShowCursor(1);
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
360 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
361 if (WinID < 0)
14142
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 13787
diff changeset
362 DestroyWindow(vo_window);
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 13787
diff changeset
363 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
364 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
365 }