diff --git a/reactos/subsystems/win32/win32k/include/userfuncs.h b/reactos/subsystems/win32/win32k/include/userfuncs.h index 448ca928e11..84911e8f58d 100644 --- a/reactos/subsystems/win32/win32k/include/userfuncs.h +++ b/reactos/subsystems/win32/win32k/include/userfuncs.h @@ -79,6 +79,9 @@ NTSTATUS FASTCALL InitSessionImpl(VOID); /*************** METRIC.C ***************/ +BOOL FASTCALL +InitMetrics(VOID); + ULONG FASTCALL UserGetSystemMetrics(ULONG Index); diff --git a/reactos/subsystems/win32/win32k/ntuser/metric.c b/reactos/subsystems/win32/win32k/ntuser/metric.c index 311e9050e72..28eb9d99f8a 100644 --- a/reactos/subsystems/win32/win32k/ntuser/metric.c +++ b/reactos/subsystems/win32/win32k/ntuser/metric.c @@ -1,23 +1,4 @@ /* - * ReactOS W32 Subsystem - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -/* - * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * PURPOSE: Window classes @@ -39,432 +20,189 @@ static BOOL Setup = FALSE; /* FUNCTIONS *****************************************************************/ +// FIXME: These are only win xp default values, mostly hardcoded. They should be +// read from the registry. It must be possible to change or reinitialize the +// values, for example desk.cpl BOOL FASTCALL InitMetrics(VOID) { - INT Index; - NTSTATUS Status; - PWINSTATION_OBJECT WinStaObject; - ULONG Width = 640, Height = 480; + NTSTATUS Status; + PWINSTATION_OBJECT WinStaObject; + ULONG Width = 640, Height = 480; + PSYSTEM_CURSORINFO CurInfo; + HDC hScreenDC; + PDC pScreenDC; - for (Index = 0; Index < SM_CMETRICS; Index++) - { - switch (Index) - { - case SM_CXSCREEN: - { - HDC ScreenDCHandle; - PDC ScreenDC; + hScreenDC = IntGdiCreateDC(NULL, NULL, NULL, NULL, TRUE); + if (hScreenDC) + { + pScreenDC = DC_LockDc(hScreenDC); + if (pScreenDC) + { + Width = ((PGDIDEVICE)pScreenDC->pPDev)->GDIInfo.ulHorzRes; + Height = ((PGDIDEVICE)pScreenDC->pPDev)->GDIInfo.ulVertRes; + DC_UnlockDc(pScreenDC); + } + NtGdiDeleteObjectApp(hScreenDC); + } - ScreenDCHandle = IntGdiCreateDC(NULL, NULL, NULL, NULL, TRUE); - if (NULL != ScreenDCHandle) - { - ScreenDC = DC_LockDc(ScreenDCHandle); - if (NULL != ScreenDC) - { - Width = ((PGDIDEVICE)ScreenDC->pPDev)->GDIInfo.ulHorzRes; - Height = ((PGDIDEVICE)ScreenDC->pPDev)->GDIInfo.ulVertRes; - DC_UnlockDc(ScreenDC); - } - NtGdiDeleteObjectApp(ScreenDCHandle); - } - gpsi->SystemMetrics[Index] = Width; - break; - } - case SM_CYSCREEN: - gpsi->SystemMetrics[Index] = Height; - break; - case SM_ARRANGE: - gpsi->SystemMetrics[Index] = 8; - break; - case SM_CLEANBOOT: - gpsi->SystemMetrics[Index] = 0; - break; - case SM_CMOUSEBUTTONS: - gpsi->SystemMetrics[Index] = 2; - break; - case SM_CXBORDER: - case SM_CYBORDER: - gpsi->SystemMetrics[Index] = 1; - break; - case SM_CXCURSOR: - case SM_CYCURSOR: - gpsi->SystemMetrics[Index] = 32; - break; - case SM_CXDLGFRAME: - case SM_CYDLGFRAME: - gpsi->SystemMetrics[Index] = 3; - break; - case SM_CXDOUBLECLK: - case SM_CYDOUBLECLK: - case SM_SWAPBUTTON: - { - PSYSTEM_CURSORINFO CurInfo; - Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation, - KernelMode, - 0, - &WinStaObject); - if (!NT_SUCCESS(Status)) - gpsi->SystemMetrics[Index] = 0xFFFFFFFF; - break; + Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation, + KernelMode, + 0, + &WinStaObject); + if (NT_SUCCESS(Status)) + { + CurInfo = IntGetSysCursorInfo(WinStaObject); + } + else + { + CurInfo = NULL; + } - CurInfo = IntGetSysCursorInfo(WinStaObject); - switch(Index) - { - case SM_CXDOUBLECLK: - gpsi->SystemMetrics[Index] = CurInfo->DblClickWidth; - break; - case SM_CYDOUBLECLK: - gpsi->SystemMetrics[Index] = CurInfo->DblClickWidth; - break; - case SM_SWAPBUTTON: - gpsi->SystemMetrics[Index] = CurInfo->SwapButtons; - break; - } + gpsi->SystemMetrics[SM_CXSCREEN] = Width; + gpsi->SystemMetrics[SM_CYSCREEN] = Height; + gpsi->SystemMetrics[SM_CXVSCROLL] = 16; + gpsi->SystemMetrics[SM_CYHSCROLL] = 16; + /* FIXME: "reg://Control Panel/Desktop/WindowMetrics/CaptionHeight" + 1 */ + gpsi->SystemMetrics[SM_CYCAPTION] = 19; + gpsi->SystemMetrics[SM_CXBORDER] = 1; + gpsi->SystemMetrics[SM_CYBORDER] = 1; + gpsi->SystemMetrics[SM_CXDLGFRAME] = 3; + gpsi->SystemMetrics[SM_CYDLGFRAME] = 3; + gpsi->SystemMetrics[SM_CYVTHUMB] = 16; + gpsi->SystemMetrics[SM_CXHTHUMB] = 16; + gpsi->SystemMetrics[SM_CXICON] = 32; + gpsi->SystemMetrics[SM_CYICON] = 32; + gpsi->SystemMetrics[SM_CXCURSOR] = 32; + gpsi->SystemMetrics[SM_CYCURSOR] = 32; + gpsi->SystemMetrics[SM_CYMENU] = 19; + /* FIXME: shouldn't we take borders etc into account??? */ + gpsi->SystemMetrics[SM_CXFULLSCREEN] = gpsi->SystemMetrics[SM_CXSCREEN]; + gpsi->SystemMetrics[SM_CYFULLSCREEN] = gpsi->SystemMetrics[SM_CYSCREEN]; + gpsi->SystemMetrics[SM_CYKANJIWINDOW] = 0; + gpsi->SystemMetrics[SM_MOUSEPRESENT] = 1; + gpsi->SystemMetrics[SM_CYVSCROLL] = 16; + gpsi->SystemMetrics[SM_CXHSCROLL] = 16; + gpsi->SystemMetrics[SM_DEBUG] = 0; + gpsi->SystemMetrics[SM_SWAPBUTTON] = CurInfo ? CurInfo->SwapButtons : 0xFFFFFFFF; + gpsi->SystemMetrics[SM_RESERVED1] = 0; + gpsi->SystemMetrics[SM_RESERVED2] = 0; + gpsi->SystemMetrics[SM_RESERVED3] = 0; + gpsi->SystemMetrics[SM_RESERVED4] = 0; + gpsi->SystemMetrics[SM_CXMIN] = 112; + gpsi->SystemMetrics[SM_CYMIN] = 27; + gpsi->SystemMetrics[SM_CXSIZE] = 18; + gpsi->SystemMetrics[SM_CYSIZE] = 18; + gpsi->SystemMetrics[SM_CXFRAME] = 4; + gpsi->SystemMetrics[SM_CYFRAME] = 4; + gpsi->SystemMetrics[SM_CXMINTRACK] = 112; + gpsi->SystemMetrics[SM_CYMINTRACK] = 27; + gpsi->SystemMetrics[SM_CXDOUBLECLK] = CurInfo ? CurInfo->DblClickWidth : 0xFFFFFFFF; + gpsi->SystemMetrics[SM_CYDOUBLECLK] = CurInfo ? CurInfo->DblClickWidth : 0xFFFFFFFF; + gpsi->SystemMetrics[SM_CXICONSPACING] = 64; + gpsi->SystemMetrics[SM_CYICONSPACING] = 64; + gpsi->SystemMetrics[SM_MENUDROPALIGNMENT] = 0; + gpsi->SystemMetrics[SM_PENWINDOWS] = 0; + gpsi->SystemMetrics[SM_DBCSENABLED] = 0; + gpsi->SystemMetrics[SM_CMOUSEBUTTONS] = 2; + gpsi->SystemMetrics[SM_SECURE] = 0; + gpsi->SystemMetrics[SM_CXEDGE] = 2; + gpsi->SystemMetrics[SM_CYEDGE] = 2; + gpsi->SystemMetrics[SM_CXMINSPACING] = 160; + gpsi->SystemMetrics[SM_CYMINSPACING] = 24; + gpsi->SystemMetrics[SM_CXSMICON] = 16; + gpsi->SystemMetrics[SM_CYSMICON] = 16; + gpsi->SystemMetrics[SM_CYSMCAPTION] = 15; + gpsi->SystemMetrics[SM_CXSMSIZE] = 12; + gpsi->SystemMetrics[SM_CYSMSIZE] = 14; + gpsi->SystemMetrics[SM_CXMENUSIZE] = 18; + gpsi->SystemMetrics[SM_CYMENUSIZE] = 18; + gpsi->SystemMetrics[SM_ARRANGE] = 8; + gpsi->SystemMetrics[SM_CXMINIMIZED] = 160; + gpsi->SystemMetrics[SM_CYMINIMIZED] = 24; + gpsi->SystemMetrics[SM_CXMAXTRACK] = gpsi->SystemMetrics[SM_CYSCREEN] + 12; + gpsi->SystemMetrics[SM_CYMAXTRACK] = gpsi->SystemMetrics[SM_CYSCREEN] + 12; + /* This seems to be 8 pixels greater than the screen width */ + gpsi->SystemMetrics[SM_CXMAXIMIZED] = gpsi->SystemMetrics[SM_CXSCREEN] + 8; + /* This seems to be 20 pixels less than the screen height, taskbar maybe? */ + gpsi->SystemMetrics[SM_CYMAXIMIZED] = gpsi->SystemMetrics[SM_CYSCREEN] - 20; + gpsi->SystemMetrics[SM_NETWORK] = 3; + gpsi->SystemMetrics[64] = 0; + gpsi->SystemMetrics[65] = 0; + gpsi->SystemMetrics[66] = 0; + gpsi->SystemMetrics[SM_CLEANBOOT] = 0; + gpsi->SystemMetrics[SM_CXDRAG] = 4; + gpsi->SystemMetrics[SM_CYDRAG] = 4; + gpsi->SystemMetrics[SM_SHOWSOUNDS] = 0; + gpsi->SystemMetrics[SM_CXMENUCHECK] = 13; + gpsi->SystemMetrics[SM_CYMENUCHECK] = 13; + gpsi->SystemMetrics[SM_SLOWMACHINE] = 0; + gpsi->SystemMetrics[SM_MIDEASTENABLED] = 0; + gpsi->SystemMetrics[SM_MOUSEWHEELPRESENT] = 1; + gpsi->SystemMetrics[SM_XVIRTUALSCREEN] = 0; + gpsi->SystemMetrics[SM_YVIRTUALSCREEN] = 0; + gpsi->SystemMetrics[SM_CXVIRTUALSCREEN] = Width; + gpsi->SystemMetrics[SM_CYVIRTUALSCREEN] = Height; + gpsi->SystemMetrics[SM_CMONITORS] = 1; + gpsi->SystemMetrics[SM_SAMEDISPLAYFORMAT] = 1; + gpsi->SystemMetrics[SM_IMMENABLED] = 0; + gpsi->SystemMetrics[SM_CXFOCUSBORDER] = 1; + gpsi->SystemMetrics[SM_CYFOCUSBORDER] = 1; + gpsi->SystemMetrics[SM_TABLETPC] = 0; + gpsi->SystemMetrics[SM_MEDIACENTER] = 0; + gpsi->SystemMetrics[SM_STARTER] = 0; + gpsi->SystemMetrics[SM_SERVERR2] = 0; +#if (_WIN32_WINNT >= 0x0600) + gpsi->SystemMetrics[90] = 0; + gpsi->SystemMetrics[SM_MOUSEHORIZONTALWHEELPRESENT] = 0; + gpsi->SystemMetrics[SM_CXPADDEDBORDER] = 0; +#endif - ObDereferenceObject(WinStaObject); - break; - } - case SM_CXDRAG: - case SM_CYDRAG: - gpsi->SystemMetrics[Index] = 2; - break; - case SM_CXEDGE: - case SM_CYEDGE: - gpsi->SystemMetrics[Index] = 2; - break; - case SM_CXFRAME: - case SM_CYFRAME: - gpsi->SystemMetrics[Index] = 4; - break; - case SM_CXFULLSCREEN: - /* FIXME: shouldn't we take borders etc into account??? */ - gpsi->SystemMetrics[Index] = gpsi->SystemMetrics[SM_CXSCREEN]; - break; - case SM_CYFULLSCREEN: - gpsi->SystemMetrics[Index] = gpsi->SystemMetrics[SM_CYSCREEN]; - break; - case SM_CXHSCROLL: - case SM_CYHSCROLL: - gpsi->SystemMetrics[Index] = 16; - break; - case SM_CYVTHUMB: - case SM_CXHTHUMB: - gpsi->SystemMetrics[Index] = 16; - break; - case SM_CXICON: - case SM_CYICON: - gpsi->SystemMetrics[Index] = 32; - break; - case SM_CXICONSPACING: - case SM_CYICONSPACING: - gpsi->SystemMetrics[Index] = 64; - break; - case SM_CXMAXIMIZED: - /* This seems to be 8 pixels greater than the screen width */ - gpsi->SystemMetrics[Index] = gpsi->SystemMetrics[SM_CXSCREEN] + 8; - break; - case SM_CYMAXIMIZED: - /* This seems to be 20 pixels less than the screen height, taskbar maybe? */ - gpsi->SystemMetrics[Index] = gpsi->SystemMetrics[SM_CYSCREEN] - 20; - break; - case SM_CXMAXTRACK: - gpsi->SystemMetrics[Index] = gpsi->SystemMetrics[SM_CYSCREEN] + 12; - break; - case SM_CYMAXTRACK: - gpsi->SystemMetrics[Index] = gpsi->SystemMetrics[SM_CYSCREEN] + 12; - break; - case SM_CXMENUCHECK: - case SM_CYMENUCHECK: - gpsi->SystemMetrics[Index] = 13; - break; - case SM_CXMENUSIZE: - case SM_CYMENUSIZE: - gpsi->SystemMetrics[Index] = 18; - break; - case SM_CXMIN: - gpsi->SystemMetrics[Index] = 112; - break; - case SM_CYMIN: - gpsi->SystemMetrics[Index] = 27; - break; - case SM_CXMINIMIZED: - gpsi->SystemMetrics[Index] = 160; - break; - case SM_CYMINIMIZED: - gpsi->SystemMetrics[Index] = 24; - break; - case SM_CXMINSPACING: - gpsi->SystemMetrics[Index] = 160; - break; - case SM_CYMINSPACING: - gpsi->SystemMetrics[Index] = 24; - break; - case SM_CXMINTRACK: - gpsi->SystemMetrics[Index] = 112; - break; - case SM_CYMINTRACK: - gpsi->SystemMetrics[Index] = 27; - break; - case SM_CXSIZE: - case SM_CYSIZE: - gpsi->SystemMetrics[Index] = 18; - break; - case SM_CXSMICON: - case SM_CYSMICON: - gpsi->SystemMetrics[Index] = 16; - break; - case SM_CXSMSIZE: - gpsi->SystemMetrics[Index] = 12; - break; - case SM_CYSMSIZE: - gpsi->SystemMetrics[Index] = 14; - break; - case SM_CXVSCROLL: - case SM_CYVSCROLL: - gpsi->SystemMetrics[Index] = 16; - break; - case SM_CYCAPTION: - gpsi->SystemMetrics[Index] = 19; - break; - case SM_CYKANJIWINDOW: - gpsi->SystemMetrics[Index] = 0; - break; - case SM_CYMENU: - gpsi->SystemMetrics[Index] = 19; - break; - case SM_CYSMCAPTION: - gpsi->SystemMetrics[Index] = 15; - break; - case SM_DBCSENABLED: - case SM_DEBUG: - case SM_MENUDROPALIGNMENT: - case SM_MIDEASTENABLED: - gpsi->SystemMetrics[Index] = 0; - break; - case SM_MOUSEPRESENT: - gpsi->SystemMetrics[Index] = 1; - break; - case SM_NETWORK: - gpsi->SystemMetrics[Index] = 3; - break; - case SM_PENWINDOWS: - case SM_SECURE: - case SM_SHOWSOUNDS: - case SM_SLOWMACHINE: - gpsi->SystemMetrics[Index] = 0; - break; - case SM_CMONITORS: - gpsi->SystemMetrics[Index] = 1; - break; - case SM_REMOTESESSION: - gpsi->SystemMetrics[Index] = 0; - break; - default: - gpsi->SystemMetrics[Index] = 0xFFFFFFFF; - } - } - gpsi->SRVINFO_Flags |= SRVINFO_METRICS; - Setup = TRUE; - return TRUE; + gpsi->SRVINFO_Flags |= SRVINFO_METRICS; + Setup = TRUE; + + if (NT_SUCCESS(Status)) + { + ObDereferenceObject(WinStaObject); + } + + return TRUE; } ULONG FASTCALL UserGetSystemMetrics(ULONG Index) { - NTSTATUS Status; - PWINSTATION_OBJECT WinStaObject; - ULONG Width, Height, Result; + ASSERT(gpsi); + DPRINT("UserGetSystemMetrics(%d)\n", Index); -// DPRINT1("UserGetSystemMetrics -> %d\n",Index); + // FIXME: Do this when loading + if (!Setup) + { + InitMetrics(); + } - if (Index >= SM_CMETRICS) - { - DPRINT1("UserGetSystemMetrics() called with invalid index %d\n", Index); - return 0; - } + /* Get metrics from array */ + if (Index < SM_CMETRICS) + { + return gpsi->SystemMetrics[Index]; + } - if (gpsi && Setup) - return gpsi->SystemMetrics[Index]; - else - { - Result = 0; - switch (Index) - { - case SM_ARRANGE: - return(8); - case SM_CLEANBOOT: - return(0); - case SM_CMOUSEBUTTONS: - return(2); - case SM_CXBORDER: - case SM_CYBORDER: - return(1); - case SM_CXCURSOR: - case SM_CYCURSOR: - return(32); - case SM_CXDLGFRAME: - case SM_CYDLGFRAME: - return(3); - case SM_CXDOUBLECLK: - case SM_CYDOUBLECLK: - case SM_SWAPBUTTON: - { - PSYSTEM_CURSORINFO CurInfo; - Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation, - KernelMode, - 0, - &WinStaObject); - if (!NT_SUCCESS(Status)) - return 0xFFFFFFFF; + /* Handle special values */ + switch (Index) + { + case SM_REMOTESESSION: + return 0; // FIXME - CurInfo = IntGetSysCursorInfo(WinStaObject); - switch(Index) - { - case SM_CXDOUBLECLK: - Result = CurInfo->DblClickWidth; - break; - case SM_CYDOUBLECLK: - Result = CurInfo->DblClickWidth; - break; - case SM_SWAPBUTTON: - Result = (UINT)CurInfo->SwapButtons; - break; - } + case SM_SHUTTINGDOWN: + return 0; // FIXME - ObDereferenceObject(WinStaObject); - return Result; - } + case SM_REMOTECONTROL: + return 0; // FIXME + } - case SM_CXDRAG: - case SM_CYDRAG: - return(2); - case SM_CXEDGE: - case SM_CYEDGE: - return(2); - case SM_CXFRAME: - case SM_CYFRAME: - return(4); - case SM_CXFULLSCREEN: - /* FIXME: shouldn't we take borders etc into account??? */ - return UserGetSystemMetrics(SM_CXSCREEN); - case SM_CYFULLSCREEN: - return UserGetSystemMetrics(SM_CYSCREEN); - case SM_CXHSCROLL: - case SM_CYHSCROLL: - return(16); - case SM_CYVTHUMB: - case SM_CXHTHUMB: - return(16); - case SM_CXICON: - case SM_CYICON: - return(32); - case SM_CXICONSPACING: - case SM_CYICONSPACING: - return(64); - case SM_CXMAXIMIZED: - return(UserGetSystemMetrics(SM_CXSCREEN) + 8); /* This seems to be 8 - pixels greater than - the screen width */ - case SM_CYMAXIMIZED: - return(UserGetSystemMetrics(SM_CYSCREEN) - 20); /* This seems to be 20 - pixels less than - the screen height, - taskbar maybe? */ - case SM_CXMAXTRACK: - return(UserGetSystemMetrics(SM_CYSCREEN) + 12); - case SM_CYMAXTRACK: - return(UserGetSystemMetrics(SM_CYSCREEN) + 12); - case SM_CXMENUCHECK: - case SM_CYMENUCHECK: - return(13); - case SM_CXMENUSIZE: - case SM_CYMENUSIZE: - return(18); - case SM_CXMIN: - return(112); - case SM_CYMIN: - return(27); - case SM_CXMINIMIZED: - return(160); - case SM_CYMINIMIZED: - return(24); - case SM_CXMINSPACING: - return(160); - case SM_CYMINSPACING: - return(24); - case SM_CXMINTRACK: - return(112); - case SM_CYMINTRACK: - return(27); - case SM_CXSCREEN: - case SM_CYSCREEN: - { - HDC ScreenDCHandle; - PDC ScreenDC; - - Width = 640; - Height = 480; - ScreenDCHandle = IntGdiCreateDC(NULL, NULL, NULL, NULL, TRUE); - if (NULL != ScreenDCHandle) - { - ScreenDC = DC_LockDc(ScreenDCHandle); - if (NULL != ScreenDC) - { - Width = ((PGDIDEVICE)ScreenDC->pPDev)->GDIInfo.ulHorzRes; - Height = ((PGDIDEVICE)ScreenDC->pPDev)->GDIInfo.ulVertRes; - DC_UnlockDc(ScreenDC); - } - NtGdiDeleteObjectApp(ScreenDCHandle); - } - return SM_CXSCREEN == Index ? Width : Height; - } - case SM_CXSIZE: - InitMetrics(); - case SM_CYSIZE: - return(18); - case SM_CXSMICON: - case SM_CYSMICON: - return(16); - case SM_CXSMSIZE: - return(12); - case SM_CYSMSIZE: - return(14); - case SM_CXVSCROLL: - case SM_CYVSCROLL: - return(16); - case SM_CYCAPTION: - return(19); - case SM_CYKANJIWINDOW: - return 0; - case SM_CYMENU: - return(19); - case SM_CYSMCAPTION: - return(15); - case SM_DBCSENABLED: - case SM_DEBUG: - case SM_MENUDROPALIGNMENT: - case SM_MIDEASTENABLED: - return(0); - case SM_MOUSEPRESENT: - return(1); - case SM_NETWORK: - return(3); - case SM_PENWINDOWS: - case SM_SECURE: - case SM_SHOWSOUNDS: - case SM_SLOWMACHINE: - return(0); - case SM_CMONITORS: - return(1); - case SM_REMOTESESSION: - return (0); - - default: - return(0xFFFFFFFF); - } - } + DPRINT1("UserGetSystemMetrics() called with invalid index %d\n", Index); + return 0; }