1706f2543Smrg/* 2706f2543Smrg *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved. 3706f2543Smrg * 4706f2543Smrg *Permission is hereby granted, free of charge, to any person obtaining 5706f2543Smrg * a copy of this software and associated documentation files (the 6706f2543Smrg *"Software"), to deal in the Software without restriction, including 7706f2543Smrg *without limitation the rights to use, copy, modify, merge, publish, 8706f2543Smrg *distribute, sublicense, and/or sell copies of the Software, and to 9706f2543Smrg *permit persons to whom the Software is furnished to do so, subject to 10706f2543Smrg *the following conditions: 11706f2543Smrg * 12706f2543Smrg *The above copyright notice and this permission notice shall be 13706f2543Smrg *included in all copies or substantial portions of the Software. 14706f2543Smrg * 15706f2543Smrg *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16706f2543Smrg *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17706f2543Smrg *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18706f2543Smrg *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR 19706f2543Smrg *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 20706f2543Smrg *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21706f2543Smrg *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22706f2543Smrg * 23706f2543Smrg *Except as contained in this notice, the name of Harold L Hunt II 24706f2543Smrg *shall not be used in advertising or otherwise to promote the sale, use 25706f2543Smrg *or other dealings in this Software without prior written authorization 26706f2543Smrg *from Harold L Hunt II. 27706f2543Smrg * 28706f2543Smrg * Authors: Harold L Hunt II 29706f2543Smrg */ 30706f2543Smrg 31706f2543Smrg#ifdef HAVE_XWIN_CONFIG_H 32706f2543Smrg#include <xwin-config.h> 33706f2543Smrg#endif 34706f2543Smrg#include "win.h" 35706f2543Smrg 36706f2543Smrg#ifdef XWIN_NATIVEGDI 37706f2543Smrg/* See Porting Layer Definition - p. 33 */ 38706f2543Smrg/* 39706f2543Smrg * Called by clients, returns the best size for a cursor, tile, or 40706f2543Smrg * stipple, specified by class (sometimes called kind) 41706f2543Smrg */ 42706f2543Smrg 43706f2543Smrgvoid 44706f2543SmrgwinQueryBestSizeNativeGDI (int class, unsigned short *pWidth, 45706f2543Smrg unsigned short *pHeight, ScreenPtr pScreen) 46706f2543Smrg{ 47706f2543Smrg ErrorF ("winQueryBestSizeNativeGDI\n"); 48706f2543Smrg} 49706f2543Smrg#endif 50706f2543Smrg 51706f2543Smrg 52706f2543Smrg/* 53706f2543Smrg * Count the number of one bits in a color mask. 54706f2543Smrg */ 55706f2543Smrg 56706f2543SmrgCARD8 57706f2543SmrgwinCountBits (DWORD dw) 58706f2543Smrg{ 59706f2543Smrg DWORD dwBits = 0; 60706f2543Smrg 61706f2543Smrg while (dw) 62706f2543Smrg { 63706f2543Smrg dwBits += (dw & 1); 64706f2543Smrg dw >>= 1; 65706f2543Smrg } 66706f2543Smrg 67706f2543Smrg return dwBits; 68706f2543Smrg} 69706f2543Smrg 70706f2543Smrg 71706f2543Smrg/* 72706f2543Smrg * Modify the screen pixmap to point to the new framebuffer address 73706f2543Smrg */ 74706f2543Smrg 75706f2543SmrgBool 76706f2543SmrgwinUpdateFBPointer (ScreenPtr pScreen, void *pbits) 77706f2543Smrg{ 78706f2543Smrg winScreenPriv(pScreen); 79706f2543Smrg winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; 80706f2543Smrg 81706f2543Smrg /* Location of shadow framebuffer has changed */ 82706f2543Smrg pScreenInfo->pfb = pbits; 83706f2543Smrg 84706f2543Smrg /* Update the screen pixmap */ 85706f2543Smrg if (!(*pScreen->ModifyPixmapHeader) (pScreen->devPrivate, 86706f2543Smrg pScreen->width, 87706f2543Smrg pScreen->height, 88706f2543Smrg pScreen->rootDepth, 89706f2543Smrg BitsPerPixel (pScreen->rootDepth), 90706f2543Smrg PixmapBytePad (pScreenInfo->dwStride, 91706f2543Smrg pScreenInfo->dwBPP), 92706f2543Smrg pScreenInfo->pfb)) 93706f2543Smrg { 94706f2543Smrg FatalError ("winUpdateFramebufferPointer - Failed modifying "\ 95706f2543Smrg "screen pixmap\n"); 96706f2543Smrg } 97706f2543Smrg 98706f2543Smrg return TRUE; 99706f2543Smrg} 100706f2543Smrg 101706f2543Smrg 102706f2543Smrg#ifdef XWIN_NATIVEGDI 103706f2543Smrg/* 104706f2543Smrg * Paint the window background with the specified color 105706f2543Smrg */ 106706f2543Smrg 107706f2543SmrgBOOL 108706f2543SmrgwinPaintBackground (HWND hwnd, COLORREF colorref) 109706f2543Smrg{ 110706f2543Smrg HDC hdc; 111706f2543Smrg HBRUSH hbrush; 112706f2543Smrg RECT rect; 113706f2543Smrg 114706f2543Smrg /* Create an hdc */ 115706f2543Smrg hdc = GetDC (hwnd); 116706f2543Smrg if (hdc == NULL) 117706f2543Smrg { 118706f2543Smrg printf ("gdiWindowProc - GetDC failed\n"); 119706f2543Smrg exit (1); 120706f2543Smrg } 121706f2543Smrg 122706f2543Smrg /* Create and select blue brush */ 123706f2543Smrg hbrush = CreateSolidBrush (colorref); 124706f2543Smrg if (hbrush == NULL) 125706f2543Smrg { 126706f2543Smrg printf ("gdiWindowProc - CreateSolidBrush failed\n"); 127706f2543Smrg exit (1); 128706f2543Smrg } 129706f2543Smrg 130706f2543Smrg /* Get window extents */ 131706f2543Smrg if (GetClientRect (hwnd, &rect) == FALSE) 132706f2543Smrg { 133706f2543Smrg printf ("gdiWindowProc - GetClientRect failed\n"); 134706f2543Smrg exit (1); 135706f2543Smrg } 136706f2543Smrg 137706f2543Smrg /* Fill window with blue brush */ 138706f2543Smrg if (FillRect (hdc, &rect, hbrush) == 0) 139706f2543Smrg { 140706f2543Smrg printf ("gdiWindowProc - FillRect failed\n"); 141706f2543Smrg exit (1); 142706f2543Smrg } 143706f2543Smrg 144706f2543Smrg /* Delete blue brush */ 145706f2543Smrg DeleteObject (hbrush); 146706f2543Smrg 147706f2543Smrg /* Release the hdc */ 148706f2543Smrg ReleaseDC (hwnd, hdc); 149706f2543Smrg 150706f2543Smrg return TRUE; 151706f2543Smrg} 152706f2543Smrg#endif 153