[NTOSKRNL/USERINIT/WIN32K]
[reactos.git] / reactos / subsystems / win32 / win32k / ntuser / metric.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Window classes
5 * FILE: subsys/win32k/ntuser/metric.c
6 * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
7 * Timo Kreuzer (timo.kreuzer@reactos.org)
8 */
9
10 /* INCLUDES ******************************************************************/
11
12 #include <win32k.h>
13
14 #define NDEBUG
15 #include <debug.h>
16
17
18 static BOOL Setup = FALSE;
19
20 /* FUNCTIONS *****************************************************************/
21
22 BOOL
23 FASTCALL
24 InitMetrics(VOID)
25 {
26 INT *piSysMet = gpsi->aiSysMet;
27 ULONG Width, Height;
28
29 /* note: used for the SM_CLEANBOOT metric */
30 DWORD dwValue = 0;
31 HKEY hKey = 0;
32
33 /* Clean boot */
34 piSysMet[SM_CLEANBOOT] = 0; // fallback value of 0 (normal mode)
35 if(NT_SUCCESS(RegOpenKey(L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Option", &hKey)))
36 {
37 if(RegReadDWORD(hKey, L"OptionValue", &dwValue)) piSysMet[SM_CLEANBOOT] = (INT)dwValue;
38 ZwClose(hKey);
39 }
40
41 /* FIXME: HACK, due to missing PDEV on first init */
42 if (!pPrimarySurface)
43 {
44 Width = 640;
45 Height = 480;
46 }
47 else
48 {
49 Width = pPrimarySurface->gdiinfo.ulHorzRes;
50 Height = pPrimarySurface->gdiinfo.ulVertRes;
51 }
52
53 /* Screen sizes */
54 piSysMet[SM_CXSCREEN] = Width;
55 piSysMet[SM_CYSCREEN] = Height;
56 piSysMet[SM_XVIRTUALSCREEN] = 0;
57 piSysMet[SM_YVIRTUALSCREEN] = 0;
58 piSysMet[SM_CXVIRTUALSCREEN] = Width;
59 piSysMet[SM_CYVIRTUALSCREEN] = Height;
60
61 /* NC area sizes */
62 piSysMet[SM_CYCAPTION] = gspv.ncm.iCaptionHeight + 1; // 19
63 piSysMet[SM_CYSMCAPTION] = gspv.ncm.iSmCaptionHeight + 1; // 15;
64 piSysMet[SM_CXSIZE] = gspv.ncm.iCaptionHeight; // 18;
65 piSysMet[SM_CYSIZE] = gspv.ncm.iCaptionHeight; // 18;
66 piSysMet[SM_CXSMSIZE] = gspv.ncm.iSmCaptionWidth; // 12; xp: piSysMet(SM_CYSMCAPTION) - 1
67 piSysMet[SM_CYSMSIZE] = gspv.ncm.iSmCaptionHeight; // 14;
68 piSysMet[SM_CXBORDER] = 1; // seems to be hardcoded
69 piSysMet[SM_CYBORDER] = 1; // seems to be hardcoded
70 piSysMet[SM_CXFOCUSBORDER] = 1;
71 piSysMet[SM_CYFOCUSBORDER] = 1;
72 piSysMet[SM_CXDLGFRAME] = 3;
73 piSysMet[SM_CYDLGFRAME] = 3;
74 piSysMet[SM_CXEDGE] = 2;
75 piSysMet[SM_CYEDGE] = 2;
76 piSysMet[SM_CXFRAME] = piSysMet[SM_CXDLGFRAME] + gspv.ncm.iBorderWidth; // 4
77 piSysMet[SM_CYFRAME] = piSysMet[SM_CYDLGFRAME] + gspv.ncm.iBorderWidth; // 4
78 #if (_WIN32_WINNT >= 0x0600)
79 piSysMet[SM_CXPADDEDBORDER] = 0;
80 #endif
81
82 /* Window sizes */
83 DPRINT("ncm.iCaptionWidth=%d,GetSystemMetrics(SM_CYSIZE)=%d,GetSystemMetrics(SM_CXFRAME)=%d,avcwCaption=%d \n",
84 gspv.ncm.iCaptionWidth, piSysMet[SM_CYSIZE],piSysMet[SM_CXFRAME], gspv.tmCaptionFont.tmAveCharWidth);
85
86 piSysMet[SM_CXMIN] = 3 * max(gspv.ncm.iCaptionWidth, 8) // 112
87 + piSysMet[SM_CYSIZE] + 4
88 + 4 * gspv.tmCaptionFont.tmAveCharWidth
89 + 2 * piSysMet[SM_CXFRAME];
90 piSysMet[SM_CYMIN] = piSysMet[SM_CYCAPTION] + 2 * piSysMet[SM_CYFRAME];// 27
91 piSysMet[SM_CXMAXIMIZED] = piSysMet[SM_CXSCREEN] + 2 * piSysMet[SM_CXFRAME];
92 piSysMet[SM_CYMAXIMIZED] = piSysMet[SM_CYSCREEN] - 20;
93 piSysMet[SM_CXFULLSCREEN] = piSysMet[SM_CXSCREEN];
94 piSysMet[SM_CYFULLSCREEN] = piSysMet[SM_CYMAXIMIZED] - piSysMet[SM_CYMIN];
95 piSysMet[SM_CYKANJIWINDOW] = 0;
96 piSysMet[SM_CXMINIMIZED] = gspv.mm.iWidth + 6;
97 piSysMet[SM_CYMINIMIZED] = piSysMet[SM_CYCAPTION] + 5;
98 piSysMet[SM_CXMINSPACING] = piSysMet[SM_CXMINIMIZED] + gspv.mm.iHorzGap;
99 piSysMet[SM_CYMINSPACING] = piSysMet[SM_CYMINIMIZED] + gspv.mm.iVertGap;
100 piSysMet[SM_CXMAXTRACK] = piSysMet[SM_CXVIRTUALSCREEN] + 4
101 + 2 * piSysMet[SM_CXFRAME];
102 piSysMet[SM_CYMAXTRACK] = piSysMet[SM_CYVIRTUALSCREEN] + 4
103 + 2 * piSysMet[SM_CYFRAME];
104
105 /* Icon */
106 piSysMet[SM_CXVSCROLL] = gspv.ncm.iScrollWidth; //16;
107 piSysMet[SM_CYVTHUMB] = gspv.ncm.iScrollHeight; //16;
108 piSysMet[SM_CYHSCROLL] = gspv.ncm.iScrollWidth; //16;
109 piSysMet[SM_CXHTHUMB] = gspv.ncm.iScrollHeight; //16;
110 piSysMet[SM_CYVSCROLL] = gspv.ncm.iScrollHeight; // 16
111 piSysMet[SM_CXHSCROLL] = gspv.ncm.iScrollHeight; // 16;
112 piSysMet[SM_CXICON] = 32;
113 piSysMet[SM_CYICON] = 32;
114 piSysMet[SM_CXSMICON] = 16;
115 piSysMet[SM_CYSMICON] = 16;
116 piSysMet[SM_CXICONSPACING] = gspv.im.iHorzSpacing;// 64;
117 piSysMet[SM_CYICONSPACING] = gspv.im.iVertSpacing; // 64;
118 piSysMet[SM_CXCURSOR] = 32;
119 piSysMet[SM_CYCURSOR] = 32;
120 piSysMet[SM_CXMINTRACK] = piSysMet[SM_CXMIN]; // 117
121 piSysMet[SM_CYMINTRACK] = piSysMet[SM_CYMIN]; // 27
122 piSysMet[SM_CXDRAG] = 4;
123 piSysMet[SM_CYDRAG] = 4;
124 piSysMet[SM_ARRANGE] = gspv.mm.iArrange; // 8;
125
126 /* Menu */
127 piSysMet[SM_CYMENU] = gspv.ncm.iMenuHeight + 1;//19;
128 piSysMet[SM_MENUDROPALIGNMENT] = gspv.bMenuDropAlign;
129 piSysMet[SM_CXMENUCHECK] = ((1 + gspv.tmMenuFont.tmHeight +
130 gspv.tmMenuFont.tmExternalLeading) & ~1) - 1; // 13;
131 piSysMet[SM_CYMENUCHECK] = piSysMet[SM_CXMENUCHECK];
132 piSysMet[SM_CXMENUSIZE] = gspv.ncm.iMenuWidth; //18;
133 piSysMet[SM_CYMENUSIZE] = gspv.ncm.iMenuHeight; //18;
134
135 /* Mouse */
136 piSysMet[SM_MOUSEPRESENT] = 1;
137 piSysMet[SM_MOUSEWHEELPRESENT] = 1;
138 piSysMet[SM_CMOUSEBUTTONS] = 2;
139 piSysMet[SM_SWAPBUTTON] = gspv.bMouseBtnSwap ? 1 : 0;
140 piSysMet[SM_CXDOUBLECLK] = gspv.iDblClickWidth;
141 piSysMet[SM_CYDOUBLECLK] = gspv.iDblClickHeight;
142 #if (_WIN32_WINNT >= 0x0600)
143 piSysMet[SM_MOUSEHORIZONTALWHEELPRESENT] = 0;
144 #endif
145
146 /* Version info */
147 piSysMet[SM_TABLETPC] = 0;
148 piSysMet[SM_MEDIACENTER] = 0;
149 piSysMet[SM_STARTER] = 0;
150 piSysMet[SM_SERVERR2] = 0;
151 piSysMet[SM_PENWINDOWS] = 0;
152
153 /* Other */
154 piSysMet[SM_DEBUG] = 0;
155 piSysMet[SM_NETWORK] = 3;
156 piSysMet[SM_SLOWMACHINE] = 0;
157 piSysMet[SM_SECURE] = 0;
158 piSysMet[SM_DBCSENABLED] = 0;
159 piSysMet[SM_SHOWSOUNDS] = gspv.bShowSounds;
160 piSysMet[SM_MIDEASTENABLED] = 0;
161 piSysMet[SM_CMONITORS] = 1;
162 piSysMet[SM_SAMEDISPLAYFORMAT] = 1;
163 piSysMet[SM_IMMENABLED] = 0;
164
165 /* Reserved */
166 piSysMet[SM_RESERVED1] = 0;
167 piSysMet[SM_RESERVED2] = 0;
168 piSysMet[SM_RESERVED3] = 0;
169 piSysMet[SM_RESERVED4] = 0;
170 piSysMet[64] = 0;
171 piSysMet[65] = 0;
172 piSysMet[66] = 0;
173 #if (_WIN32_WINNT >= 0x0600)
174 piSysMet[90] = 0;
175 #endif
176
177 gpsi->dwSRVIFlags |= SRVINFO_METRICS;
178 Setup = TRUE;
179
180 return TRUE;
181 }
182
183 ULONG FASTCALL
184 UserGetSystemMetrics(ULONG Index)
185 {
186 ASSERT(gpsi);
187 ASSERT(Setup);
188 DPRINT("UserGetSystemMetrics(%d)\n", Index);
189
190 /* Get metrics from array */
191 if (Index < SM_CMETRICS)
192 {
193 return gpsi->aiSysMet[Index];
194 }
195
196 /* Handle special values */
197 switch (Index)
198 {
199 case SM_REMOTESESSION:
200 return 0; // FIXME
201
202 case SM_SHUTTINGDOWN:
203 return 0; // FIXME
204
205 case SM_REMOTECONTROL:
206 return 0; // FIXME
207 }
208
209 DPRINT1("UserGetSystemMetrics() called with invalid index %d\n", Index);
210 return 0;
211 }
212
213
214 /* EOF */