| 1 | /*      User-based primary surface driver | 
|---|
| 2 | * | 
|---|
| 3 | * Copyright 2000 TransGaming Technologies Inc. | 
|---|
| 4 | * | 
|---|
| 5 | * This library is free software; you can redistribute it and/or | 
|---|
| 6 | * modify it under the terms of the GNU Lesser General Public | 
|---|
| 7 | * License as published by the Free Software Foundation; either | 
|---|
| 8 | * version 2.1 of the License, or (at your option) any later version. | 
|---|
| 9 | * | 
|---|
| 10 | * This library is distributed in the hope that it will be useful, | 
|---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
|---|
| 13 | * Lesser General Public License for more details. | 
|---|
| 14 | * | 
|---|
| 15 | * You should have received a copy of the GNU Lesser General Public | 
|---|
| 16 | * License along with this library; if not, write to the Free Software | 
|---|
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | 
|---|
| 18 | */ | 
|---|
| 19 |  | 
|---|
| 20 | #include <windows.h> | 
|---|
| 21 |  | 
|---|
| 22 | #include <assert.h> | 
|---|
| 23 | #include <stdlib.h> | 
|---|
| 24 | #include <string.h> | 
|---|
| 25 |  | 
|---|
| 26 | #include "winerror.h" | 
|---|
| 27 |  | 
|---|
| 28 | #include "wine/debug.h" | 
|---|
| 29 |  | 
|---|
| 30 | WINE_DEFAULT_DEBUG_CHANNEL(ddraw); | 
|---|
| 31 |  | 
|---|
| 32 | static LRESULT WINAPI DirectDrawSurface_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); | 
|---|
| 33 |  | 
|---|
| 34 | void DirectDrawSurface_RegisterClass(void) | 
|---|
| 35 | { | 
|---|
| 36 | WNDCLASSA wc; | 
|---|
| 37 | memset(&wc, 0, sizeof(wc)); | 
|---|
| 38 | wc.lpfnWndProc = DirectDrawSurface_WndProc; | 
|---|
| 39 | wc.cbWndExtra  = sizeof(DWORD); | 
|---|
| 40 | wc.hCursor     = (HCURSOR)IDC_ARROWA; | 
|---|
| 41 | wc.lpszClassName = "WINE_DDRAW"; | 
|---|
| 42 | RegisterClassA(&wc); | 
|---|
| 43 | } | 
|---|
| 44 |  | 
|---|
| 45 | void DirectDrawSurface_UnregisterClass(void) | 
|---|
| 46 | { | 
|---|
| 47 | UnregisterClassA("WINE_DDRAW", 0); | 
|---|
| 48 | } | 
|---|
| 49 |  | 
|---|
| 50 | static LRESULT WINAPI DirectDrawSurface_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 51 | { | 
|---|
| 52 | LRESULT ret; | 
|---|
| 53 |  | 
|---|
| 54 | HWND window = (HWND)GetWindowLongA(hwnd, 0); | 
|---|
| 55 |  | 
|---|
| 56 | if(window) { | 
|---|
| 57 | switch (msg) { | 
|---|
| 58 | case WM_DESTROY: | 
|---|
| 59 | case WM_NCDESTROY: | 
|---|
| 60 | case WM_SHOWWINDOW: | 
|---|
| 61 | case WM_WINDOWPOSCHANGING: | 
|---|
| 62 | case WM_WINDOWPOSCHANGED: | 
|---|
| 63 | case WM_SIZE: | 
|---|
| 64 | case WM_MOVE: | 
|---|
| 65 | case WM_ERASEBKGND: | 
|---|
| 66 | case WM_SYNCPAINT: | 
|---|
| 67 | /* since we're pretending fullscreen, | 
|---|
| 68 | * let's not pass these on to the app */ | 
|---|
| 69 | ret = DefWindowProcA(hwnd, msg, wParam, lParam); | 
|---|
| 70 | break; | 
|---|
| 71 | case WM_NCHITTEST: | 
|---|
| 72 | ret = HTCLIENT; | 
|---|
| 73 | break; | 
|---|
| 74 | case WM_MOUSEACTIVATE: | 
|---|
| 75 | ret = MA_NOACTIVATE; | 
|---|
| 76 | break; | 
|---|
| 77 | case WM_PAINT: | 
|---|
| 78 | { | 
|---|
| 79 | PAINTSTRUCT ps; | 
|---|
| 80 | HDC dc; | 
|---|
| 81 | dc = BeginPaint(hwnd, &ps); | 
|---|
| 82 | /* call User_copy_to_screen? */ | 
|---|
| 83 | EndPaint(hwnd, &ps); | 
|---|
| 84 | ret = 0; | 
|---|
| 85 | } | 
|---|
| 86 | break; | 
|---|
| 87 | default: | 
|---|
| 88 | ret = window ? SendMessageA(window, msg, wParam, lParam) | 
|---|
| 89 | : DefWindowProcA(hwnd, msg, wParam, lParam); | 
|---|
| 90 | } | 
|---|
| 91 | } else { | 
|---|
| 92 | if (msg == WM_CREATE) { | 
|---|
| 93 | CREATESTRUCTA *cs = (CREATESTRUCTA *)lParam; | 
|---|
| 94 | HWND hwndOwner = (HWND)cs->lpCreateParams; | 
|---|
| 95 | SetWindowLongA(hwnd, 0, (LONG)hwndOwner); | 
|---|
| 96 | } | 
|---|
| 97 | ret = DefWindowProcA(hwnd, msg, wParam, lParam); | 
|---|
| 98 | } | 
|---|
| 99 | return ret; | 
|---|
| 100 | } | 
|---|
| 101 |  | 
|---|
| 102 | HWND DirectDrawSurface_CreateWindow(DWORD dwWidth, DWORD dwHeight, HWND hwndOwner) | 
|---|
| 103 | { | 
|---|
| 104 | HWND hwnd; | 
|---|
| 105 |  | 
|---|
| 106 | hwnd = CreateWindowExA(WS_EX_TOPMOST | WS_EX_LAYERED | WS_EX_TRANSPARENT, | 
|---|
| 107 | "WINE_DDRAW", "DirectDraw", | 
|---|
| 108 | WS_POPUP, 0, 0, dwWidth, dwHeight, | 
|---|
| 109 | GetDesktopWindow(), 0, 0, (LPVOID)hwndOwner); | 
|---|
| 110 |  | 
|---|
| 111 | SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, | 
|---|
| 112 | SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE| | 
|---|
| 113 | SWP_NOREDRAW|SWP_NOSENDCHANGING|SWP_NOSIZE|SWP_SHOWWINDOW); | 
|---|
| 114 | UpdateWindow(hwnd); | 
|---|
| 115 |  | 
|---|
| 116 | return hwnd; | 
|---|
| 117 | } | 
|---|