annotate libvo/w32_common.c @ 28140:49dadf7bd73a

100l, forgot an assignment, broke special keys handling for X11-based vos.
author reimar
date Sun, 21 Dec 2008 04:11:51 +0000
parents 28bf0d126da2
children 39fc19c00428
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22423
8f95e2a3c797 Add support for tracking mouse movements.
reimar
parents: 22416
diff changeset
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
8f95e2a3c797 Add support for tracking mouse movements.
reimar
parents: 22416
diff changeset
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
8f95e2a3c797 Add support for tracking mouse movements.
reimar
parents: 22416
diff changeset
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
25945
491e43b45aa9 Avoid a useless extra pointer variable.
reimar
parents: 25944
diff changeset
21 static const char classname[] = "MPlayer - Media player for Win32";
10880
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
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
24 // last non-fullscreen extends
25946
04f280a9f4f4 Make some variables static.
reimar
parents: 25945
diff changeset
25 static int prev_width;
04f280a9f4f4 Make some variables static.
reimar
parents: 25945
diff changeset
26 static int prev_height;
04f280a9f4f4 Make some variables static.
reimar
parents: 25945
diff changeset
27 static int prev_x;
04f280a9f4f4 Make some variables static.
reimar
parents: 25945
diff changeset
28 static int prev_y;
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
29
25946
04f280a9f4f4 Make some variables static.
reimar
parents: 25945
diff changeset
30 static uint32_t o_dwidth;
04f280a9f4f4 Make some variables static.
reimar
parents: 25945
diff changeset
31 static uint32_t 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
32
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
33 static HINSTANCE hInstance;
21631
2d3fdf94a50c Fix compilation under MinGW with X11 enabled
reimar
parents: 20972
diff changeset
34 #define vo_window vo_w32_window
14142
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 13787
diff changeset
35 HWND vo_window = 0;
17115
dbe315450a32 Fix message handling, process resize events
reimar
parents: 17006
diff changeset
36 static int event_flags;
18116
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
37 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
38
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
39 static HMONITOR (WINAPI* myMonitorFromWindow)(HWND, DWORD);
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
40 static BOOL (WINAPI* myGetMonitorInfo)(HMONITOR, LPMONITORINFO);
18116
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
41 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
42
28137
28bf0d126da2 Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents: 28040
diff changeset
43 static const struct keymap vk_map[] = {
28bf0d126da2 Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents: 28040
diff changeset
44 // special keys
28bf0d126da2 Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents: 28040
diff changeset
45 {VK_ESCAPE, KEY_ESC}, {VK_BACK, KEY_BS}, {VK_TAB, KEY_TAB}, {VK_CONTROL, KEY_CTRL},
28bf0d126da2 Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents: 28040
diff changeset
46
28bf0d126da2 Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents: 28040
diff changeset
47 // cursor keys
28bf0d126da2 Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents: 28040
diff changeset
48 {VK_LEFT, KEY_LEFT}, {VK_UP, KEY_UP}, {VK_RIGHT, KEY_RIGHT}, {VK_DOWN, KEY_DOWN},
28bf0d126da2 Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents: 28040
diff changeset
49
28bf0d126da2 Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents: 28040
diff changeset
50 // navigation block
28bf0d126da2 Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents: 28040
diff changeset
51 {VK_INSERT, KEY_INSERT}, {VK_DELETE, KEY_DELETE}, {VK_HOME, KEY_HOME}, {VK_END, KEY_END},
28bf0d126da2 Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents: 28040
diff changeset
52 {VK_PRIOR, KEY_PAGE_UP}, {VK_NEXT, KEY_PAGE_DOWN},
28bf0d126da2 Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents: 28040
diff changeset
53
28bf0d126da2 Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents: 28040
diff changeset
54 {0, 0}
28bf0d126da2 Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents: 28040
diff changeset
55 };
28bf0d126da2 Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents: 28040
diff changeset
56
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
57 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
58 RECT r;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
59 POINT p;
28137
28bf0d126da2 Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents: 28040
diff changeset
60 int mpkey;
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
61 switch (message) {
25944
8a1c062707ff Do not uselessly erase background, OpenGL will take care of drawing everything.
reimar
parents: 25942
diff changeset
62 case WM_ERASEBKGND: // no need to erase background seperately
8a1c062707ff Do not uselessly erase background, OpenGL will take care of drawing everything.
reimar
parents: 25942
diff changeset
63 return 1;
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
64 case WM_PAINT:
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
65 event_flags |= VO_EVENT_EXPOSE;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
66 break;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
67 case WM_MOVE:
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
68 p.x = 0;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
69 p.y = 0;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
70 ClientToScreen(vo_window, &p);
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
71 vo_dx = p.x;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
72 vo_dy = p.y;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
73 break;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
74 case WM_SIZE:
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
75 event_flags |= VO_EVENT_RESIZE;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
76 GetClientRect(vo_window, &r);
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
77 vo_dwidth = r.right;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
78 vo_dheight = r.bottom;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
79 break;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
80 case WM_WINDOWPOSCHANGING:
25918
35698e5aa40c Implement keepaspect for Windows OpenGL vos.
reimar
parents: 25787
diff changeset
81 if (vo_keepaspect && !vo_fs) {
35698e5aa40c Implement keepaspect for Windows OpenGL vos.
reimar
parents: 25787
diff changeset
82 WINDOWPOS *wpos = lParam;
35698e5aa40c Implement keepaspect for Windows OpenGL vos.
reimar
parents: 25787
diff changeset
83 int xborder, yborder;
35698e5aa40c Implement keepaspect for Windows OpenGL vos.
reimar
parents: 25787
diff changeset
84 RECT r2;
35698e5aa40c Implement keepaspect for Windows OpenGL vos.
reimar
parents: 25787
diff changeset
85 GetClientRect(vo_window, &r);
35698e5aa40c Implement keepaspect for Windows OpenGL vos.
reimar
parents: 25787
diff changeset
86 GetWindowRect(vo_window, &r2);
35698e5aa40c Implement keepaspect for Windows OpenGL vos.
reimar
parents: 25787
diff changeset
87 xborder = (r2.right - r2.left) - (r.right - r.left);
35698e5aa40c Implement keepaspect for Windows OpenGL vos.
reimar
parents: 25787
diff changeset
88 yborder = (r2.bottom - r2.top) - (r.bottom - r.top);
35698e5aa40c Implement keepaspect for Windows OpenGL vos.
reimar
parents: 25787
diff changeset
89 wpos->cx -= xborder; wpos->cy -= yborder;
35698e5aa40c Implement keepaspect for Windows OpenGL vos.
reimar
parents: 25787
diff changeset
90 aspect_fit(&wpos->cx, &wpos->cy, wpos->cx, wpos->cy);
35698e5aa40c Implement keepaspect for Windows OpenGL vos.
reimar
parents: 25787
diff changeset
91 wpos->cx += xborder; wpos->cy += yborder;
35698e5aa40c Implement keepaspect for Windows OpenGL vos.
reimar
parents: 25787
diff changeset
92 }
18927
278eaf3ed5d8 Convince windows to allow window sizes > screen size
reimar
parents: 18116
diff changeset
93 return 0;
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
94 case WM_CLOSE:
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
95 mplayer_put_key(KEY_CLOSE_WIN);
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
96 break;
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
97 case WM_SYSCOMMAND:
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
98 switch (wParam) {
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
99 case SC_SCREENSAVE:
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
100 case SC_MONITORPOWER:
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
101 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
102 return 0;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
103 }
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
104 break;
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
105 case WM_KEYDOWN:
28137
28bf0d126da2 Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents: 28040
diff changeset
106 mpkey = lookup_keymap_table(vk_map, wParam);
28bf0d126da2 Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents: 28040
diff changeset
107 if (mpkey)
28bf0d126da2 Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents: 28040
diff changeset
108 mplayer_put_key(mpkey);
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
109 break;
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
110 case WM_CHAR:
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
111 mplayer_put_key(wParam);
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_LBUTTONDOWN:
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
114 if (!vo_nomouse_input && (vo_fs || (wParam & MK_CONTROL))) {
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
115 mplayer_put_key(MOUSE_BTN0);
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
116 break;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
117 }
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
118 if (!vo_fs) {
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
119 ReleaseCapture();
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
120 SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0);
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
121 return 0;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
122 }
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
123 break;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
124 case WM_MBUTTONDOWN:
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
125 if (!vo_nomouse_input)
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
126 mplayer_put_key(MOUSE_BTN1);
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
127 break;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
128 case WM_RBUTTONDOWN:
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
129 if (!vo_nomouse_input)
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
130 mplayer_put_key(MOUSE_BTN2);
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
131 break;
22423
8f95e2a3c797 Add support for tracking mouse movements.
reimar
parents: 22416
diff changeset
132 case WM_MOUSEMOVE:
8f95e2a3c797 Add support for tracking mouse movements.
reimar
parents: 22416
diff changeset
133 if (enable_mouse_movements) {
8f95e2a3c797 Add support for tracking mouse movements.
reimar
parents: 22416
diff changeset
134 char cmd_str[40];
8f95e2a3c797 Add support for tracking mouse movements.
reimar
parents: 22416
diff changeset
135 snprintf(cmd_str, sizeof(cmd_str), "set_mouse_pos %i %i",
8f95e2a3c797 Add support for tracking mouse movements.
reimar
parents: 22416
diff changeset
136 GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
8f95e2a3c797 Add support for tracking mouse movements.
reimar
parents: 22416
diff changeset
137 mp_input_queue_cmd(mp_input_parse_cmd(cmd_str));
8f95e2a3c797 Add support for tracking mouse movements.
reimar
parents: 22416
diff changeset
138 }
8f95e2a3c797 Add support for tracking mouse movements.
reimar
parents: 22416
diff changeset
139 break;
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
140 case WM_MOUSEWHEEL:
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
141 if (!vo_nomouse_input) {
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
142 int x = GET_WHEEL_DELTA_WPARAM(wParam);
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
143 if (x > 0)
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
144 mplayer_put_key(MOUSE_BTN3);
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
145 else
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
146 mplayer_put_key(MOUSE_BTN4);
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
147 break;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
148 }
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
149 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
150
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
151 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
152 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
153
27920
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
154 /**
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
155 * \brief Dispatch incoming window events and handle them.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
156 *
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
157 * This function should be placed inside libvo's function "check_events".
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
158 *
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
159 * Global libvo variables changed:
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
160 * vo_dwidth: new window client area width
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
161 * vo_dheight: new window client area height
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
162 *
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
163 * \return int with these flags possibly set, take care to handle in the right order
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
164 * if it matters in your driver:
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
165 *
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
166 * VO_EVENT_RESIZE = The window was resized. If necessary reinit your
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
167 * driver render context accordingly.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
168 * VO_EVENT_EXPOSE = The window was exposed. Call e.g. flip_frame() to redraw
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
169 * the window if the movie is paused.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
170 */
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
171 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
172 MSG msg;
17115
dbe315450a32 Fix message handling, process resize events
reimar
parents: 17006
diff changeset
173 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
174 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
175 TranslateMessage(&msg);
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
176 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
177 }
22415
c36b8d705d08 Generate resize events when size of -wid window changes.
reimar
parents: 21631
diff changeset
178 if (WinID >= 0) {
c36b8d705d08 Generate resize events when size of -wid window changes.
reimar
parents: 21631
diff changeset
179 RECT r;
28040
9081df26c512 More robust w32 -wid size handling
reimar
parents: 28039
diff changeset
180 GetClientRect(vo_window, &r);
9081df26c512 More robust w32 -wid size handling
reimar
parents: 28039
diff changeset
181 if (r.right != vo_dwidth || r.bottom != vo_dheight) {
9081df26c512 More robust w32 -wid size handling
reimar
parents: 28039
diff changeset
182 vo_dwidth = r.right; vo_dheight = r.bottom;
9081df26c512 More robust w32 -wid size handling
reimar
parents: 28039
diff changeset
183 event_flags |= VO_EVENT_RESIZE;
9081df26c512 More robust w32 -wid size handling
reimar
parents: 28039
diff changeset
184 }
25933
9b395b94d6a7 Hack: Create a child window for Windows OpenGL with -wid, since (esp. nVidia)
reimar
parents: 25918
diff changeset
185 GetClientRect(WinID, &r);
22415
c36b8d705d08 Generate resize events when size of -wid window changes.
reimar
parents: 21631
diff changeset
186 if (r.right != vo_dwidth || r.bottom != vo_dheight)
25933
9b395b94d6a7 Hack: Create a child window for Windows OpenGL with -wid, since (esp. nVidia)
reimar
parents: 25918
diff changeset
187 MoveWindow(vo_window, 0, 0, r.right, r.bottom, FALSE);
22415
c36b8d705d08 Generate resize events when size of -wid window changes.
reimar
parents: 21631
diff changeset
188 }
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
189
17115
dbe315450a32 Fix message handling, process resize events
reimar
parents: 17006
diff changeset
190 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
191 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
192
18116
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
193 static BOOL CALLBACK mon_enum(HMONITOR hmon, HDC hdc, LPRECT r, LPARAM p) {
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
194 // this defaults to the last screen if specified number does not exist
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
195 xinerama_x = r->left;
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
196 xinerama_y = r->top;
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
197 vo_screenwidth = r->right - r->left;
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
198 vo_screenheight = r->bottom - r->top;
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
199 if (mon_cnt == xinerama_screen)
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
200 return FALSE;
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
201 mon_cnt++;
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
202 return TRUE;
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
203 }
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
204
27920
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
205 /**
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
206 * \brief Update screen information.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
207 *
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
208 * This function should be called in libvo's "control" callback
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
209 * with parameter VOCTRL_UPDATE_SCREENINFO.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
210 * Note that this also enables the new API where geometry and aspect
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
211 * calculations are done in video_out.c:config_video_out
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
212 *
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
213 * Global libvo variables changed:
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
214 * xinerama_x
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
215 * xinerama_y
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
216 * vo_screenwidth
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
217 * vo_screenheight
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
218 */
21631
2d3fdf94a50c Fix compilation under MinGW with X11 enabled
reimar
parents: 20972
diff changeset
219 void w32_update_xinerama_info(void) {
18116
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
220 xinerama_x = xinerama_y = 0;
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
221 if (xinerama_screen < -1) {
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
222 int tmp;
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
223 xinerama_x = GetSystemMetrics(SM_XVIRTUALSCREEN);
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
224 xinerama_y = GetSystemMetrics(SM_YVIRTUALSCREEN);
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
225 tmp = GetSystemMetrics(SM_CXVIRTUALSCREEN);
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
226 if (tmp) vo_screenwidth = tmp;
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
227 tmp = GetSystemMetrics(SM_CYVIRTUALSCREEN);
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
228 if (tmp) vo_screenheight = tmp;
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
229 } else if (xinerama_screen == -1 && myMonitorFromWindow && myGetMonitorInfo) {
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
230 MONITORINFO mi;
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
231 HMONITOR m = myMonitorFromWindow(vo_window, MONITOR_DEFAULTTOPRIMARY);
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
232 mi.cbSize = sizeof(mi);
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
233 myGetMonitorInfo(m, &mi);
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
234 xinerama_x = mi.rcMonitor.left;
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
235 xinerama_y = mi.rcMonitor.top;
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
236 vo_screenwidth = mi.rcMonitor.right - mi.rcMonitor.left;
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
237 vo_screenheight = mi.rcMonitor.bottom - mi.rcMonitor.top;
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
238 } else if (xinerama_screen > 0 && myEnumDisplayMonitors) {
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
239 mon_cnt = 0;
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
240 myEnumDisplayMonitors(NULL, NULL, mon_enum, 0);
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
241 }
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
242 aspect_save_screenres(vo_screenwidth, vo_screenheight);
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
243 }
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
244
25785
bda4125e24bf Fix some function types from unspecified to empty argument list
reimar
parents: 25719
diff changeset
245 static void updateScreenProperties(void) {
14747
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
246 DEVMODE dm;
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
247 dm.dmSize = sizeof dm;
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
248 dm.dmDriverExtra = 0;
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
249 dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
250 if (!EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &dm)) {
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
251 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
252 return;
14747
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
253 }
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
254
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
255 vo_screenwidth = dm.dmPelsWidth;
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
256 vo_screenheight = dm.dmPelsHeight;
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
257 vo_depthonscreen = dm.dmBitsPerPel;
21631
2d3fdf94a50c Fix compilation under MinGW with X11 enabled
reimar
parents: 20972
diff changeset
258 w32_update_xinerama_info();
14747
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
259 }
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
260
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
261 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
262 DEVMODE dm;
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
263 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
264 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
265
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
266 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
267 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
268 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
269 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
270
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
271 if (vo_vm) {
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
272 int bestMode = -1;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
273 int bestScore = INT_MAX;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
274 int i;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
275 for (i = 0; EnumDisplaySettings(0, i, &dm); ++i) {
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
276 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
277 if (dm.dmBitsPerPel != vo_depthonscreen) continue;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
278 if (dm.dmPelsWidth < o_dwidth) continue;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
279 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
280
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
281 if (score < bestScore) {
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
282 bestScore = score;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
283 bestMode = i;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
284 }
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
285 }
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
286
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
287 if (bestMode != -1)
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
288 EnumDisplaySettings(0, bestMode, &dm);
14747
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
289
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
290 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
291 }
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
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
294 static void resetMode(void) {
14142
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 13787
diff changeset
295 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
296 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
297 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
298
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
299 static int createRenderingContext(void) {
11542
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
diff changeset
300 HWND layer = HWND_NOTOPMOST;
16213
917079aa9fee Cleanup, move declarations to beginning of block.
reimar
parents: 16109
diff changeset
301 PIXELFORMATDESCRIPTOR pfd;
24314
20359547f3c3 Remove global vo_hdc, since it is recommended to release a DC as soon as possible.
reimar
parents: 23587
diff changeset
302 HDC vo_hdc = GetDC(vo_window);
17006
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
303 RECT r;
16213
917079aa9fee Cleanup, move declarations to beginning of block.
reimar
parents: 16109
diff changeset
304 int pf;
18948
c2aee29c80b6 Do not fiddle (too much) with external (WinID) windows
reimar
parents: 18927
diff changeset
305 if (WinID < 0) {
17006
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
306 int style = (vo_border && !vo_fs) ?
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
307 (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
308
11542
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
diff changeset
309 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
310 if (vo_fs) {
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
311 changeMode();
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
312 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
313 } else {
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
314 resetMode();
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
315 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
316 }
14747
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
317 updateScreenProperties();
17006
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
318 ShowWindow(vo_window, SW_HIDE);
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
319 SetWindowLong(vo_window, GWL_STYLE, style);
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
320 if (vo_fs) {
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
321 prev_width = vo_dwidth;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
322 prev_height = vo_dheight;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
323 prev_x = vo_dx;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
324 prev_y = vo_dy;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
325 vo_dwidth = vo_screenwidth;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
326 vo_dheight = vo_screenheight;
18116
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
327 vo_dx = xinerama_x;
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
328 vo_dy = xinerama_y;
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
329 } else {
23587
58bd3640c0c2 Hack around some fullscreen issues with gl under Windows
reimar
parents: 22823
diff changeset
330 // make sure there are no "stale" resize events
58bd3640c0c2 Hack around some fullscreen issues with gl under Windows
reimar
parents: 22823
diff changeset
331 // that would set vo_d* to wrong values
58bd3640c0c2 Hack around some fullscreen issues with gl under Windows
reimar
parents: 22823
diff changeset
332 vo_w32_check_events();
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
333 vo_dwidth = prev_width;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
334 vo_dheight = prev_height;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
335 vo_dx = prev_x;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
336 vo_dy = prev_y;
20657
5fe83dd75490 Hack around Windows focus problem with -vo gl
reimar
parents: 20655
diff changeset
337 // HACK around what probably is a windows focus bug:
5fe83dd75490 Hack around Windows focus problem with -vo gl
reimar
parents: 20655
diff changeset
338 // when pressing 'f' on the console, then 'f' again to
5fe83dd75490 Hack around Windows focus problem with -vo gl
reimar
parents: 20655
diff changeset
339 // return to windowed mode, any input into the video
5fe83dd75490 Hack around Windows focus problem with -vo gl
reimar
parents: 20655
diff changeset
340 // window is lost forever.
5fe83dd75490 Hack around Windows focus problem with -vo gl
reimar
parents: 20655
diff changeset
341 SetFocus(vo_window);
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
342 }
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
343 r.left = vo_dx;
17006
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
344 r.right = r.left + vo_dwidth;
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
345 r.top = vo_dy;
17006
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
346 r.bottom = r.top + vo_dheight;
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
347 AdjustWindowRect(&r, style, 0);
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
348 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
349 }
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 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
352 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
353 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
354 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
355 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
356 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
357 pfd.iLayerType = PFD_MAIN_PLANE;
16213
917079aa9fee Cleanup, move declarations to beginning of block.
reimar
parents: 16109
diff changeset
358 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
359 if (!pf) {
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
360 mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to select a valid pixel format!\n");
24315
12f2487fb845 Fix compilation after patch to remove global vo_hdc
reimar
parents: 24314
diff changeset
361 ReleaseDC(vo_window, vo_hdc);
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
362 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
363 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
364
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
365 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
366
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
367 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
368
24315
12f2487fb845 Fix compilation after patch to remove global vo_hdc
reimar
parents: 24314
diff changeset
369 ReleaseDC(vo_window, vo_hdc);
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
370 return 1;
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
371 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
372
27920
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
373 /**
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
374 * \brief Configure and show window on the screen.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
375 *
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
376 * This function should be called in libvo's "config" callback.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
377 * It configures a window and shows it on the screen.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
378 *
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
379 * Global libvo variables changed:
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
380 * vo_fs
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
381 * vo_vm
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
382 *
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
383 * \return 1 - Success, 0 - Failure
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
384 */
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
385 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
386 // store original size for videomode switching
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
387 o_dwidth = width;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
388 o_dheight = height;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
389
28038
174c85faada7 Do not override the vo_dwidth/vo_dheight values in vo_w32_config
reimar
parents: 27941
diff changeset
390 if (WinID < 0) {
28039
a95ac8f0336e Reindent after previous commit
reimar
parents: 28038
diff changeset
391 // the desired size is ignored in wid mode, it always matches the window size.
a95ac8f0336e Reindent after previous commit
reimar
parents: 28038
diff changeset
392 prev_width = vo_dwidth = width;
a95ac8f0336e Reindent after previous commit
reimar
parents: 28038
diff changeset
393 prev_height = vo_dheight = height;
a95ac8f0336e Reindent after previous commit
reimar
parents: 28038
diff changeset
394 prev_x = vo_dx;
a95ac8f0336e Reindent after previous commit
reimar
parents: 28038
diff changeset
395 prev_y = vo_dy;
28038
174c85faada7 Do not override the vo_dwidth/vo_dheight values in vo_w32_config
reimar
parents: 27941
diff changeset
396 }
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
397
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
398 vo_fs = flags & VOFLAG_FULLSCREEN;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
399 vo_vm = flags & VOFLAG_MODESWITCHING;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
400 return createRenderingContext();
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
401 }
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
402
27920
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
403 /**
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
404 * \brief Initialize w32_common framework.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
405 *
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
406 * The first function that should be called from the w32_common framework.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
407 * It handles window creation on the screen with proper title and attributes.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
408 * It also initializes the framework's internal variables. The function should
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
409 * be called after your own preinit initialization and you shouldn't do any
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
410 * window management on your own.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
411 *
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
412 * Global libvo variables changed:
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
413 * vo_w32_window
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
414 * vo_depthonscreen
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
415 * vo_screenwidth
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
416 * vo_screenheight
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
417 *
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
418 * \return 1 = Success, 0 = Failure
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
419 */
21631
2d3fdf94a50c Fix compilation under MinGW with X11 enabled
reimar
parents: 20972
diff changeset
420 int vo_w32_init(void) {
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
421 HICON mplayerIcon = 0;
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
422 char exedir[MAX_PATH];
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
423 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
424
14142
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 13787
diff changeset
425 if (vo_window)
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
426 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
427
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
428 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
429
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
430 if (GetModuleFileName(0, exedir, MAX_PATH))
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
431 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
432 if (!mplayerIcon)
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
433 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
434
16226
94bb243636e1 10l, initializers don't work without a declaration :-(
reimar
parents: 16213
diff changeset
435 {
25944
8a1c062707ff Do not uselessly erase background, OpenGL will take care of drawing everything.
reimar
parents: 25942
diff changeset
436 WNDCLASSEX wcex = { sizeof wcex, CS_OWNDC | CS_DBLCLKS, WndProc, 0, 0, hInstance, mplayerIcon, LoadCursor(0, IDC_ARROW), NULL, 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
437
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
438 if (!RegisterClassEx(&wcex)) {
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
439 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
440 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
441 }
16226
94bb243636e1 10l, initializers don't work without a declaration :-(
reimar
parents: 16213
diff changeset
442 }
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
443
16282
273d33249c25 -wid support for windows. Not well tested, might still behave a bit weird.
reimar
parents: 16226
diff changeset
444 if (WinID >= 0)
25933
9b395b94d6a7 Hack: Create a child window for Windows OpenGL with -wid, since (esp. nVidia)
reimar
parents: 25918
diff changeset
445 {
9b395b94d6a7 Hack: Create a child window for Windows OpenGL with -wid, since (esp. nVidia)
reimar
parents: 25918
diff changeset
446 RECT r;
9b395b94d6a7 Hack: Create a child window for Windows OpenGL with -wid, since (esp. nVidia)
reimar
parents: 25918
diff changeset
447 GetClientRect(WinID, &r);
9b395b94d6a7 Hack: Create a child window for Windows OpenGL with -wid, since (esp. nVidia)
reimar
parents: 25918
diff changeset
448 vo_dwidth = r.right; vo_dheight = r.bottom;
25934
f0e227951c06 Make sure the -wid window does not get notified when we destroy our attached child window.
reimar
parents: 25933
diff changeset
449 vo_window = CreateWindowEx(WS_EX_NOPARENTNOTIFY, classname, classname,
25933
9b395b94d6a7 Hack: Create a child window for Windows OpenGL with -wid, since (esp. nVidia)
reimar
parents: 25918
diff changeset
450 WS_CHILD | WS_VISIBLE,
9b395b94d6a7 Hack: Create a child window for Windows OpenGL with -wid, since (esp. nVidia)
reimar
parents: 25918
diff changeset
451 0, 0, vo_dwidth, vo_dheight, WinID, 0, hInstance, 0);
27870
31a44a9c8687 Fix Windows OpenGL -wid:
reimar
parents: 25946
diff changeset
452 EnableWindow(vo_window, 0);
25933
9b395b94d6a7 Hack: Create a child window for Windows OpenGL with -wid, since (esp. nVidia)
reimar
parents: 25918
diff changeset
453 } else
17006
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
454 vo_window = CreateWindowEx(0, classname, classname,
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
455 vo_border ? (WS_OVERLAPPEDWINDOW | WS_SIZEBOX) : WS_POPUP,
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
456 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
457 if (!vo_window) {
22416
02783a09e1b3 Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents: 22415
diff changeset
458 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
459 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
460 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
461
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
462 myMonitorFromWindow = NULL;
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
463 myGetMonitorInfo = NULL;
18116
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
464 myEnumDisplayMonitors = NULL;
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
465 user32 = GetModuleHandle("user32.dll");
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
466 if (user32) {
25787
143989c7a3bf Avoid some pointer conversion warnings (the code is messy but not wrong)
reimar
parents: 25785
diff changeset
467 myMonitorFromWindow = (void *)GetProcAddress(user32, "MonitorFromWindow");
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
468 myGetMonitorInfo = GetProcAddress(user32, "GetMonitorInfoA");
18116
d75953576ae4 Fix and improve xinerama support
reimar
parents: 18089
diff changeset
469 myEnumDisplayMonitors = GetProcAddress(user32, "EnumDisplayMonitors");
18079
f57317460375 fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents: 17126
diff changeset
470 }
14747
d87cc822b343 Remove a lot of duplicate code
reimar
parents: 14142
diff changeset
471 updateScreenProperties();
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
472
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
473 return 1;
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
474 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
475
27920
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
476 /**
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
477 * \brief Toogle fullscreen / windowed mode.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
478 *
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
479 * Should be called on VOCTRL_FULLSCREEN event. The window is
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
480 * always resized after this call, so the rendering context
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
481 * should be reinitialized with the new dimensions.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
482 * It is unspecified if vo_check_events will create a resize
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
483 * event in addition or not.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
484 *
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
485 * Global libvo variables changed:
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
486 * vo_dwidth
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
487 * vo_dheight
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
488 * vo_fs
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
489 */
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
490
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
491 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
492 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
493
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
494 createRenderingContext();
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
495 }
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
496
27920
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
497 /**
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
498 * \brief Toogle window border attribute.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
499 *
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
500 * Should be called on VOCTRL_BORDER event.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
501 *
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
502 * Global libvo variables changed:
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
503 * vo_border
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
504 */
25785
bda4125e24bf Fix some function types from unspecified to empty argument list
reimar
parents: 25719
diff changeset
505 void vo_w32_border(void) {
17006
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
506 vo_border = !vo_border;
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
507 createRenderingContext();
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
508 }
852499addaa8 Enable border toggling for gl and gl2 under windows.
reimar
parents: 16892
diff changeset
509
27920
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
510 /**
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
511 * \brief Toogle window ontop attribute.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
512 *
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
513 * Should be called on VOCTRL_ONTOP event.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
514 *
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
515 * Global libvo variables changed:
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
516 * vo_ontop
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
517 */
11542
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
diff changeset
518 void vo_w32_ontop( void )
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
diff changeset
519 {
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
diff changeset
520 vo_ontop = !vo_ontop;
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
diff changeset
521 if (!vo_fs) {
25719
a6cc5f6799cb Fix the bug where the window would become smaller each time vo_ontop is toggled.
reimar
parents: 24315
diff changeset
522 createRenderingContext();
11542
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
diff changeset
523 }
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
diff changeset
524 }
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 11479
diff changeset
525
27920
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
526 /**
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
527 * \brief Uninitialize w32_common framework.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
528 *
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
529 * Should be called last in video driver's uninit function. First release
27941
ae133248dd9b cosmetics: typo fixes
diego
parents: 27920
diff changeset
530 * anything built on top of the created window e.g. rendering context inside
27920
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
531 * and call vo_w32_uninit at the end.
81571689eba3 Doxygen documentation for w32_common.c
reimar
parents: 27870
diff changeset
532 */
25785
bda4125e24bf Fix some function types from unspecified to empty argument list
reimar
parents: 25719
diff changeset
533 void vo_w32_uninit(void) {
10880
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
534 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
535 resetMode();
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
536 ShowCursor(1);
ba9557e864c0 vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff changeset
537 vo_depthonscreen = 0;
14142
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 13787
diff changeset
538 DestroyWindow(vo_window);
f0c1ee83b216 Improving gl2 under windows, moving some functionality to gl_common
reimar
parents: 13787
diff changeset
539 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
540 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
541 }