ReactOS 0.4.15-dev-8096-ga0eec98
metric.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Win32k subsystem
4 * PURPOSE: Window classes
5 * FILE: win32ss/user/ntuser/metric.c
6 * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 * Timo Kreuzer (timo.kreuzer@reactos.org)
8 */
9
10#include <win32k.h>
11DBG_DEFAULT_CHANNEL(UserSysparams);
12
13static BOOL Setup = FALSE;
14
15/* FUNCTIONS *****************************************************************/
16
18{
20}
21
23{
25 return TRUE;
26
27 return !!RegGetSectionDWORD(L"IMM", L"LoadIMM", FALSE);
28}
29
31{
32#if 1
33 return FALSE; /* FIXME: Cicero is not supported yet */
34#else
35 if (RegGetSectionDWORD(L"IMM", L"DontLoadCTFIME", FALSE))
36 return FALSE;
37
38 return UserIsIMMEnabled();
39#endif
40}
41
42BOOL
45{
46 INT *piSysMet = gpsi->aiSysMet;
48
49 /* Note: used for the SM_CLEANBOOT metric */
50 DWORD dwValue = 0;
51 HKEY hKey = 0;
52
53 /* Clean boot */
54 piSysMet[SM_CLEANBOOT] = 0; // Fallback value of 0 (normal mode)
55 if(NT_SUCCESS(RegOpenKey(L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Option", &hKey)))
56 {
57 if(RegReadDWORD(hKey, L"OptionValue", &dwValue)) piSysMet[SM_CLEANBOOT] = (INT)dwValue;
59 }
60
61 /* FIXME: HACK, due to missing MDEV on first init */
62 if (!gpmdev)
63 {
64 Width = 640;
65 Height = 480;
66 }
67 else
68 {
71 }
72
73 /* Screen sizes */
74 piSysMet[SM_CXSCREEN] = Width;
75 piSysMet[SM_CYSCREEN] = Height;
76 piSysMet[SM_XVIRTUALSCREEN] = 0;
77 piSysMet[SM_YVIRTUALSCREEN] = 0;
78 piSysMet[SM_CXVIRTUALSCREEN] = Width;
79 piSysMet[SM_CYVIRTUALSCREEN] = Height;
80
81 /* NC area sizes */
82 piSysMet[SM_CYCAPTION] = gspv.ncm.iCaptionHeight + 1; // 19
83 piSysMet[SM_CYSMCAPTION] = gspv.ncm.iSmCaptionHeight + 1; // 15;
84 piSysMet[SM_CXSIZE] = gspv.ncm.iCaptionHeight; // 18;
85 piSysMet[SM_CYSIZE] = gspv.ncm.iCaptionHeight; // 18;
86 piSysMet[SM_CXSMSIZE] = gspv.ncm.iSmCaptionWidth; // 12; XP: piSysMet(SM_CYSMCAPTION) - 1
87 piSysMet[SM_CYSMSIZE] = gspv.ncm.iSmCaptionHeight; // 14;
88 piSysMet[SM_CXBORDER] = 1; // Seems to be hardcoded
89 piSysMet[SM_CYBORDER] = 1; // Seems to be hardcoded
90 piSysMet[SM_CXFOCUSBORDER] = 1;
91 piSysMet[SM_CYFOCUSBORDER] = 1;
92 piSysMet[SM_CXDLGFRAME] = 3;
93 piSysMet[SM_CYDLGFRAME] = 3;
94 piSysMet[SM_CXEDGE] = 2;
95 piSysMet[SM_CYEDGE] = 2;
96 piSysMet[SM_CXFRAME] = piSysMet[SM_CXDLGFRAME] + gspv.ncm.iBorderWidth; // 4
97 piSysMet[SM_CYFRAME] = piSysMet[SM_CYDLGFRAME] + gspv.ncm.iBorderWidth; // 4
98#if (_WIN32_WINNT >= 0x0600)
99 piSysMet[SM_CXPADDEDBORDER] = 0;
100#endif
101
102 /* Window sizes */
103 TRACE("ncm.iCaptionWidth=%d,GetSystemMetrics(SM_CYSIZE)=%d,GetSystemMetrics(SM_CXFRAME)=%d,avcwCaption=%d \n",
104 gspv.ncm.iCaptionWidth, piSysMet[SM_CYSIZE],piSysMet[SM_CXFRAME], gspv.tmCaptionFont.tmAveCharWidth);
105
106 piSysMet[SM_CXMIN] = 3 * max(gspv.ncm.iCaptionWidth, 8) // 112
107 + piSysMet[SM_CYSIZE] + 4
109 + 2 * piSysMet[SM_CXFRAME];
110 piSysMet[SM_CYMIN] = piSysMet[SM_CYCAPTION] + 2 * piSysMet[SM_CYFRAME]; // 27
111 piSysMet[SM_CXMAXIMIZED] = piSysMet[SM_CXSCREEN] + 2 * piSysMet[SM_CXFRAME];
112 piSysMet[SM_CYMAXIMIZED] = piSysMet[SM_CYSCREEN] - 20;
113 piSysMet[SM_CXFULLSCREEN] = piSysMet[SM_CXSCREEN];
114 piSysMet[SM_CYFULLSCREEN] = piSysMet[SM_CYMAXIMIZED] - piSysMet[SM_CYMIN];
115 piSysMet[SM_CYKANJIWINDOW] = 0;
116 piSysMet[SM_CXMINIMIZED] = gspv.mm.iWidth + 6;
117 piSysMet[SM_CYMINIMIZED] = piSysMet[SM_CYCAPTION] + 5;
118 piSysMet[SM_CXMINSPACING] = piSysMet[SM_CXMINIMIZED] + gspv.mm.iHorzGap;
119 piSysMet[SM_CYMINSPACING] = piSysMet[SM_CYMINIMIZED] + gspv.mm.iVertGap;
120 piSysMet[SM_CXMAXTRACK] = piSysMet[SM_CXVIRTUALSCREEN] + 4
121 + 2 * piSysMet[SM_CXFRAME];
122 piSysMet[SM_CYMAXTRACK] = piSysMet[SM_CYVIRTUALSCREEN] + 4
123 + 2 * piSysMet[SM_CYFRAME];
124
125 /* Icon */
126 piSysMet[SM_CXVSCROLL] = gspv.ncm.iScrollWidth; // 16;
127 piSysMet[SM_CYVTHUMB] = gspv.ncm.iScrollHeight; // 16;
128 piSysMet[SM_CYHSCROLL] = gspv.ncm.iScrollWidth; // 16;
129 piSysMet[SM_CXHTHUMB] = gspv.ncm.iScrollHeight; // 16;
130 piSysMet[SM_CYVSCROLL] = gspv.ncm.iScrollHeight; // 16
131 piSysMet[SM_CXHSCROLL] = gspv.ncm.iScrollHeight; // 16;
132 piSysMet[SM_CXICON] = 32;
133 piSysMet[SM_CYICON] = 32;
134 piSysMet[SM_CXSMICON] = 16;
135 piSysMet[SM_CYSMICON] = 16;
136 piSysMet[SM_CXICONSPACING] = gspv.im.iHorzSpacing; // 64;
137 piSysMet[SM_CYICONSPACING] = gspv.im.iVertSpacing; // 64;
138 piSysMet[SM_CXCURSOR] = 32;
139 piSysMet[SM_CYCURSOR] = 32;
140 piSysMet[SM_CXMINTRACK] = piSysMet[SM_CXMIN]; // 117
141 piSysMet[SM_CYMINTRACK] = piSysMet[SM_CYMIN]; // 27
142 piSysMet[SM_CXDRAG] = 4;
143 piSysMet[SM_CYDRAG] = 4;
144 piSysMet[SM_ARRANGE] = gspv.mm.iArrange; // 8;
145
146 /* Menu */
147 piSysMet[SM_CYMENU] = gspv.ncm.iMenuHeight + 1; // 19;
149 piSysMet[SM_CXMENUCHECK] = ((1 + gspv.tmMenuFont.tmHeight +
150 gspv.tmMenuFont.tmExternalLeading) & ~1) - 1; // 13;
151 piSysMet[SM_CYMENUCHECK] = piSysMet[SM_CXMENUCHECK];
152 piSysMet[SM_CXMENUSIZE] = gspv.ncm.iMenuWidth; // 18;
153 piSysMet[SM_CYMENUSIZE] = gspv.ncm.iMenuHeight; // 18;
154
155 /* Mouse */
156 piSysMet[SM_MOUSEPRESENT] = 1;
157 piSysMet[SM_MOUSEWHEELPRESENT] = 1;
158 piSysMet[SM_CMOUSEBUTTONS] = 2;
159 piSysMet[SM_SWAPBUTTON] = gspv.bMouseBtnSwap ? 1 : 0;
162#if (_WIN32_WINNT >= 0x0600)
163 piSysMet[SM_MOUSEHORIZONTALWHEELPRESENT] = 0;
164#endif
165
166 /* Version info */
167 piSysMet[SM_TABLETPC] = 0;
168 piSysMet[SM_MEDIACENTER] = 0;
169 piSysMet[SM_STARTER] = 0;
170 piSysMet[SM_SERVERR2] = 0;
171 piSysMet[SM_PENWINDOWS] = 0;
172
173 /* Other */
174 piSysMet[SM_DEBUG] = 0;
175 piSysMet[SM_NETWORK] = 3;
176 piSysMet[SM_SLOWMACHINE] = 0;
177 piSysMet[SM_SECURE] = 0;
179 piSysMet[SM_SHOWSOUNDS] = gspv.bShowSounds;
180 piSysMet[SM_MIDEASTENABLED] = 0;
181 piSysMet[SM_CMONITORS] = 1;
182 piSysMet[SM_SAMEDISPLAYFORMAT] = 1;
183 piSysMet[SM_IMMENABLED] = NLS_MB_CODE_PAGE_TAG;
184
185 /* Reserved */
186 piSysMet[SM_RESERVED1] = 0;
187 piSysMet[SM_RESERVED2] = 0;
188 piSysMet[SM_RESERVED3] = 0;
189 piSysMet[SM_RESERVED4] = 0;
190 piSysMet[64] = 0;
191 piSysMet[65] = 0;
192 piSysMet[66] = 0;
193#if (_WIN32_WINNT >= 0x0600)
194 piSysMet[90] = 0;
195#endif
196
197 if (UserIsDBCSEnabled())
198 gpsi->dwSRVIFlags |= SRVINFO_DBCSENABLED; /* DBCS Support */
199
201 gpsi->dwSRVIFlags |= SRVINFO_IMM32; /* IME Support */
202
204 gpsi->dwSRVIFlags |= SRVINFO_CICERO_ENABLED; /* Cicero support */
205
206 Setup = TRUE;
207
208 return TRUE;
209}
210
211LONG
212NTAPI
214{
215 ASSERT(gpsi);
216 ASSERT(Setup);
217 TRACE("UserGetSystemMetrics(%lu)\n", Index);
218
219 if (Index == SM_DBCSENABLED)
221
222 if (Index == SM_IMMENABLED)
223 return !!(gpsi->dwSRVIFlags & SRVINFO_IMM32);
224
225 /* Get metrics from array */
226 if (Index < SM_CMETRICS)
227 {
228 return gpsi->aiSysMet[Index];
229 }
230
231 /* Handle special values */
232 switch (Index)
233 {
234 case SM_REMOTESESSION:
235 return 0; // FIXME
236
237 case SM_SHUTTINGDOWN:
238 return 0; // FIXME
239
240 case SM_REMOTECONTROL:
241 return 0; // FIXME
242 }
243
244 ERR("UserGetSystemMetrics() called with invalid index %lu\n", Index);
245 return 0;
246}
247
248/* EOF */
#define ERR(fmt,...)
Definition: debug.h:113
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:106
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PSERVERINFO gpsi
Definition: imm.c:18
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
#define SRVINFO_DBCSENABLED
Definition: ntuser.h:948
#define SRVINFO_CICERO_ENABLED
Definition: ntuser.h:951
#define SRVINFO_IMM32
Definition: ntuser.h:949
if(dx< 0)
Definition: linetemp.h:194
PMDEVOBJ gpmdev
Definition: mdevobj.c:14
#define ASSERT(a)
Definition: mode.c:44
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define FASTCALL
Definition: nt_native.h:50
#define NLS_MB_CODE_PAGE_TAG
Definition: nt_native.h:212
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define INT
Definition: polytest.cpp:20
#define TRACE(s)
Definition: solgame.cpp:4
ULONG ulVertRes
Definition: winddi.h:883
ULONG ulHorzRes
Definition: winddi.h:882
PPDEVOBJ ppdevGlobal
Definition: mdevobj.h:16
GDIINFO gdiinfo
Definition: pdevobj.h:123
MINIMIZEDMETRICS mm
Definition: sysparams.h:52
TEXTMETRICW tmCaptionFont
Definition: sysparams.h:139
NONCLIENTMETRICSW ncm
Definition: sysparams.h:51
INT iDblClickHeight
Definition: sysparams.h:89
BOOL bMouseBtnSwap
Definition: sysparams.h:82
TEXTMETRICW tmMenuFont
Definition: sysparams.h:138
ICONMETRICSW im
Definition: sysparams.h:53
BOOL bMenuDropAlign
Definition: sysparams.h:130
BOOL bShowSounds
Definition: sysparams.h:71
INT iDblClickWidth
Definition: sysparams.h:88
DWORD dwSRVIFlags
Definition: ntuser.h:1051
LONG tmAveCharWidth
Definition: wingdi.h:2388
LONG tmExternalLeading
Definition: wingdi.h:2387
LONG tmHeight
Definition: wingdi.h:2383
#define max(a, b)
Definition: svc.c:63
#define NTAPI
Definition: typedefs.h:36
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
_In_ WDFCOLLECTION _In_ ULONG Index
DWORD NTAPI RegGetSectionDWORD(LPCWSTR pszSection, PCWSTR pszValue, DWORD dwDefault)
Definition: registry.c:172
BOOL NTAPI RegReadDWORD(HKEY hkey, PCWSTR pwszValue, PDWORD pdwData)
Definition: registry.c:149
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:213
static BOOL Setup
Definition: metric.c:13
BOOL FASTCALL UserIsIMMEnabled(VOID)
Definition: metric.c:22
BOOL NTAPI InitMetrics(VOID)
Definition: metric.c:44
BOOL FASTCALL UserIsDBCSEnabled(VOID)
Definition: metric.c:17
BOOL FASTCALL UserIsCiceroEnabled(VOID)
Definition: metric.c:30
SPIVALUES gspv
Definition: sysparams.c:17
#define RegOpenKey
Definition: winreg.h:519
#define SM_MENUDROPALIGNMENT
Definition: winuser.h:1003
#define SM_CXMINIMIZED
Definition: winuser.h:1020
#define SM_NETWORK
Definition: winuser.h:1026
#define SM_CYVIRTUALSCREEN
Definition: winuser.h:1039
#define SM_CYEDGE
Definition: winuser.h:1009
#define SM_MIDEASTENABLED
Definition: winuser.h:1034
#define SM_CXDRAG
Definition: winuser.h:1028
#define SM_CXDOUBLECLK
Definition: winuser.h:999
#define SM_CXHTHUMB
Definition: winuser.h:971
#define SM_CYSCREEN
Definition: winuser.h:960
#define SM_RESERVED3
Definition: winuser.h:987
#define SM_CXEDGE
Definition: winuser.h:1008
#define SM_CYVSCROLL
Definition: winuser.h:981
#define SM_CMOUSEBUTTONS
Definition: winuser.h:1006
#define SM_CXMENUCHECK
Definition: winuser.h:1031
#define SM_CYSIZE
Definition: winuser.h:992
#define SM_PENWINDOWS
Definition: winuser.h:1004
#define SM_CXMINTRACK
Definition: winuser.h:997
#define SM_MOUSEPRESENT
Definition: winuser.h:980
#define SM_CXVSCROLL
Definition: winuser.h:961
#define SM_SAMEDISPLAYFORMAT
Definition: winuser.h:1041
#define SM_CYVTHUMB
Definition: winuser.h:970
#define SM_CYMINIMIZED
Definition: winuser.h:1021
#define SM_DEBUG
Definition: winuser.h:983
#define SM_CXFRAME
Definition: winuser.h:994
#define SM_CYICONSPACING
Definition: winuser.h:1002
#define SM_MOUSEWHEELPRESENT
Definition: winuser.h:1035
#define SM_CYMENU
Definition: winuser.h:976
#define SM_CYSMICON
Definition: winuser.h:1013
#define SM_CYDOUBLECLK
Definition: winuser.h:1000
#define SM_CXSIZE
Definition: winuser.h:991
#define SM_CYFRAME
Definition: winuser.h:996
#define SM_CYHSCROLL
Definition: winuser.h:962
#define SM_CXFULLSCREEN
Definition: winuser.h:977
#define SM_RESERVED1
Definition: winuser.h:985
#define SM_CXVIRTUALSCREEN
Definition: winuser.h:1038
#define SM_CXMIN
Definition: winuser.h:989
#define SM_CYBORDER
Definition: winuser.h:965
#define SM_CXSMICON
Definition: winuser.h:1012
#define SM_CYMIN
Definition: winuser.h:990
#define SM_CYMENUCHECK
Definition: winuser.h:1032
#define SM_CYICON
Definition: winuser.h:973
#define SM_CXMAXTRACK
Definition: winuser.h:1022
#define SM_CXMAXIMIZED
Definition: winuser.h:1024
#define SM_CYMINSPACING
Definition: winuser.h:1011
#define SM_CXSMSIZE
Definition: winuser.h:1015
#define SM_CXBORDER
Definition: winuser.h:964
#define SM_RESERVED2
Definition: winuser.h:986
#define SM_CYMAXTRACK
Definition: winuser.h:1023
#define SM_CYFULLSCREEN
Definition: winuser.h:978
#define SM_DBCSENABLED
Definition: winuser.h:1005
#define SM_CXDLGFRAME
Definition: winuser.h:966
#define SM_CYKANJIWINDOW
Definition: winuser.h:979
#define SM_CXHSCROLL
Definition: winuser.h:982
#define SM_RESERVED4
Definition: winuser.h:988
#define SM_SHOWSOUNDS
Definition: winuser.h:1030
#define SM_CXMENUSIZE
Definition: winuser.h:1017
#define SM_ARRANGE
Definition: winuser.h:1019
#define SM_CYSMCAPTION
Definition: winuser.h:1014
#define SM_CYSMSIZE
Definition: winuser.h:1016
#define SM_CYDLGFRAME
Definition: winuser.h:968
#define SM_CLEANBOOT
Definition: winuser.h:1027
#define SM_REMOTESESSION
Definition: winuser.h:1058
#define SM_CXSCREEN
Definition: winuser.h:959
#define SM_SWAPBUTTON
Definition: winuser.h:984
#define SM_SLOWMACHINE
Definition: winuser.h:1033
#define SM_CYMENUSIZE
Definition: winuser.h:1018
#define SM_XVIRTUALSCREEN
Definition: winuser.h:1036
#define SM_CYCURSOR
Definition: winuser.h:975
#define SM_CYDRAG
Definition: winuser.h:1029
#define SM_CXICON
Definition: winuser.h:972
#define SM_CMONITORS
Definition: winuser.h:1040
#define SM_CYMAXIMIZED
Definition: winuser.h:1025
#define SM_CYCAPTION
Definition: winuser.h:963
#define SM_CYMINTRACK
Definition: winuser.h:998
#define SM_CXICONSPACING
Definition: winuser.h:1001
#define SM_CXMINSPACING
Definition: winuser.h:1010
#define SM_YVIRTUALSCREEN
Definition: winuser.h:1037
#define SM_SECURE
Definition: winuser.h:1007
#define SM_CMETRICS
Definition: winuser.h:1065
#define SM_CXCURSOR
Definition: winuser.h:974