Sync to trunk HEAD (r43416)
[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 <w32k.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 NTSTATUS Status;
27 PWINSTATION_OBJECT WinStaObject;
28 ULONG Width = 640, Height = 480;
29 PSYSTEM_CURSORINFO CurInfo;
30 INT *piSysMet;
31
32 Width = pPrimarySurface->gdiinfo.ulHorzRes;
33 Height = pPrimarySurface->gdiinfo.ulVertRes;
34
35 Status = IntValidateWindowStationHandle(PsGetCurrentProcess()->Win32WindowStation,
36 KernelMode,
37 0,
38 &WinStaObject);
39 if (NT_SUCCESS(Status))
40 {
41 CurInfo = IntGetSysCursorInfo(WinStaObject);
42 }
43 else
44 {
45 CurInfo = NULL;
46 }
47
48 piSysMet = gpsi->aiSysMet;
49
50 /* Screen sizes */
51 piSysMet[SM_CXSCREEN] = Width;
52 piSysMet[SM_CYSCREEN] = Height;
53 piSysMet[SM_XVIRTUALSCREEN] = 0;
54 piSysMet[SM_YVIRTUALSCREEN] = 0;
55 piSysMet[SM_CXVIRTUALSCREEN] = Width;
56 piSysMet[SM_CYVIRTUALSCREEN] = Height;
57
58 /* NC area sizes */
59 piSysMet[SM_CYCAPTION] = gspv.ncm.iCaptionHeight + 1; // 19
60 piSysMet[SM_CYSMCAPTION] = gspv.ncm.iSmCaptionHeight + 1; // 15;
61 piSysMet[SM_CXSIZE] = gspv.ncm.iCaptionHeight; // 18;
62 piSysMet[SM_CYSIZE] = gspv.ncm.iCaptionHeight; // 18;
63 piSysMet[SM_CXSMSIZE] = gspv.ncm.iSmCaptionWidth; // 12; xp: piSysMet(SM_CYSMCAPTION) - 1
64 piSysMet[SM_CYSMSIZE] = gspv.ncm.iSmCaptionHeight; // 14;
65 piSysMet[SM_CXBORDER] = 1; // seems to be hardcoded
66 piSysMet[SM_CYBORDER] = 1; // seems to be hardcoded
67 piSysMet[SM_CXFOCUSBORDER] = 1;
68 piSysMet[SM_CYFOCUSBORDER] = 1;
69 piSysMet[SM_CXDLGFRAME] = 3;
70 piSysMet[SM_CYDLGFRAME] = 3;
71 piSysMet[SM_CXEDGE] = 2;
72 piSysMet[SM_CYEDGE] = 2;
73 piSysMet[SM_CXFRAME] = piSysMet[SM_CXDLGFRAME] + gspv.ncm.iBorderWidth; // 4
74 piSysMet[SM_CYFRAME] = piSysMet[SM_CYDLGFRAME] + gspv.ncm.iBorderWidth; // 4
75 #if (_WIN32_WINNT >= 0x0600)
76 piSysMet[SM_CXPADDEDBORDER] = 0;
77 #endif
78
79 /* Window sizes */
80 DPRINT("ncm.iCaptionWidth=%d,GetSystemMetrics(SM_CYSIZE)=%d,GetSystemMetrics(SM_CXFRAME)=%d,avcwCaption=%d \n",
81 gspv.ncm.iCaptionWidth, piSysMet[SM_CYSIZE],piSysMet[SM_CXFRAME], gspv.tmCaptionFont.tmAveCharWidth);
82
83 piSysMet[SM_CXMIN] = 3 * max(gspv.ncm.iCaptionWidth, 8) // 112
84 + piSysMet[SM_CYSIZE] + 4
85 + 4 * gspv.tmCaptionFont.tmAveCharWidth
86 + 2 * piSysMet[SM_CXFRAME];
87 piSysMet[SM_CYMIN] = piSysMet[SM_CYCAPTION] + 2 * piSysMet[SM_CYFRAME];// 27
88 piSysMet[SM_CXMAXIMIZED] = piSysMet[SM_CXSCREEN] + 2 * piSysMet[SM_CXFRAME];
89 piSysMet[SM_CYMAXIMIZED] = piSysMet[SM_CYSCREEN] - 20;
90 piSysMet[SM_CXFULLSCREEN] = piSysMet[SM_CXSCREEN];
91 piSysMet[SM_CYFULLSCREEN] = piSysMet[SM_CYMAXIMIZED] - piSysMet[SM_CYMIN];
92 piSysMet[SM_CYKANJIWINDOW] = 0;
93 piSysMet[SM_CXMINIMIZED] = gspv.mm.iWidth + 6;
94 piSysMet[SM_CYMINIMIZED] = piSysMet[SM_CYCAPTION] + 5;
95 piSysMet[SM_CXMINSPACING] = piSysMet[SM_CXMINIMIZED] + gspv.mm.iHorzGap;
96 piSysMet[SM_CYMINSPACING] = piSysMet[SM_CYMINIMIZED] + gspv.mm.iVertGap;
97 piSysMet[SM_CXMAXTRACK] = piSysMet[SM_CXVIRTUALSCREEN] + 4
98 + 2 * piSysMet[SM_CXFRAME];
99 piSysMet[SM_CYMAXTRACK] = piSysMet[SM_CYVIRTUALSCREEN] + 4
100 + 2 * piSysMet[SM_CYFRAME];
101
102 /* Icon */
103 piSysMet[SM_CXVSCROLL] = gspv.ncm.iScrollWidth; //16;
104 piSysMet[SM_CYVTHUMB] = gspv.ncm.iScrollHeight; //16;
105 piSysMet[SM_CYHSCROLL] = gspv.ncm.iScrollWidth; //16;
106 piSysMet[SM_CXHTHUMB] = gspv.ncm.iScrollHeight; //16;
107 piSysMet[SM_CYVSCROLL] = gspv.ncm.iScrollHeight; // 16
108 piSysMet[SM_CXHSCROLL] = gspv.ncm.iScrollHeight; // 16;
109 piSysMet[SM_CXICON] = 32;
110 piSysMet[SM_CYICON] = 32;
111 piSysMet[SM_CXSMICON] = 16;
112 piSysMet[SM_CYSMICON] = 16;
113 piSysMet[SM_CXICONSPACING] = gspv.im.iHorzSpacing;// 64;
114 piSysMet[SM_CYICONSPACING] = gspv.im.iVertSpacing; // 64;
115 piSysMet[SM_CXCURSOR] = 32;
116 piSysMet[SM_CYCURSOR] = 32;
117 piSysMet[SM_CXMINTRACK] = piSysMet[SM_CXMIN]; // 117
118 piSysMet[SM_CYMINTRACK] = piSysMet[SM_CYMIN]; // 27
119 piSysMet[SM_CXDRAG] = 4;
120 piSysMet[SM_CYDRAG] = 4;
121 piSysMet[SM_ARRANGE] = gspv.mm.iArrange; // 8;
122
123 /* Menu */
124 piSysMet[SM_CYMENU] = gspv.ncm.iMenuHeight + 1;//19;
125 piSysMet[SM_MENUDROPALIGNMENT] = gspv.bMenuDropAlign;
126 piSysMet[SM_CXMENUCHECK] = ((1 + gspv.tmMenuFont.tmHeight +
127 gspv.tmMenuFont.tmExternalLeading) & ~1) - 1; // 13;
128 piSysMet[SM_CYMENUCHECK] = piSysMet[SM_CXMENUCHECK];
129 piSysMet[SM_CXMENUSIZE] = gspv.ncm.iMenuWidth; //18;
130 piSysMet[SM_CYMENUSIZE] = gspv.ncm.iMenuHeight; //18;
131
132 /* Mouse */
133 piSysMet[SM_MOUSEPRESENT] = 1;
134 piSysMet[SM_MOUSEWHEELPRESENT] = 1;
135 piSysMet[SM_CMOUSEBUTTONS] = 2;
136 piSysMet[SM_SWAPBUTTON] = gspv.bMouseBtnSwap ? 1 : 0;
137 piSysMet[SM_CXDOUBLECLK] = gspv.iDblClickWidth;
138 piSysMet[SM_CYDOUBLECLK] = gspv.iDblClickHeight;
139 #if (_WIN32_WINNT >= 0x0600)
140 piSysMet[SM_MOUSEHORIZONTALWHEELPRESENT] = 0;
141 #endif
142
143 /* Version info */
144 piSysMet[SM_TABLETPC] = 0;
145 piSysMet[SM_MEDIACENTER] = 0;
146 piSysMet[SM_STARTER] = 0;
147 piSysMet[SM_SERVERR2] = 0;
148 piSysMet[SM_PENWINDOWS] = 0;
149
150 /* Other */
151 piSysMet[SM_DEBUG] = 0;
152 piSysMet[SM_NETWORK] = 3;
153 piSysMet[SM_SLOWMACHINE] = 0;
154 piSysMet[SM_SECURE] = 0;
155 piSysMet[SM_DBCSENABLED] = 0;
156 piSysMet[SM_CLEANBOOT] = 0;
157 piSysMet[SM_SHOWSOUNDS] = gspv.bShowSounds;
158 piSysMet[SM_MIDEASTENABLED] = 0;
159 piSysMet[SM_CMONITORS] = 1;
160 piSysMet[SM_SAMEDISPLAYFORMAT] = 1;
161 piSysMet[SM_IMMENABLED] = 0;
162
163 /* Reserved */
164 piSysMet[SM_RESERVED1] = 0;
165 piSysMet[SM_RESERVED2] = 0;
166 piSysMet[SM_RESERVED3] = 0;
167 piSysMet[SM_RESERVED4] = 0;
168 piSysMet[64] = 0;
169 piSysMet[65] = 0;
170 piSysMet[66] = 0;
171 #if (_WIN32_WINNT >= 0x0600)
172 piSysMet[90] = 0;
173 #endif
174
175 gpsi->dwSRVIFlags |= SRVINFO_METRICS;
176 Setup = TRUE;
177
178 if (NT_SUCCESS(Status))
179 {
180 ObDereferenceObject(WinStaObject);
181 }
182
183 return TRUE;
184 }
185
186 ULONG FASTCALL
187 UserGetSystemMetrics(ULONG Index)
188 {
189 ASSERT(gpsi);
190 ASSERT(Setup);
191 DPRINT("UserGetSystemMetrics(%d)\n", Index);
192
193 /* Get metrics from array */
194 if (Index < SM_CMETRICS)
195 {
196 return gpsi->aiSysMet[Index];
197 }
198
199 /* Handle special values */
200 switch (Index)
201 {
202 case SM_REMOTESESSION:
203 return 0; // FIXME
204
205 case SM_SHUTTINGDOWN:
206 return 0; // FIXME
207
208 case SM_REMOTECONTROL:
209 return 0; // FIXME
210 }
211
212 DPRINT1("UserGetSystemMetrics() called with invalid index %d\n", Index);
213 return 0;
214 }
215
216
217 /* EOF */