winmisc.c revision 05b261ec
105b261ecSmrg/* 205b261ecSmrg *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved. 305b261ecSmrg * 405b261ecSmrg *Permission is hereby granted, free of charge, to any person obtaining 505b261ecSmrg * a copy of this software and associated documentation files (the 605b261ecSmrg *"Software"), to deal in the Software without restriction, including 705b261ecSmrg *without limitation the rights to use, copy, modify, merge, publish, 805b261ecSmrg *distribute, sublicense, and/or sell copies of the Software, and to 905b261ecSmrg *permit persons to whom the Software is furnished to do so, subject to 1005b261ecSmrg *the following conditions: 1105b261ecSmrg * 1205b261ecSmrg *The above copyright notice and this permission notice shall be 1305b261ecSmrg *included in all copies or substantial portions of the Software. 1405b261ecSmrg * 1505b261ecSmrg *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 1605b261ecSmrg *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 1705b261ecSmrg *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 1805b261ecSmrg *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR 1905b261ecSmrg *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 2005b261ecSmrg *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 2105b261ecSmrg *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2205b261ecSmrg * 2305b261ecSmrg *Except as contained in this notice, the name of Harold L Hunt II 2405b261ecSmrg *shall not be used in advertising or otherwise to promote the sale, use 2505b261ecSmrg *or other dealings in this Software without prior written authorization 2605b261ecSmrg *from Harold L Hunt II. 2705b261ecSmrg * 2805b261ecSmrg * Authors: Harold L Hunt II 2905b261ecSmrg */ 3005b261ecSmrg 3105b261ecSmrg#ifdef HAVE_XWIN_CONFIG_H 3205b261ecSmrg#include <xwin-config.h> 3305b261ecSmrg#endif 3405b261ecSmrg#include "win.h" 3505b261ecSmrg 3605b261ecSmrg#ifdef XWIN_NATIVEGDI 3705b261ecSmrg/* See Porting Layer Definition - p. 33 */ 3805b261ecSmrg/* 3905b261ecSmrg * Called by clients, returns the best size for a cursor, tile, or 4005b261ecSmrg * stipple, specified by class (sometimes called kind) 4105b261ecSmrg */ 4205b261ecSmrg 4305b261ecSmrgvoid 4405b261ecSmrgwinQueryBestSizeNativeGDI (int class, unsigned short *pWidth, 4505b261ecSmrg unsigned short *pHeight, ScreenPtr pScreen) 4605b261ecSmrg{ 4705b261ecSmrg ErrorF ("winQueryBestSizeNativeGDI\n"); 4805b261ecSmrg} 4905b261ecSmrg#endif 5005b261ecSmrg 5105b261ecSmrg 5205b261ecSmrg/* 5305b261ecSmrg * Count the number of one bits in a color mask. 5405b261ecSmrg */ 5505b261ecSmrg 5605b261ecSmrgCARD8 5705b261ecSmrgwinCountBits (DWORD dw) 5805b261ecSmrg{ 5905b261ecSmrg DWORD dwBits = 0; 6005b261ecSmrg 6105b261ecSmrg while (dw) 6205b261ecSmrg { 6305b261ecSmrg dwBits += (dw & 1); 6405b261ecSmrg dw >>= 1; 6505b261ecSmrg } 6605b261ecSmrg 6705b261ecSmrg return dwBits; 6805b261ecSmrg} 6905b261ecSmrg 7005b261ecSmrg 7105b261ecSmrg/* 7205b261ecSmrg * Modify the screen pixmap to point to the new framebuffer address 7305b261ecSmrg */ 7405b261ecSmrg 7505b261ecSmrgBool 7605b261ecSmrgwinUpdateFBPointer (ScreenPtr pScreen, void *pbits) 7705b261ecSmrg{ 7805b261ecSmrg winScreenPriv(pScreen); 7905b261ecSmrg winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; 8005b261ecSmrg 8105b261ecSmrg /* Location of shadow framebuffer has changed */ 8205b261ecSmrg pScreenInfo->pfb = pbits; 8305b261ecSmrg 8405b261ecSmrg /* Update the screen pixmap */ 8505b261ecSmrg if (!(*pScreen->ModifyPixmapHeader) (pScreen->devPrivate, 8605b261ecSmrg pScreen->width, 8705b261ecSmrg pScreen->height, 8805b261ecSmrg pScreen->rootDepth, 8905b261ecSmrg BitsPerPixel (pScreen->rootDepth), 9005b261ecSmrg PixmapBytePad (pScreenInfo->dwStride, 9105b261ecSmrg pScreenInfo->dwBPP), 9205b261ecSmrg pScreenInfo->pfb)) 9305b261ecSmrg { 9405b261ecSmrg FatalError ("winUpdateFramebufferPointer - Failed modifying "\ 9505b261ecSmrg "screen pixmap\n"); 9605b261ecSmrg } 9705b261ecSmrg 9805b261ecSmrg return TRUE; 9905b261ecSmrg} 10005b261ecSmrg 10105b261ecSmrg 10205b261ecSmrg#ifdef XWIN_NATIVEGDI 10305b261ecSmrg/* 10405b261ecSmrg * Paint the window background with the specified color 10505b261ecSmrg */ 10605b261ecSmrg 10705b261ecSmrgBOOL 10805b261ecSmrgwinPaintBackground (HWND hwnd, COLORREF colorref) 10905b261ecSmrg{ 11005b261ecSmrg HDC hdc; 11105b261ecSmrg HBRUSH hbrush; 11205b261ecSmrg RECT rect; 11305b261ecSmrg 11405b261ecSmrg /* Create an hdc */ 11505b261ecSmrg hdc = GetDC (hwnd); 11605b261ecSmrg if (hdc == NULL) 11705b261ecSmrg { 11805b261ecSmrg printf ("gdiWindowProc - GetDC failed\n"); 11905b261ecSmrg exit (1); 12005b261ecSmrg } 12105b261ecSmrg 12205b261ecSmrg /* Create and select blue brush */ 12305b261ecSmrg hbrush = CreateSolidBrush (colorref); 12405b261ecSmrg if (hbrush == NULL) 12505b261ecSmrg { 12605b261ecSmrg printf ("gdiWindowProc - CreateSolidBrush failed\n"); 12705b261ecSmrg exit (1); 12805b261ecSmrg } 12905b261ecSmrg 13005b261ecSmrg /* Get window extents */ 13105b261ecSmrg if (GetClientRect (hwnd, &rect) == FALSE) 13205b261ecSmrg { 13305b261ecSmrg printf ("gdiWindowProc - GetClientRect failed\n"); 13405b261ecSmrg exit (1); 13505b261ecSmrg } 13605b261ecSmrg 13705b261ecSmrg /* Fill window with blue brush */ 13805b261ecSmrg if (FillRect (hdc, &rect, hbrush) == 0) 13905b261ecSmrg { 14005b261ecSmrg printf ("gdiWindowProc - FillRect failed\n"); 14105b261ecSmrg exit (1); 14205b261ecSmrg } 14305b261ecSmrg 14405b261ecSmrg /* Delete blue brush */ 14505b261ecSmrg DeleteObject (hbrush); 14605b261ecSmrg 14705b261ecSmrg /* Release the hdc */ 14805b261ecSmrg ReleaseDC (hwnd, hdc); 14905b261ecSmrg 15005b261ecSmrg return TRUE; 15105b261ecSmrg} 15205b261ecSmrg#endif 153