ReactOS  0.4.14-dev-77-gd9e7c48
metric.c File Reference
#include <win32k.h>
Include dependency graph for metric.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (UserSysparams)
 
BOOL NTAPI InitMetrics (VOID)
 
LONG NTAPI UserGetSystemMetrics (ULONG Index)
 

Variables

static BOOL Setup = FALSE
 

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserSysparams  )

◆ InitMetrics()

BOOL NTAPI InitMetrics ( VOID  )

Definition at line 19 of file metric.c.

20 {
21  INT *piSysMet = gpsi->aiSysMet;
22  ULONG Width, Height;
23 
24  /* Note: used for the SM_CLEANBOOT metric */
25  DWORD dwValue = 0;
26  HKEY hKey = 0;
27 
28  /* Clean boot */
29  piSysMet[SM_CLEANBOOT] = 0; // Fallback value of 0 (normal mode)
30  if(NT_SUCCESS(RegOpenKey(L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Option", &hKey)))
31  {
32  if(RegReadDWORD(hKey, L"OptionValue", &dwValue)) piSysMet[SM_CLEANBOOT] = (INT)dwValue;
33  ZwClose(hKey);
34  }
35 
36  /* FIXME: HACK, due to missing PDEV on first init */
37  if (!gppdevPrimary)
38  {
39  Width = 640;
40  Height = 480;
41  }
42  else
43  {
46  }
47 
48  /* Screen sizes */
49  piSysMet[SM_CXSCREEN] = Width;
50  piSysMet[SM_CYSCREEN] = Height;
51  piSysMet[SM_XVIRTUALSCREEN] = 0;
52  piSysMet[SM_YVIRTUALSCREEN] = 0;
53  piSysMet[SM_CXVIRTUALSCREEN] = Width;
54  piSysMet[SM_CYVIRTUALSCREEN] = Height;
55 
56  /* NC area sizes */
57  piSysMet[SM_CYCAPTION] = gspv.ncm.iCaptionHeight + 1; // 19
58  piSysMet[SM_CYSMCAPTION] = gspv.ncm.iSmCaptionHeight + 1; // 15;
59  piSysMet[SM_CXSIZE] = gspv.ncm.iCaptionHeight; // 18;
60  piSysMet[SM_CYSIZE] = gspv.ncm.iCaptionHeight; // 18;
61  piSysMet[SM_CXSMSIZE] = gspv.ncm.iSmCaptionWidth; // 12; XP: piSysMet(SM_CYSMCAPTION) - 1
62  piSysMet[SM_CYSMSIZE] = gspv.ncm.iSmCaptionHeight; // 14;
63  piSysMet[SM_CXBORDER] = 1; // Seems to be hardcoded
64  piSysMet[SM_CYBORDER] = 1; // Seems to be hardcoded
65  piSysMet[SM_CXFOCUSBORDER] = 1;
66  piSysMet[SM_CYFOCUSBORDER] = 1;
67  piSysMet[SM_CXDLGFRAME] = 3;
68  piSysMet[SM_CYDLGFRAME] = 3;
69  piSysMet[SM_CXEDGE] = 2;
70  piSysMet[SM_CYEDGE] = 2;
71  piSysMet[SM_CXFRAME] = piSysMet[SM_CXDLGFRAME] + gspv.ncm.iBorderWidth; // 4
72  piSysMet[SM_CYFRAME] = piSysMet[SM_CYDLGFRAME] + gspv.ncm.iBorderWidth; // 4
73 #if (_WIN32_WINNT >= 0x0600)
74  piSysMet[SM_CXPADDEDBORDER] = 0;
75 #endif
76 
77  /* Window sizes */
78  TRACE("ncm.iCaptionWidth=%d,GetSystemMetrics(SM_CYSIZE)=%d,GetSystemMetrics(SM_CXFRAME)=%d,avcwCaption=%d \n",
79  gspv.ncm.iCaptionWidth, piSysMet[SM_CYSIZE],piSysMet[SM_CXFRAME], gspv.tmCaptionFont.tmAveCharWidth);
80 
81  piSysMet[SM_CXMIN] = 3 * max(gspv.ncm.iCaptionWidth, 8) // 112
82  + piSysMet[SM_CYSIZE] + 4
84  + 2 * piSysMet[SM_CXFRAME];
85  piSysMet[SM_CYMIN] = piSysMet[SM_CYCAPTION] + 2 * piSysMet[SM_CYFRAME]; // 27
86  piSysMet[SM_CXMAXIMIZED] = piSysMet[SM_CXSCREEN] + 2 * piSysMet[SM_CXFRAME];
87  piSysMet[SM_CYMAXIMIZED] = piSysMet[SM_CYSCREEN] - 20;
88  piSysMet[SM_CXFULLSCREEN] = piSysMet[SM_CXSCREEN];
89  piSysMet[SM_CYFULLSCREEN] = piSysMet[SM_CYMAXIMIZED] - piSysMet[SM_CYMIN];
90  piSysMet[SM_CYKANJIWINDOW] = 0;
91  piSysMet[SM_CXMINIMIZED] = gspv.mm.iWidth + 6;
92  piSysMet[SM_CYMINIMIZED] = piSysMet[SM_CYCAPTION] + 5;
93  piSysMet[SM_CXMINSPACING] = piSysMet[SM_CXMINIMIZED] + gspv.mm.iHorzGap;
94  piSysMet[SM_CYMINSPACING] = piSysMet[SM_CYMINIMIZED] + gspv.mm.iVertGap;
95  piSysMet[SM_CXMAXTRACK] = piSysMet[SM_CXVIRTUALSCREEN] + 4
96  + 2 * piSysMet[SM_CXFRAME];
97  piSysMet[SM_CYMAXTRACK] = piSysMet[SM_CYVIRTUALSCREEN] + 4
98  + 2 * piSysMet[SM_CYFRAME];
99 
100  /* Icon */
101  piSysMet[SM_CXVSCROLL] = gspv.ncm.iScrollWidth; // 16;
102  piSysMet[SM_CYVTHUMB] = gspv.ncm.iScrollHeight; // 16;
103  piSysMet[SM_CYHSCROLL] = gspv.ncm.iScrollWidth; // 16;
104  piSysMet[SM_CXHTHUMB] = gspv.ncm.iScrollHeight; // 16;
105  piSysMet[SM_CYVSCROLL] = gspv.ncm.iScrollHeight; // 16
106  piSysMet[SM_CXHSCROLL] = gspv.ncm.iScrollHeight; // 16;
107  piSysMet[SM_CXICON] = 32;
108  piSysMet[SM_CYICON] = 32;
109  piSysMet[SM_CXSMICON] = 16;
110  piSysMet[SM_CYSMICON] = 16;
111  piSysMet[SM_CXICONSPACING] = gspv.im.iHorzSpacing; // 64;
112  piSysMet[SM_CYICONSPACING] = gspv.im.iVertSpacing; // 64;
113  piSysMet[SM_CXCURSOR] = 32;
114  piSysMet[SM_CYCURSOR] = 32;
115  piSysMet[SM_CXMINTRACK] = piSysMet[SM_CXMIN]; // 117
116  piSysMet[SM_CYMINTRACK] = piSysMet[SM_CYMIN]; // 27
117  piSysMet[SM_CXDRAG] = 4;
118  piSysMet[SM_CYDRAG] = 4;
119  piSysMet[SM_ARRANGE] = gspv.mm.iArrange; // 8;
120 
121  /* Menu */
122  piSysMet[SM_CYMENU] = gspv.ncm.iMenuHeight + 1; // 19;
124  piSysMet[SM_CXMENUCHECK] = ((1 + gspv.tmMenuFont.tmHeight +
125  gspv.tmMenuFont.tmExternalLeading) & ~1) - 1; // 13;
126  piSysMet[SM_CYMENUCHECK] = piSysMet[SM_CXMENUCHECK];
127  piSysMet[SM_CXMENUSIZE] = gspv.ncm.iMenuWidth; // 18;
128  piSysMet[SM_CYMENUSIZE] = gspv.ncm.iMenuHeight; // 18;
129 
130  /* Mouse */
131  piSysMet[SM_MOUSEPRESENT] = 1;
132  piSysMet[SM_MOUSEWHEELPRESENT] = 1;
133  piSysMet[SM_CMOUSEBUTTONS] = 2;
134  piSysMet[SM_SWAPBUTTON] = gspv.bMouseBtnSwap ? 1 : 0;
135  piSysMet[SM_CXDOUBLECLK] = gspv.iDblClickWidth;
136  piSysMet[SM_CYDOUBLECLK] = gspv.iDblClickHeight;
137 #if (_WIN32_WINNT >= 0x0600)
138  piSysMet[SM_MOUSEHORIZONTALWHEELPRESENT] = 0;
139 #endif
140 
141  /* Version info */
142  piSysMet[SM_TABLETPC] = 0;
143  piSysMet[SM_MEDIACENTER] = 0;
144  piSysMet[SM_STARTER] = 0;
145  piSysMet[SM_SERVERR2] = 0;
146  piSysMet[SM_PENWINDOWS] = 0;
147 
148  /* Other */
149  piSysMet[SM_DEBUG] = 0;
150  piSysMet[SM_NETWORK] = 3;
151  piSysMet[SM_SLOWMACHINE] = 0;
152  piSysMet[SM_SECURE] = 0;
153  piSysMet[SM_DBCSENABLED] = 0;
154  piSysMet[SM_SHOWSOUNDS] = gspv.bShowSounds;
155  piSysMet[SM_MIDEASTENABLED] = 0;
156  piSysMet[SM_CMONITORS] = 1;
157  piSysMet[SM_SAMEDISPLAYFORMAT] = 1;
158  piSysMet[SM_IMMENABLED] = 0;
159 
160  /* Reserved */
161  piSysMet[SM_RESERVED1] = 0;
162  piSysMet[SM_RESERVED2] = 0;
163  piSysMet[SM_RESERVED3] = 0;
164  piSysMet[SM_RESERVED4] = 0;
165  piSysMet[64] = 0;
166  piSysMet[65] = 0;
167  piSysMet[66] = 0;
168 #if (_WIN32_WINNT >= 0x0600)
169  piSysMet[90] = 0;
170 #endif
171 
173  Setup = TRUE;
174 
175  return TRUE;
176 }
#define SM_CXICONSPACING
Definition: winuser.h:991
#define max(a, b)
Definition: svc.c:63
#define SM_CYDOUBLECLK
Definition: winuser.h:990
#define SM_CYHSCROLL
Definition: winuser.h:952
#define TRUE
Definition: types.h:120
#define SM_SHOWSOUNDS
Definition: winuser.h:1020
#define SM_CYSIZE
Definition: winuser.h:982
#define SM_XVIRTUALSCREEN
Definition: winuser.h:1026
#define SM_CYMENUSIZE
Definition: winuser.h:1008
LONG tmExternalLeading
Definition: wingdi.h:2382
#define SM_CMONITORS
Definition: winuser.h:1030
#define SM_CYMINTRACK
Definition: winuser.h:988
#define SM_MOUSEPRESENT
Definition: winuser.h:970
#define SM_CXVIRTUALSCREEN
Definition: winuser.h:1028
#define SM_CXMINIMIZED
Definition: winuser.h:1010
BOOL bMouseBtnSwap
Definition: sysparams.h:82
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
GDIINFO gdiinfo
Definition: pdevobj.h:124
PPDEVOBJ gppdevPrimary
Definition: pdevobj.c:13
#define SM_MIDEASTENABLED
Definition: winuser.h:1024
LONG tmAveCharWidth
Definition: wingdi.h:2383
#define SM_SLOWMACHINE
Definition: winuser.h:1023
#define INT
Definition: polytest.cpp:20
#define SM_CYVSCROLL
Definition: winuser.h:971
NONCLIENTMETRICSW ncm
Definition: sysparams.h:51
#define SM_CXMENUCHECK
Definition: winuser.h:1021
#define SM_CYCURSOR
Definition: winuser.h:965
#define SM_CMOUSEBUTTONS
Definition: winuser.h:996
#define SM_CXEDGE
Definition: winuser.h:998
#define SM_CYSMICON
Definition: winuser.h:1003
#define SM_NETWORK
Definition: winuser.h:1016
#define SM_CYMAXTRACK
Definition: winuser.h:1013
#define SM_CYFRAME
Definition: winuser.h:986
#define SM_CXFRAME
Definition: winuser.h:984
PSERVERINFO gpsi
Definition: main.c:27
int32_t INT
Definition: typedefs.h:56
#define SM_CXMINSPACING
Definition: winuser.h:1000
#define SM_CXSCREEN
Definition: winuser.h:949
#define SM_CYMENUCHECK
Definition: winuser.h:1022
DWORD dwSRVIFlags
Definition: ntuser.h:1004
#define SM_CYMAXIMIZED
Definition: winuser.h:1015
#define SM_CYDLGFRAME
Definition: winuser.h:958
#define SM_CXICON
Definition: winuser.h:962
#define SM_RESERVED2
Definition: winuser.h:976
ULONG ulHorzRes
Definition: winddi.h:882
#define SM_CXHTHUMB
Definition: winuser.h:961
#define SM_CYEDGE
Definition: winuser.h:999
#define SM_CXDRAG
Definition: winuser.h:1018
#define SM_SECURE
Definition: winuser.h:997
#define SM_CYVTHUMB
Definition: winuser.h:960
#define SM_PENWINDOWS
Definition: winuser.h:994
#define SM_CYMIN
Definition: winuser.h:980
TEXTMETRICW tmCaptionFont
Definition: sysparams.h:139
#define SM_CYVIRTUALSCREEN
Definition: winuser.h:1029
#define SM_RESERVED4
Definition: winuser.h:978
#define SM_CLEANBOOT
Definition: winuser.h:1017
#define SM_CYSMSIZE
Definition: winuser.h:1006
#define SM_CYSCREEN
Definition: winuser.h:950
#define TRACE(s)
Definition: solgame.cpp:4
#define SM_CYCAPTION
Definition: winuser.h:953
#define SM_CXHSCROLL
Definition: winuser.h:972
#define SM_CXCURSOR
Definition: winuser.h:964
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SM_CXMAXIMIZED
Definition: winuser.h:1014
#define SM_CXDLGFRAME
Definition: winuser.h:956
#define SRVINFO_METRICS
Definition: ntuser.h:912
#define SM_CXMINTRACK
Definition: winuser.h:987
BOOL NTAPI RegReadDWORD(HKEY hkey, PWSTR pwszValue, PDWORD pdwData)
Definition: registry.c:150
#define SM_CXSMSIZE
Definition: winuser.h:1005
SPIVALUES gspv
Definition: sysparams.c:17
BOOL bShowSounds
Definition: sysparams.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SM_CXSMICON
Definition: winuser.h:1002
#define SM_CYBORDER
Definition: winuser.h:955
#define SM_CYICON
Definition: winuser.h:963
#define SM_CYMINIMIZED
Definition: winuser.h:1011
static const WCHAR L[]
Definition: oid.c:1250
#define SM_CYICONSPACING
Definition: winuser.h:992
BOOL bMenuDropAlign
Definition: sysparams.h:130
#define SM_CXBORDER
Definition: winuser.h:954
#define SM_MENUDROPALIGNMENT
Definition: winuser.h:993
#define SM_YVIRTUALSCREEN
Definition: winuser.h:1027
#define SM_CYMINSPACING
Definition: winuser.h:1001
#define SM_RESERVED3
Definition: winuser.h:977
#define SM_ARRANGE
Definition: winuser.h:1009
#define SM_DEBUG
Definition: winuser.h:973
INT iDblClickHeight
Definition: sysparams.h:89
ICONMETRICSW im
Definition: sysparams.h:53
#define SM_SAMEDISPLAYFORMAT
Definition: winuser.h:1031
#define SM_CXVSCROLL
Definition: winuser.h:951
TEXTMETRICW tmMenuFont
Definition: sysparams.h:138
#define SM_SWAPBUTTON
Definition: winuser.h:974
#define SM_CXMAXTRACK
Definition: winuser.h:1012
#define SM_CYFULLSCREEN
Definition: winuser.h:968
#define SM_CXSIZE
Definition: winuser.h:981
unsigned int ULONG
Definition: retypes.h:1
INT iDblClickWidth
Definition: sysparams.h:88
#define SM_CYKANJIWINDOW
Definition: winuser.h:969
#define SM_CXFULLSCREEN
Definition: winuser.h:967
#define SM_CYMENU
Definition: winuser.h:966
#define SM_CYDRAG
Definition: winuser.h:1019
static BOOL Setup
Definition: metric.c:13
LONG tmHeight
Definition: wingdi.h:2378
ULONG ulVertRes
Definition: winddi.h:883
#define SM_DBCSENABLED
Definition: winuser.h:995
#define RegOpenKey
Definition: winreg.h:519
#define SM_MOUSEWHEELPRESENT
Definition: winuser.h:1025
#define SM_RESERVED1
Definition: winuser.h:975
#define SM_CYSMCAPTION
Definition: winuser.h:1004
#define SM_CXDOUBLECLK
Definition: winuser.h:989
MINIMIZEDMETRICS mm
Definition: sysparams.h:52
#define SM_CXMIN
Definition: winuser.h:979
#define SM_CXMENUSIZE
Definition: winuser.h:1007

Referenced by co_IntInitializeDesktopGraphics(), SpiUpdatePerUserSystemParameters(), UserChangeDisplaySettings(), and UserSystemParametersInfo().

◆ UserGetSystemMetrics()

LONG NTAPI UserGetSystemMetrics ( ULONG  Index)

Definition at line 180 of file metric.c.

181 {
182  ASSERT(gpsi);
183  ASSERT(Setup);
184  TRACE("UserGetSystemMetrics(%lu)\n", Index);
185 
186  /* Get metrics from array */
187  if (Index < SM_CMETRICS)
188  {
189  return gpsi->aiSysMet[Index];
190  }
191 
192  /* Handle special values */
193  switch (Index)
194  {
195  case SM_REMOTESESSION:
196  return 0; // FIXME
197 
198  case SM_SHUTTINGDOWN:
199  return 0; // FIXME
200 
201  case SM_REMOTECONTROL:
202  return 0; // FIXME
203  }
204 
205  ERR("UserGetSystemMetrics() called with invalid index %lu\n", Index);
206  return 0;
207 }
PSERVERINFO gpsi
Definition: main.c:27
#define SM_CMETRICS
Definition: winuser.h:1055
#define TRACE(s)
Definition: solgame.cpp:4
static const UCHAR Index[8]
Definition: usbohci.c:18
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ERR(fmt,...)
Definition: debug.h:109
static BOOL Setup
Definition: metric.c:13
#define SM_REMOTESESSION
Definition: winuser.h:1048

Referenced by co_IntProcessMouseMessage(), co_WinPosArrangeIconicWindows(), co_WinPosDoWinPosChanging(), co_WinPosGetMinMaxInfo(), co_WinPosMinMaximize(), DefWndDoSizeMove(), DefWndStartSizeMove(), GetNCHitEx(), IntCalculateThumb(), IntCreateDesktop(), IntCreateWindow(), IntDefWindowProc(), IntDrawMenuBarTemp(), IntFixWindowCoordinates(), IntGetClientRect(), IntGetScrollBarRect(), intGetTitleBarInfo(), IntGetWindowBorderMeasures(), IntPaintDesktop(), MENU_CalcItemSize(), MENU_DrawBitmapItem(), MENU_DrawMenuBar(), MENU_DrawMenuItem(), MENU_EnsureMenuItemVisible(), MENU_FindItemByCoords(), MENU_FindItemByKey(), MENU_GetBitmapItemSize(), MENU_GetMaxPopupHeight(), MENU_ShowPopup(), MENU_ShowSubPopup(), NC_DoNCPaint(), NC_DrawFrame(), NC_GetInsideRect(), NC_GetSysPopupPos(), NC_HandleNCCalcSize(), NtUserCreateCaret(), NtUserDragDetect(), NtUserGetClipCursor(), NtUserSwitchDesktop(), UserDrawCaption(), UserDrawCaptionBar(), UserDrawCaptionButton(), UserDrawCaptionText(), UserDrawIconEx(), UserDrawMovingFrame(), UserDrawSysMenuButton(), UserGetWindowBorders(), UserSendMouseInput(), UserSetClassLongPtr(), and WinPosFindIconPos().

Variable Documentation

◆ Setup

BOOL Setup = FALSE
static

Definition at line 13 of file metric.c.

Referenced by InitMetrics(), and UserGetSystemMetrics().