Avoid a warning on FreeBSD.
[wine/multimedia.git] / windows / painting.c
blobdcf6bb1a75043c7bc038ef88f81261d0a1088c41
1 /*
2 * Window painting functions
4 * Copyright 1993, 1994, 1995 Alexandre Julliard
5 * 1999 Alex Korobka
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "config.h"
23 #include "wine/port.h"
25 #include <stdarg.h>
26 #include <string.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "wine/winuser16.h"
31 #include "wownt32.h"
32 #include "wine/unicode.h"
33 #include "wine/server.h"
34 #include "user.h"
35 #include "win.h"
36 #include "message.h"
37 #include "dce.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(win);
41 WINE_DECLARE_DEBUG_CHANNEL(nonclient);
43 HPALETTE (WINAPI *pfnGDISelectPalette)(HDC hdc, HPALETTE hpal, WORD bkgnd ) = NULL;
44 UINT (WINAPI *pfnGDIRealizePalette)(HDC hdc) = NULL;
47 /***********************************************************************
48 * SelectPalette (Not a Windows API)
50 HPALETTE WINAPI SelectPalette( HDC hDC, HPALETTE hPal, BOOL bForceBackground )
52 WORD wBkgPalette = 1;
54 if (!bForceBackground && (hPal != GetStockObject(DEFAULT_PALETTE)))
56 HWND hwnd = WindowFromDC( hDC );
57 if (hwnd)
59 HWND hForeground = GetForegroundWindow();
60 /* set primary palette if it's related to current active */
61 if (hForeground == hwnd || IsChild(hForeground,hwnd)) wBkgPalette = 0;
64 return pfnGDISelectPalette( hDC, hPal, wBkgPalette);
68 /***********************************************************************
69 * UserRealizePalette (USER32.@)
71 UINT WINAPI UserRealizePalette( HDC hDC )
73 UINT realized = pfnGDIRealizePalette( hDC );
75 /* do not send anything if no colors were changed */
76 if (realized && IsDCCurrentPalette16( HDC_16(hDC) ))
78 /* send palette change notification */
79 HWND hWnd = WindowFromDC( hDC );
80 if (hWnd) SendMessageTimeoutW( HWND_BROADCAST, WM_PALETTECHANGED, (WPARAM)hWnd, 0,
81 SMTO_ABORTIFHUNG, 2000, NULL );
83 return realized;