From 56ef1fec3044fa434c5d042fb550411660a91b5d Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 8 Dec 2004 14:12:09 +0000 Subject: [PATCH] Moved palette functions to user_main.c and removed windows/painting.c. --- dlls/user/Makefile.in | 1 - dlls/user/user_main.c | 51 +++++++++++++++++++++++++++++-- include/user.h | 2 -- windows/painting.c | 84 --------------------------------------------------- 4 files changed, 48 insertions(+), 90 deletions(-) delete mode 100644 windows/painting.c diff --git a/dlls/user/Makefile.in b/dlls/user/Makefile.in index b79d75a01c9..da94714e1e1 100644 --- a/dlls/user/Makefile.in +++ b/dlls/user/Makefile.in @@ -29,7 +29,6 @@ C_SRCS = \ $(TOPOBJDIR)/windows/msgbox.c \ $(TOPOBJDIR)/windows/multimon.c \ $(TOPOBJDIR)/windows/nonclient.c \ - $(TOPOBJDIR)/windows/painting.c \ $(TOPOBJDIR)/windows/queue.c \ $(TOPOBJDIR)/windows/rect.c \ $(TOPOBJDIR)/windows/scroll.c \ diff --git a/dlls/user/user_main.c b/dlls/user/user_main.c index ee49f8316d5..70d2a037011 100644 --- a/dlls/user/user_main.c +++ b/dlls/user/user_main.c @@ -42,8 +42,9 @@ USER_DRIVER USER_Driver; WORD USER_HeapSel = 0; /* USER heap selector */ HMODULE user32_module = 0; -extern HPALETTE (WINAPI *pfnGDISelectPalette)(HDC hdc, HPALETTE hpal, WORD bkgnd ); -extern UINT (WINAPI *pfnGDIRealizePalette)(HDC hdc); +static HPALETTE (WINAPI *pfnGDISelectPalette)( HDC hdc, HPALETTE hpal, WORD bkgnd ); +static UINT (WINAPI *pfnGDIRealizePalette)( HDC hdc ); +static HPALETTE hPrimaryPalette; static HMODULE graphics_driver; static DWORD exiting_thread_id; @@ -136,6 +137,50 @@ static BOOL load_driver(void) /*********************************************************************** + * UserSelectPalette (Not a Windows API) + */ +static HPALETTE WINAPI UserSelectPalette( HDC hDC, HPALETTE hPal, BOOL bForceBackground ) +{ + WORD wBkgPalette = 1; + + if (!bForceBackground && (hPal != GetStockObject(DEFAULT_PALETTE))) + { + HWND hwnd = WindowFromDC( hDC ); + if (hwnd) + { + HWND hForeground = GetForegroundWindow(); + /* set primary palette if it's related to current active */ + if (hForeground == hwnd || IsChild(hForeground,hwnd)) + { + wBkgPalette = 0; + hPrimaryPalette = hPal; + } + } + } + return pfnGDISelectPalette( hDC, hPal, wBkgPalette); +} + + +/*********************************************************************** + * UserRealizePalette (USER32.@) + */ +UINT WINAPI UserRealizePalette( HDC hDC ) +{ + UINT realized = pfnGDIRealizePalette( hDC ); + + /* do not send anything if no colors were changed */ + if (realized && GetCurrentObject( hDC, OBJ_PAL ) == hPrimaryPalette) + { + /* send palette change notification */ + HWND hWnd = WindowFromDC( hDC ); + if (hWnd) SendMessageTimeoutW( HWND_BROADCAST, WM_PALETTECHANGED, (WPARAM)hWnd, 0, + SMTO_ABORTIFHUNG, 2000, NULL ); + } + return realized; +} + + +/*********************************************************************** * palette_init * * Patch the function pointers in GDI for SelectPalette and RealizePalette @@ -150,7 +195,7 @@ static void palette_init(void) return; } if ((ptr = (void**)GetProcAddress( module, "pfnSelectPalette" ))) - pfnGDISelectPalette = InterlockedExchangePointer( ptr, SelectPalette ); + pfnGDISelectPalette = InterlockedExchangePointer( ptr, UserSelectPalette ); else ERR( "cannot find pfnSelectPalette in GDI32\n" ); if ((ptr = (void**)GetProcAddress( module, "pfnRealizePalette" ))) pfnGDIRealizePalette = InterlockedExchangePointer( ptr, UserRealizePalette ); diff --git a/include/user.h b/include/user.h index ce2e689fea1..3047d7272c4 100644 --- a/include/user.h +++ b/include/user.h @@ -156,8 +156,6 @@ extern INT SYSMETRICS_Set( INT index, INT value ); extern void SYSPARAMS_GetDoubleClickSize( INT *width, INT *height ); extern INT SYSPARAMS_GetMouseButtonSwap( void ); -extern HPALETTE WINAPI SelectPalette( HDC hDC, HPALETTE hPal, BOOL bForceBackground ); - extern BOOL CLIPBOARD_ReleaseOwner(void); extern DWORD USER16_AlertableWait; diff --git a/windows/painting.c b/windows/painting.c deleted file mode 100644 index dcf6bb1a750..00000000000 --- a/windows/painting.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Window painting functions - * - * Copyright 1993, 1994, 1995 Alexandre Julliard - * 1999 Alex Korobka - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" -#include "wine/port.h" - -#include -#include -#include "windef.h" -#include "winbase.h" -#include "wingdi.h" -#include "wine/winuser16.h" -#include "wownt32.h" -#include "wine/unicode.h" -#include "wine/server.h" -#include "user.h" -#include "win.h" -#include "message.h" -#include "dce.h" -#include "wine/debug.h" - -WINE_DEFAULT_DEBUG_CHANNEL(win); -WINE_DECLARE_DEBUG_CHANNEL(nonclient); - -HPALETTE (WINAPI *pfnGDISelectPalette)(HDC hdc, HPALETTE hpal, WORD bkgnd ) = NULL; -UINT (WINAPI *pfnGDIRealizePalette)(HDC hdc) = NULL; - - -/*********************************************************************** - * SelectPalette (Not a Windows API) - */ -HPALETTE WINAPI SelectPalette( HDC hDC, HPALETTE hPal, BOOL bForceBackground ) -{ - WORD wBkgPalette = 1; - - if (!bForceBackground && (hPal != GetStockObject(DEFAULT_PALETTE))) - { - HWND hwnd = WindowFromDC( hDC ); - if (hwnd) - { - HWND hForeground = GetForegroundWindow(); - /* set primary palette if it's related to current active */ - if (hForeground == hwnd || IsChild(hForeground,hwnd)) wBkgPalette = 0; - } - } - return pfnGDISelectPalette( hDC, hPal, wBkgPalette); -} - - -/*********************************************************************** - * UserRealizePalette (USER32.@) - */ -UINT WINAPI UserRealizePalette( HDC hDC ) -{ - UINT realized = pfnGDIRealizePalette( hDC ); - - /* do not send anything if no colors were changed */ - if (realized && IsDCCurrentPalette16( HDC_16(hDC) )) - { - /* send palette change notification */ - HWND hWnd = WindowFromDC( hDC ); - if (hWnd) SendMessageTimeoutW( HWND_BROADCAST, WM_PALETTECHANGED, (WPARAM)hWnd, 0, - SMTO_ABORTIFHUNG, 2000, NULL ); - } - return realized; -} -- 2.11.4.GIT