2009-02-08 03:27:30 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2007-03-04 13:20:51 +00:00
|
|
|
#include <stdio.h>
|
2003-09-19 14:33:51 +00:00
|
|
|
#include <limits.h>
|
|
|
|
#include <windows.h>
|
2007-03-04 13:20:51 +00:00
|
|
|
#include <windowsx.h>
|
2003-09-19 14:33:51 +00:00
|
|
|
|
2004-10-28 01:15:53 +00:00
|
|
|
#include "osdep/keycodes.h"
|
|
|
|
#include "input/input.h"
|
|
|
|
#include "input/mouse.h"
|
|
|
|
#include "mp_msg.h"
|
2003-09-19 14:33:51 +00:00
|
|
|
#include "video_out.h"
|
|
|
|
#include "aspect.h"
|
|
|
|
#include "w32_common.h"
|
2007-03-29 17:16:11 +00:00
|
|
|
#include "mp_fifo.h"
|
2003-09-19 14:33:51 +00:00
|
|
|
|
2007-03-04 13:20:51 +00:00
|
|
|
extern int enable_mouse_movements;
|
2003-09-19 14:33:51 +00:00
|
|
|
|
2006-04-12 20:17:07 +00:00
|
|
|
#ifndef MONITOR_DEFAULTTOPRIMARY
|
|
|
|
#define MONITOR_DEFAULTTOPRIMARY 1
|
|
|
|
#endif
|
|
|
|
|
2008-02-10 19:55:15 +00:00
|
|
|
static const char classname[] = "MPlayer - Media player for Win32";
|
2003-09-19 14:33:51 +00:00
|
|
|
int vo_vm = 0;
|
|
|
|
|
2006-04-12 14:11:26 +00:00
|
|
|
// last non-fullscreen extends
|
2008-02-10 19:58:05 +00:00
|
|
|
static int prev_width;
|
|
|
|
static int prev_height;
|
|
|
|
static int prev_x;
|
|
|
|
static int prev_y;
|
2006-04-12 14:11:26 +00:00
|
|
|
|
2008-02-10 19:58:05 +00:00
|
|
|
static uint32_t o_dwidth;
|
|
|
|
static uint32_t o_dheight;
|
2003-09-19 14:33:51 +00:00
|
|
|
|
|
|
|
static HINSTANCE hInstance;
|
2006-12-17 12:33:09 +00:00
|
|
|
#define vo_window vo_w32_window
|
2004-12-11 16:57:42 +00:00
|
|
|
HWND vo_window = 0;
|
2005-12-06 22:15:03 +00:00
|
|
|
static int event_flags;
|
2006-04-16 13:38:28 +00:00
|
|
|
static int mon_cnt;
|
2003-09-19 14:33:51 +00:00
|
|
|
|
2006-04-12 14:11:26 +00:00
|
|
|
static HMONITOR (WINAPI* myMonitorFromWindow)(HWND, DWORD);
|
|
|
|
static BOOL (WINAPI* myGetMonitorInfo)(HMONITOR, LPMONITORINFO);
|
2006-04-16 13:38:28 +00:00
|
|
|
static BOOL (WINAPI* myEnumDisplayMonitors)(HDC, LPCRECT, MONITORENUMPROC, LPARAM);
|
2006-04-12 14:11:26 +00:00
|
|
|
|
2008-12-20 11:52:11 +00:00
|
|
|
static const struct keymap vk_map[] = {
|
|
|
|
// special keys
|
|
|
|
{VK_ESCAPE, KEY_ESC}, {VK_BACK, KEY_BS}, {VK_TAB, KEY_TAB}, {VK_CONTROL, KEY_CTRL},
|
|
|
|
|
|
|
|
// cursor keys
|
|
|
|
{VK_LEFT, KEY_LEFT}, {VK_UP, KEY_UP}, {VK_RIGHT, KEY_RIGHT}, {VK_DOWN, KEY_DOWN},
|
|
|
|
|
|
|
|
// navigation block
|
|
|
|
{VK_INSERT, KEY_INSERT}, {VK_DELETE, KEY_DELETE}, {VK_HOME, KEY_HOME}, {VK_END, KEY_END},
|
|
|
|
{VK_PRIOR, KEY_PAGE_UP}, {VK_NEXT, KEY_PAGE_DOWN},
|
|
|
|
|
2008-12-30 17:00:11 +00:00
|
|
|
// F-keys
|
|
|
|
{VK_F1, KEY_F+1}, {VK_F2, KEY_F+2}, {VK_F3, KEY_F+3}, {VK_F4, KEY_F+4},
|
|
|
|
{VK_F5, KEY_F+5}, {VK_F6, KEY_F+6}, {VK_F7, KEY_F+7}, {VK_F8, KEY_F+8},
|
|
|
|
{VK_F9, KEY_F+9}, {VK_F10, KEY_F+10}, {VK_F11, KEY_F+11}, {VK_F1, KEY_F+12},
|
|
|
|
// numpad
|
|
|
|
{VK_NUMPAD0, KEY_KP0}, {VK_NUMPAD1, KEY_KP1}, {VK_NUMPAD2, KEY_KP2},
|
|
|
|
{VK_NUMPAD3, KEY_KP3}, {VK_NUMPAD4, KEY_KP4}, {VK_NUMPAD5, KEY_KP5},
|
|
|
|
{VK_NUMPAD6, KEY_KP6}, {VK_NUMPAD7, KEY_KP7}, {VK_NUMPAD8, KEY_KP8},
|
|
|
|
{VK_NUMPAD9, KEY_KP9}, {VK_DECIMAL, KEY_KPDEC},
|
|
|
|
|
2008-12-20 11:52:11 +00:00
|
|
|
{0, 0}
|
|
|
|
};
|
|
|
|
|
2003-09-19 14:33:51 +00:00
|
|
|
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
|
2006-04-12 14:11:26 +00:00
|
|
|
RECT r;
|
|
|
|
POINT p;
|
2008-12-20 11:52:11 +00:00
|
|
|
int mpkey;
|
2003-09-19 14:33:51 +00:00
|
|
|
switch (message) {
|
2008-02-10 19:47:54 +00:00
|
|
|
case WM_ERASEBKGND: // no need to erase background seperately
|
|
|
|
return 1;
|
2007-03-04 10:39:02 +00:00
|
|
|
case WM_PAINT:
|
|
|
|
event_flags |= VO_EVENT_EXPOSE;
|
|
|
|
break;
|
|
|
|
case WM_MOVE:
|
|
|
|
p.x = 0;
|
|
|
|
p.y = 0;
|
|
|
|
ClientToScreen(vo_window, &p);
|
|
|
|
vo_dx = p.x;
|
|
|
|
vo_dy = p.y;
|
|
|
|
break;
|
|
|
|
case WM_SIZE:
|
|
|
|
event_flags |= VO_EVENT_RESIZE;
|
|
|
|
GetClientRect(vo_window, &r);
|
|
|
|
vo_dwidth = r.right;
|
|
|
|
vo_dheight = r.bottom;
|
|
|
|
break;
|
|
|
|
case WM_WINDOWPOSCHANGING:
|
2008-02-02 17:22:07 +00:00
|
|
|
if (vo_keepaspect && !vo_fs) {
|
|
|
|
WINDOWPOS *wpos = lParam;
|
|
|
|
int xborder, yborder;
|
|
|
|
RECT r2;
|
|
|
|
GetClientRect(vo_window, &r);
|
|
|
|
GetWindowRect(vo_window, &r2);
|
|
|
|
xborder = (r2.right - r2.left) - (r.right - r.left);
|
|
|
|
yborder = (r2.bottom - r2.top) - (r.bottom - r.top);
|
|
|
|
wpos->cx -= xborder; wpos->cy -= yborder;
|
|
|
|
aspect_fit(&wpos->cx, &wpos->cy, wpos->cx, wpos->cy);
|
|
|
|
wpos->cx += xborder; wpos->cy += yborder;
|
|
|
|
}
|
2006-07-07 11:14:25 +00:00
|
|
|
return 0;
|
2007-03-04 10:39:02 +00:00
|
|
|
case WM_CLOSE:
|
|
|
|
mplayer_put_key(KEY_CLOSE_WIN);
|
|
|
|
break;
|
2003-09-19 14:33:51 +00:00
|
|
|
case WM_SYSCOMMAND:
|
2007-03-04 10:39:02 +00:00
|
|
|
switch (wParam) {
|
|
|
|
case SC_SCREENSAVE:
|
|
|
|
case SC_MONITORPOWER:
|
|
|
|
mp_msg(MSGT_VO, MSGL_V, "vo: win32: killing screensaver\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
2003-09-19 14:33:51 +00:00
|
|
|
case WM_KEYDOWN:
|
2008-12-20 11:52:11 +00:00
|
|
|
mpkey = lookup_keymap_table(vk_map, wParam);
|
|
|
|
if (mpkey)
|
|
|
|
mplayer_put_key(mpkey);
|
2007-03-04 10:39:02 +00:00
|
|
|
break;
|
2003-09-19 14:33:51 +00:00
|
|
|
case WM_CHAR:
|
2007-03-04 10:39:02 +00:00
|
|
|
mplayer_put_key(wParam);
|
|
|
|
break;
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
if (!vo_nomouse_input && (vo_fs || (wParam & MK_CONTROL))) {
|
|
|
|
mplayer_put_key(MOUSE_BTN0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!vo_fs) {
|
|
|
|
ReleaseCapture();
|
|
|
|
SendMessage(hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
if (!vo_nomouse_input)
|
|
|
|
mplayer_put_key(MOUSE_BTN1);
|
|
|
|
break;
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
if (!vo_nomouse_input)
|
|
|
|
mplayer_put_key(MOUSE_BTN2);
|
|
|
|
break;
|
2007-03-04 13:20:51 +00:00
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
if (enable_mouse_movements) {
|
|
|
|
char cmd_str[40];
|
|
|
|
snprintf(cmd_str, sizeof(cmd_str), "set_mouse_pos %i %i",
|
|
|
|
GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
|
|
|
mp_input_queue_cmd(mp_input_parse_cmd(cmd_str));
|
|
|
|
}
|
|
|
|
break;
|
2007-03-04 10:39:02 +00:00
|
|
|
case WM_MOUSEWHEEL:
|
|
|
|
if (!vo_nomouse_input) {
|
|
|
|
int x = GET_WHEEL_DELTA_WPARAM(wParam);
|
|
|
|
if (x > 0)
|
|
|
|
mplayer_put_key(MOUSE_BTN3);
|
|
|
|
else
|
|
|
|
mplayer_put_key(MOUSE_BTN4);
|
|
|
|
break;
|
|
|
|
}
|
2003-09-19 14:33:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2008-11-18 12:23:23 +00:00
|
|
|
/**
|
|
|
|
* \brief Dispatch incoming window events and handle them.
|
|
|
|
*
|
|
|
|
* This function should be placed inside libvo's function "check_events".
|
|
|
|
*
|
|
|
|
* Global libvo variables changed:
|
|
|
|
* vo_dwidth: new window client area width
|
|
|
|
* vo_dheight: new window client area height
|
|
|
|
*
|
|
|
|
* \return int with these flags possibly set, take care to handle in the right order
|
|
|
|
* if it matters in your driver:
|
|
|
|
*
|
|
|
|
* VO_EVENT_RESIZE = The window was resized. If necessary reinit your
|
|
|
|
* driver render context accordingly.
|
|
|
|
* VO_EVENT_EXPOSE = The window was exposed. Call e.g. flip_frame() to redraw
|
|
|
|
* the window if the movie is paused.
|
|
|
|
*/
|
2003-09-19 14:33:51 +00:00
|
|
|
int vo_w32_check_events(void) {
|
|
|
|
MSG msg;
|
2005-12-06 22:15:03 +00:00
|
|
|
event_flags = 0;
|
2003-09-19 14:33:51 +00:00
|
|
|
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
|
2007-03-04 10:39:02 +00:00
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
2003-09-19 14:33:51 +00:00
|
|
|
}
|
2007-03-04 10:30:55 +00:00
|
|
|
if (WinID >= 0) {
|
|
|
|
RECT r;
|
2008-12-03 10:54:01 +00:00
|
|
|
GetClientRect(vo_window, &r);
|
|
|
|
if (r.right != vo_dwidth || r.bottom != vo_dheight) {
|
|
|
|
vo_dwidth = r.right; vo_dheight = r.bottom;
|
|
|
|
event_flags |= VO_EVENT_RESIZE;
|
|
|
|
}
|
2008-02-09 14:14:35 +00:00
|
|
|
GetClientRect(WinID, &r);
|
2007-03-04 10:30:55 +00:00
|
|
|
if (r.right != vo_dwidth || r.bottom != vo_dheight)
|
2008-02-09 14:14:35 +00:00
|
|
|
MoveWindow(vo_window, 0, 0, r.right, r.bottom, FALSE);
|
2007-03-04 10:30:55 +00:00
|
|
|
}
|
2003-09-19 14:33:51 +00:00
|
|
|
|
2005-12-06 22:15:03 +00:00
|
|
|
return event_flags;
|
2003-09-19 14:33:51 +00:00
|
|
|
}
|
|
|
|
|
2006-04-16 13:38:28 +00:00
|
|
|
static BOOL CALLBACK mon_enum(HMONITOR hmon, HDC hdc, LPRECT r, LPARAM p) {
|
|
|
|
// this defaults to the last screen if specified number does not exist
|
|
|
|
xinerama_x = r->left;
|
|
|
|
xinerama_y = r->top;
|
|
|
|
vo_screenwidth = r->right - r->left;
|
|
|
|
vo_screenheight = r->bottom - r->top;
|
|
|
|
if (mon_cnt == xinerama_screen)
|
|
|
|
return FALSE;
|
|
|
|
mon_cnt++;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-11-18 12:23:23 +00:00
|
|
|
/**
|
|
|
|
* \brief Update screen information.
|
|
|
|
*
|
|
|
|
* This function should be called in libvo's "control" callback
|
|
|
|
* with parameter VOCTRL_UPDATE_SCREENINFO.
|
|
|
|
* Note that this also enables the new API where geometry and aspect
|
|
|
|
* calculations are done in video_out.c:config_video_out
|
|
|
|
*
|
|
|
|
* Global libvo variables changed:
|
|
|
|
* xinerama_x
|
|
|
|
* xinerama_y
|
|
|
|
* vo_screenwidth
|
|
|
|
* vo_screenheight
|
|
|
|
*/
|
2006-12-17 12:33:09 +00:00
|
|
|
void w32_update_xinerama_info(void) {
|
2006-04-16 13:38:28 +00:00
|
|
|
xinerama_x = xinerama_y = 0;
|
|
|
|
if (xinerama_screen < -1) {
|
|
|
|
int tmp;
|
|
|
|
xinerama_x = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
|
|
|
xinerama_y = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
|
|
|
tmp = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
|
|
|
if (tmp) vo_screenwidth = tmp;
|
|
|
|
tmp = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
|
|
|
if (tmp) vo_screenheight = tmp;
|
|
|
|
} else if (xinerama_screen == -1 && myMonitorFromWindow && myGetMonitorInfo) {
|
|
|
|
MONITORINFO mi;
|
|
|
|
HMONITOR m = myMonitorFromWindow(vo_window, MONITOR_DEFAULTTOPRIMARY);
|
|
|
|
mi.cbSize = sizeof(mi);
|
|
|
|
myGetMonitorInfo(m, &mi);
|
|
|
|
xinerama_x = mi.rcMonitor.left;
|
|
|
|
xinerama_y = mi.rcMonitor.top;
|
|
|
|
vo_screenwidth = mi.rcMonitor.right - mi.rcMonitor.left;
|
|
|
|
vo_screenheight = mi.rcMonitor.bottom - mi.rcMonitor.top;
|
|
|
|
} else if (xinerama_screen > 0 && myEnumDisplayMonitors) {
|
|
|
|
mon_cnt = 0;
|
|
|
|
myEnumDisplayMonitors(NULL, NULL, mon_enum, 0);
|
|
|
|
}
|
|
|
|
aspect_save_screenres(vo_screenwidth, vo_screenheight);
|
|
|
|
}
|
|
|
|
|
2008-01-20 09:40:15 +00:00
|
|
|
static void updateScreenProperties(void) {
|
2005-02-21 14:44:39 +00:00
|
|
|
DEVMODE dm;
|
|
|
|
dm.dmSize = sizeof dm;
|
|
|
|
dm.dmDriverExtra = 0;
|
|
|
|
dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
|
|
|
if (!EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &dm)) {
|
2007-03-04 10:39:02 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to enumerate display settings!\n");
|
|
|
|
return;
|
2005-02-21 14:44:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vo_screenwidth = dm.dmPelsWidth;
|
|
|
|
vo_screenheight = dm.dmPelsHeight;
|
|
|
|
vo_depthonscreen = dm.dmBitsPerPel;
|
2006-12-17 12:33:09 +00:00
|
|
|
w32_update_xinerama_info();
|
2005-02-21 14:44:39 +00:00
|
|
|
}
|
|
|
|
|
2003-09-19 14:33:51 +00:00
|
|
|
static void changeMode(void) {
|
|
|
|
DEVMODE dm;
|
|
|
|
dm.dmSize = sizeof dm;
|
|
|
|
dm.dmDriverExtra = 0;
|
|
|
|
|
|
|
|
dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
|
|
|
dm.dmBitsPerPel = vo_depthonscreen;
|
|
|
|
dm.dmPelsWidth = vo_screenwidth;
|
|
|
|
dm.dmPelsHeight = vo_screenheight;
|
|
|
|
|
|
|
|
if (vo_vm) {
|
2007-03-04 10:39:02 +00:00
|
|
|
int bestMode = -1;
|
|
|
|
int bestScore = INT_MAX;
|
|
|
|
int i;
|
|
|
|
for (i = 0; EnumDisplaySettings(0, i, &dm); ++i) {
|
|
|
|
int score = (dm.dmPelsWidth - o_dwidth) * (dm.dmPelsHeight - o_dheight);
|
|
|
|
if (dm.dmBitsPerPel != vo_depthonscreen) continue;
|
|
|
|
if (dm.dmPelsWidth < o_dwidth) continue;
|
|
|
|
if (dm.dmPelsHeight < o_dheight) continue;
|
|
|
|
|
|
|
|
if (score < bestScore) {
|
|
|
|
bestScore = score;
|
|
|
|
bestMode = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bestMode != -1)
|
|
|
|
EnumDisplaySettings(0, bestMode, &dm);
|
2003-09-19 14:33:51 +00:00
|
|
|
|
|
|
|
ChangeDisplaySettings(&dm, CDS_FULLSCREEN);
|
2005-02-21 14:44:39 +00:00
|
|
|
}
|
2003-09-19 14:33:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void resetMode(void) {
|
2004-12-11 16:57:42 +00:00
|
|
|
if (vo_vm)
|
2003-09-19 14:33:51 +00:00
|
|
|
ChangeDisplaySettings(0, 0);
|
|
|
|
}
|
|
|
|
|
2006-04-12 14:11:26 +00:00
|
|
|
static int createRenderingContext(void) {
|
2003-11-30 16:36:10 +00:00
|
|
|
HWND layer = HWND_NOTOPMOST;
|
2005-08-14 10:30:18 +00:00
|
|
|
PIXELFORMATDESCRIPTOR pfd;
|
2007-09-03 08:44:36 +00:00
|
|
|
HDC vo_hdc = GetDC(vo_window);
|
2005-11-17 20:49:46 +00:00
|
|
|
RECT r;
|
2005-08-14 10:30:18 +00:00
|
|
|
int pf;
|
2006-07-08 14:57:25 +00:00
|
|
|
if (WinID < 0) {
|
2005-11-17 20:49:46 +00:00
|
|
|
int style = (vo_border && !vo_fs) ?
|
|
|
|
(WS_OVERLAPPEDWINDOW | WS_SIZEBOX) : WS_POPUP;
|
2003-09-19 14:33:51 +00:00
|
|
|
|
2003-11-30 16:36:10 +00:00
|
|
|
if (vo_fs || vo_ontop) layer = HWND_TOPMOST;
|
2003-09-19 14:33:51 +00:00
|
|
|
if (vo_fs) {
|
2007-03-04 10:39:02 +00:00
|
|
|
changeMode();
|
|
|
|
while (ShowCursor(0) >= 0) /**/ ;
|
2003-09-19 14:33:51 +00:00
|
|
|
} else {
|
2007-03-04 10:39:02 +00:00
|
|
|
resetMode();
|
|
|
|
while (ShowCursor(1) < 0) /**/ ;
|
2003-09-19 14:33:51 +00:00
|
|
|
}
|
2005-02-21 14:44:39 +00:00
|
|
|
updateScreenProperties();
|
2005-11-17 20:49:46 +00:00
|
|
|
ShowWindow(vo_window, SW_HIDE);
|
|
|
|
SetWindowLong(vo_window, GWL_STYLE, style);
|
2006-04-12 14:11:26 +00:00
|
|
|
if (vo_fs) {
|
|
|
|
prev_width = vo_dwidth;
|
|
|
|
prev_height = vo_dheight;
|
|
|
|
prev_x = vo_dx;
|
|
|
|
prev_y = vo_dy;
|
|
|
|
vo_dwidth = vo_screenwidth;
|
|
|
|
vo_dheight = vo_screenheight;
|
2006-04-16 13:38:28 +00:00
|
|
|
vo_dx = xinerama_x;
|
|
|
|
vo_dy = xinerama_y;
|
2006-04-12 14:11:26 +00:00
|
|
|
} else {
|
2007-06-22 22:06:58 +00:00
|
|
|
// make sure there are no "stale" resize events
|
|
|
|
// that would set vo_d* to wrong values
|
|
|
|
vo_w32_check_events();
|
2006-04-12 14:11:26 +00:00
|
|
|
vo_dwidth = prev_width;
|
|
|
|
vo_dheight = prev_height;
|
|
|
|
vo_dx = prev_x;
|
|
|
|
vo_dy = prev_y;
|
2006-11-04 21:44:53 +00:00
|
|
|
// HACK around what probably is a windows focus bug:
|
|
|
|
// when pressing 'f' on the console, then 'f' again to
|
|
|
|
// return to windowed mode, any input into the video
|
|
|
|
// window is lost forever.
|
|
|
|
SetFocus(vo_window);
|
2006-04-12 14:11:26 +00:00
|
|
|
}
|
|
|
|
r.left = vo_dx;
|
2005-11-17 20:49:46 +00:00
|
|
|
r.right = r.left + vo_dwidth;
|
2006-04-12 14:11:26 +00:00
|
|
|
r.top = vo_dy;
|
2005-11-17 20:49:46 +00:00
|
|
|
r.bottom = r.top + vo_dheight;
|
|
|
|
AdjustWindowRect(&r, style, 0);
|
|
|
|
SetWindowPos(vo_window, layer, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_SHOWWINDOW);
|
2006-07-08 14:57:25 +00:00
|
|
|
}
|
2003-09-19 14:33:51 +00:00
|
|
|
|
|
|
|
memset(&pfd, 0, sizeof pfd);
|
|
|
|
pfd.nSize = sizeof pfd;
|
|
|
|
pfd.nVersion = 1;
|
|
|
|
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
|
|
|
|
pfd.iPixelType = PFD_TYPE_RGBA;
|
|
|
|
pfd.cColorBits = 24;
|
|
|
|
pfd.iLayerType = PFD_MAIN_PLANE;
|
2005-08-14 10:30:18 +00:00
|
|
|
pf = ChoosePixelFormat(vo_hdc, &pfd);
|
2003-09-19 14:33:51 +00:00
|
|
|
if (!pf) {
|
2007-03-04 10:39:02 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to select a valid pixel format!\n");
|
2007-09-03 13:18:26 +00:00
|
|
|
ReleaseDC(vo_window, vo_hdc);
|
2007-03-04 10:39:02 +00:00
|
|
|
return 0;
|
2003-09-19 14:33:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SetPixelFormat(vo_hdc, pf, &pfd);
|
|
|
|
|
|
|
|
mp_msg(MSGT_VO, MSGL_V, "vo: win32: running at %dx%d with depth %d\n", vo_screenwidth, vo_screenheight, vo_depthonscreen);
|
|
|
|
|
2007-09-03 13:18:26 +00:00
|
|
|
ReleaseDC(vo_window, vo_hdc);
|
2003-09-19 14:33:51 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-11-18 12:23:23 +00:00
|
|
|
/**
|
|
|
|
* \brief Configure and show window on the screen.
|
|
|
|
*
|
|
|
|
* This function should be called in libvo's "config" callback.
|
|
|
|
* It configures a window and shows it on the screen.
|
|
|
|
*
|
|
|
|
* Global libvo variables changed:
|
|
|
|
* vo_fs
|
|
|
|
* vo_vm
|
|
|
|
*
|
|
|
|
* \return 1 - Success, 0 - Failure
|
|
|
|
*/
|
2006-04-12 14:11:26 +00:00
|
|
|
int vo_w32_config(uint32_t width, uint32_t height, uint32_t flags) {
|
|
|
|
// store original size for videomode switching
|
|
|
|
o_dwidth = width;
|
|
|
|
o_dheight = height;
|
|
|
|
|
2008-12-03 10:38:50 +00:00
|
|
|
if (WinID < 0) {
|
2008-12-03 10:42:53 +00:00
|
|
|
// the desired size is ignored in wid mode, it always matches the window size.
|
|
|
|
prev_width = vo_dwidth = width;
|
|
|
|
prev_height = vo_dheight = height;
|
|
|
|
prev_x = vo_dx;
|
|
|
|
prev_y = vo_dy;
|
2008-12-03 10:38:50 +00:00
|
|
|
}
|
2006-04-12 14:11:26 +00:00
|
|
|
|
|
|
|
vo_fs = flags & VOFLAG_FULLSCREEN;
|
|
|
|
vo_vm = flags & VOFLAG_MODESWITCHING;
|
|
|
|
return createRenderingContext();
|
|
|
|
}
|
|
|
|
|
2008-11-18 12:23:23 +00:00
|
|
|
/**
|
|
|
|
* \brief Initialize w32_common framework.
|
|
|
|
*
|
|
|
|
* The first function that should be called from the w32_common framework.
|
|
|
|
* It handles window creation on the screen with proper title and attributes.
|
|
|
|
* It also initializes the framework's internal variables. The function should
|
|
|
|
* be called after your own preinit initialization and you shouldn't do any
|
|
|
|
* window management on your own.
|
|
|
|
*
|
|
|
|
* Global libvo variables changed:
|
|
|
|
* vo_w32_window
|
|
|
|
* vo_depthonscreen
|
|
|
|
* vo_screenwidth
|
|
|
|
* vo_screenheight
|
|
|
|
*
|
|
|
|
* \return 1 = Success, 0 = Failure
|
|
|
|
*/
|
2006-12-17 12:33:09 +00:00
|
|
|
int vo_w32_init(void) {
|
2007-03-04 10:39:02 +00:00
|
|
|
HICON mplayerIcon = 0;
|
|
|
|
char exedir[MAX_PATH];
|
|
|
|
HINSTANCE user32;
|
2003-09-19 14:33:51 +00:00
|
|
|
|
2004-12-11 16:57:42 +00:00
|
|
|
if (vo_window)
|
2007-03-04 10:39:02 +00:00
|
|
|
return 1;
|
2003-09-19 14:33:51 +00:00
|
|
|
|
|
|
|
hInstance = GetModuleHandle(0);
|
|
|
|
|
|
|
|
if (GetModuleFileName(0, exedir, MAX_PATH))
|
2007-03-04 10:39:02 +00:00
|
|
|
mplayerIcon = ExtractIcon(hInstance, exedir, 0);
|
2003-09-19 14:33:51 +00:00
|
|
|
if (!mplayerIcon)
|
2007-03-04 10:39:02 +00:00
|
|
|
mplayerIcon = LoadIcon(0, IDI_APPLICATION);
|
2003-09-19 14:33:51 +00:00
|
|
|
|
2005-08-14 23:16:17 +00:00
|
|
|
{
|
2008-02-10 19:47:54 +00:00
|
|
|
WNDCLASSEX wcex = { sizeof wcex, CS_OWNDC | CS_DBLCLKS, WndProc, 0, 0, hInstance, mplayerIcon, LoadCursor(0, IDC_ARROW), NULL, 0, classname, mplayerIcon };
|
2003-09-19 14:33:51 +00:00
|
|
|
|
|
|
|
if (!RegisterClassEx(&wcex)) {
|
2007-03-04 10:39:02 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to register window class!\n");
|
|
|
|
return 0;
|
2003-09-19 14:33:51 +00:00
|
|
|
}
|
2005-08-14 23:16:17 +00:00
|
|
|
}
|
2003-09-19 14:33:51 +00:00
|
|
|
|
2005-08-21 09:59:45 +00:00
|
|
|
if (WinID >= 0)
|
2008-02-09 14:14:35 +00:00
|
|
|
{
|
|
|
|
RECT r;
|
|
|
|
GetClientRect(WinID, &r);
|
|
|
|
vo_dwidth = r.right; vo_dheight = r.bottom;
|
2008-02-09 14:47:10 +00:00
|
|
|
vo_window = CreateWindowEx(WS_EX_NOPARENTNOTIFY, classname, classname,
|
2008-02-09 14:14:35 +00:00
|
|
|
WS_CHILD | WS_VISIBLE,
|
|
|
|
0, 0, vo_dwidth, vo_dheight, WinID, 0, hInstance, 0);
|
2008-11-11 19:21:36 +00:00
|
|
|
EnableWindow(vo_window, 0);
|
2008-02-09 14:14:35 +00:00
|
|
|
} else
|
2005-11-17 20:49:46 +00:00
|
|
|
vo_window = CreateWindowEx(0, classname, classname,
|
|
|
|
vo_border ? (WS_OVERLAPPEDWINDOW | WS_SIZEBOX) : WS_POPUP,
|
|
|
|
CW_USEDEFAULT, 0, 100, 100, 0, 0, hInstance, 0);
|
2004-12-11 16:57:42 +00:00
|
|
|
if (!vo_window) {
|
2007-03-04 10:39:02 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_ERR, "vo: win32: unable to create window!\n");
|
|
|
|
return 0;
|
2003-09-19 14:33:51 +00:00
|
|
|
}
|
|
|
|
|
2006-04-12 14:11:26 +00:00
|
|
|
myMonitorFromWindow = NULL;
|
|
|
|
myGetMonitorInfo = NULL;
|
2006-04-16 13:38:28 +00:00
|
|
|
myEnumDisplayMonitors = NULL;
|
2006-04-12 14:11:26 +00:00
|
|
|
user32 = GetModuleHandle("user32.dll");
|
|
|
|
if (user32) {
|
2008-01-20 09:50:50 +00:00
|
|
|
myMonitorFromWindow = (void *)GetProcAddress(user32, "MonitorFromWindow");
|
2006-04-12 14:11:26 +00:00
|
|
|
myGetMonitorInfo = GetProcAddress(user32, "GetMonitorInfoA");
|
2006-04-16 13:38:28 +00:00
|
|
|
myEnumDisplayMonitors = GetProcAddress(user32, "EnumDisplayMonitors");
|
2006-04-12 14:11:26 +00:00
|
|
|
}
|
2005-02-21 14:44:39 +00:00
|
|
|
updateScreenProperties();
|
2003-09-19 14:33:51 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-11-18 12:23:23 +00:00
|
|
|
/**
|
|
|
|
* \brief Toogle fullscreen / windowed mode.
|
|
|
|
*
|
|
|
|
* Should be called on VOCTRL_FULLSCREEN event. The window is
|
|
|
|
* always resized after this call, so the rendering context
|
|
|
|
* should be reinitialized with the new dimensions.
|
|
|
|
* It is unspecified if vo_check_events will create a resize
|
|
|
|
* event in addition or not.
|
|
|
|
*
|
|
|
|
* Global libvo variables changed:
|
|
|
|
* vo_dwidth
|
|
|
|
* vo_dheight
|
|
|
|
* vo_fs
|
|
|
|
*/
|
|
|
|
|
2003-09-19 14:33:51 +00:00
|
|
|
void vo_w32_fullscreen(void) {
|
|
|
|
vo_fs = !vo_fs;
|
|
|
|
|
|
|
|
createRenderingContext();
|
|
|
|
}
|
|
|
|
|
2008-11-18 12:23:23 +00:00
|
|
|
/**
|
|
|
|
* \brief Toogle window border attribute.
|
|
|
|
*
|
|
|
|
* Should be called on VOCTRL_BORDER event.
|
|
|
|
*
|
|
|
|
* Global libvo variables changed:
|
|
|
|
* vo_border
|
|
|
|
*/
|
2008-01-20 09:40:15 +00:00
|
|
|
void vo_w32_border(void) {
|
2005-11-17 20:49:46 +00:00
|
|
|
vo_border = !vo_border;
|
|
|
|
createRenderingContext();
|
|
|
|
}
|
|
|
|
|
2008-11-18 12:23:23 +00:00
|
|
|
/**
|
|
|
|
* \brief Toogle window ontop attribute.
|
|
|
|
*
|
|
|
|
* Should be called on VOCTRL_ONTOP event.
|
|
|
|
*
|
|
|
|
* Global libvo variables changed:
|
|
|
|
* vo_ontop
|
|
|
|
*/
|
2003-11-30 16:36:10 +00:00
|
|
|
void vo_w32_ontop( void )
|
|
|
|
{
|
|
|
|
vo_ontop = !vo_ontop;
|
|
|
|
if (!vo_fs) {
|
2008-01-13 21:01:30 +00:00
|
|
|
createRenderingContext();
|
2003-11-30 16:36:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-18 12:23:23 +00:00
|
|
|
/**
|
|
|
|
* \brief Uninitialize w32_common framework.
|
|
|
|
*
|
|
|
|
* Should be called last in video driver's uninit function. First release
|
2008-11-21 19:32:19 +00:00
|
|
|
* anything built on top of the created window e.g. rendering context inside
|
2008-11-18 12:23:23 +00:00
|
|
|
* and call vo_w32_uninit at the end.
|
|
|
|
*/
|
2008-01-20 09:40:15 +00:00
|
|
|
void vo_w32_uninit(void) {
|
2003-09-19 14:33:51 +00:00
|
|
|
mp_msg(MSGT_VO, MSGL_V, "vo: win32: uninit\n");
|
|
|
|
resetMode();
|
|
|
|
ShowCursor(1);
|
|
|
|
vo_depthonscreen = 0;
|
2004-12-11 16:57:42 +00:00
|
|
|
DestroyWindow(vo_window);
|
|
|
|
vo_window = 0;
|
2003-11-16 14:37:42 +00:00
|
|
|
UnregisterClass(classname, 0);
|
2003-09-19 14:33:51 +00:00
|
|
|
}
|