Use server information structure for system colors.

svn path=/trunk/; revision=33760
This commit is contained in:
James Tabor 2008-05-29 18:51:17 +00:00
parent 616f5e97e0
commit c03961764a
3 changed files with 40 additions and 40 deletions

View file

@ -1,4 +1,4 @@
/* $Id$ /*
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll * PROJECT: ReactOS user32.dll
@ -33,10 +33,6 @@ void FASTCALL MenuInitSysMenuPopup(HMENU Menu, DWORD Style, DWORD ClsStyle, LONG
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
COLORREF SysColors[NUM_SYSCOLORS] = {0};
HPEN SysPens[NUM_SYSCOLORS] = {0};
HBRUSH SysBrushes[NUM_SYSCOLORS] = {0};
/* Bits in the dwKeyData */ /* Bits in the dwKeyData */
#define KEYDATA_ALT 0x2000 #define KEYDATA_ALT 0x2000
#define KEYDATA_PREVSTATE 0x4000 #define KEYDATA_PREVSTATE 0x4000
@ -55,13 +51,8 @@ InitStockObjects(void)
we should rather map the table into usermode. But it only affects the we should rather map the table into usermode. But it only affects the
SysColors table - the pens, brushes and stock objects are not affected SysColors table - the pens, brushes and stock objects are not affected
as their handles never change. But it'd be faster to map them, too. */ as their handles never change. But it'd be faster to map them, too. */
if(SysBrushes[0] == NULL)
{ // Done! g_psi!
/* only initialize once */
(void)NtUserGetSysColors(SysColors, NUM_SYSCOLORS);
(void)NtUserGetSysColorPens(SysPens, NUM_SYSCOLORS);
(void)NtUserGetSysColorBrushes(SysBrushes, NUM_SYSCOLORS);
}
} }
/* /*
@ -72,7 +63,7 @@ GetSysColor(int nIndex)
{ {
if(nIndex >= 0 && nIndex <= NUM_SYSCOLORS) if(nIndex >= 0 && nIndex <= NUM_SYSCOLORS)
{ {
return SysColors[nIndex]; return g_psi->SysColors[nIndex];
} }
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
@ -87,7 +78,7 @@ GetSysColorPen(int nIndex)
{ {
if(nIndex >= 0 && nIndex <= NUM_SYSCOLORS) if(nIndex >= 0 && nIndex <= NUM_SYSCOLORS)
{ {
return SysPens[nIndex]; return g_psi->SysColorPens[nIndex];
} }
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
@ -102,7 +93,7 @@ GetSysColorBrush(int nIndex)
{ {
if(nIndex >= 0 && nIndex <= NUM_SYSCOLORS) if(nIndex >= 0 && nIndex <= NUM_SYSCOLORS)
{ {
return SysBrushes[nIndex]; return g_psi->SysColorBrushes[nIndex];
} }
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
@ -132,11 +123,6 @@ SetSysColors(
if(cElements > 0) if(cElements > 0)
{ {
Ret = NtUserSetSysColors(&ChangeSysColors, cElements); Ret = NtUserSetSysColors(&ChangeSysColors, cElements);
if(Ret)
{
/* FIXME - just change it in the usermode structure, too, instead of asking win32k again */
(void)NtUserGetSysColors(SysColors, NUM_SYSCOLORS);
}
} }
else else
{ {

View file

@ -171,8 +171,12 @@ typedef struct _WINDOW
typedef struct _SERVERINFO typedef struct _SERVERINFO
{ {
// DWORD SystemMetrics[SM_CMETRICS]; // System Metrics
// COLORREF SystemColorCopy[COLOR_MENUBAR+1]; // Backup Copy of system colors.
COLORREF SysColors[COLOR_MENUBAR+1]; // GetSysColor
HBRUSH SysColorBrushes[COLOR_MENUBAR+1]; // GetSysColorBrush
HPEN SysColorPens[COLOR_MENUBAR+1]; // ReactOS exclusive
DWORD SrvEventActivity; DWORD SrvEventActivity;
} SERVERINFO, *PSERVERINFO; } SERVERINFO, *PSERVERINFO;
typedef struct _W32PROCESSINFO typedef struct _W32PROCESSINFO

View file

@ -28,6 +28,8 @@
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
extern PSERVERINFO gpsi;
static COLORREF SysColors[] = static COLORREF SysColors[] =
{ {
RGB(212, 208, 200), /* COLOR_SCROLLBAR */ RGB(212, 208, 200), /* COLOR_SCROLLBAR */
@ -64,8 +66,11 @@ static COLORREF SysColors[] =
}; };
#define NUM_SYSCOLORS (sizeof(SysColors) / sizeof(SysColors[0])) #define NUM_SYSCOLORS (sizeof(SysColors) / sizeof(SysColors[0]))
static HPEN SysColorPens[NUM_SYSCOLORS]; //static HPEN SysColorPens[NUM_SYSCOLORS];
static HBRUSH SysColorBrushes[NUM_SYSCOLORS]; //static HBRUSH SysColorBrushes[NUM_SYSCOLORS];
// System Bitmap DC and System Display DC...
HDC hSystemBM, hSystemDisplayDC;
/* GDI stock objects */ /* GDI stock objects */
@ -182,9 +187,9 @@ IntSetSysColors(UINT nColors, INT *Elements, COLORREF *Colors)
{ {
if((UINT)(*Elements) < NUM_SYSCOLORS) if((UINT)(*Elements) < NUM_SYSCOLORS)
{ {
SysColors[*Elements] = *Colors; gpsi->SysColors[*Elements] = *Colors;
IntGdiSetSolidBrushColor(SysColorBrushes[*Elements], *Colors); IntGdiSetSolidBrushColor(gpsi->SysColorBrushes[*Elements], *Colors);
IntGdiSetSolidPenColor(SysColorPens[*Elements], *Colors); IntGdiSetSolidPenColor(gpsi->SysColorPens[*Elements], *Colors);
} }
Elements++; Elements++;
Colors++; Colors++;
@ -209,7 +214,7 @@ IntGetSysColorBrushes(HBRUSH *Brushes, UINT nBrushes)
for(i = 0; i < nBrushes; i++) for(i = 0; i < nBrushes; i++)
{ {
*(Brushes++) = SysColorBrushes[i]; *(Brushes++) = gpsi->SysColorBrushes[i];
} }
return nBrushes > 0; return nBrushes > 0;
@ -218,7 +223,7 @@ IntGetSysColorBrushes(HBRUSH *Brushes, UINT nBrushes)
HGDIOBJ FASTCALL HGDIOBJ FASTCALL
IntGetSysColorBrush(INT Object) IntGetSysColorBrush(INT Object)
{ {
return ((Object < 0) || (NUM_SYSCOLORS <= Object)) ? NULL : SysColorBrushes[Object]; return ((Object < 0) || (NUM_SYSCOLORS <= Object)) ? NULL : gpsi->SysColorBrushes[Object];
} }
BOOL FASTCALL BOOL FASTCALL
@ -236,7 +241,7 @@ IntGetSysColorPens(HPEN *Pens, UINT nPens)
for(i = 0; i < nPens; i++) for(i = 0; i < nPens; i++)
{ {
*(Pens++) = SysColorPens[i]; *(Pens++) = gpsi->SysColorPens[i];
} }
return nPens > 0; return nPens > 0;
@ -256,7 +261,7 @@ IntGetSysColors(COLORREF *Colors, UINT nColors)
return FALSE; return FALSE;
} }
col = &SysColors[0]; col = &gpsi->SysColors[0];
for(i = 0; i < nColors; i++) for(i = 0; i < nColors; i++)
{ {
*(Colors++) = *(col++); *(Colors++) = *(col++);
@ -268,7 +273,7 @@ IntGetSysColors(COLORREF *Colors, UINT nColors)
DWORD FASTCALL DWORD FASTCALL
IntGetSysColor(INT nIndex) IntGetSysColor(INT nIndex)
{ {
return (NUM_SYSCOLORS <= (UINT)nIndex) ? 0 : SysColors[nIndex]; return (NUM_SYSCOLORS <= (UINT)nIndex) ? 0 : gpsi->SysColors[nIndex];
} }
VOID FASTCALL VOID FASTCALL
@ -277,15 +282,20 @@ CreateSysColorObjects(VOID)
UINT i; UINT i;
LOGPEN Pen; LOGPEN Pen;
for(i = 0; i < NUM_SYSCOLORS; i++)
{
gpsi->SysColors[i] = SysColors[i];
}
/* Create the syscolor brushes */ /* Create the syscolor brushes */
for(i = 0; i < NUM_SYSCOLORS; i++) for(i = 0; i < NUM_SYSCOLORS; i++)
{ {
if(SysColorBrushes[i] == NULL) if(gpsi->SysColorBrushes[i] == NULL)
{ {
SysColorBrushes[i] = IntGdiCreateSolidBrush(SysColors[i]); gpsi->SysColorBrushes[i] = IntGdiCreateSolidBrush(SysColors[i]);
if(SysColorBrushes[i] != NULL) if(gpsi->SysColorBrushes[i] != NULL)
{ {
GDIOBJ_ConvertToStockObj((HGDIOBJ*)&SysColorBrushes[i]); GDIOBJ_ConvertToStockObj((HGDIOBJ*)&gpsi->SysColorBrushes[i]);
} }
} }
} }
@ -296,13 +306,13 @@ CreateSysColorObjects(VOID)
Pen.lopnWidth.y = 0; Pen.lopnWidth.y = 0;
for(i = 0; i < NUM_SYSCOLORS; i++) for(i = 0; i < NUM_SYSCOLORS; i++)
{ {
if(SysColorPens[i] == NULL) if(gpsi->SysColorPens[i] == NULL)
{ {
Pen.lopnColor = SysColors[i]; Pen.lopnColor = SysColors[i];
SysColorPens[i] = IntGdiExtCreatePen(Pen.lopnStyle, Pen.lopnWidth.x, BS_SOLID, Pen.lopnColor, 0, 0, 0, NULL, 0, TRUE, NULL); gpsi->SysColorPens[i] = IntGdiExtCreatePen(Pen.lopnStyle, Pen.lopnWidth.x, BS_SOLID, Pen.lopnColor, 0, 0, 0, NULL, 0, TRUE, NULL);
if(SysColorPens[i] != NULL) if(gpsi->SysColorPens[i] != NULL)
{ {
GDIOBJ_ConvertToStockObj((HGDIOBJ*)&SysColorPens[i]); GDIOBJ_ConvertToStockObj((HGDIOBJ*)&gpsi->SysColorPens[i]);
} }
} }
} }