Mercurial > mplayer.hg
annotate libvo/w32_common.c @ 31321:22713e4fde5f
Add CONFIG_LIBRTMP and HAVE_ISATTY #defines to config.h for FFmpeg.
author | diego |
---|---|
date | Sun, 13 Jun 2010 17:18:48 +0000 |
parents | aab85e35de52 |
children | 4bfaa9fc1c16 |
rev | line source |
---|---|
28446
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28179
diff
changeset
|
1 /* |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28179
diff
changeset
|
2 * This file is part of MPlayer. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28179
diff
changeset
|
3 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28179
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28179
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28179
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28179
diff
changeset
|
7 * (at your option) any later version. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28179
diff
changeset
|
8 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28179
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28179
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28179
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28179
diff
changeset
|
12 * GNU General Public License for more details. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28179
diff
changeset
|
13 * |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28179
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28179
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28179
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28179
diff
changeset
|
17 */ |
7681eab10aea
Add standard license headers, unify header formatting.
diego
parents:
28179
diff
changeset
|
18 |
22423 | 19 #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
|
20 #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
|
21 #include <windows.h> |
22423 | 22 #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
|
23 |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12936
diff
changeset
|
24 #include "osdep/keycodes.h" |
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12936
diff
changeset
|
25 #include "input/input.h" |
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12936
diff
changeset
|
26 #include "input/mouse.h" |
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
12936
diff
changeset
|
27 #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
|
28 #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
|
29 #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
|
30 #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
|
31 #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
|
32 |
18081
192e778f1ba1
define MONITOR_DEFAULTTOPRIMARY if necessary, some mingw version seem to miss it
reimar
parents:
18079
diff
changeset
|
33 #ifndef MONITOR_DEFAULTTOPRIMARY |
192e778f1ba1
define MONITOR_DEFAULTTOPRIMARY if necessary, some mingw version seem to miss it
reimar
parents:
18079
diff
changeset
|
34 #define MONITOR_DEFAULTTOPRIMARY 1 |
192e778f1ba1
define MONITOR_DEFAULTTOPRIMARY if necessary, some mingw version seem to miss it
reimar
parents:
18079
diff
changeset
|
35 #endif |
192e778f1ba1
define MONITOR_DEFAULTTOPRIMARY if necessary, some mingw version seem to miss it
reimar
parents:
18079
diff
changeset
|
36 |
28920
49b76e202f98
"MPlayer - The Movie Player" should be used as the player name.
diego
parents:
28678
diff
changeset
|
37 static const char classname[] = "MPlayer - The Movie Player"; |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
38 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
|
39 |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
40 // last non-fullscreen extends |
25946 | 41 static int prev_width; |
42 static int prev_height; | |
43 static int prev_x; | |
44 static int prev_y; | |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
45 |
25946 | 46 static uint32_t o_dwidth; |
47 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
|
48 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
49 static HINSTANCE hInstance; |
21631 | 50 #define vo_window vo_w32_window |
14142
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
13787
diff
changeset
|
51 HWND vo_window = 0; |
29904
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
52 /** HDC used when rendering to a device instead of window */ |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
53 static HDC dev_hdc; |
17115 | 54 static int event_flags; |
18116 | 55 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
|
56 |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
57 static HMONITOR (WINAPI* myMonitorFromWindow)(HWND, DWORD); |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
58 static BOOL (WINAPI* myGetMonitorInfo)(HMONITOR, LPMONITORINFO); |
18116 | 59 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
|
60 |
31017 | 61 static const struct mp_keymap vk_map[] = { |
28137
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28040
diff
changeset
|
62 // special keys |
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28040
diff
changeset
|
63 {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
|
64 |
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28040
diff
changeset
|
65 // cursor keys |
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28040
diff
changeset
|
66 {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
|
67 |
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28040
diff
changeset
|
68 // navigation block |
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28040
diff
changeset
|
69 {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
|
70 {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
|
71 |
28179
39fc19c00428
Support F- and numpad keys for w32_common based vos.
reimar
parents:
28137
diff
changeset
|
72 // F-keys |
39fc19c00428
Support F- and numpad keys for w32_common based vos.
reimar
parents:
28137
diff
changeset
|
73 {VK_F1, KEY_F+1}, {VK_F2, KEY_F+2}, {VK_F3, KEY_F+3}, {VK_F4, KEY_F+4}, |
39fc19c00428
Support F- and numpad keys for w32_common based vos.
reimar
parents:
28137
diff
changeset
|
74 {VK_F5, KEY_F+5}, {VK_F6, KEY_F+6}, {VK_F7, KEY_F+7}, {VK_F8, KEY_F+8}, |
39fc19c00428
Support F- and numpad keys for w32_common based vos.
reimar
parents:
28137
diff
changeset
|
75 {VK_F9, KEY_F+9}, {VK_F10, KEY_F+10}, {VK_F11, KEY_F+11}, {VK_F1, KEY_F+12}, |
39fc19c00428
Support F- and numpad keys for w32_common based vos.
reimar
parents:
28137
diff
changeset
|
76 // numpad |
39fc19c00428
Support F- and numpad keys for w32_common based vos.
reimar
parents:
28137
diff
changeset
|
77 {VK_NUMPAD0, KEY_KP0}, {VK_NUMPAD1, KEY_KP1}, {VK_NUMPAD2, KEY_KP2}, |
39fc19c00428
Support F- and numpad keys for w32_common based vos.
reimar
parents:
28137
diff
changeset
|
78 {VK_NUMPAD3, KEY_KP3}, {VK_NUMPAD4, KEY_KP4}, {VK_NUMPAD5, KEY_KP5}, |
39fc19c00428
Support F- and numpad keys for w32_common based vos.
reimar
parents:
28137
diff
changeset
|
79 {VK_NUMPAD6, KEY_KP6}, {VK_NUMPAD7, KEY_KP7}, {VK_NUMPAD8, KEY_KP8}, |
39fc19c00428
Support F- and numpad keys for w32_common based vos.
reimar
parents:
28137
diff
changeset
|
80 {VK_NUMPAD9, KEY_KP9}, {VK_DECIMAL, KEY_KPDEC}, |
39fc19c00428
Support F- and numpad keys for w32_common based vos.
reimar
parents:
28137
diff
changeset
|
81 |
28137
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28040
diff
changeset
|
82 {0, 0} |
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28040
diff
changeset
|
83 }; |
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28040
diff
changeset
|
84 |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
85 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
|
86 RECT r; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
87 POINT p; |
28137
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28040
diff
changeset
|
88 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
|
89 switch (message) { |
25944
8a1c062707ff
Do not uselessly erase background, OpenGL will take care of drawing everything.
reimar
parents:
25942
diff
changeset
|
90 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
|
91 return 1; |
22416
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
92 case WM_PAINT: |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
93 event_flags |= VO_EVENT_EXPOSE; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
94 break; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
95 case WM_MOVE: |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
96 p.x = 0; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
97 p.y = 0; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
98 ClientToScreen(vo_window, &p); |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
99 vo_dx = p.x; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
100 vo_dy = p.y; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
101 break; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
102 case WM_SIZE: |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
103 event_flags |= VO_EVENT_RESIZE; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
104 GetClientRect(vo_window, &r); |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
105 vo_dwidth = r.right; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
106 vo_dheight = r.bottom; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
107 break; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
108 case WM_WINDOWPOSCHANGING: |
29517 | 109 if (vo_keepaspect && !vo_fs && WinID < 0) { |
25918 | 110 WINDOWPOS *wpos = lParam; |
111 int xborder, yborder; | |
28678
c48f4a1835da
Calculate border size in aspect keeping code by using AdjustWindowRect
reimar
parents:
28446
diff
changeset
|
112 r.left = r.top = 0; |
c48f4a1835da
Calculate border size in aspect keeping code by using AdjustWindowRect
reimar
parents:
28446
diff
changeset
|
113 r.right = wpos->cx; |
c48f4a1835da
Calculate border size in aspect keeping code by using AdjustWindowRect
reimar
parents:
28446
diff
changeset
|
114 r.bottom = wpos->cy; |
c48f4a1835da
Calculate border size in aspect keeping code by using AdjustWindowRect
reimar
parents:
28446
diff
changeset
|
115 AdjustWindowRect(&r, GetWindowLong(vo_window, GWL_STYLE), 0); |
c48f4a1835da
Calculate border size in aspect keeping code by using AdjustWindowRect
reimar
parents:
28446
diff
changeset
|
116 xborder = (r.right - r.left) - wpos->cx; |
c48f4a1835da
Calculate border size in aspect keeping code by using AdjustWindowRect
reimar
parents:
28446
diff
changeset
|
117 yborder = (r.bottom - r.top) - wpos->cy; |
25918 | 118 wpos->cx -= xborder; wpos->cy -= yborder; |
119 aspect_fit(&wpos->cx, &wpos->cy, wpos->cx, wpos->cy); | |
120 wpos->cx += xborder; wpos->cy += yborder; | |
121 } | |
18927
278eaf3ed5d8
Convince windows to allow window sizes > screen size
reimar
parents:
18116
diff
changeset
|
122 return 0; |
22416
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
123 case WM_CLOSE: |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
124 mplayer_put_key(KEY_CLOSE_WIN); |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
125 break; |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
126 case WM_SYSCOMMAND: |
22416
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
127 switch (wParam) { |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
128 case SC_SCREENSAVE: |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
129 case SC_MONITORPOWER: |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
130 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
|
131 return 0; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
132 } |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
133 break; |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
134 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
|
135 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
|
136 if (mpkey) |
28bf0d126da2
Add and use a special lookup function to do table-based translation to MPlayer keycodes.
reimar
parents:
28040
diff
changeset
|
137 mplayer_put_key(mpkey); |
22416
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
138 break; |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
139 case WM_CHAR: |
22416
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
140 mplayer_put_key(wParam); |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
141 break; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
142 case WM_LBUTTONDOWN: |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
143 if (!vo_nomouse_input && (vo_fs || (wParam & MK_CONTROL))) { |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
144 mplayer_put_key(MOUSE_BTN0); |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
145 break; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
146 } |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
147 if (!vo_fs) { |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
148 ReleaseCapture(); |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
149 SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0); |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
150 return 0; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
151 } |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
152 break; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
153 case WM_MBUTTONDOWN: |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
154 if (!vo_nomouse_input) |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
155 mplayer_put_key(MOUSE_BTN1); |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
156 break; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
157 case WM_RBUTTONDOWN: |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
158 if (!vo_nomouse_input) |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
159 mplayer_put_key(MOUSE_BTN2); |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
160 break; |
22423 | 161 case WM_MOUSEMOVE: |
31049
b40e41324173
Avoid duplicating mouse-movement command-generation code.
reimar
parents:
31047
diff
changeset
|
162 vo_mouse_movement(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); |
22423 | 163 break; |
22416
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
164 case WM_MOUSEWHEEL: |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
165 if (!vo_nomouse_input) { |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
166 int x = GET_WHEEL_DELTA_WPARAM(wParam); |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
167 if (x > 0) |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
168 mplayer_put_key(MOUSE_BTN3); |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
169 else |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
170 mplayer_put_key(MOUSE_BTN4); |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
171 break; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
172 } |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
173 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28920
diff
changeset
|
174 |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
175 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
|
176 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
177 |
27920 | 178 /** |
179 * \brief Dispatch incoming window events and handle them. | |
180 * | |
181 * This function should be placed inside libvo's function "check_events". | |
182 * | |
183 * Global libvo variables changed: | |
184 * vo_dwidth: new window client area width | |
185 * vo_dheight: new window client area height | |
186 * | |
187 * \return int with these flags possibly set, take care to handle in the right order | |
188 * if it matters in your driver: | |
189 * | |
190 * VO_EVENT_RESIZE = The window was resized. If necessary reinit your | |
191 * driver render context accordingly. | |
192 * VO_EVENT_EXPOSE = The window was exposed. Call e.g. flip_frame() to redraw | |
193 * the window if the movie is paused. | |
194 */ | |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
195 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
|
196 MSG msg; |
17115 | 197 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
|
198 while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { |
22416
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
199 TranslateMessage(&msg); |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
200 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
|
201 } |
22415
c36b8d705d08
Generate resize events when size of -wid window changes.
reimar
parents:
21631
diff
changeset
|
202 if (WinID >= 0) { |
31125
ff79dd5474f8
Handle -wid Window being closed for direct3d and gl vos on Windows.
reimar
parents:
31049
diff
changeset
|
203 BOOL res; |
22415
c36b8d705d08
Generate resize events when size of -wid window changes.
reimar
parents:
21631
diff
changeset
|
204 RECT r; |
31125
ff79dd5474f8
Handle -wid Window being closed for direct3d and gl vos on Windows.
reimar
parents:
31049
diff
changeset
|
205 res = GetClientRect(vo_window, &r); |
ff79dd5474f8
Handle -wid Window being closed for direct3d and gl vos on Windows.
reimar
parents:
31049
diff
changeset
|
206 if (res && (r.right != vo_dwidth || r.bottom != vo_dheight)) { |
28040 | 207 vo_dwidth = r.right; vo_dheight = r.bottom; |
208 event_flags |= VO_EVENT_RESIZE; | |
209 } | |
31125
ff79dd5474f8
Handle -wid Window being closed for direct3d and gl vos on Windows.
reimar
parents:
31049
diff
changeset
|
210 res = GetClientRect(WinID, &r); |
ff79dd5474f8
Handle -wid Window being closed for direct3d and gl vos on Windows.
reimar
parents:
31049
diff
changeset
|
211 if (res && (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
|
212 MoveWindow(vo_window, 0, 0, r.right, r.bottom, FALSE); |
31125
ff79dd5474f8
Handle -wid Window being closed for direct3d and gl vos on Windows.
reimar
parents:
31049
diff
changeset
|
213 if (!IsWindow(WinID)) |
ff79dd5474f8
Handle -wid Window being closed for direct3d and gl vos on Windows.
reimar
parents:
31049
diff
changeset
|
214 // Window has probably been closed, e.g. due to program crash |
ff79dd5474f8
Handle -wid Window being closed for direct3d and gl vos on Windows.
reimar
parents:
31049
diff
changeset
|
215 mplayer_put_key(KEY_CLOSE_WIN); |
22415
c36b8d705d08
Generate resize events when size of -wid window changes.
reimar
parents:
21631
diff
changeset
|
216 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28920
diff
changeset
|
217 |
17115 | 218 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
|
219 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
220 |
18116 | 221 static BOOL CALLBACK mon_enum(HMONITOR hmon, HDC hdc, LPRECT r, LPARAM p) { |
222 // this defaults to the last screen if specified number does not exist | |
223 xinerama_x = r->left; | |
224 xinerama_y = r->top; | |
225 vo_screenwidth = r->right - r->left; | |
226 vo_screenheight = r->bottom - r->top; | |
227 if (mon_cnt == xinerama_screen) | |
228 return FALSE; | |
229 mon_cnt++; | |
230 return TRUE; | |
231 } | |
232 | |
27920 | 233 /** |
234 * \brief Update screen information. | |
235 * | |
236 * This function should be called in libvo's "control" callback | |
237 * with parameter VOCTRL_UPDATE_SCREENINFO. | |
238 * Note that this also enables the new API where geometry and aspect | |
239 * calculations are done in video_out.c:config_video_out | |
240 * | |
241 * Global libvo variables changed: | |
242 * xinerama_x | |
243 * xinerama_y | |
244 * vo_screenwidth | |
245 * vo_screenheight | |
246 */ | |
21631 | 247 void w32_update_xinerama_info(void) { |
18116 | 248 xinerama_x = xinerama_y = 0; |
249 if (xinerama_screen < -1) { | |
250 int tmp; | |
251 xinerama_x = GetSystemMetrics(SM_XVIRTUALSCREEN); | |
252 xinerama_y = GetSystemMetrics(SM_YVIRTUALSCREEN); | |
253 tmp = GetSystemMetrics(SM_CXVIRTUALSCREEN); | |
254 if (tmp) vo_screenwidth = tmp; | |
255 tmp = GetSystemMetrics(SM_CYVIRTUALSCREEN); | |
256 if (tmp) vo_screenheight = tmp; | |
257 } else if (xinerama_screen == -1 && myMonitorFromWindow && myGetMonitorInfo) { | |
258 MONITORINFO mi; | |
259 HMONITOR m = myMonitorFromWindow(vo_window, MONITOR_DEFAULTTOPRIMARY); | |
260 mi.cbSize = sizeof(mi); | |
261 myGetMonitorInfo(m, &mi); | |
262 xinerama_x = mi.rcMonitor.left; | |
263 xinerama_y = mi.rcMonitor.top; | |
264 vo_screenwidth = mi.rcMonitor.right - mi.rcMonitor.left; | |
265 vo_screenheight = mi.rcMonitor.bottom - mi.rcMonitor.top; | |
266 } else if (xinerama_screen > 0 && myEnumDisplayMonitors) { | |
267 mon_cnt = 0; | |
268 myEnumDisplayMonitors(NULL, NULL, mon_enum, 0); | |
269 } | |
270 aspect_save_screenres(vo_screenwidth, vo_screenheight); | |
271 } | |
272 | |
25785
bda4125e24bf
Fix some function types from unspecified to empty argument list
reimar
parents:
25719
diff
changeset
|
273 static void updateScreenProperties(void) { |
14747 | 274 DEVMODE dm; |
275 dm.dmSize = sizeof dm; | |
276 dm.dmDriverExtra = 0; | |
277 dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; | |
278 if (!EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &dm)) { | |
22416
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
279 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
|
280 return; |
14747 | 281 } |
282 | |
283 vo_screenwidth = dm.dmPelsWidth; | |
284 vo_screenheight = dm.dmPelsHeight; | |
285 vo_depthonscreen = dm.dmBitsPerPel; | |
21631 | 286 w32_update_xinerama_info(); |
14747 | 287 } |
288 | |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
289 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
|
290 DEVMODE dm; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
291 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
|
292 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
|
293 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
294 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
|
295 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
|
296 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
|
297 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
|
298 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
299 if (vo_vm) { |
22416
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
300 int bestMode = -1; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
301 int bestScore = INT_MAX; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
302 int i; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
303 for (i = 0; EnumDisplaySettings(0, i, &dm); ++i) { |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
304 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
|
305 if (dm.dmBitsPerPel != vo_depthonscreen) continue; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
306 if (dm.dmPelsWidth < o_dwidth) continue; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
307 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
|
308 |
22416
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
309 if (score < bestScore) { |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
310 bestScore = score; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
311 bestMode = i; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
312 } |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
313 } |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
314 |
22416
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
315 if (bestMode != -1) |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
316 EnumDisplaySettings(0, bestMode, &dm); |
14747 | 317 |
318 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
|
319 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
320 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
321 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
322 static void resetMode(void) { |
14142
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
13787
diff
changeset
|
323 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
|
324 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
|
325 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
326 |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
327 static int createRenderingContext(void) { |
11542 | 328 HWND layer = HWND_NOTOPMOST; |
17006
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
329 RECT r; |
18948
c2aee29c80b6
Do not fiddle (too much) with external (WinID) windows
reimar
parents:
18927
diff
changeset
|
330 if (WinID < 0) { |
17006
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
331 int style = (vo_border && !vo_fs) ? |
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
332 (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
|
333 |
11542 | 334 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
|
335 if (vo_fs) { |
22416
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
336 changeMode(); |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
337 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
|
338 } else { |
22416
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
339 resetMode(); |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
340 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
|
341 } |
14747 | 342 updateScreenProperties(); |
17006
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
343 ShowWindow(vo_window, SW_HIDE); |
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
344 SetWindowLong(vo_window, GWL_STYLE, style); |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
345 if (vo_fs) { |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
346 prev_width = vo_dwidth; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
347 prev_height = vo_dheight; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
348 prev_x = vo_dx; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
349 prev_y = vo_dy; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
350 vo_dwidth = vo_screenwidth; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
351 vo_dheight = vo_screenheight; |
18116 | 352 vo_dx = xinerama_x; |
353 vo_dy = xinerama_y; | |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
354 } else { |
23587
58bd3640c0c2
Hack around some fullscreen issues with gl under Windows
reimar
parents:
22823
diff
changeset
|
355 // make sure there are no "stale" resize events |
58bd3640c0c2
Hack around some fullscreen issues with gl under Windows
reimar
parents:
22823
diff
changeset
|
356 // that would set vo_d* to wrong values |
58bd3640c0c2
Hack around some fullscreen issues with gl under Windows
reimar
parents:
22823
diff
changeset
|
357 vo_w32_check_events(); |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
358 vo_dwidth = prev_width; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
359 vo_dheight = prev_height; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
360 vo_dx = prev_x; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
361 vo_dy = prev_y; |
20657 | 362 // HACK around what probably is a windows focus bug: |
363 // when pressing 'f' on the console, then 'f' again to | |
364 // return to windowed mode, any input into the video | |
365 // window is lost forever. | |
366 SetFocus(vo_window); | |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
367 } |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
368 r.left = vo_dx; |
17006
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
369 r.right = r.left + vo_dwidth; |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
370 r.top = vo_dy; |
17006
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
371 r.bottom = r.top + vo_dheight; |
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
372 AdjustWindowRect(&r, style, 0); |
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
373 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
|
374 } |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
375 return 1; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
376 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
377 |
27920 | 378 /** |
379 * \brief Configure and show window on the screen. | |
380 * | |
381 * This function should be called in libvo's "config" callback. | |
382 * It configures a window and shows it on the screen. | |
383 * | |
384 * Global libvo variables changed: | |
385 * vo_fs | |
386 * vo_vm | |
387 * | |
388 * \return 1 - Success, 0 - Failure | |
389 */ | |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
390 int vo_w32_config(uint32_t width, uint32_t height, uint32_t flags) { |
30467 | 391 // we already have a fully initialized window, so nothing needs to be done |
392 if (flags & VOFLAG_HIDDEN) | |
31126 | 393 return 1; |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
394 // store original size for videomode switching |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
395 o_dwidth = width; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
396 o_dheight = height; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
397 |
28038
174c85faada7
Do not override the vo_dwidth/vo_dheight values in vo_w32_config
reimar
parents:
27941
diff
changeset
|
398 if (WinID < 0) { |
28039 | 399 // the desired size is ignored in wid mode, it always matches the window size. |
400 prev_width = vo_dwidth = width; | |
401 prev_height = vo_dheight = height; | |
402 prev_x = vo_dx; | |
403 prev_y = vo_dy; | |
28038
174c85faada7
Do not override the vo_dwidth/vo_dheight values in vo_w32_config
reimar
parents:
27941
diff
changeset
|
404 } |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
405 |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
406 vo_fs = flags & VOFLAG_FULLSCREEN; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
407 vo_vm = flags & VOFLAG_MODESWITCHING; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
408 return createRenderingContext(); |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
409 } |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
410 |
27920 | 411 /** |
29904
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
412 * \brief return the name of the selected device if it is indepedant |
31127 | 413 * \return pointer to string, must be freed. |
29904
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
414 */ |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
415 static char *get_display_name(void) { |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
416 DISPLAY_DEVICE disp; |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
417 disp.cb = sizeof(disp); |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
418 EnumDisplayDevices(NULL, vo_adapter_num, &disp, 0); |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
419 if (disp.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
420 return NULL; |
31127 | 421 return strdup(disp.DeviceName); |
29904
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
422 } |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
423 |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
424 /** |
27920 | 425 * \brief Initialize w32_common framework. |
426 * | |
427 * The first function that should be called from the w32_common framework. | |
428 * It handles window creation on the screen with proper title and attributes. | |
429 * It also initializes the framework's internal variables. The function should | |
430 * be called after your own preinit initialization and you shouldn't do any | |
431 * window management on your own. | |
432 * | |
433 * Global libvo variables changed: | |
434 * vo_w32_window | |
435 * vo_depthonscreen | |
436 * vo_screenwidth | |
437 * vo_screenheight | |
438 * | |
439 * \return 1 = Success, 0 = Failure | |
440 */ | |
21631 | 441 int vo_w32_init(void) { |
30466
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
442 PIXELFORMATDESCRIPTOR pfd; |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
443 HDC vo_hdc; |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
444 int pf; |
22416
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
445 HICON mplayerIcon = 0; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
446 char exedir[MAX_PATH]; |
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
447 HINSTANCE user32; |
29904
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
448 char *dev; |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
449 |
14142
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
13787
diff
changeset
|
450 if (vo_window) |
22416
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
451 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
|
452 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
453 hInstance = GetModuleHandle(0); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28920
diff
changeset
|
454 |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
455 if (GetModuleFileName(0, exedir, MAX_PATH)) |
22416
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
456 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
|
457 if (!mplayerIcon) |
22416
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
458 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
|
459 |
16226
94bb243636e1
10l, initializers don't work without a declaration :-(
reimar
parents:
16213
diff
changeset
|
460 { |
25944
8a1c062707ff
Do not uselessly erase background, OpenGL will take care of drawing everything.
reimar
parents:
25942
diff
changeset
|
461 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
|
462 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
463 if (!RegisterClassEx(&wcex)) { |
22416
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
464 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
|
465 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
|
466 } |
16226
94bb243636e1
10l, initializers don't work without a declaration :-(
reimar
parents:
16213
diff
changeset
|
467 } |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
468 |
16282
273d33249c25
-wid support for windows. Not well tested, might still behave a bit weird.
reimar
parents:
16226
diff
changeset
|
469 if (WinID >= 0) |
25933
9b395b94d6a7
Hack: Create a child window for Windows OpenGL with -wid, since (esp. nVidia)
reimar
parents:
25918
diff
changeset
|
470 { |
9b395b94d6a7
Hack: Create a child window for Windows OpenGL with -wid, since (esp. nVidia)
reimar
parents:
25918
diff
changeset
|
471 RECT r; |
9b395b94d6a7
Hack: Create a child window for Windows OpenGL with -wid, since (esp. nVidia)
reimar
parents:
25918
diff
changeset
|
472 GetClientRect(WinID, &r); |
9b395b94d6a7
Hack: Create a child window for Windows OpenGL with -wid, since (esp. nVidia)
reimar
parents:
25918
diff
changeset
|
473 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
|
474 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
|
475 WS_CHILD | WS_VISIBLE, |
9b395b94d6a7
Hack: Create a child window for Windows OpenGL with -wid, since (esp. nVidia)
reimar
parents:
25918
diff
changeset
|
476 0, 0, vo_dwidth, vo_dheight, WinID, 0, hInstance, 0); |
27870 | 477 EnableWindow(vo_window, 0); |
25933
9b395b94d6a7
Hack: Create a child window for Windows OpenGL with -wid, since (esp. nVidia)
reimar
parents:
25918
diff
changeset
|
478 } else |
17006
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
479 vo_window = CreateWindowEx(0, classname, classname, |
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
480 vo_border ? (WS_OVERLAPPEDWINDOW | WS_SIZEBOX) : WS_POPUP, |
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
481 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
|
482 if (!vo_window) { |
22416
02783a09e1b3
Whitespace-only cosmetics: get rid of all remaining tabs
reimar
parents:
22415
diff
changeset
|
483 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
|
484 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
|
485 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
486 |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
487 myMonitorFromWindow = NULL; |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
488 myGetMonitorInfo = NULL; |
18116 | 489 myEnumDisplayMonitors = NULL; |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
490 user32 = GetModuleHandle("user32.dll"); |
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
491 if (user32) { |
25787
143989c7a3bf
Avoid some pointer conversion warnings (the code is messy but not wrong)
reimar
parents:
25785
diff
changeset
|
492 myMonitorFromWindow = (void *)GetProcAddress(user32, "MonitorFromWindow"); |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
493 myGetMonitorInfo = GetProcAddress(user32, "GetMonitorInfoA"); |
18116 | 494 myEnumDisplayMonitors = GetProcAddress(user32, "EnumDisplayMonitors"); |
18079
f57317460375
fixes and cleanup for windows fullscreen switching (restore old position,
reimar
parents:
17126
diff
changeset
|
495 } |
29904
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
496 dev_hdc = 0; |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
497 dev = get_display_name(); |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
498 if (dev) dev_hdc = CreateDC(dev, NULL, NULL, NULL); |
31127 | 499 free(dev); |
14747 | 500 updateScreenProperties(); |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
501 |
30466
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
502 vo_hdc = vo_w32_get_dc(vo_window); |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
503 memset(&pfd, 0, sizeof pfd); |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
504 pfd.nSize = sizeof pfd; |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
505 pfd.nVersion = 1; |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
506 pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
507 pfd.iPixelType = PFD_TYPE_RGBA; |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
508 pfd.cColorBits = 24; |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
509 pfd.iLayerType = PFD_MAIN_PLANE; |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
510 pf = ChoosePixelFormat(vo_hdc, &pfd); |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
511 if (!pf) { |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
512 mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to select a valid pixel format!\n"); |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
513 vo_w32_release_dc(vo_window, vo_hdc); |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
514 return 0; |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
515 } |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
516 |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
517 SetPixelFormat(vo_hdc, pf, &pfd); |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
518 vo_w32_release_dc(vo_window, vo_hdc); |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
519 |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
520 mp_msg(MSGT_VO, MSGL_V, "vo: win32: running at %dx%d with depth %d\n", vo_screenwidth, vo_screenheight, vo_depthonscreen); |
cd3f6962fcfd
Set the PixelFormat right after creating the window and set it only once.
reimar
parents:
29904
diff
changeset
|
521 |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
522 return 1; |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
523 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
524 |
27920 | 525 /** |
526 * \brief Toogle fullscreen / windowed mode. | |
527 * | |
528 * Should be called on VOCTRL_FULLSCREEN event. The window is | |
529 * always resized after this call, so the rendering context | |
530 * should be reinitialized with the new dimensions. | |
531 * It is unspecified if vo_check_events will create a resize | |
532 * event in addition or not. | |
533 * | |
534 * Global libvo variables changed: | |
535 * vo_dwidth | |
536 * vo_dheight | |
537 * vo_fs | |
538 */ | |
539 | |
10880
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
540 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
|
541 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
|
542 |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
543 createRenderingContext(); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
544 } |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
545 |
27920 | 546 /** |
547 * \brief Toogle window border attribute. | |
548 * | |
549 * Should be called on VOCTRL_BORDER event. | |
550 * | |
551 * Global libvo variables changed: | |
552 * vo_border | |
553 */ | |
25785
bda4125e24bf
Fix some function types from unspecified to empty argument list
reimar
parents:
25719
diff
changeset
|
554 void vo_w32_border(void) { |
17006
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
555 vo_border = !vo_border; |
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
556 createRenderingContext(); |
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
557 } |
852499addaa8
Enable border toggling for gl and gl2 under windows.
reimar
parents:
16892
diff
changeset
|
558 |
27920 | 559 /** |
560 * \brief Toogle window ontop attribute. | |
561 * | |
562 * Should be called on VOCTRL_ONTOP event. | |
563 * | |
564 * Global libvo variables changed: | |
565 * vo_ontop | |
566 */ | |
11542 | 567 void vo_w32_ontop( void ) |
568 { | |
569 vo_ontop = !vo_ontop; | |
570 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
|
571 createRenderingContext(); |
11542 | 572 } |
573 } | |
574 | |
27920 | 575 /** |
576 * \brief Uninitialize w32_common framework. | |
577 * | |
578 * Should be called last in video driver's uninit function. First release | |
27941 | 579 * anything built on top of the created window e.g. rendering context inside |
27920 | 580 * and call vo_w32_uninit at the end. |
581 */ | |
25785
bda4125e24bf
Fix some function types from unspecified to empty argument list
reimar
parents:
25719
diff
changeset
|
582 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
|
583 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
|
584 resetMode(); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
585 ShowCursor(1); |
ba9557e864c0
vo_gl2 port to win32 patch by Tristan Seligmann <mithrandi-mplayer-dev-eng at mithrandi.za.net>
faust3
parents:
diff
changeset
|
586 vo_depthonscreen = 0; |
29904
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
587 if (dev_hdc) DeleteDC(dev_hdc); |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
588 dev_hdc = 0; |
14142
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
13787
diff
changeset
|
589 DestroyWindow(vo_window); |
f0c1ee83b216
Improving gl2 under windows, moving some functionality to gl_common
reimar
parents:
13787
diff
changeset
|
590 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
|
591 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
|
592 } |
29904
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
593 |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
594 /** |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
595 * \brief get a device context to draw in |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
596 * |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
597 * \param wnd window the DC should belong to if it makes sense |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
598 */ |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
599 HDC vo_w32_get_dc(HWND wnd) { |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
600 if (dev_hdc) return dev_hdc; |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
601 return GetDC(wnd); |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
602 } |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
603 |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
604 /** |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
605 * \brief release a device context |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
606 * |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
607 * \param wnd window the DC probably belongs to |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
608 */ |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
609 void vo_w32_release_dc(HWND wnd, HDC dc) { |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
610 if (dev_hdc) return; |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
611 ReleaseDC(wnd, dc); |
f529a2bb299d
Add support for Windows OpenGL rendering onto a device instead of into a window.
reimar
parents:
29517
diff
changeset
|
612 } |