/*
* Directx v2 or later DirectDraw interface
*
* Copyright (c) 2002 - 2005 Sascha Sommer <saschasommer@freenet.de>
*
* 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.
*/
#include <windows.h>
#include <windowsx.h>
#include <ddraw.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "config.h"
#include "video_out.h"
#include "video_out_internal.h"
#include "fastmemcpy.h"
#include "input/input.h"
#include "osdep/keycodes.h"
#include "input/mouse.h"
#include "mp_msg.h"
#include "aspect.h"
#include "geometry.h"
#include "mp_fifo.h"
#include "sub.h"
#ifdef CONFIG_GUI
#include "gui/interface.h"
#endif
#ifndef WM_XBUTTONDOWN
# define WM_XBUTTONDOWN 0x020B
# define WM_XBUTTONUP 0x020C
# define WM_XBUTTONDBLCLK 0x020D
#endif
#define WNDCLASSNAME_WINDOWED "MPlayer - The Movie Player"
#define WNDCLASSNAME_FULLSCREEN "MPlayer - Fullscreen"
#define WNDSTYLE WS_OVERLAPPEDWINDOW|WS_SIZEBOX
static LPDIRECTDRAWCOLORCONTROL g_cc = NULL; //color control interface
static LPDIRECTDRAW7 g_lpdd = NULL; //DirectDraw Object
static LPDIRECTDRAWSURFACE7 g_lpddsPrimary = NULL; //Primary Surface: viewport through the Desktop
static LPDIRECTDRAWSURFACE7 g_lpddsOverlay = NULL; //Overlay Surface
static LPDIRECTDRAWSURFACE7 g_lpddsBack = NULL; //Back surface
static LPDIRECTDRAWCLIPPER g_lpddclipper; //clipper object, can only be used without overlay
static DDSURFACEDESC2 ddsdsf; //surface descripiton needed for locking
static HINSTANCE hddraw_dll; //handle to ddraw.dll
static RECT rd; //rect of our stretched image
static RECT rs; //rect of our source image
static HWND hWnd=NULL; //handle to the window
static HWND hWndFS=NULL; //fullscreen window
static HBRUSH colorbrush = NULL; // Handle to colorkey brush
static HBRUSH blackbrush = NULL; // Handle to black brush
static HICON mplayericon = NULL; // Handle to mplayer icon
static HCURSOR mplayercursor = NULL; // Handle to mplayer cursor
static uint32_t image_width, image_height; //image width and height
static uint32_t d_image_width, d_image_height; //image width and height zoomed
static uint8_t *image=NULL; //image data
static void* tmp_image = NULL;
static uint32_t image_format=0; //image format
static uint32_t primary_image_format;
static uint32_t vm_height=0;
static uint32_t vm_width=0;
static uint32_t vm_bpp=0;
static uint32_t dstride; //surface stride
static uint32_t nooverlay = 0; //NonOverlay mode
static DWORD destcolorkey; //colorkey for our surface
static COLORREF windowcolor = RGB(0,0,16); //windowcolor == colorkey
static int adapter_count=0;
static GUID selected_guid;
static GUID *selected_guid_ptr = NULL;
static RECT monitor_rect; //monitor coordinates
static float window_aspect;
static BOOL (WINAPI* myGetMonitorInfo)(HMONITOR, LPMONITORINFO) = NULL;
static RECT last_rect = {0xDEADC0DE, 0xDEADC0DE, 0xDEADC0DE, 0xDEADC0DE};
extern int vidmode;
/*****************************************************************************
* DirectDraw GUIDs.
* Defining them here allows us to get rid of the dxguid library during
* the linking stage.
*****************************************************************************/
const GUID IID_IDirectDraw7 =
{
0x15e65ec0,0x3b9c,0x11d2,{0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b}
};
const GUID IID_ID
|