dbghelp: Use local declarations of r_debug and link_map structs.
[wine.git] / dlls / user32 / sysparams.c
blobab386a074e8a069a89f662ad87b3f5399ae4ff16
1 /*
2 * System parameters functions
4 * Copyright 1994 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
23 #include <assert.h>
24 #include <limits.h>
25 #include <stdarg.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
30 #define NONAMELESSUNION
31 #define NONAMELESSSTRUCT
33 #include "windef.h"
34 #include "winbase.h"
35 #include "winnls.h"
36 #include "wingdi.h"
37 #include "winuser.h"
38 #include "winreg.h"
39 #include "wine/wingdi16.h"
40 #include "winerror.h"
42 #include "initguid.h"
43 #include "devguid.h"
44 #include "setupapi.h"
45 #include "controls.h"
46 #include "win.h"
47 #include "user_private.h"
48 #include "wine/gdi_driver.h"
49 #include "wine/unicode.h"
50 #include "wine/asm.h"
51 #include "wine/debug.h"
53 WINE_DEFAULT_DEBUG_CHANNEL(system);
55 /* System parameter indexes */
56 enum spi_index
58 SPI_SETWORKAREA_IDX,
59 SPI_INDEX_COUNT
62 /**
63 * Names of the registry subkeys of HKEY_CURRENT_USER key and value names
64 * for the system parameters.
67 /* the various registry keys that are used to store parameters */
68 enum parameter_key
70 COLORS_KEY,
71 DESKTOP_KEY,
72 KEYBOARD_KEY,
73 MOUSE_KEY,
74 METRICS_KEY,
75 SOUND_KEY,
76 VERSION_KEY,
77 SHOWSOUNDS_KEY,
78 KEYBOARDPREF_KEY,
79 SCREENREADER_KEY,
80 AUDIODESC_KEY,
81 NB_PARAM_KEYS
84 static const WCHAR COLORS_REGKEY[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','C','o','l','o','r','s',0};
85 static const WCHAR DESKTOP_REGKEY[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
86 static const WCHAR KEYBOARD_REGKEY[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','K','e','y','b','o','a','r','d',0};
87 static const WCHAR MOUSE_REGKEY[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','M','o','u','s','e',0};
88 static const WCHAR METRICS_REGKEY[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p','\\',
89 'W','i','n','d','o','w','M','e','t','r','i','c','s',0};
90 static const WCHAR SOUND_REGKEY[]= {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','S','o','u','n','d',0};
91 static const WCHAR VERSION_REGKEY[] = {'S','o','f','t','w','a','r','e','\\',
92 'M','i','c','r','o','s','o','f','t','\\',
93 'W','i','n','d','o','w','s',' ','N','T','\\',
94 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
95 'W','i','n','d','o','w','s',0};
96 static const WCHAR SHOWSOUNDS_REGKEY[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
97 'A','c','c','e','s','s','i','b','i','l','i','t','y','\\',
98 'S','h','o','w','S','o','u','n','d','s',0};
99 static const WCHAR KEYBOARDPREF_REGKEY[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
100 'A','c','c','e','s','s','i','b','i','l','i','t','y','\\',
101 'K','e','y','b','o','a','r','d',' ','P','r','e','f','e','r','e','n','c','e',0};
102 static const WCHAR SCREENREADER_REGKEY[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
103 'A','c','c','e','s','s','i','b','i','l','i','t','y','\\',
104 'B','l','i','n','d',' ','A','c','c','e','s','s',0};
105 static const WCHAR AUDIODESC_REGKEY[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
106 'A','c','c','e','s','s','i','b','i','l','i','t','y','\\',
107 'A','u','d','i','o','D','e','s','c','r','i','p','t','i','o','n',0};
109 static const WCHAR *parameter_key_names[NB_PARAM_KEYS] =
111 COLORS_REGKEY,
112 DESKTOP_REGKEY,
113 KEYBOARD_REGKEY,
114 MOUSE_REGKEY,
115 METRICS_REGKEY,
116 SOUND_REGKEY,
117 VERSION_REGKEY,
118 SHOWSOUNDS_REGKEY,
119 KEYBOARDPREF_REGKEY,
120 SCREENREADER_REGKEY,
121 AUDIODESC_REGKEY,
124 /* parameter key values; the first char is actually an enum parameter_key to specify the key */
125 static const WCHAR BEEP_VALNAME[]= {SOUND_KEY,'B','e','e','p',0};
126 static const WCHAR MOUSETHRESHOLD1_VALNAME[]= {MOUSE_KEY,'M','o','u','s','e','T','h','r','e','s','h','o','l','d','1',0};
127 static const WCHAR MOUSETHRESHOLD2_VALNAME[]= {MOUSE_KEY,'M','o','u','s','e','T','h','r','e','s','h','o','l','d','2',0};
128 static const WCHAR MOUSEACCELERATION_VALNAME[]= {MOUSE_KEY,'M','o','u','s','e','S','p','e','e','d',0};
129 static const WCHAR BORDER_VALNAME[]= {METRICS_KEY,'B','o','r','d','e','r','W','i','d','t','h',0};
130 static const WCHAR KEYBOARDSPEED_VALNAME[]= {KEYBOARD_KEY,'K','e','y','b','o','a','r','d','S','p','e','e','d',0};
131 static const WCHAR ICONHORIZONTALSPACING_VALNAME[]= {METRICS_KEY,'I','c','o','n','S','p','a','c','i','n','g',0};
132 static const WCHAR SCREENSAVETIMEOUT_VALNAME[]= {DESKTOP_KEY,'S','c','r','e','e','n','S','a','v','e','T','i','m','e','O','u','t',0};
133 static const WCHAR SCREENSAVEACTIVE_VALNAME[]= {DESKTOP_KEY,'S','c','r','e','e','n','S','a','v','e','A','c','t','i','v','e',0};
134 static const WCHAR GRIDGRANULARITY_VALNAME[]= {DESKTOP_KEY,'G','r','i','d','G','r','a','n','u','l','a','r','i','t','y',0};
135 static const WCHAR KEYBOARDDELAY_VALNAME[]= {KEYBOARD_KEY,'K','e','y','b','o','a','r','d','D','e','l','a','y',0};
136 static const WCHAR ICONVERTICALSPACING_VALNAME[]= {METRICS_KEY,'I','c','o','n','V','e','r','t','i','c','a','l','S','p','a','c','i','n','g',0};
137 static const WCHAR ICONTITLEWRAP_VALNAME[]= {DESKTOP_KEY,'I','c','o','n','T','i','t','l','e','W','r','a','p',0};
138 static const WCHAR ICONTITLEWRAP_MIRROR[]= {METRICS_KEY,'I','c','o','n','T','i','t','l','e','W','r','a','p',0};
139 static const WCHAR ICONTITLELOGFONT_VALNAME[]= {METRICS_KEY,'I','c','o','n','F','o','n','t',0};
140 static const WCHAR MENUDROPALIGNMENT_VALNAME[]= {DESKTOP_KEY,'M','e','n','u','D','r','o','p','A','l','i','g','n','m','e','n','t',0};
141 static const WCHAR MENUDROPALIGNMENT_MIRROR[]= {VERSION_KEY,'M','e','n','u','D','r','o','p','A','l','i','g','n','m','e','n','t',0};
142 static const WCHAR MOUSETRAILS_VALNAME[]= {MOUSE_KEY,'M','o','u','s','e','T','r','a','i','l','s',0};
143 static const WCHAR SNAPTODEFBUTTON_VALNAME[]= {MOUSE_KEY,'S','n','a','p','T','o','D','e','f','a','u','l','t','B','u','t','t','o','n',0};
144 static const WCHAR DOUBLECLKWIDTH_VALNAME[]= {MOUSE_KEY,'D','o','u','b','l','e','C','l','i','c','k','W','i','d','t','h',0};
145 static const WCHAR DOUBLECLKWIDTH_MIRROR[]= {DESKTOP_KEY,'D','o','u','b','l','e','C','l','i','c','k','W','i','d','t','h',0};
146 static const WCHAR DOUBLECLKHEIGHT_VALNAME[]= {MOUSE_KEY,'D','o','u','b','l','e','C','l','i','c','k','H','e','i','g','h','t',0};
147 static const WCHAR DOUBLECLKHEIGHT_MIRROR[]= {DESKTOP_KEY,'D','o','u','b','l','e','C','l','i','c','k','H','e','i','g','h','t',0};
148 static const WCHAR DOUBLECLICKTIME_VALNAME[]= {MOUSE_KEY,'D','o','u','b','l','e','C','l','i','c','k','S','p','e','e','d',0};
149 static const WCHAR MOUSEBUTTONSWAP_VALNAME[]= {MOUSE_KEY,'S','w','a','p','M','o','u','s','e','B','u','t','t','o','n','s',0};
150 static const WCHAR DRAGFULLWINDOWS_VALNAME[]= {DESKTOP_KEY,'D','r','a','g','F','u','l','l','W','i','n','d','o','w','s',0};
151 static const WCHAR SHOWSOUNDS_VALNAME[]= {SHOWSOUNDS_KEY,'O','n',0};
152 static const WCHAR KEYBOARDPREF_VALNAME[]= {KEYBOARDPREF_KEY,'O','n',0};
153 static const WCHAR SCREENREADER_VALNAME[]= {SCREENREADER_KEY,'O','n',0};
154 static const WCHAR DESKWALLPAPER_VALNAME[]= {DESKTOP_KEY,'W','a','l','l','p','a','p','e','r',0};
155 static const WCHAR DESKPATTERN_VALNAME[]= {DESKTOP_KEY,'P','a','t','t','e','r','n',0};
156 static const WCHAR FONTSMOOTHING_VALNAME[]= {DESKTOP_KEY,'F','o','n','t','S','m','o','o','t','h','i','n','g',0};
157 static const WCHAR DRAGWIDTH_VALNAME[]= {DESKTOP_KEY,'D','r','a','g','W','i','d','t','h',0};
158 static const WCHAR DRAGHEIGHT_VALNAME[]= {DESKTOP_KEY,'D','r','a','g','H','e','i','g','h','t',0};
159 static const WCHAR DPISCALINGVER_VALNAME[]= {DESKTOP_KEY,'D','p','i','S','c','a','l','i','n','g','V','e','r',0};
160 static const WCHAR LOGPIXELS_VALNAME[]= {DESKTOP_KEY,'L','o','g','P','i','x','e','l','s',0};
161 static const WCHAR LOWPOWERACTIVE_VALNAME[]= {DESKTOP_KEY,'L','o','w','P','o','w','e','r','A','c','t','i','v','e',0};
162 static const WCHAR POWEROFFACTIVE_VALNAME[]= {DESKTOP_KEY,'P','o','w','e','r','O','f','f','A','c','t','i','v','e',0};
163 static const WCHAR USERPREFERENCESMASK_VALNAME[]= {DESKTOP_KEY,'U','s','e','r','P','r','e','f','e','r','e','n','c','e','s','M','a','s','k',0};
164 static const WCHAR MOUSEHOVERWIDTH_VALNAME[]= {MOUSE_KEY,'M','o','u','s','e','H','o','v','e','r','W','i','d','t','h',0};
165 static const WCHAR MOUSEHOVERHEIGHT_VALNAME[]= {MOUSE_KEY,'M','o','u','s','e','H','o','v','e','r','H','e','i','g','h','t',0};
166 static const WCHAR MOUSEHOVERTIME_VALNAME[]= {MOUSE_KEY,'M','o','u','s','e','H','o','v','e','r','T','i','m','e',0};
167 static const WCHAR WHEELSCROLLCHARS_VALNAME[]= {DESKTOP_KEY,'W','h','e','e','l','S','c','r','o','l','l','C','h','a','r','s',0};
168 static const WCHAR WHEELSCROLLLINES_VALNAME[]= {DESKTOP_KEY,'W','h','e','e','l','S','c','r','o','l','l','L','i','n','e','s',0};
169 static const WCHAR ACTIVEWINDOWTRACKING_VALNAME[]= {MOUSE_KEY,'A','c','t','i','v','e','W','i','n','d','o','w','T','r','a','c','k','i','n','g',0};
170 static const WCHAR MENUSHOWDELAY_VALNAME[]= {DESKTOP_KEY,'M','e','n','u','S','h','o','w','D','e','l','a','y',0};
171 static const WCHAR BLOCKSENDINPUTRESETS_VALNAME[]= {DESKTOP_KEY,'B','l','o','c','k','S','e','n','d','I','n','p','u','t','R','e','s','e','t','s',0};
172 static const WCHAR FOREGROUNDLOCKTIMEOUT_VALNAME[]= {DESKTOP_KEY,'F','o','r','e','g','r','o','u','n','d','L','o','c','k','T','i','m','e','o','u','t',0};
173 static const WCHAR ACTIVEWNDTRKTIMEOUT_VALNAME[]= {DESKTOP_KEY,'A','c','t','i','v','e','W','n','d','T','r','a','c','k','T','i','m','e','o','u','t',0};
174 static const WCHAR FOREGROUNDFLASHCOUNT_VALNAME[]= {DESKTOP_KEY,'F','o','r','e','g','r','o','u','n','d','F','l','a','s','h','C','o','u','n','t',0};
175 static const WCHAR CARETWIDTH_VALNAME[]= {DESKTOP_KEY,'C','a','r','e','t','W','i','d','t','h',0};
176 static const WCHAR MOUSECLICKLOCKTIME_VALNAME[]= {DESKTOP_KEY,'C','l','i','c','k','L','o','c','k','T','i','m','e',0};
177 static const WCHAR MOUSESPEED_VALNAME[]= {MOUSE_KEY,'M','o','u','s','e','S','e','n','s','i','t','i','v','i','t','y',0};
178 static const WCHAR FONTSMOOTHINGTYPE_VALNAME[]= {DESKTOP_KEY,'F','o','n','t','S','m','o','o','t','h','i','n','g','T','y','p','e',0};
179 static const WCHAR FONTSMOOTHINGCONTRAST_VALNAME[]= {DESKTOP_KEY,'F','o','n','t','S','m','o','o','t','h','i','n','g','G','a','m','m','a',0};
180 static const WCHAR FONTSMOOTHINGORIENTATION_VALNAME[]= {DESKTOP_KEY,'F','o','n','t','S','m','o','o','t','h','i','n','g','O','r','i','e','n','t','a','t','i','o','n',0};
181 static const WCHAR FOCUSBORDERWIDTH_VALNAME[]= {DESKTOP_KEY,'F','o','c','u','s','B','o','r','d','e','r','W','i','d','t','h',0};
182 static const WCHAR FOCUSBORDERHEIGHT_VALNAME[]= {DESKTOP_KEY,'F','o','c','u','s','B','o','r','d','e','r','H','e','i','g','h','t',0};
183 static const WCHAR SCROLLWIDTH_VALNAME[]= {METRICS_KEY,'S','c','r','o','l','l','W','i','d','t','h',0};
184 static const WCHAR SCROLLHEIGHT_VALNAME[]= {METRICS_KEY,'S','c','r','o','l','l','H','e','i','g','h','t',0};
185 static const WCHAR CAPTIONWIDTH_VALNAME[]= {METRICS_KEY,'C','a','p','t','i','o','n','W','i','d','t','h',0};
186 static const WCHAR CAPTIONHEIGHT_VALNAME[]= {METRICS_KEY,'C','a','p','t','i','o','n','H','e','i','g','h','t',0};
187 static const WCHAR SMCAPTIONWIDTH_VALNAME[]= {METRICS_KEY,'S','m','C','a','p','t','i','o','n','W','i','d','t','h',0};
188 static const WCHAR SMCAPTIONHEIGHT_VALNAME[]= {METRICS_KEY,'S','m','C','a','p','t','i','o','n','H','e','i','g','h','t',0};
189 static const WCHAR MENUWIDTH_VALNAME[]= {METRICS_KEY,'M','e','n','u','W','i','d','t','h',0};
190 static const WCHAR MENUHEIGHT_VALNAME[]= {METRICS_KEY,'M','e','n','u','H','e','i','g','h','t',0};
191 static const WCHAR PADDEDBORDERWIDTH_VALNAME[]= {METRICS_KEY,'P','a','d','d','e','d','B','o','r','d','e','r','W','i','d','t','h',0};
192 static const WCHAR CAPTIONLOGFONT_VALNAME[]= {METRICS_KEY,'C','a','p','t','i','o','n','F','o','n','t',0};
193 static const WCHAR SMCAPTIONLOGFONT_VALNAME[]= {METRICS_KEY,'S','m','C','a','p','t','i','o','n','F','o','n','t',0};
194 static const WCHAR MENULOGFONT_VALNAME[]= {METRICS_KEY,'M','e','n','u','F','o','n','t',0};
195 static const WCHAR MESSAGELOGFONT_VALNAME[]= {METRICS_KEY,'M','e','s','s','a','g','e','F','o','n','t',0};
196 static const WCHAR STATUSLOGFONT_VALNAME[]= {METRICS_KEY,'S','t','a','t','u','s','F','o','n','t',0};
197 static const WCHAR MINWIDTH_VALNAME[] = {METRICS_KEY,'M','i','n','W','i','d','t','h',0};
198 static const WCHAR MINHORZGAP_VALNAME[] = {METRICS_KEY,'M','i','n','H','o','r','z','G','a','p',0};
199 static const WCHAR MINVERTGAP_VALNAME[] = {METRICS_KEY,'M','i','n','V','e','r','t','G','a','p',0};
200 static const WCHAR MINARRANGE_VALNAME[] = {METRICS_KEY,'M','i','n','A','r','r','a','n','g','e',0};
201 static const WCHAR COLOR_SCROLLBAR_VALNAME[] = {COLORS_KEY,'S','c','r','o','l','l','b','a','r',0};
202 static const WCHAR COLOR_BACKGROUND_VALNAME[] = {COLORS_KEY,'B','a','c','k','g','r','o','u','n','d',0};
203 static const WCHAR COLOR_ACTIVECAPTION_VALNAME[] = {COLORS_KEY,'A','c','t','i','v','e','T','i','t','l','e',0};
204 static const WCHAR COLOR_INACTIVECAPTION_VALNAME[] = {COLORS_KEY,'I','n','a','c','t','i','v','e','T','i','t','l','e',0};
205 static const WCHAR COLOR_MENU_VALNAME[] = {COLORS_KEY,'M','e','n','u',0};
206 static const WCHAR COLOR_WINDOW_VALNAME[] = {COLORS_KEY,'W','i','n','d','o','w',0};
207 static const WCHAR COLOR_WINDOWFRAME_VALNAME[] = {COLORS_KEY,'W','i','n','d','o','w','F','r','a','m','e',0};
208 static const WCHAR COLOR_MENUTEXT_VALNAME[] = {COLORS_KEY,'M','e','n','u','T','e','x','t',0};
209 static const WCHAR COLOR_WINDOWTEXT_VALNAME[] = {COLORS_KEY,'W','i','n','d','o','w','T','e','x','t',0};
210 static const WCHAR COLOR_CAPTIONTEXT_VALNAME[] = {COLORS_KEY,'T','i','t','l','e','T','e','x','t',0};
211 static const WCHAR COLOR_ACTIVEBORDER_VALNAME[] = {COLORS_KEY,'A','c','t','i','v','e','B','o','r','d','e','r',0};
212 static const WCHAR COLOR_INACTIVEBORDER_VALNAME[] = {COLORS_KEY,'I','n','a','c','t','i','v','e','B','o','r','d','e','r',0};
213 static const WCHAR COLOR_APPWORKSPACE_VALNAME[] = {COLORS_KEY,'A','p','p','W','o','r','k','S','p','a','c','e',0};
214 static const WCHAR COLOR_HIGHLIGHT_VALNAME[] = {COLORS_KEY,'H','i','l','i','g','h','t',0};
215 static const WCHAR COLOR_HIGHLIGHTTEXT_VALNAME[] = {COLORS_KEY,'H','i','l','i','g','h','t','T','e','x','t',0};
216 static const WCHAR COLOR_BTNFACE_VALNAME[] = {COLORS_KEY,'B','u','t','t','o','n','F','a','c','e',0};
217 static const WCHAR COLOR_BTNSHADOW_VALNAME[] = {COLORS_KEY,'B','u','t','t','o','n','S','h','a','d','o','w',0};
218 static const WCHAR COLOR_GRAYTEXT_VALNAME[] = {COLORS_KEY,'G','r','a','y','T','e','x','t',0};
219 static const WCHAR COLOR_BTNTEXT_VALNAME[] = {COLORS_KEY,'B','u','t','t','o','n','T','e','x','t',0};
220 static const WCHAR COLOR_INACTIVECAPTIONTEXT_VALNAME[] = {COLORS_KEY,'I','n','a','c','t','i','v','e','T','i','t','l','e','T','e','x','t',0};
221 static const WCHAR COLOR_BTNHIGHLIGHT_VALNAME[] = {COLORS_KEY,'B','u','t','t','o','n','H','i','l','i','g','h','t',0};
222 static const WCHAR COLOR_3DDKSHADOW_VALNAME[] = {COLORS_KEY,'B','u','t','t','o','n','D','k','S','h','a','d','o','w',0};
223 static const WCHAR COLOR_3DLIGHT_VALNAME[] = {COLORS_KEY,'B','u','t','t','o','n','L','i','g','h','t',0};
224 static const WCHAR COLOR_INFOTEXT_VALNAME[] = {COLORS_KEY,'I','n','f','o','T','e','x','t',0};
225 static const WCHAR COLOR_INFOBK_VALNAME[] = {COLORS_KEY,'I','n','f','o','W','i','n','d','o','w',0};
226 static const WCHAR COLOR_ALTERNATEBTNFACE_VALNAME[] = {COLORS_KEY,'B','u','t','t','o','n','A','l','t','e','r','n','a','t','e','F','a','c','e',0};
227 static const WCHAR COLOR_HOTLIGHT_VALNAME[] = {COLORS_KEY,'H','o','t','T','r','a','c','k','i','n','g','C','o','l','o','r',0};
228 static const WCHAR COLOR_GRADIENTACTIVECAPTION_VALNAME[] = {COLORS_KEY,'G','r','a','d','i','e','n','t','A','c','t','i','v','e','T','i','t','l','e',0};
229 static const WCHAR COLOR_GRADIENTINACTIVECAPTION_VALNAME[] = {COLORS_KEY,'G','r','a','d','i','e','n','t','I','n','a','c','t','i','v','e','T','i','t','l','e',0};
230 static const WCHAR COLOR_MENUHILIGHT_VALNAME[] = {COLORS_KEY,'M','e','n','u','H','i','l','i','g','h','t',0};
231 static const WCHAR COLOR_MENUBAR_VALNAME[] = {COLORS_KEY,'M','e','n','u','B','a','r',0};
232 static const WCHAR AUDIODESC_LOCALE_VALNAME[] = {AUDIODESC_KEY,'L','o','c','a','l','e',0};
233 static const WCHAR AUDIODESC_ON_VALNAME[] = {AUDIODESC_KEY,'O','n',0};
235 /* FIXME - real value */
236 static const WCHAR SCREENSAVERRUNNING_VALNAME[]= {DESKTOP_KEY,'W','I','N','E','_','S','c','r','e','e','n','S','a','v','e','r','R','u','n','n','i','n','g',0};
238 static const WCHAR WINE_CURRENT_USER_REGKEY[] = {'S','o','f','t','w','a','r','e','\\',
239 'W','i','n','e',0};
241 /* volatile registry branch under WINE_CURRENT_USER_REGKEY for temporary values storage */
242 static const WCHAR WINE_CURRENT_USER_REGKEY_TEMP_PARAMS[] = {'T','e','m','p','o','r','a','r','y',' ',
243 'S','y','s','t','e','m',' ',
244 'P','a','r','a','m','e','t','e','r','s',0};
246 static const WCHAR Yes[] = {'Y','e','s',0};
247 static const WCHAR No[] = {'N','o',0};
248 static const WCHAR CSu[] = {'%','u',0};
249 static const WCHAR CSd[] = {'%','d',0};
250 static const WCHAR CSrgb[] = {'%','u',' ','%','u',' ','%','u',0};
252 /* Wine specific monitor properties */
253 DEFINE_DEVPROPKEY(WINE_DEVPROPKEY_MONITOR_STATEFLAGS, 0x233a9ef3, 0xafc4, 0x4abd, 0xb5, 0x64, 0xc3, 0x2f, 0x21, 0xf1, 0x53, 0x5b, 2);
254 DEFINE_DEVPROPKEY(WINE_DEVPROPKEY_MONITOR_RCMONITOR, 0x233a9ef3, 0xafc4, 0x4abd, 0xb5, 0x64, 0xc3, 0x2f, 0x21, 0xf1, 0x53, 0x5b, 3);
255 DEFINE_DEVPROPKEY(WINE_DEVPROPKEY_MONITOR_RCWORK, 0x233a9ef3, 0xafc4, 0x4abd, 0xb5, 0x64, 0xc3, 0x2f, 0x21, 0xf1, 0x53, 0x5b, 4);
256 DEFINE_DEVPROPKEY(WINE_DEVPROPKEY_MONITOR_ADAPTERNAME, 0x233a9ef3, 0xafc4, 0x4abd, 0xb5, 0x64, 0xc3, 0x2f, 0x21, 0xf1, 0x53, 0x5b, 5);
258 #define NULLDRV_DEFAULT_HMONITOR ((HMONITOR)(UINT_PTR)(0x10000 + 1))
260 /* Strings for monitor functions */
261 static const WCHAR DEFAULT_ADAPTER_NAME[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
262 static const WCHAR DEFAULT_MONITOR_NAME[] = {'\\','\\','.','\\',
263 'D','I','S','P','L','A','Y','1','\\',
264 'M','o','n','i','t','o','r','0',0};
265 static const WCHAR DEFAULT_ADAPTER_STRING[] = {'W','i','n','e',' ','A','d','a','p','t','e','r',0};
266 static const WCHAR DEFAULT_MONITOR_STRING[] = {'G','e','n','e','r','i','c',' ','N','o','n','-','P','n','P',' ','M','o','n','i','t','o','r',0};
267 static const WCHAR DEFAULT_ADAPTER_ID[] = {'P','C','I','\\',
268 'V','E','N','_','0','0','0','0','&',
269 'D','E','V','_','0','0','0','0','&',
270 'S','U','B','S','Y','S','_','0','0','0','0','0','0','0','0','&',
271 'R','E','V','_','0','0',0};
272 static const WCHAR DEFAULT_MONITOR_ID[] = {'M','O','N','I','T','O','R','\\',
273 'D','e','f','a','u','l','t','_','M','o','n','i','t','o','r','\\',
274 '{','4','d','3','6','e','9','6','e','-','e','3','2','5','-','1','1','c','e','-',
275 'b','f','c','1','-','0','8','0','0','2','b','e','1','0','3','1','8','}',
276 '\\','0','0','0','0',0};
277 static const WCHAR DEFAULT_MONITOR_INTERFACE_ID[] = {'\\','\\','\?','\\',
278 'D','I','S','P','L','A','Y','#','D','e','f','a','u','l','t','_','M','o','n','i','t','o','r','#',
279 '4','&','1','7','f','0','f','f','5','4','&','0','&','U','I','D','0','#',
280 '{','e','6','f','0','7','b','5','f','-','e','e','9','7','-','4','a','9','0','-',
281 'b','0','7','6','-','3','3','f','5','7','b','f','4','e','a','a','7','}',0};
282 static const WCHAR BACKSLASH[] = {'\\',0};
283 static const WCHAR DRIVER_DESC[] = {'D','r','i','v','e','r','D','e','s','c',0};
284 static const WCHAR STATE_FLAGS[] = {'S','t','a','t','e','F','l','a','g','s',0};
285 static const WCHAR GPU_ID[] = {'G','P','U','I','D',0};
286 static const WCHAR DISPLAY[] = {'D','I','S','P','L','A','Y',0};
287 static const WCHAR ADAPTER_PREFIX[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y'};
288 static const WCHAR MONITOR_ID_VALUE_FMT[] = {'M','o','n','i','t','o','r','I','D','%','d',0};
289 static const WCHAR VIDEO_KEY[] = {'H','A','R','D','W','A','R','E','\\',
290 'D','E','V','I','C','E','M','A','P','\\',
291 'V','I','D','E','O','\\',0};
292 static const WCHAR NT_CLASS[] = {'\\','R','e','g','i','s','t','r','y','\\',
293 'M','a','c','h','i','n','e','\\',
294 'S','y','s','t','e','m','\\',
295 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
296 'C','o','n','t','r','o','l','\\',
297 'C','l','a','s','s','\\',0};
298 static const WCHAR ADAPTER_FMT[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','%','d',0};
299 static const WCHAR MONITOR_FMT[] = {'\\','\\','.','\\',
300 'D','I','S','P','L','A','Y','%','d','\\',
301 'M','o','n','i','t','o','r','%','d',0};
302 static const WCHAR VIDEO_VALUE_FMT[] = {'\\','D','e','v','i','c','e','\\',
303 'V','i','d','e','o','%','d',0};
304 static const WCHAR MONITOR_INTERFACE_PREFIX[] = {'\\','\\','\?','\\',0};
305 static const WCHAR GUID_DEVINTERFACE_MONITOR[] = {'#','{','e','6','f','0','7','b','5','f','-','e','e','9','7','-',
306 '4','a','9','0','-','b','0','7','6','-','3','3','f','5','7','b','f','4','e','a','a','7','}',0};
308 /* Cached monitor information */
309 static MONITORINFOEXW *monitors;
310 static UINT monitor_count;
311 static FILETIME last_query_monitors_time;
312 static CRITICAL_SECTION monitors_section;
313 static CRITICAL_SECTION_DEBUG monitors_critsect_debug =
315 0, 0, &monitors_section,
316 { &monitors_critsect_debug.ProcessLocksList, &monitors_critsect_debug.ProcessLocksList },
317 0, 0, { (DWORD_PTR)(__FILE__ ": monitors_section") }
319 static CRITICAL_SECTION monitors_section = { &monitors_critsect_debug, -1 , 0, 0, 0, 0 };
321 static HDC display_dc;
322 static CRITICAL_SECTION display_dc_section;
323 static CRITICAL_SECTION_DEBUG critsect_debug =
325 0, 0, &display_dc_section,
326 { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
327 0, 0, { (DWORD_PTR)(__FILE__ ": display_dc_section") }
329 static CRITICAL_SECTION display_dc_section = { &critsect_debug, -1 ,0, 0, 0, 0 };
332 /* Indicators whether system parameter value is loaded */
333 static char spi_loaded[SPI_INDEX_COUNT];
335 static BOOL notify_change = TRUE;
337 /* System parameters storage */
338 static RECT work_area;
339 static UINT system_dpi;
340 static DPI_AWARENESS dpi_awareness;
341 static DPI_AWARENESS default_awareness = DPI_AWARENESS_UNAWARE;
343 static HKEY volatile_base_key;
344 static HKEY video_key;
346 union sysparam_all_entry;
348 struct sysparam_entry
350 BOOL (*get)( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi );
351 BOOL (*set)( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags );
352 BOOL (*init)( union sysparam_all_entry *entry );
353 const WCHAR *regval;
354 const WCHAR *mirror;
355 BOOL loaded;
358 struct sysparam_uint_entry
360 struct sysparam_entry hdr;
361 UINT val;
364 struct sysparam_bool_entry
366 struct sysparam_entry hdr;
367 BOOL val;
370 struct sysparam_dword_entry
372 struct sysparam_entry hdr;
373 DWORD val;
376 struct sysparam_rgb_entry
378 struct sysparam_entry hdr;
379 COLORREF val;
380 HBRUSH brush;
381 HPEN pen;
384 struct sysparam_binary_entry
386 struct sysparam_entry hdr;
387 void *ptr;
388 size_t size;
391 struct sysparam_path_entry
393 struct sysparam_entry hdr;
394 WCHAR path[MAX_PATH];
397 struct sysparam_font_entry
399 struct sysparam_entry hdr;
400 UINT weight;
401 LOGFONTW val;
402 WCHAR fullname[LF_FACESIZE];
405 struct sysparam_pref_entry
407 struct sysparam_entry hdr;
408 struct sysparam_binary_entry *parent;
409 UINT offset;
410 UINT mask;
413 union sysparam_all_entry
415 struct sysparam_entry hdr;
416 struct sysparam_uint_entry uint;
417 struct sysparam_bool_entry bool;
418 struct sysparam_dword_entry dword;
419 struct sysparam_rgb_entry rgb;
420 struct sysparam_binary_entry bin;
421 struct sysparam_path_entry path;
422 struct sysparam_font_entry font;
423 struct sysparam_pref_entry pref;
426 static void SYSPARAMS_LogFont16To32W( const LOGFONT16 *font16, LPLOGFONTW font32 )
428 font32->lfHeight = font16->lfHeight;
429 font32->lfWidth = font16->lfWidth;
430 font32->lfEscapement = font16->lfEscapement;
431 font32->lfOrientation = font16->lfOrientation;
432 font32->lfWeight = font16->lfWeight;
433 font32->lfItalic = font16->lfItalic;
434 font32->lfUnderline = font16->lfUnderline;
435 font32->lfStrikeOut = font16->lfStrikeOut;
436 font32->lfCharSet = font16->lfCharSet;
437 font32->lfOutPrecision = font16->lfOutPrecision;
438 font32->lfClipPrecision = font16->lfClipPrecision;
439 font32->lfQuality = font16->lfQuality;
440 font32->lfPitchAndFamily = font16->lfPitchAndFamily;
441 MultiByteToWideChar( CP_ACP, 0, font16->lfFaceName, -1, font32->lfFaceName, LF_FACESIZE );
442 font32->lfFaceName[LF_FACESIZE-1] = 0;
445 static void SYSPARAMS_LogFont32WTo32A( const LOGFONTW* font32W, LPLOGFONTA font32A )
447 font32A->lfHeight = font32W->lfHeight;
448 font32A->lfWidth = font32W->lfWidth;
449 font32A->lfEscapement = font32W->lfEscapement;
450 font32A->lfOrientation = font32W->lfOrientation;
451 font32A->lfWeight = font32W->lfWeight;
452 font32A->lfItalic = font32W->lfItalic;
453 font32A->lfUnderline = font32W->lfUnderline;
454 font32A->lfStrikeOut = font32W->lfStrikeOut;
455 font32A->lfCharSet = font32W->lfCharSet;
456 font32A->lfOutPrecision = font32W->lfOutPrecision;
457 font32A->lfClipPrecision = font32W->lfClipPrecision;
458 font32A->lfQuality = font32W->lfQuality;
459 font32A->lfPitchAndFamily = font32W->lfPitchAndFamily;
460 WideCharToMultiByte( CP_ACP, 0, font32W->lfFaceName, -1, font32A->lfFaceName, LF_FACESIZE, NULL, NULL );
461 font32A->lfFaceName[LF_FACESIZE-1] = 0;
464 static void SYSPARAMS_LogFont32ATo32W( const LOGFONTA* font32A, LPLOGFONTW font32W )
466 font32W->lfHeight = font32A->lfHeight;
467 font32W->lfWidth = font32A->lfWidth;
468 font32W->lfEscapement = font32A->lfEscapement;
469 font32W->lfOrientation = font32A->lfOrientation;
470 font32W->lfWeight = font32A->lfWeight;
471 font32W->lfItalic = font32A->lfItalic;
472 font32W->lfUnderline = font32A->lfUnderline;
473 font32W->lfStrikeOut = font32A->lfStrikeOut;
474 font32W->lfCharSet = font32A->lfCharSet;
475 font32W->lfOutPrecision = font32A->lfOutPrecision;
476 font32W->lfClipPrecision = font32A->lfClipPrecision;
477 font32W->lfQuality = font32A->lfQuality;
478 font32W->lfPitchAndFamily = font32A->lfPitchAndFamily;
479 MultiByteToWideChar( CP_ACP, 0, font32A->lfFaceName, -1, font32W->lfFaceName, LF_FACESIZE );
480 font32W->lfFaceName[LF_FACESIZE-1] = 0;
483 static void SYSPARAMS_NonClientMetrics32WTo32A( const NONCLIENTMETRICSW* lpnm32W, LPNONCLIENTMETRICSA lpnm32A )
485 lpnm32A->iBorderWidth = lpnm32W->iBorderWidth;
486 lpnm32A->iScrollWidth = lpnm32W->iScrollWidth;
487 lpnm32A->iScrollHeight = lpnm32W->iScrollHeight;
488 lpnm32A->iCaptionWidth = lpnm32W->iCaptionWidth;
489 lpnm32A->iCaptionHeight = lpnm32W->iCaptionHeight;
490 SYSPARAMS_LogFont32WTo32A( &lpnm32W->lfCaptionFont, &lpnm32A->lfCaptionFont );
491 lpnm32A->iSmCaptionWidth = lpnm32W->iSmCaptionWidth;
492 lpnm32A->iSmCaptionHeight = lpnm32W->iSmCaptionHeight;
493 SYSPARAMS_LogFont32WTo32A( &lpnm32W->lfSmCaptionFont, &lpnm32A->lfSmCaptionFont );
494 lpnm32A->iMenuWidth = lpnm32W->iMenuWidth;
495 lpnm32A->iMenuHeight = lpnm32W->iMenuHeight;
496 SYSPARAMS_LogFont32WTo32A( &lpnm32W->lfMenuFont, &lpnm32A->lfMenuFont );
497 SYSPARAMS_LogFont32WTo32A( &lpnm32W->lfStatusFont, &lpnm32A->lfStatusFont );
498 SYSPARAMS_LogFont32WTo32A( &lpnm32W->lfMessageFont, &lpnm32A->lfMessageFont );
499 if (lpnm32A->cbSize > FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth))
501 if (lpnm32W->cbSize > FIELD_OFFSET(NONCLIENTMETRICSW, iPaddedBorderWidth))
502 lpnm32A->iPaddedBorderWidth = lpnm32W->iPaddedBorderWidth;
503 else
504 lpnm32A->iPaddedBorderWidth = 0;
508 static void SYSPARAMS_NonClientMetrics32ATo32W( const NONCLIENTMETRICSA* lpnm32A, LPNONCLIENTMETRICSW lpnm32W )
510 lpnm32W->iBorderWidth = lpnm32A->iBorderWidth;
511 lpnm32W->iScrollWidth = lpnm32A->iScrollWidth;
512 lpnm32W->iScrollHeight = lpnm32A->iScrollHeight;
513 lpnm32W->iCaptionWidth = lpnm32A->iCaptionWidth;
514 lpnm32W->iCaptionHeight = lpnm32A->iCaptionHeight;
515 SYSPARAMS_LogFont32ATo32W( &lpnm32A->lfCaptionFont, &lpnm32W->lfCaptionFont );
516 lpnm32W->iSmCaptionWidth = lpnm32A->iSmCaptionWidth;
517 lpnm32W->iSmCaptionHeight = lpnm32A->iSmCaptionHeight;
518 SYSPARAMS_LogFont32ATo32W( &lpnm32A->lfSmCaptionFont, &lpnm32W->lfSmCaptionFont );
519 lpnm32W->iMenuWidth = lpnm32A->iMenuWidth;
520 lpnm32W->iMenuHeight = lpnm32A->iMenuHeight;
521 SYSPARAMS_LogFont32ATo32W( &lpnm32A->lfMenuFont, &lpnm32W->lfMenuFont );
522 SYSPARAMS_LogFont32ATo32W( &lpnm32A->lfStatusFont, &lpnm32W->lfStatusFont );
523 SYSPARAMS_LogFont32ATo32W( &lpnm32A->lfMessageFont, &lpnm32W->lfMessageFont );
524 if (lpnm32W->cbSize > FIELD_OFFSET(NONCLIENTMETRICSW, iPaddedBorderWidth))
526 if (lpnm32A->cbSize > FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth))
527 lpnm32W->iPaddedBorderWidth = lpnm32A->iPaddedBorderWidth;
528 else
529 lpnm32W->iPaddedBorderWidth = 0;
534 /* Helper functions to retrieve monitors info */
536 struct monitor_info
538 int count;
539 RECT primary_rect;
540 RECT virtual_rect;
543 static BOOL CALLBACK monitor_info_proc( HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM lp )
545 MONITORINFO mi;
546 struct monitor_info *info = (struct monitor_info *)lp;
547 info->count++;
548 UnionRect( &info->virtual_rect, &info->virtual_rect, rect );
549 mi.cbSize = sizeof(mi);
550 if (GetMonitorInfoW( monitor, &mi ) && (mi.dwFlags & MONITORINFOF_PRIMARY))
551 info->primary_rect = mi.rcMonitor;
552 return TRUE;
555 static void get_monitors_info( struct monitor_info *info )
557 info->count = 0;
558 SetRectEmpty( &info->primary_rect );
559 SetRectEmpty( &info->virtual_rect );
560 EnumDisplayMonitors( 0, NULL, monitor_info_proc, (LPARAM)info );
563 RECT get_virtual_screen_rect(void)
565 struct monitor_info info;
566 get_monitors_info( &info );
567 return info.virtual_rect;
570 static BOOL get_primary_adapter(WCHAR *name)
572 DISPLAY_DEVICEW dd;
573 DWORD i;
575 dd.cb = sizeof(dd);
576 for (i = 0; EnumDisplayDevicesW(NULL, i, &dd, 0); ++i)
578 if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
580 lstrcpyW(name, dd.DeviceName);
581 return TRUE;
585 return FALSE;
588 /* get text metrics and/or "average" char width of the specified logfont
589 * for the specified dc */
590 static void get_text_metr_size( HDC hdc, LOGFONTW *plf, TEXTMETRICW * ptm, UINT *psz)
592 HFONT hfont, hfontsav;
593 TEXTMETRICW tm;
594 if( !ptm) ptm = &tm;
595 hfont = CreateFontIndirectW( plf);
596 if( !hfont || ( hfontsav = SelectObject( hdc, hfont)) == NULL ) {
597 ptm->tmHeight = -1;
598 if( psz) *psz = 10;
599 if( hfont) DeleteObject( hfont);
600 return;
602 GetTextMetricsW( hdc, ptm);
603 if( psz)
604 if( !(*psz = GdiGetCharDimensions( hdc, ptm, NULL)))
605 *psz = 10;
606 SelectObject( hdc, hfontsav);
607 DeleteObject( hfont);
610 /***********************************************************************
611 * SYSPARAMS_NotifyChange
613 * Sends notification about system parameter update.
615 static void SYSPARAMS_NotifyChange( UINT uiAction, UINT fWinIni )
617 static const WCHAR emptyW[1];
619 if (notify_change)
621 if (fWinIni & SPIF_UPDATEINIFILE)
623 if (fWinIni & (SPIF_SENDWININICHANGE | SPIF_SENDCHANGE))
624 SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE,
625 uiAction, (LPARAM) emptyW,
626 SMTO_ABORTIFHUNG, 2000, NULL );
628 else
630 /* FIXME notify other wine processes with internal message */
635 /* retrieve the cached base keys for a given entry */
636 static BOOL get_base_keys( enum parameter_key index, HKEY *base_key, HKEY *volatile_key )
638 static HKEY base_keys[NB_PARAM_KEYS];
639 static HKEY volatile_keys[NB_PARAM_KEYS];
640 HKEY key;
642 if (!base_keys[index] && base_key)
644 if (RegCreateKeyW( HKEY_CURRENT_USER, parameter_key_names[index], &key )) return FALSE;
645 if (InterlockedCompareExchangePointer( (void **)&base_keys[index], key, 0 ))
646 RegCloseKey( key );
648 if (!volatile_keys[index] && volatile_key)
650 if (RegCreateKeyExW( volatile_base_key, parameter_key_names[index],
651 0, 0, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &key, 0 )) return FALSE;
652 if (InterlockedCompareExchangePointer( (void **)&volatile_keys[index], key, 0 ))
653 RegCloseKey( key );
655 if (base_key) *base_key = base_keys[index];
656 if (volatile_key) *volatile_key = volatile_keys[index];
657 return TRUE;
660 /* load a value to a registry entry */
661 static DWORD load_entry( struct sysparam_entry *entry, void *data, DWORD size )
663 DWORD type, count;
664 HKEY base_key, volatile_key;
666 if (!get_base_keys( entry->regval[0], &base_key, &volatile_key )) return FALSE;
668 count = size;
669 if (RegQueryValueExW( volatile_key, entry->regval + 1, NULL, &type, data, &count ))
671 count = size;
672 if (RegQueryValueExW( base_key, entry->regval + 1, NULL, &type, data, &count )) count = 0;
674 /* make sure strings are null-terminated */
675 if (size && count == size && type == REG_SZ) ((WCHAR *)data)[count / sizeof(WCHAR) - 1] = 0;
676 entry->loaded = TRUE;
677 return count;
680 /* save a value to a registry entry */
681 static BOOL save_entry( const struct sysparam_entry *entry, const void *data, DWORD size,
682 DWORD type, UINT flags )
684 HKEY base_key, volatile_key;
686 if (flags & SPIF_UPDATEINIFILE)
688 if (!get_base_keys( entry->regval[0], &base_key, &volatile_key )) return FALSE;
689 if (RegSetValueExW( base_key, entry->regval + 1, 0, type, data, size )) return FALSE;
690 RegDeleteValueW( volatile_key, entry->regval + 1 );
692 if (entry->mirror && get_base_keys( entry->mirror[0], &base_key, NULL ))
693 RegSetValueExW( base_key, entry->mirror + 1, 0, type, data, size );
695 else
697 if (!get_base_keys( entry->regval[0], NULL, &volatile_key )) return FALSE;
698 if (RegSetValueExW( volatile_key, entry->regval + 1, 0, type, data, size )) return FALSE;
700 return TRUE;
703 /* save a string value to a registry entry */
704 static BOOL save_entry_string( const struct sysparam_entry *entry, const WCHAR *str, UINT flags )
706 return save_entry( entry, str, (strlenW(str) + 1) * sizeof(WCHAR), REG_SZ, flags );
709 /* initialize an entry in the registry if missing */
710 static BOOL init_entry( struct sysparam_entry *entry, const void *data, DWORD size, DWORD type )
712 HKEY base_key;
714 if (!get_base_keys( entry->regval[0], &base_key, NULL )) return FALSE;
715 if (!RegQueryValueExW( base_key, entry->regval + 1, NULL, NULL, NULL, NULL )) return TRUE;
716 if (RegSetValueExW( base_key, entry->regval + 1, 0, type, data, size )) return FALSE;
717 if (entry->mirror && get_base_keys( entry->mirror[0], &base_key, NULL ))
718 RegSetValueExW( base_key, entry->mirror + 1, 0, type, data, size );
719 entry->loaded = TRUE;
720 return TRUE;
723 /* initialize a string value in the registry if missing */
724 static BOOL init_entry_string( struct sysparam_entry *entry, const WCHAR *str )
726 return init_entry( entry, str, (strlenW(str) + 1) * sizeof(WCHAR), REG_SZ );
729 HDC get_display_dc(void)
731 static const WCHAR DISPLAY[] = {'D','I','S','P','L','A','Y',0};
732 EnterCriticalSection( &display_dc_section );
733 if (!display_dc) display_dc = CreateDCW( DISPLAY, NULL, NULL, NULL );
734 return display_dc;
737 void release_display_dc( HDC hdc )
739 LeaveCriticalSection( &display_dc_section );
742 static HANDLE get_display_device_init_mutex( void )
744 static const WCHAR init_mutexW[] = {'d','i','s','p','l','a','y','_','d','e','v','i','c','e','_','i','n','i','t',0};
745 HANDLE mutex = CreateMutexW( NULL, FALSE, init_mutexW );
747 WaitForSingleObject( mutex, INFINITE );
748 return mutex;
751 static void release_display_device_init_mutex( HANDLE mutex )
753 ReleaseMutex( mutex );
754 CloseHandle( mutex );
757 /* Wait until graphics driver is loaded by explorer */
758 static void wait_graphics_driver_ready(void)
760 static BOOL ready = FALSE;
762 if (!ready)
764 SendMessageW( GetDesktopWindow(), WM_NULL, 0, 0 );
765 ready = TRUE;
769 /* map value from system dpi to standard 96 dpi for storing in the registry */
770 static int map_from_system_dpi( int val )
772 return MulDiv( val, USER_DEFAULT_SCREEN_DPI, GetDpiForSystem() );
775 /* map value from 96 dpi to system or custom dpi */
776 static int map_to_dpi( int val, UINT dpi )
778 if (!dpi) dpi = GetDpiForSystem();
779 return MulDiv( val, dpi, USER_DEFAULT_SCREEN_DPI );
782 static INT CALLBACK real_fontname_proc(const LOGFONTW *lf, const TEXTMETRICW *ntm, DWORD type, LPARAM lparam)
784 const ENUMLOGFONTW *elf = (const ENUMLOGFONTW *)lf;
785 WCHAR *fullname = (WCHAR *)lparam;
787 lstrcpynW( fullname, elf->elfFullName, LF_FACESIZE );
788 return 0;
791 static void get_real_fontname( LOGFONTW *lf, WCHAR fullname[LF_FACESIZE] )
793 HDC hdc = get_display_dc();
794 strcpyW( fullname, lf->lfFaceName );
795 EnumFontFamiliesExW( hdc, lf, real_fontname_proc, (LPARAM)fullname, 0 );
796 release_display_dc( hdc );
799 /* adjust some of the raw values found in the registry */
800 static void normalize_nonclientmetrics( NONCLIENTMETRICSW *pncm)
802 TEXTMETRICW tm;
803 HDC hdc = get_display_dc();
805 if( pncm->iBorderWidth < 1) pncm->iBorderWidth = 1;
806 if( pncm->iCaptionWidth < 8) pncm->iCaptionWidth = 8;
807 if( pncm->iScrollWidth < 8) pncm->iScrollWidth = 8;
808 if( pncm->iScrollHeight < 8) pncm->iScrollHeight = 8;
810 /* adjust some heights to the corresponding font */
811 get_text_metr_size( hdc, &pncm->lfMenuFont, &tm, NULL);
812 pncm->iMenuHeight = max( pncm->iMenuHeight, 2 + tm.tmHeight + tm.tmExternalLeading );
813 get_text_metr_size( hdc, &pncm->lfCaptionFont, &tm, NULL);
814 pncm->iCaptionHeight = max( pncm->iCaptionHeight, 2 + tm.tmHeight);
815 get_text_metr_size( hdc, &pncm->lfSmCaptionFont, &tm, NULL);
816 pncm->iSmCaptionHeight = max( pncm->iSmCaptionHeight, 2 + tm.tmHeight);
817 release_display_dc( hdc );
820 static BOOL CALLBACK enum_monitors( HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM lp )
822 MONITORINFO mi;
824 mi.cbSize = sizeof(mi);
825 if (GetMonitorInfoW( monitor, &mi ) && (mi.dwFlags & MONITORINFOF_PRIMARY))
827 LPRECT work = (LPRECT)lp;
828 *work = mi.rcWork;
829 return FALSE;
831 return TRUE;
834 /* load a uint parameter from the registry */
835 static BOOL get_uint_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
837 if (!ptr_param) return FALSE;
839 if (!entry->hdr.loaded)
841 WCHAR buf[32];
843 if (load_entry( &entry->hdr, buf, sizeof(buf) )) entry->uint.val = atoiW( buf );
845 *(UINT *)ptr_param = entry->uint.val;
846 return TRUE;
849 /* set a uint parameter in the registry */
850 static BOOL set_uint_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
852 WCHAR buf[32];
854 wsprintfW( buf, CSu, int_param );
855 if (!save_entry_string( &entry->hdr, buf, flags )) return FALSE;
856 entry->uint.val = int_param;
857 entry->hdr.loaded = TRUE;
858 return TRUE;
861 /* initialize a uint parameter */
862 static BOOL init_uint_entry( union sysparam_all_entry *entry )
864 WCHAR buf[32];
866 wsprintfW( buf, CSu, entry->uint.val );
867 return init_entry_string( &entry->hdr, buf );
870 /* set an int parameter in the registry */
871 static BOOL set_int_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
873 WCHAR buf[32];
875 wsprintfW( buf, CSd, int_param );
876 if (!save_entry_string( &entry->hdr, buf, flags )) return FALSE;
877 entry->uint.val = int_param;
878 entry->hdr.loaded = TRUE;
879 return TRUE;
882 /* initialize an int parameter */
883 static BOOL init_int_entry( union sysparam_all_entry *entry )
885 WCHAR buf[32];
887 wsprintfW( buf, CSd, entry->uint.val );
888 return init_entry_string( &entry->hdr, buf );
891 /* load a twips parameter from the registry */
892 static BOOL get_twips_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
894 int val;
896 if (!ptr_param) return FALSE;
898 if (!entry->hdr.loaded)
900 WCHAR buf[32];
902 if (load_entry( &entry->hdr, buf, sizeof(buf) )) entry->uint.val = atoiW( buf );
905 /* Dimensions are quoted as being "twips" values if negative and pixels if positive.
906 * One inch is 1440 twips.
907 * See for example
908 * Technical Reference to the Windows 2000 Registry ->
909 * HKEY_CURRENT_USER -> Control Panel -> Desktop -> WindowMetrics
911 val = entry->uint.val;
912 if (val < 0)
913 val = MulDiv( -val, dpi, 1440 );
914 else
915 val = map_to_dpi( val, dpi );
917 *(int *)ptr_param = val;
918 return TRUE;
921 /* set a twips parameter in the registry */
922 static BOOL set_twips_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
924 int val = int_param;
925 if (val > 0) val = map_from_system_dpi( val );
926 return set_int_entry( entry, val, ptr_param, flags );
929 /* load a bool parameter from the registry */
930 static BOOL get_bool_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
932 if (!ptr_param) return FALSE;
934 if (!entry->hdr.loaded)
936 WCHAR buf[32];
938 if (load_entry( &entry->hdr, buf, sizeof(buf) )) entry->bool.val = atoiW( buf ) != 0;
940 *(UINT *)ptr_param = entry->bool.val;
941 return TRUE;
944 /* set a bool parameter in the registry */
945 static BOOL set_bool_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
947 WCHAR buf[32];
949 wsprintfW( buf, CSu, int_param != 0 );
950 if (!save_entry_string( &entry->hdr, buf, flags )) return FALSE;
951 entry->bool.val = int_param != 0;
952 entry->hdr.loaded = TRUE;
953 return TRUE;
956 /* initialize a bool parameter */
957 static BOOL init_bool_entry( union sysparam_all_entry *entry )
959 WCHAR buf[32];
961 wsprintfW( buf, CSu, entry->bool.val != 0 );
962 return init_entry_string( &entry->hdr, buf );
965 /* load a bool parameter using Yes/No strings from the registry */
966 static BOOL get_yesno_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
968 if (!ptr_param) return FALSE;
970 if (!entry->hdr.loaded)
972 WCHAR buf[32];
974 if (load_entry( &entry->hdr, buf, sizeof(buf) )) entry->bool.val = !lstrcmpiW( Yes, buf );
976 *(UINT *)ptr_param = entry->bool.val;
977 return TRUE;
980 /* set a bool parameter using Yes/No strings from the registry */
981 static BOOL set_yesno_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
983 const WCHAR *str = int_param ? Yes : No;
985 if (!save_entry_string( &entry->hdr, str, flags )) return FALSE;
986 entry->bool.val = int_param != 0;
987 entry->hdr.loaded = TRUE;
988 return TRUE;
991 /* initialize a bool parameter using Yes/No strings */
992 static BOOL init_yesno_entry( union sysparam_all_entry *entry )
994 return init_entry_string( &entry->hdr, entry->bool.val ? Yes : No );
997 /* load a dword (binary) parameter from the registry */
998 static BOOL get_dword_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
1000 if (!ptr_param) return FALSE;
1002 if (!entry->hdr.loaded)
1004 DWORD val;
1005 if (load_entry( &entry->hdr, &val, sizeof(val) ) == sizeof(DWORD)) entry->dword.val = val;
1007 *(DWORD *)ptr_param = entry->dword.val;
1008 return TRUE;
1011 /* set a dword (binary) parameter in the registry */
1012 static BOOL set_dword_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
1014 DWORD val = PtrToUlong( ptr_param );
1016 if (!save_entry( &entry->hdr, &val, sizeof(val), REG_DWORD, flags )) return FALSE;
1017 entry->dword.val = val;
1018 entry->hdr.loaded = TRUE;
1019 return TRUE;
1022 /* initialize a dword parameter */
1023 static BOOL init_dword_entry( union sysparam_all_entry *entry )
1025 return init_entry( &entry->hdr, &entry->dword.val, sizeof(entry->dword.val), REG_DWORD );
1028 /* load an RGB parameter from the registry */
1029 static BOOL get_rgb_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
1031 if (!ptr_param) return FALSE;
1033 if (!entry->hdr.loaded)
1035 WCHAR buf[32];
1037 if (load_entry( &entry->hdr, buf, sizeof(buf) ))
1039 DWORD r, g, b;
1040 WCHAR *end, *str = buf;
1042 r = strtoulW( str, &end, 10 );
1043 if (end == str || !*end) goto done;
1044 str = end + 1;
1045 g = strtoulW( str, &end, 10 );
1046 if (end == str || !*end) goto done;
1047 str = end + 1;
1048 b = strtoulW( str, &end, 10 );
1049 if (end == str) goto done;
1050 if (r > 255 || g > 255 || b > 255) goto done;
1051 entry->rgb.val = RGB( r, g, b );
1054 done:
1055 *(COLORREF *)ptr_param = entry->rgb.val;
1056 return TRUE;
1059 /* set an RGB parameter in the registry */
1060 static BOOL set_rgb_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
1062 WCHAR buf[32];
1063 HBRUSH brush;
1064 HPEN pen;
1066 wsprintfW( buf, CSrgb, GetRValue(int_param), GetGValue(int_param), GetBValue(int_param) );
1067 if (!save_entry_string( &entry->hdr, buf, flags )) return FALSE;
1068 entry->rgb.val = int_param;
1069 entry->hdr.loaded = TRUE;
1070 if ((brush = InterlockedExchangePointer( (void **)&entry->rgb.brush, 0 )))
1072 __wine_make_gdi_object_system( brush, FALSE );
1073 DeleteObject( brush );
1075 if ((pen = InterlockedExchangePointer( (void **)&entry->rgb.pen, 0 )))
1077 __wine_make_gdi_object_system( pen, FALSE );
1078 DeleteObject( pen );
1080 return TRUE;
1083 /* initialize an RGB parameter */
1084 static BOOL init_rgb_entry( union sysparam_all_entry *entry )
1086 WCHAR buf[32];
1088 wsprintfW( buf, CSrgb, GetRValue(entry->rgb.val), GetGValue(entry->rgb.val), GetBValue(entry->rgb.val) );
1089 return init_entry_string( &entry->hdr, buf );
1092 /* load a font (binary) parameter from the registry */
1093 static BOOL get_font_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
1095 LOGFONTW font;
1097 if (!ptr_param) return FALSE;
1099 if (!entry->hdr.loaded)
1101 switch (load_entry( &entry->hdr, &font, sizeof(font) ))
1103 case sizeof(font):
1104 if (font.lfHeight > 0) /* positive height value means points ( inch/72 ) */
1105 font.lfHeight = -MulDiv( font.lfHeight, USER_DEFAULT_SCREEN_DPI, 72 );
1106 entry->font.val = font;
1107 break;
1108 case sizeof(LOGFONT16): /* win9x-winME format */
1109 SYSPARAMS_LogFont16To32W( (LOGFONT16 *)&font, &entry->font.val );
1110 if (entry->font.val.lfHeight > 0)
1111 entry->font.val.lfHeight = -MulDiv( entry->font.val.lfHeight, USER_DEFAULT_SCREEN_DPI, 72 );
1112 break;
1113 default:
1114 WARN( "Unknown format in key %s value %s\n",
1115 debugstr_w( parameter_key_names[entry->hdr.regval[0]] ),
1116 debugstr_w( entry->hdr.regval + 1 ));
1117 /* fall through */
1118 case 0: /* use the default GUI font */
1119 GetObjectW( GetStockObject( DEFAULT_GUI_FONT ), sizeof(font), &font );
1120 font.lfHeight = map_from_system_dpi( font.lfHeight );
1121 font.lfWeight = entry->font.weight;
1122 entry->font.val = font;
1123 break;
1125 get_real_fontname( &entry->font.val, entry->font.fullname );
1126 entry->hdr.loaded = TRUE;
1128 font = entry->font.val;
1129 font.lfHeight = map_to_dpi( font.lfHeight, dpi );
1130 strcpyW( font.lfFaceName, entry->font.fullname );
1131 *(LOGFONTW *)ptr_param = font;
1132 return TRUE;
1135 /* set a font (binary) parameter in the registry */
1136 static BOOL set_font_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
1138 LOGFONTW font;
1139 WCHAR *ptr;
1141 memcpy( &font, ptr_param, sizeof(font) );
1142 /* zero pad the end of lfFaceName so we don't save uninitialised data */
1143 ptr = memchrW( font.lfFaceName, 0, LF_FACESIZE );
1144 if (ptr) memset( ptr, 0, (font.lfFaceName + LF_FACESIZE - ptr) * sizeof(WCHAR) );
1145 if (font.lfHeight < 0) font.lfHeight = map_from_system_dpi( font.lfHeight );
1147 if (!save_entry( &entry->hdr, &font, sizeof(font), REG_BINARY, flags )) return FALSE;
1148 entry->font.val = font;
1149 get_real_fontname( &entry->font.val, entry->font.fullname );
1150 entry->hdr.loaded = TRUE;
1151 return TRUE;
1154 /* initialize a font (binary) parameter */
1155 static BOOL init_font_entry( union sysparam_all_entry *entry )
1157 GetObjectW( GetStockObject( DEFAULT_GUI_FONT ), sizeof(entry->font.val), &entry->font.val );
1158 entry->font.val.lfHeight = map_from_system_dpi( entry->font.val.lfHeight );
1159 entry->font.val.lfWeight = entry->font.weight;
1160 get_real_fontname( &entry->font.val, entry->font.fullname );
1161 return init_entry( &entry->hdr, &entry->font.val, sizeof(entry->font.val), REG_BINARY );
1164 /* get a path parameter in the registry */
1165 static BOOL get_path_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
1167 if (!ptr_param) return FALSE;
1169 if (!entry->hdr.loaded)
1171 WCHAR buffer[MAX_PATH];
1173 if (load_entry( &entry->hdr, buffer, sizeof(buffer) ))
1174 lstrcpynW( entry->path.path, buffer, MAX_PATH );
1176 lstrcpynW( ptr_param, entry->path.path, int_param );
1177 return TRUE;
1180 /* set a path parameter in the registry */
1181 static BOOL set_path_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
1183 WCHAR buffer[MAX_PATH];
1184 BOOL ret;
1186 lstrcpynW( buffer, ptr_param, MAX_PATH );
1187 ret = save_entry_string( &entry->hdr, buffer, flags );
1188 if (ret)
1190 strcpyW( entry->path.path, buffer );
1191 entry->hdr.loaded = TRUE;
1193 return ret;
1196 /* initialize a path parameter */
1197 static BOOL init_path_entry( union sysparam_all_entry *entry )
1199 return init_entry_string( &entry->hdr, entry->path.path );
1202 /* get a binary parameter in the registry */
1203 static BOOL get_binary_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
1205 if (!ptr_param) return FALSE;
1207 if (!entry->hdr.loaded)
1209 void *buffer = HeapAlloc( GetProcessHeap(), 0, entry->bin.size );
1210 DWORD len = load_entry( &entry->hdr, buffer, entry->bin.size );
1212 if (len)
1214 memcpy( entry->bin.ptr, buffer, entry->bin.size );
1215 memset( (char *)entry->bin.ptr + len, 0, entry->bin.size - len );
1217 HeapFree( GetProcessHeap(), 0, buffer );
1219 memcpy( ptr_param, entry->bin.ptr, min( int_param, entry->bin.size ) );
1220 return TRUE;
1223 /* set a binary parameter in the registry */
1224 static BOOL set_binary_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
1226 BOOL ret;
1227 void *buffer = HeapAlloc( GetProcessHeap(), 0, entry->bin.size );
1229 memcpy( buffer, entry->bin.ptr, entry->bin.size );
1230 memcpy( buffer, ptr_param, min( int_param, entry->bin.size ));
1231 ret = save_entry( &entry->hdr, buffer, entry->bin.size, REG_BINARY, flags );
1232 if (ret)
1234 memcpy( entry->bin.ptr, buffer, entry->bin.size );
1235 entry->hdr.loaded = TRUE;
1237 HeapFree( GetProcessHeap(), 0, buffer );
1238 return ret;
1241 /* initialize a binary parameter */
1242 static BOOL init_binary_entry( union sysparam_all_entry *entry )
1244 return init_entry( &entry->hdr, entry->bin.ptr, entry->bin.size, REG_BINARY );
1247 /* get a user pref parameter in the registry */
1248 static BOOL get_userpref_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
1250 union sysparam_all_entry *parent_entry = (union sysparam_all_entry *)entry->pref.parent;
1251 BYTE prefs[8];
1253 if (!ptr_param) return FALSE;
1255 if (!parent_entry->hdr.get( parent_entry, sizeof(prefs), prefs, dpi )) return FALSE;
1256 *(BOOL *)ptr_param = (prefs[entry->pref.offset] & entry->pref.mask) != 0;
1257 return TRUE;
1260 /* set a user pref parameter in the registry */
1261 static BOOL set_userpref_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
1263 union sysparam_all_entry *parent_entry = (union sysparam_all_entry *)entry->pref.parent;
1264 BYTE prefs[8];
1266 parent_entry->hdr.loaded = FALSE; /* force loading it again */
1267 if (!parent_entry->hdr.get( parent_entry, sizeof(prefs), prefs, GetDpiForSystem() )) return FALSE;
1269 if (PtrToUlong( ptr_param )) prefs[entry->pref.offset] |= entry->pref.mask;
1270 else prefs[entry->pref.offset] &= ~entry->pref.mask;
1272 return parent_entry->hdr.set( parent_entry, sizeof(prefs), prefs, flags );
1275 static BOOL get_entry_dpi( void *ptr, UINT int_param, void *ptr_param, UINT dpi )
1277 union sysparam_all_entry *entry = ptr;
1278 return entry->hdr.get( entry, int_param, ptr_param, dpi );
1281 static BOOL get_entry( void *ptr, UINT int_param, void *ptr_param )
1283 return get_entry_dpi( ptr, int_param, ptr_param, GetDpiForSystem() );
1286 static BOOL set_entry( void *ptr, UINT int_param, void *ptr_param, UINT flags )
1288 union sysparam_all_entry *entry = ptr;
1289 return entry->hdr.set( entry, int_param, ptr_param, flags );
1292 #define UINT_ENTRY(name,val) \
1293 struct sysparam_uint_entry entry_##name = { { get_uint_entry, set_uint_entry, init_uint_entry, \
1294 name ##_VALNAME }, (val) }
1296 #define UINT_ENTRY_MIRROR(name,val) \
1297 struct sysparam_uint_entry entry_##name = { { get_uint_entry, set_uint_entry, init_uint_entry, \
1298 name ##_VALNAME, name ##_MIRROR }, (val) }
1300 #define INT_ENTRY(name,val) \
1301 struct sysparam_uint_entry entry_##name = { { get_uint_entry, set_int_entry, init_int_entry, \
1302 name ##_VALNAME }, (val) }
1304 #define BOOL_ENTRY(name,val) \
1305 struct sysparam_bool_entry entry_##name = { { get_bool_entry, set_bool_entry, init_bool_entry, \
1306 name ##_VALNAME }, (val) }
1308 #define BOOL_ENTRY_MIRROR(name,val) \
1309 struct sysparam_bool_entry entry_##name = { { get_bool_entry, set_bool_entry, init_bool_entry, \
1310 name ##_VALNAME, name ##_MIRROR }, (val) }
1312 #define YESNO_ENTRY(name,val) \
1313 struct sysparam_bool_entry entry_##name = { { get_yesno_entry, set_yesno_entry, init_yesno_entry, \
1314 name ##_VALNAME }, (val) }
1316 #define TWIPS_ENTRY(name,val) \
1317 struct sysparam_uint_entry entry_##name = { { get_twips_entry, set_twips_entry, init_int_entry, \
1318 name ##_VALNAME }, (val) }
1320 #define DWORD_ENTRY(name,val) \
1321 struct sysparam_dword_entry entry_##name = { { get_dword_entry, set_dword_entry, init_dword_entry, \
1322 name ##_VALNAME }, (val) }
1324 #define BINARY_ENTRY(name,data) \
1325 struct sysparam_binary_entry entry_##name = { { get_binary_entry, set_binary_entry, init_binary_entry, \
1326 name ##_VALNAME }, data, sizeof(data) }
1328 #define PATH_ENTRY(name) \
1329 struct sysparam_path_entry entry_##name = { { get_path_entry, set_path_entry, init_path_entry, \
1330 name ##_VALNAME } }
1332 #define FONT_ENTRY(name,weight) \
1333 struct sysparam_font_entry entry_##name = { { get_font_entry, set_font_entry, init_font_entry, \
1334 name ##_VALNAME }, (weight) }
1336 #define USERPREF_ENTRY(name,offset,mask) \
1337 struct sysparam_pref_entry entry_##name = { { get_userpref_entry, set_userpref_entry }, \
1338 &entry_USERPREFERENCESMASK, (offset), (mask) }
1340 static UINT_ENTRY( DRAGWIDTH, 4 );
1341 static UINT_ENTRY( DRAGHEIGHT, 4 );
1342 static UINT_ENTRY( DOUBLECLICKTIME, 500 );
1343 static UINT_ENTRY( FONTSMOOTHING, 2 );
1344 static UINT_ENTRY( GRIDGRANULARITY, 0 );
1345 static UINT_ENTRY( KEYBOARDDELAY, 1 );
1346 static UINT_ENTRY( KEYBOARDSPEED, 31 );
1347 static UINT_ENTRY( MENUSHOWDELAY, 400 );
1348 static UINT_ENTRY( MINARRANGE, ARW_HIDE );
1349 static UINT_ENTRY( MINHORZGAP, 0 );
1350 static UINT_ENTRY( MINVERTGAP, 0 );
1351 static UINT_ENTRY( MINWIDTH, 154 );
1352 static UINT_ENTRY( MOUSEHOVERHEIGHT, 4 );
1353 static UINT_ENTRY( MOUSEHOVERTIME, 400 );
1354 static UINT_ENTRY( MOUSEHOVERWIDTH, 4 );
1355 static UINT_ENTRY( MOUSESPEED, 10 );
1356 static UINT_ENTRY( MOUSETRAILS, 0 );
1357 static UINT_ENTRY( SCREENSAVETIMEOUT, 300 );
1358 static UINT_ENTRY( WHEELSCROLLCHARS, 3 );
1359 static UINT_ENTRY( WHEELSCROLLLINES, 3 );
1360 static UINT_ENTRY_MIRROR( DOUBLECLKHEIGHT, 4 );
1361 static UINT_ENTRY_MIRROR( DOUBLECLKWIDTH, 4 );
1362 static UINT_ENTRY_MIRROR( MENUDROPALIGNMENT, 0 );
1364 static INT_ENTRY( MOUSETHRESHOLD1, 6 );
1365 static INT_ENTRY( MOUSETHRESHOLD2, 10 );
1366 static INT_ENTRY( MOUSEACCELERATION, 1 );
1368 static BOOL_ENTRY( BLOCKSENDINPUTRESETS, FALSE );
1369 static BOOL_ENTRY( DRAGFULLWINDOWS, FALSE );
1370 static BOOL_ENTRY( KEYBOARDPREF, TRUE );
1371 static BOOL_ENTRY( LOWPOWERACTIVE, FALSE );
1372 static BOOL_ENTRY( MOUSEBUTTONSWAP, FALSE );
1373 static BOOL_ENTRY( POWEROFFACTIVE, FALSE );
1374 static BOOL_ENTRY( SCREENREADER, FALSE );
1375 static BOOL_ENTRY( SCREENSAVEACTIVE, TRUE );
1376 static BOOL_ENTRY( SCREENSAVERRUNNING, FALSE );
1377 static BOOL_ENTRY( SHOWSOUNDS, FALSE );
1378 static BOOL_ENTRY( SNAPTODEFBUTTON, FALSE );
1379 static BOOL_ENTRY_MIRROR( ICONTITLEWRAP, TRUE );
1380 static BOOL_ENTRY( AUDIODESC_ON, FALSE);
1382 static YESNO_ENTRY( BEEP, TRUE );
1384 static TWIPS_ENTRY( BORDER, -15 );
1385 static TWIPS_ENTRY( CAPTIONHEIGHT, -270 );
1386 static TWIPS_ENTRY( CAPTIONWIDTH, -270 );
1387 static TWIPS_ENTRY( ICONHORIZONTALSPACING, -1125 );
1388 static TWIPS_ENTRY( ICONVERTICALSPACING, -1125 );
1389 static TWIPS_ENTRY( MENUHEIGHT, -270 );
1390 static TWIPS_ENTRY( MENUWIDTH, -270 );
1391 static TWIPS_ENTRY( PADDEDBORDERWIDTH, 0 );
1392 static TWIPS_ENTRY( SCROLLHEIGHT, -240 );
1393 static TWIPS_ENTRY( SCROLLWIDTH, -240 );
1394 static TWIPS_ENTRY( SMCAPTIONHEIGHT, -225 );
1395 static TWIPS_ENTRY( SMCAPTIONWIDTH, -225 );
1397 static DWORD_ENTRY( ACTIVEWINDOWTRACKING, 0 );
1398 static DWORD_ENTRY( ACTIVEWNDTRKTIMEOUT, 0 );
1399 static DWORD_ENTRY( CARETWIDTH, 1 );
1400 static DWORD_ENTRY( DPISCALINGVER, 0 );
1401 static DWORD_ENTRY( FOCUSBORDERHEIGHT, 1 );
1402 static DWORD_ENTRY( FOCUSBORDERWIDTH, 1 );
1403 static DWORD_ENTRY( FONTSMOOTHINGCONTRAST, 0 );
1404 static DWORD_ENTRY( FONTSMOOTHINGORIENTATION, FE_FONTSMOOTHINGORIENTATIONRGB );
1405 static DWORD_ENTRY( FONTSMOOTHINGTYPE, FE_FONTSMOOTHINGSTANDARD );
1406 static DWORD_ENTRY( FOREGROUNDFLASHCOUNT, 3 );
1407 static DWORD_ENTRY( FOREGROUNDLOCKTIMEOUT, 0 );
1408 static DWORD_ENTRY( LOGPIXELS, 0 );
1409 static DWORD_ENTRY( MOUSECLICKLOCKTIME, 1200 );
1410 static DWORD_ENTRY( AUDIODESC_LOCALE, 0 );
1412 static PATH_ENTRY( DESKPATTERN );
1413 static PATH_ENTRY( DESKWALLPAPER );
1415 static BYTE user_prefs[8] = { 0x30, 0x00, 0x00, 0x80, 0x10, 0x00, 0x00, 0x00 };
1416 static BINARY_ENTRY( USERPREFERENCESMASK, user_prefs );
1418 static FONT_ENTRY( CAPTIONLOGFONT, FW_BOLD );
1419 static FONT_ENTRY( ICONTITLELOGFONT, FW_NORMAL );
1420 static FONT_ENTRY( MENULOGFONT, FW_NORMAL );
1421 static FONT_ENTRY( MESSAGELOGFONT, FW_NORMAL );
1422 static FONT_ENTRY( SMCAPTIONLOGFONT, FW_NORMAL );
1423 static FONT_ENTRY( STATUSLOGFONT, FW_NORMAL );
1425 static USERPREF_ENTRY( MENUANIMATION, 0, 0x02 );
1426 static USERPREF_ENTRY( COMBOBOXANIMATION, 0, 0x04 );
1427 static USERPREF_ENTRY( LISTBOXSMOOTHSCROLLING, 0, 0x08 );
1428 static USERPREF_ENTRY( GRADIENTCAPTIONS, 0, 0x10 );
1429 static USERPREF_ENTRY( KEYBOARDCUES, 0, 0x20 );
1430 static USERPREF_ENTRY( ACTIVEWNDTRKZORDER, 0, 0x40 );
1431 static USERPREF_ENTRY( HOTTRACKING, 0, 0x80 );
1432 static USERPREF_ENTRY( MENUFADE, 1, 0x02 );
1433 static USERPREF_ENTRY( SELECTIONFADE, 1, 0x04 );
1434 static USERPREF_ENTRY( TOOLTIPANIMATION, 1, 0x08 );
1435 static USERPREF_ENTRY( TOOLTIPFADE, 1, 0x10 );
1436 static USERPREF_ENTRY( CURSORSHADOW, 1, 0x20 );
1437 static USERPREF_ENTRY( MOUSESONAR, 1, 0x40 );
1438 static USERPREF_ENTRY( MOUSECLICKLOCK, 1, 0x80 );
1439 static USERPREF_ENTRY( MOUSEVANISH, 2, 0x01 );
1440 static USERPREF_ENTRY( FLATMENU, 2, 0x02 );
1441 static USERPREF_ENTRY( DROPSHADOW, 2, 0x04 );
1442 static USERPREF_ENTRY( UIEFFECTS, 3, 0x80 );
1443 static USERPREF_ENTRY( DISABLEOVERLAPPEDCONTENT, 4, 0x01 );
1444 static USERPREF_ENTRY( CLIENTAREAANIMATION, 4, 0x02 );
1445 static USERPREF_ENTRY( CLEARTYPE, 4, 0x10 );
1446 static USERPREF_ENTRY( SPEECHRECOGNITION, 4, 0x20 );
1448 static struct sysparam_rgb_entry system_colors[] =
1450 #define RGB_ENTRY(name,val) { { get_rgb_entry, set_rgb_entry, init_rgb_entry, name ##_VALNAME }, (val) }
1451 RGB_ENTRY( COLOR_SCROLLBAR, RGB(212, 208, 200) ),
1452 RGB_ENTRY( COLOR_BACKGROUND, RGB(58, 110, 165) ),
1453 RGB_ENTRY( COLOR_ACTIVECAPTION, RGB(10, 36, 106) ),
1454 RGB_ENTRY( COLOR_INACTIVECAPTION, RGB(128, 128, 128) ),
1455 RGB_ENTRY( COLOR_MENU, RGB(212, 208, 200) ),
1456 RGB_ENTRY( COLOR_WINDOW, RGB(255, 255, 255) ),
1457 RGB_ENTRY( COLOR_WINDOWFRAME, RGB(0, 0, 0) ),
1458 RGB_ENTRY( COLOR_MENUTEXT, RGB(0, 0, 0) ),
1459 RGB_ENTRY( COLOR_WINDOWTEXT, RGB(0, 0, 0) ),
1460 RGB_ENTRY( COLOR_CAPTIONTEXT, RGB(255, 255, 255) ),
1461 RGB_ENTRY( COLOR_ACTIVEBORDER, RGB(212, 208, 200) ),
1462 RGB_ENTRY( COLOR_INACTIVEBORDER, RGB(212, 208, 200) ),
1463 RGB_ENTRY( COLOR_APPWORKSPACE, RGB(128, 128, 128) ),
1464 RGB_ENTRY( COLOR_HIGHLIGHT, RGB(10, 36, 106) ),
1465 RGB_ENTRY( COLOR_HIGHLIGHTTEXT, RGB(255, 255, 255) ),
1466 RGB_ENTRY( COLOR_BTNFACE, RGB(212, 208, 200) ),
1467 RGB_ENTRY( COLOR_BTNSHADOW, RGB(128, 128, 128) ),
1468 RGB_ENTRY( COLOR_GRAYTEXT, RGB(128, 128, 128) ),
1469 RGB_ENTRY( COLOR_BTNTEXT, RGB(0, 0, 0) ),
1470 RGB_ENTRY( COLOR_INACTIVECAPTIONTEXT, RGB(212, 208, 200) ),
1471 RGB_ENTRY( COLOR_BTNHIGHLIGHT, RGB(255, 255, 255) ),
1472 RGB_ENTRY( COLOR_3DDKSHADOW, RGB(64, 64, 64) ),
1473 RGB_ENTRY( COLOR_3DLIGHT, RGB(212, 208, 200) ),
1474 RGB_ENTRY( COLOR_INFOTEXT, RGB(0, 0, 0) ),
1475 RGB_ENTRY( COLOR_INFOBK, RGB(255, 255, 225) ),
1476 RGB_ENTRY( COLOR_ALTERNATEBTNFACE, RGB(181, 181, 181) ),
1477 RGB_ENTRY( COLOR_HOTLIGHT, RGB(0, 0, 200) ),
1478 RGB_ENTRY( COLOR_GRADIENTACTIVECAPTION, RGB(166, 202, 240) ),
1479 RGB_ENTRY( COLOR_GRADIENTINACTIVECAPTION, RGB(192, 192, 192) ),
1480 RGB_ENTRY( COLOR_MENUHILIGHT, RGB(10, 36, 106) ),
1481 RGB_ENTRY( COLOR_MENUBAR, RGB(212, 208, 200) )
1482 #undef RGB_ENTRY
1485 /* entries that are initialized by default in the registry */
1486 static union sysparam_all_entry * const default_entries[] =
1488 (union sysparam_all_entry *)&entry_ACTIVEWINDOWTRACKING,
1489 (union sysparam_all_entry *)&entry_ACTIVEWNDTRKTIMEOUT,
1490 (union sysparam_all_entry *)&entry_BEEP,
1491 (union sysparam_all_entry *)&entry_BLOCKSENDINPUTRESETS,
1492 (union sysparam_all_entry *)&entry_BORDER,
1493 (union sysparam_all_entry *)&entry_CAPTIONHEIGHT,
1494 (union sysparam_all_entry *)&entry_CAPTIONWIDTH,
1495 (union sysparam_all_entry *)&entry_CARETWIDTH,
1496 (union sysparam_all_entry *)&entry_DESKWALLPAPER,
1497 (union sysparam_all_entry *)&entry_DOUBLECLICKTIME,
1498 (union sysparam_all_entry *)&entry_DOUBLECLKHEIGHT,
1499 (union sysparam_all_entry *)&entry_DOUBLECLKWIDTH,
1500 (union sysparam_all_entry *)&entry_DRAGFULLWINDOWS,
1501 (union sysparam_all_entry *)&entry_DRAGHEIGHT,
1502 (union sysparam_all_entry *)&entry_DRAGWIDTH,
1503 (union sysparam_all_entry *)&entry_FOCUSBORDERHEIGHT,
1504 (union sysparam_all_entry *)&entry_FOCUSBORDERWIDTH,
1505 (union sysparam_all_entry *)&entry_FONTSMOOTHING,
1506 (union sysparam_all_entry *)&entry_FONTSMOOTHINGCONTRAST,
1507 (union sysparam_all_entry *)&entry_FONTSMOOTHINGORIENTATION,
1508 (union sysparam_all_entry *)&entry_FONTSMOOTHINGTYPE,
1509 (union sysparam_all_entry *)&entry_FOREGROUNDFLASHCOUNT,
1510 (union sysparam_all_entry *)&entry_FOREGROUNDLOCKTIMEOUT,
1511 (union sysparam_all_entry *)&entry_ICONHORIZONTALSPACING,
1512 (union sysparam_all_entry *)&entry_ICONTITLEWRAP,
1513 (union sysparam_all_entry *)&entry_ICONVERTICALSPACING,
1514 (union sysparam_all_entry *)&entry_KEYBOARDDELAY,
1515 (union sysparam_all_entry *)&entry_KEYBOARDPREF,
1516 (union sysparam_all_entry *)&entry_KEYBOARDSPEED,
1517 (union sysparam_all_entry *)&entry_LOWPOWERACTIVE,
1518 (union sysparam_all_entry *)&entry_MENUHEIGHT,
1519 (union sysparam_all_entry *)&entry_MENUSHOWDELAY,
1520 (union sysparam_all_entry *)&entry_MENUWIDTH,
1521 (union sysparam_all_entry *)&entry_MOUSEACCELERATION,
1522 (union sysparam_all_entry *)&entry_MOUSEBUTTONSWAP,
1523 (union sysparam_all_entry *)&entry_MOUSECLICKLOCKTIME,
1524 (union sysparam_all_entry *)&entry_MOUSEHOVERHEIGHT,
1525 (union sysparam_all_entry *)&entry_MOUSEHOVERTIME,
1526 (union sysparam_all_entry *)&entry_MOUSEHOVERWIDTH,
1527 (union sysparam_all_entry *)&entry_MOUSESPEED,
1528 (union sysparam_all_entry *)&entry_MOUSETHRESHOLD1,
1529 (union sysparam_all_entry *)&entry_MOUSETHRESHOLD2,
1530 (union sysparam_all_entry *)&entry_PADDEDBORDERWIDTH,
1531 (union sysparam_all_entry *)&entry_SCREENREADER,
1532 (union sysparam_all_entry *)&entry_SCROLLHEIGHT,
1533 (union sysparam_all_entry *)&entry_SCROLLWIDTH,
1534 (union sysparam_all_entry *)&entry_SHOWSOUNDS,
1535 (union sysparam_all_entry *)&entry_SMCAPTIONHEIGHT,
1536 (union sysparam_all_entry *)&entry_SMCAPTIONWIDTH,
1537 (union sysparam_all_entry *)&entry_SNAPTODEFBUTTON,
1538 (union sysparam_all_entry *)&entry_USERPREFERENCESMASK,
1539 (union sysparam_all_entry *)&entry_WHEELSCROLLCHARS,
1540 (union sysparam_all_entry *)&entry_WHEELSCROLLLINES,
1541 (union sysparam_all_entry *)&entry_AUDIODESC_LOCALE,
1542 (union sysparam_all_entry *)&entry_AUDIODESC_ON,
1545 /***********************************************************************
1546 * SYSPARAMS_Init
1548 void SYSPARAMS_Init(void)
1550 static const WCHAR def_key_name[] = {'S','o','f','t','w','a','r','e','\\','F','o','n','t','s',0};
1551 static const WCHAR def_value_name[] = {'L','o','g','P','i','x','e','l','s',0};
1552 HKEY key;
1553 DWORD i, dispos, dpi_scaling;
1555 /* this one must be non-volatile */
1556 if (RegCreateKeyW( HKEY_CURRENT_USER, WINE_CURRENT_USER_REGKEY, &key ))
1558 ERR("Can't create wine registry branch\n");
1559 return;
1562 /* @@ Wine registry key: HKCU\Software\Wine\Temporary System Parameters */
1563 if (RegCreateKeyExW( key, WINE_CURRENT_USER_REGKEY_TEMP_PARAMS, 0, 0,
1564 REG_OPTION_VOLATILE, KEY_ALL_ACCESS, 0, &volatile_base_key, &dispos ))
1565 ERR("Can't create non-permanent wine registry branch\n");
1567 RegCloseKey( key );
1569 get_dword_entry( (union sysparam_all_entry *)&entry_LOGPIXELS, 0, &system_dpi, 0 );
1570 if (!system_dpi) /* check fallback key */
1572 if (!RegOpenKeyW( HKEY_CURRENT_CONFIG, def_key_name, &key ))
1574 DWORD type, size = sizeof(system_dpi);
1575 if (RegQueryValueExW( key, def_value_name, NULL, &type, (void *)&system_dpi, &size ) ||
1576 type != REG_DWORD)
1577 system_dpi = 0;
1578 RegCloseKey( key );
1581 if (!system_dpi) system_dpi = USER_DEFAULT_SCREEN_DPI;
1583 /* FIXME: what do the DpiScalingVer flags mean? */
1584 get_dword_entry( (union sysparam_all_entry *)&entry_DPISCALINGVER, 0, &dpi_scaling, 0 );
1585 if (!dpi_scaling)
1587 default_awareness = DPI_AWARENESS_PER_MONITOR_AWARE;
1588 dpi_awareness = 0x10 | default_awareness;
1591 if (volatile_base_key && dispos == REG_CREATED_NEW_KEY) /* first process, initialize entries */
1593 for (i = 0; i < ARRAY_SIZE( default_entries ); i++)
1594 default_entries[i]->hdr.init( default_entries[i] );
1598 static BOOL update_desktop_wallpaper(void)
1600 DWORD pid;
1602 if (GetWindowThreadProcessId( GetDesktopWindow(), &pid ) && pid == GetCurrentProcessId())
1604 WCHAR wallpaper[MAX_PATH], pattern[256];
1606 entry_DESKWALLPAPER.hdr.loaded = entry_DESKPATTERN.hdr.loaded = FALSE;
1607 if (get_entry( &entry_DESKWALLPAPER, MAX_PATH, wallpaper ) &&
1608 get_entry( &entry_DESKPATTERN, 256, pattern ))
1609 update_wallpaper( wallpaper, pattern );
1611 else SendMessageW( GetDesktopWindow(), WM_SETTINGCHANGE, SPI_SETDESKWALLPAPER, 0 );
1612 return TRUE;
1616 /***********************************************************************
1617 * SystemParametersInfoForDpi (USER32.@)
1619 BOOL WINAPI SystemParametersInfoForDpi( UINT action, UINT val, PVOID ptr, UINT winini, UINT dpi )
1621 BOOL ret = FALSE;
1623 switch (action)
1625 case SPI_GETICONTITLELOGFONT:
1626 ret = get_entry_dpi( &entry_ICONTITLELOGFONT, val, ptr, dpi );
1627 break;
1628 case SPI_GETNONCLIENTMETRICS:
1630 NONCLIENTMETRICSW *ncm = ptr;
1632 if (!ncm) break;
1633 ret = get_entry_dpi( &entry_BORDER, 0, &ncm->iBorderWidth, dpi ) &&
1634 get_entry_dpi( &entry_SCROLLWIDTH, 0, &ncm->iScrollWidth, dpi ) &&
1635 get_entry_dpi( &entry_SCROLLHEIGHT, 0, &ncm->iScrollHeight, dpi ) &&
1636 get_entry_dpi( &entry_CAPTIONWIDTH, 0, &ncm->iCaptionWidth, dpi ) &&
1637 get_entry_dpi( &entry_CAPTIONHEIGHT, 0, &ncm->iCaptionHeight, dpi ) &&
1638 get_entry_dpi( &entry_CAPTIONLOGFONT, 0, &ncm->lfCaptionFont, dpi ) &&
1639 get_entry_dpi( &entry_SMCAPTIONWIDTH, 0, &ncm->iSmCaptionWidth, dpi ) &&
1640 get_entry_dpi( &entry_SMCAPTIONHEIGHT, 0, &ncm->iSmCaptionHeight, dpi ) &&
1641 get_entry_dpi( &entry_SMCAPTIONLOGFONT, 0, &ncm->lfSmCaptionFont, dpi ) &&
1642 get_entry_dpi( &entry_MENUWIDTH, 0, &ncm->iMenuWidth, dpi ) &&
1643 get_entry_dpi( &entry_MENUHEIGHT, 0, &ncm->iMenuHeight, dpi ) &&
1644 get_entry_dpi( &entry_MENULOGFONT, 0, &ncm->lfMenuFont, dpi ) &&
1645 get_entry_dpi( &entry_STATUSLOGFONT, 0, &ncm->lfStatusFont, dpi ) &&
1646 get_entry_dpi( &entry_MESSAGELOGFONT, 0, &ncm->lfMessageFont, dpi );
1647 if (ret && ncm->cbSize == sizeof(NONCLIENTMETRICSW))
1648 ret = get_entry_dpi( &entry_PADDEDBORDERWIDTH, 0, &ncm->iPaddedBorderWidth, dpi );
1649 normalize_nonclientmetrics( ncm );
1650 break;
1652 case SPI_GETICONMETRICS:
1654 ICONMETRICSW *im = ptr;
1655 if (im && im->cbSize == sizeof(*im))
1656 ret = get_entry_dpi( &entry_ICONHORIZONTALSPACING, 0, &im->iHorzSpacing, dpi ) &&
1657 get_entry_dpi( &entry_ICONVERTICALSPACING, 0, &im->iVertSpacing, dpi ) &&
1658 get_entry_dpi( &entry_ICONTITLEWRAP, 0, &im->iTitleWrap, dpi ) &&
1659 get_entry_dpi( &entry_ICONTITLELOGFONT, 0, &im->lfFont, dpi );
1660 break;
1662 default:
1663 SetLastError( ERROR_INVALID_PARAMETER );
1664 break;
1666 return ret;
1670 /***********************************************************************
1671 * SystemParametersInfoW (USER32.@)
1673 * Each system parameter has flag which shows whether the parameter
1674 * is loaded or not. Parameters, stored directly in SysParametersInfo are
1675 * loaded from registry only when they are requested and the flag is
1676 * "false", after the loading the flag is set to "true". On interprocess
1677 * notification of the parameter change the corresponding parameter flag is
1678 * set to "false". The parameter value will be reloaded when it is requested
1679 * the next time.
1680 * Parameters, backed by or depend on GetSystemMetrics are processed
1681 * differently. These parameters are always loaded. They are reloaded right
1682 * away on interprocess change notification. We can't do lazy loading because
1683 * we don't want to complicate GetSystemMetrics.
1684 * Parameters, backed by X settings are read from corresponding setting.
1685 * On the parameter change request the setting is changed. Interprocess change
1686 * notifications are ignored.
1687 * When parameter value is updated the changed value is stored in permanent
1688 * registry branch if saving is requested. Otherwise it is stored
1689 * in temporary branch
1691 * Some SPI values can also be stored as Twips values in the registry,
1692 * don't forget the conversion!
1694 BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam,
1695 PVOID pvParam, UINT fWinIni )
1697 #define WINE_SPI_FIXME(x) \
1698 case x: \
1700 static BOOL warn = TRUE; \
1701 if (warn) \
1703 warn = FALSE; \
1704 FIXME( "Unimplemented action: %u (%s)\n", x, #x ); \
1707 SetLastError( ERROR_INVALID_SPI_VALUE ); \
1708 ret = FALSE; \
1709 break
1710 #define WINE_SPI_WARN(x) \
1711 case x: \
1712 WARN( "Ignored action: %u (%s)\n", x, #x ); \
1713 ret = TRUE; \
1714 break
1716 BOOL ret = USER_Driver->pSystemParametersInfo( uiAction, uiParam, pvParam, fWinIni );
1717 unsigned spi_idx = 0;
1719 if (!ret) switch (uiAction)
1721 case SPI_GETBEEP:
1722 ret = get_entry( &entry_BEEP, uiParam, pvParam );
1723 break;
1724 case SPI_SETBEEP:
1725 ret = set_entry( &entry_BEEP, uiParam, pvParam, fWinIni );
1726 break;
1727 case SPI_GETMOUSE:
1728 ret = get_entry( &entry_MOUSETHRESHOLD1, uiParam, (INT *)pvParam ) &&
1729 get_entry( &entry_MOUSETHRESHOLD2, uiParam, (INT *)pvParam + 1 ) &&
1730 get_entry( &entry_MOUSEACCELERATION, uiParam, (INT *)pvParam + 2 );
1731 break;
1732 case SPI_SETMOUSE:
1733 ret = set_entry( &entry_MOUSETHRESHOLD1, ((INT *)pvParam)[0], pvParam, fWinIni ) &&
1734 set_entry( &entry_MOUSETHRESHOLD2, ((INT *)pvParam)[1], pvParam, fWinIni ) &&
1735 set_entry( &entry_MOUSEACCELERATION, ((INT *)pvParam)[2], pvParam, fWinIni );
1736 break;
1737 case SPI_GETBORDER:
1738 ret = get_entry( &entry_BORDER, uiParam, pvParam );
1739 if (*(INT*)pvParam < 1) *(INT*)pvParam = 1;
1740 break;
1741 case SPI_SETBORDER:
1742 ret = set_entry( &entry_BORDER, uiParam, pvParam, fWinIni );
1743 break;
1744 case SPI_GETKEYBOARDSPEED:
1745 ret = get_entry( &entry_KEYBOARDSPEED, uiParam, pvParam );
1746 break;
1747 case SPI_SETKEYBOARDSPEED:
1748 if (uiParam > 31) uiParam = 31;
1749 ret = set_entry( &entry_KEYBOARDSPEED, uiParam, pvParam, fWinIni );
1750 break;
1752 /* not implemented in Windows */
1753 WINE_SPI_WARN(SPI_LANGDRIVER); /* 12 */
1755 case SPI_ICONHORIZONTALSPACING:
1756 if (pvParam != NULL)
1757 ret = get_entry( &entry_ICONHORIZONTALSPACING, uiParam, pvParam );
1758 else
1760 int min_val = map_to_dpi( 32, GetDpiForSystem() );
1761 ret = set_entry( &entry_ICONHORIZONTALSPACING, max( min_val, uiParam ), pvParam, fWinIni );
1763 break;
1764 case SPI_GETSCREENSAVETIMEOUT:
1765 ret = get_entry( &entry_SCREENSAVETIMEOUT, uiParam, pvParam );
1766 break;
1767 case SPI_SETSCREENSAVETIMEOUT:
1768 ret = set_entry( &entry_SCREENSAVETIMEOUT, uiParam, pvParam, fWinIni );
1769 break;
1770 case SPI_GETSCREENSAVEACTIVE:
1771 ret = get_entry( &entry_SCREENSAVEACTIVE, uiParam, pvParam );
1772 break;
1773 case SPI_SETSCREENSAVEACTIVE:
1774 ret = set_entry( &entry_SCREENSAVEACTIVE, uiParam, pvParam, fWinIni );
1775 break;
1776 case SPI_GETGRIDGRANULARITY:
1777 ret = get_entry( &entry_GRIDGRANULARITY, uiParam, pvParam );
1778 break;
1779 case SPI_SETGRIDGRANULARITY:
1780 ret = set_entry( &entry_GRIDGRANULARITY, uiParam, pvParam, fWinIni );
1781 break;
1782 case SPI_SETDESKWALLPAPER:
1783 if (!pvParam || set_entry( &entry_DESKWALLPAPER, uiParam, pvParam, fWinIni ))
1784 ret = update_desktop_wallpaper();
1785 break;
1786 case SPI_SETDESKPATTERN:
1787 if (!pvParam || set_entry( &entry_DESKPATTERN, uiParam, pvParam, fWinIni ))
1788 ret = update_desktop_wallpaper();
1789 break;
1790 case SPI_GETKEYBOARDDELAY:
1791 ret = get_entry( &entry_KEYBOARDDELAY, uiParam, pvParam );
1792 break;
1793 case SPI_SETKEYBOARDDELAY:
1794 ret = set_entry( &entry_KEYBOARDDELAY, uiParam, pvParam, fWinIni );
1795 break;
1796 case SPI_ICONVERTICALSPACING:
1797 if (pvParam != NULL)
1798 ret = get_entry( &entry_ICONVERTICALSPACING, uiParam, pvParam );
1799 else
1801 int min_val = map_to_dpi( 32, GetDpiForSystem() );
1802 ret = set_entry( &entry_ICONVERTICALSPACING, max( min_val, uiParam ), pvParam, fWinIni );
1804 break;
1805 case SPI_GETICONTITLEWRAP:
1806 ret = get_entry( &entry_ICONTITLEWRAP, uiParam, pvParam );
1807 break;
1808 case SPI_SETICONTITLEWRAP:
1809 ret = set_entry( &entry_ICONTITLEWRAP, uiParam, pvParam, fWinIni );
1810 break;
1811 case SPI_GETMENUDROPALIGNMENT:
1812 ret = get_entry( &entry_MENUDROPALIGNMENT, uiParam, pvParam );
1813 break;
1814 case SPI_SETMENUDROPALIGNMENT:
1815 ret = set_entry( &entry_MENUDROPALIGNMENT, uiParam, pvParam, fWinIni );
1816 break;
1817 case SPI_SETDOUBLECLKWIDTH:
1818 ret = set_entry( &entry_DOUBLECLKWIDTH, uiParam, pvParam, fWinIni );
1819 break;
1820 case SPI_SETDOUBLECLKHEIGHT:
1821 ret = set_entry( &entry_DOUBLECLKHEIGHT, uiParam, pvParam, fWinIni );
1822 break;
1823 case SPI_GETICONTITLELOGFONT:
1824 ret = get_entry( &entry_ICONTITLELOGFONT, uiParam, pvParam );
1825 break;
1826 case SPI_SETDOUBLECLICKTIME:
1827 ret = set_entry( &entry_DOUBLECLICKTIME, uiParam, pvParam, fWinIni );
1828 break;
1829 case SPI_SETMOUSEBUTTONSWAP:
1830 ret = set_entry( &entry_MOUSEBUTTONSWAP, uiParam, pvParam, fWinIni );
1831 break;
1832 case SPI_SETICONTITLELOGFONT:
1833 ret = set_entry( &entry_ICONTITLELOGFONT, uiParam, pvParam, fWinIni );
1834 break;
1836 case SPI_GETFASTTASKSWITCH: /* 35 */
1837 if (!pvParam) return FALSE;
1838 *(BOOL *)pvParam = TRUE;
1839 ret = TRUE;
1840 break;
1842 case SPI_SETFASTTASKSWITCH: /* 36 */
1843 /* the action is disabled */
1844 ret = FALSE;
1845 break;
1847 case SPI_SETDRAGFULLWINDOWS:
1848 ret = set_entry( &entry_DRAGFULLWINDOWS, uiParam, pvParam, fWinIni );
1849 break;
1850 case SPI_GETDRAGFULLWINDOWS:
1851 ret = get_entry( &entry_DRAGFULLWINDOWS, uiParam, pvParam );
1852 break;
1853 case SPI_GETNONCLIENTMETRICS:
1855 LPNONCLIENTMETRICSW lpnm = pvParam;
1856 int padded_border;
1858 if (!pvParam) return FALSE;
1860 ret = get_entry( &entry_BORDER, 0, &lpnm->iBorderWidth ) &&
1861 get_entry( &entry_PADDEDBORDERWIDTH, 0, &padded_border ) &&
1862 get_entry( &entry_SCROLLWIDTH, 0, &lpnm->iScrollWidth ) &&
1863 get_entry( &entry_SCROLLHEIGHT, 0, &lpnm->iScrollHeight ) &&
1864 get_entry( &entry_CAPTIONWIDTH, 0, &lpnm->iCaptionWidth ) &&
1865 get_entry( &entry_CAPTIONHEIGHT, 0, &lpnm->iCaptionHeight ) &&
1866 get_entry( &entry_CAPTIONLOGFONT, 0, &lpnm->lfCaptionFont ) &&
1867 get_entry( &entry_SMCAPTIONWIDTH, 0, &lpnm->iSmCaptionWidth ) &&
1868 get_entry( &entry_SMCAPTIONHEIGHT, 0, &lpnm->iSmCaptionHeight ) &&
1869 get_entry( &entry_SMCAPTIONLOGFONT, 0, &lpnm->lfSmCaptionFont ) &&
1870 get_entry( &entry_MENUWIDTH, 0, &lpnm->iMenuWidth ) &&
1871 get_entry( &entry_MENUHEIGHT, 0, &lpnm->iMenuHeight ) &&
1872 get_entry( &entry_MENULOGFONT, 0, &lpnm->lfMenuFont ) &&
1873 get_entry( &entry_STATUSLOGFONT, 0, &lpnm->lfStatusFont ) &&
1874 get_entry( &entry_MESSAGELOGFONT, 0, &lpnm->lfMessageFont );
1875 if (ret)
1877 lpnm->iBorderWidth += padded_border;
1878 if (lpnm->cbSize == sizeof(NONCLIENTMETRICSW)) lpnm->iPaddedBorderWidth = 0;
1880 normalize_nonclientmetrics( lpnm );
1881 break;
1883 case SPI_SETNONCLIENTMETRICS:
1885 LPNONCLIENTMETRICSW lpnm = pvParam;
1886 int padded_border;
1888 if (lpnm && (lpnm->cbSize == sizeof(NONCLIENTMETRICSW) ||
1889 lpnm->cbSize == FIELD_OFFSET(NONCLIENTMETRICSW, iPaddedBorderWidth)))
1891 get_entry( &entry_PADDEDBORDERWIDTH, 0, &padded_border );
1893 ret = set_entry( &entry_BORDER, lpnm->iBorderWidth - padded_border, NULL, fWinIni ) &&
1894 set_entry( &entry_SCROLLWIDTH, lpnm->iScrollWidth, NULL, fWinIni ) &&
1895 set_entry( &entry_SCROLLHEIGHT, lpnm->iScrollHeight, NULL, fWinIni ) &&
1896 set_entry( &entry_CAPTIONWIDTH, lpnm->iCaptionWidth, NULL, fWinIni ) &&
1897 set_entry( &entry_CAPTIONHEIGHT, lpnm->iCaptionHeight, NULL, fWinIni ) &&
1898 set_entry( &entry_SMCAPTIONWIDTH, lpnm->iSmCaptionWidth, NULL, fWinIni ) &&
1899 set_entry( &entry_SMCAPTIONHEIGHT, lpnm->iSmCaptionHeight, NULL, fWinIni ) &&
1900 set_entry( &entry_MENUWIDTH, lpnm->iMenuWidth, NULL, fWinIni ) &&
1901 set_entry( &entry_MENUHEIGHT, lpnm->iMenuHeight, NULL, fWinIni ) &&
1902 set_entry( &entry_MENULOGFONT, 0, &lpnm->lfMenuFont, fWinIni ) &&
1903 set_entry( &entry_CAPTIONLOGFONT, 0, &lpnm->lfCaptionFont, fWinIni ) &&
1904 set_entry( &entry_SMCAPTIONLOGFONT, 0, &lpnm->lfSmCaptionFont, fWinIni ) &&
1905 set_entry( &entry_STATUSLOGFONT, 0, &lpnm->lfStatusFont, fWinIni ) &&
1906 set_entry( &entry_MESSAGELOGFONT, 0, &lpnm->lfMessageFont, fWinIni );
1908 break;
1910 case SPI_GETMINIMIZEDMETRICS:
1912 MINIMIZEDMETRICS * lpMm = pvParam;
1913 if (lpMm && lpMm->cbSize == sizeof(*lpMm)) {
1914 ret = get_entry( &entry_MINWIDTH, 0, &lpMm->iWidth ) &&
1915 get_entry( &entry_MINHORZGAP, 0, &lpMm->iHorzGap ) &&
1916 get_entry( &entry_MINVERTGAP, 0, &lpMm->iVertGap ) &&
1917 get_entry( &entry_MINARRANGE, 0, &lpMm->iArrange );
1918 lpMm->iWidth = max( 0, lpMm->iWidth );
1919 lpMm->iHorzGap = max( 0, lpMm->iHorzGap );
1920 lpMm->iVertGap = max( 0, lpMm->iVertGap );
1921 lpMm->iArrange &= 0x0f;
1923 break;
1925 case SPI_SETMINIMIZEDMETRICS:
1927 MINIMIZEDMETRICS * lpMm = pvParam;
1928 if (lpMm && lpMm->cbSize == sizeof(*lpMm))
1929 ret = set_entry( &entry_MINWIDTH, max( 0, lpMm->iWidth ), NULL, fWinIni ) &&
1930 set_entry( &entry_MINHORZGAP, max( 0, lpMm->iHorzGap ), NULL, fWinIni ) &&
1931 set_entry( &entry_MINVERTGAP, max( 0, lpMm->iVertGap ), NULL, fWinIni ) &&
1932 set_entry( &entry_MINARRANGE, lpMm->iArrange & 0x0f, NULL, fWinIni );
1933 break;
1935 case SPI_GETICONMETRICS:
1937 LPICONMETRICSW lpIcon = pvParam;
1938 if(lpIcon && lpIcon->cbSize == sizeof(*lpIcon))
1940 ret = get_entry( &entry_ICONHORIZONTALSPACING, 0, &lpIcon->iHorzSpacing ) &&
1941 get_entry( &entry_ICONVERTICALSPACING, 0, &lpIcon->iVertSpacing ) &&
1942 get_entry( &entry_ICONTITLEWRAP, 0, &lpIcon->iTitleWrap ) &&
1943 get_entry( &entry_ICONTITLELOGFONT, 0, &lpIcon->lfFont );
1945 break;
1947 case SPI_SETICONMETRICS:
1949 LPICONMETRICSW lpIcon = pvParam;
1950 if (lpIcon && lpIcon->cbSize == sizeof(*lpIcon))
1951 ret = set_entry( &entry_ICONVERTICALSPACING, max(32,lpIcon->iVertSpacing), NULL, fWinIni ) &&
1952 set_entry( &entry_ICONHORIZONTALSPACING, max(32,lpIcon->iHorzSpacing), NULL, fWinIni ) &&
1953 set_entry( &entry_ICONTITLEWRAP, lpIcon->iTitleWrap, NULL, fWinIni ) &&
1954 set_entry( &entry_ICONTITLELOGFONT, 0, &lpIcon->lfFont, fWinIni );
1955 break;
1958 case SPI_SETWORKAREA: /* 47 WINVER >= 0x400 */
1960 if (!pvParam) return FALSE;
1962 spi_idx = SPI_SETWORKAREA_IDX;
1963 work_area = *(RECT*)pvParam;
1964 spi_loaded[spi_idx] = TRUE;
1965 ret = TRUE;
1966 break;
1969 case SPI_GETWORKAREA: /* 48 WINVER >= 0x400 */
1971 if (!pvParam) return FALSE;
1973 spi_idx = SPI_SETWORKAREA_IDX;
1974 if (!spi_loaded[spi_idx])
1976 SetRect( &work_area, 0, 0,
1977 GetSystemMetrics( SM_CXSCREEN ),
1978 GetSystemMetrics( SM_CYSCREEN ) );
1979 EnumDisplayMonitors( 0, NULL, enum_monitors, (LPARAM)&work_area );
1980 spi_loaded[spi_idx] = TRUE;
1982 *(RECT*)pvParam = work_area;
1983 ret = TRUE;
1984 TRACE("work area %s\n", wine_dbgstr_rect( &work_area ));
1985 break;
1988 WINE_SPI_FIXME(SPI_SETPENWINDOWS); /* 49 WINVER >= 0x400 */
1990 case SPI_GETFILTERKEYS: /* 50 */
1992 LPFILTERKEYS lpFilterKeys = pvParam;
1993 WARN("SPI_GETFILTERKEYS not fully implemented\n");
1994 if (lpFilterKeys && lpFilterKeys->cbSize == sizeof(FILTERKEYS))
1996 /* Indicate that no FilterKeys feature available */
1997 lpFilterKeys->dwFlags = 0;
1998 lpFilterKeys->iWaitMSec = 0;
1999 lpFilterKeys->iDelayMSec = 0;
2000 lpFilterKeys->iRepeatMSec = 0;
2001 lpFilterKeys->iBounceMSec = 0;
2002 ret = TRUE;
2004 break;
2006 WINE_SPI_FIXME(SPI_SETFILTERKEYS); /* 51 */
2008 case SPI_GETTOGGLEKEYS: /* 52 */
2010 LPTOGGLEKEYS lpToggleKeys = pvParam;
2011 WARN("SPI_GETTOGGLEKEYS not fully implemented\n");
2012 if (lpToggleKeys && lpToggleKeys->cbSize == sizeof(TOGGLEKEYS))
2014 /* Indicate that no ToggleKeys feature available */
2015 lpToggleKeys->dwFlags = 0;
2016 ret = TRUE;
2018 break;
2020 WINE_SPI_FIXME(SPI_SETTOGGLEKEYS); /* 53 */
2022 case SPI_GETMOUSEKEYS: /* 54 */
2024 LPMOUSEKEYS lpMouseKeys = pvParam;
2025 WARN("SPI_GETMOUSEKEYS not fully implemented\n");
2026 if (lpMouseKeys && lpMouseKeys->cbSize == sizeof(MOUSEKEYS))
2028 /* Indicate that no MouseKeys feature available */
2029 lpMouseKeys->dwFlags = 0;
2030 lpMouseKeys->iMaxSpeed = 360;
2031 lpMouseKeys->iTimeToMaxSpeed = 1000;
2032 lpMouseKeys->iCtrlSpeed = 0;
2033 lpMouseKeys->dwReserved1 = 0;
2034 lpMouseKeys->dwReserved2 = 0;
2035 ret = TRUE;
2037 break;
2039 WINE_SPI_FIXME(SPI_SETMOUSEKEYS); /* 55 */
2041 case SPI_GETSHOWSOUNDS:
2042 ret = get_entry( &entry_SHOWSOUNDS, uiParam, pvParam );
2043 break;
2044 case SPI_SETSHOWSOUNDS:
2045 ret = set_entry( &entry_SHOWSOUNDS, uiParam, pvParam, fWinIni );
2046 break;
2048 case SPI_GETSTICKYKEYS: /* 58 */
2050 LPSTICKYKEYS lpStickyKeys = pvParam;
2051 WARN("SPI_GETSTICKYKEYS not fully implemented\n");
2052 if (lpStickyKeys && lpStickyKeys->cbSize == sizeof(STICKYKEYS))
2054 /* Indicate that no StickyKeys feature available */
2055 lpStickyKeys->dwFlags = 0;
2056 ret = TRUE;
2058 break;
2060 WINE_SPI_FIXME(SPI_SETSTICKYKEYS); /* 59 */
2062 case SPI_GETACCESSTIMEOUT: /* 60 */
2064 LPACCESSTIMEOUT lpAccessTimeout = pvParam;
2065 WARN("SPI_GETACCESSTIMEOUT not fully implemented\n");
2066 if (lpAccessTimeout && lpAccessTimeout->cbSize == sizeof(ACCESSTIMEOUT))
2068 /* Indicate that no accessibility features timeout is available */
2069 lpAccessTimeout->dwFlags = 0;
2070 lpAccessTimeout->iTimeOutMSec = 0;
2071 ret = TRUE;
2073 break;
2075 WINE_SPI_FIXME(SPI_SETACCESSTIMEOUT); /* 61 */
2077 case SPI_GETSERIALKEYS: /* 62 WINVER >= 0x400 */
2079 LPSERIALKEYSW lpSerialKeysW = pvParam;
2080 WARN("SPI_GETSERIALKEYS not fully implemented\n");
2081 if (lpSerialKeysW && lpSerialKeysW->cbSize == sizeof(SERIALKEYSW))
2083 /* Indicate that no SerialKeys feature available */
2084 lpSerialKeysW->dwFlags = 0;
2085 lpSerialKeysW->lpszActivePort = NULL;
2086 lpSerialKeysW->lpszPort = NULL;
2087 lpSerialKeysW->iBaudRate = 0;
2088 lpSerialKeysW->iPortState = 0;
2089 ret = TRUE;
2091 break;
2093 WINE_SPI_FIXME(SPI_SETSERIALKEYS); /* 63 WINVER >= 0x400 */
2095 case SPI_GETSOUNDSENTRY: /* 64 */
2097 LPSOUNDSENTRYW lpSoundSentryW = pvParam;
2098 WARN("SPI_GETSOUNDSENTRY not fully implemented\n");
2099 if (lpSoundSentryW && lpSoundSentryW->cbSize == sizeof(SOUNDSENTRYW))
2101 /* Indicate that no SoundSentry feature available */
2102 lpSoundSentryW->dwFlags = 0;
2103 lpSoundSentryW->iFSTextEffect = 0;
2104 lpSoundSentryW->iFSTextEffectMSec = 0;
2105 lpSoundSentryW->iFSTextEffectColorBits = 0;
2106 lpSoundSentryW->iFSGrafEffect = 0;
2107 lpSoundSentryW->iFSGrafEffectMSec = 0;
2108 lpSoundSentryW->iFSGrafEffectColor = 0;
2109 lpSoundSentryW->iWindowsEffect = 0;
2110 lpSoundSentryW->iWindowsEffectMSec = 0;
2111 lpSoundSentryW->lpszWindowsEffectDLL = 0;
2112 lpSoundSentryW->iWindowsEffectOrdinal = 0;
2113 ret = TRUE;
2115 break;
2117 WINE_SPI_FIXME(SPI_SETSOUNDSENTRY); /* 65 */
2119 case SPI_GETHIGHCONTRAST: /* 66 WINVER >= 0x400 */
2121 LPHIGHCONTRASTW lpHighContrastW = pvParam;
2122 WARN("SPI_GETHIGHCONTRAST not fully implemented\n");
2123 if (lpHighContrastW && lpHighContrastW->cbSize == sizeof(HIGHCONTRASTW))
2125 /* Indicate that no high contrast feature available */
2126 lpHighContrastW->dwFlags = 0;
2127 lpHighContrastW->lpszDefaultScheme = NULL;
2128 ret = TRUE;
2130 break;
2132 WINE_SPI_FIXME(SPI_SETHIGHCONTRAST); /* 67 WINVER >= 0x400 */
2134 case SPI_GETKEYBOARDPREF:
2135 ret = get_entry( &entry_KEYBOARDPREF, uiParam, pvParam );
2136 break;
2137 case SPI_SETKEYBOARDPREF:
2138 ret = set_entry( &entry_KEYBOARDPREF, uiParam, pvParam, fWinIni );
2139 break;
2140 case SPI_GETSCREENREADER:
2141 ret = get_entry( &entry_SCREENREADER, uiParam, pvParam );
2142 break;
2143 case SPI_SETSCREENREADER:
2144 ret = set_entry( &entry_SCREENREADER, uiParam, pvParam, fWinIni );
2145 break;
2147 case SPI_GETANIMATION: /* 72 WINVER >= 0x400 */
2149 LPANIMATIONINFO lpAnimInfo = pvParam;
2151 /* Tell it "disabled" */
2152 if (lpAnimInfo && lpAnimInfo->cbSize == sizeof(ANIMATIONINFO))
2154 lpAnimInfo->iMinAnimate = 0; /* Minimize and restore animation is disabled (nonzero == enabled) */
2155 ret = TRUE;
2157 break;
2159 WINE_SPI_WARN(SPI_SETANIMATION); /* 73 WINVER >= 0x400 */
2161 case SPI_GETFONTSMOOTHING:
2162 ret = get_entry( &entry_FONTSMOOTHING, uiParam, pvParam );
2163 if (ret) *(UINT *)pvParam = (*(UINT *)pvParam != 0);
2164 break;
2165 case SPI_SETFONTSMOOTHING:
2166 uiParam = uiParam ? 2 : 0; /* Win NT4/2k/XP behavior */
2167 ret = set_entry( &entry_FONTSMOOTHING, uiParam, pvParam, fWinIni );
2168 break;
2169 case SPI_SETDRAGWIDTH:
2170 ret = set_entry( &entry_DRAGWIDTH, uiParam, pvParam, fWinIni );
2171 break;
2172 case SPI_SETDRAGHEIGHT:
2173 ret = set_entry( &entry_DRAGHEIGHT, uiParam, pvParam, fWinIni );
2174 break;
2176 WINE_SPI_FIXME(SPI_SETHANDHELD); /* 78 WINVER >= 0x400 */
2178 WINE_SPI_FIXME(SPI_GETLOWPOWERTIMEOUT); /* 79 WINVER >= 0x400 */
2179 WINE_SPI_FIXME(SPI_GETPOWEROFFTIMEOUT); /* 80 WINVER >= 0x400 */
2180 WINE_SPI_FIXME(SPI_SETLOWPOWERTIMEOUT); /* 81 WINVER >= 0x400 */
2181 WINE_SPI_FIXME(SPI_SETPOWEROFFTIMEOUT); /* 82 WINVER >= 0x400 */
2183 case SPI_GETLOWPOWERACTIVE:
2184 ret = get_entry( &entry_LOWPOWERACTIVE, uiParam, pvParam );
2185 break;
2186 case SPI_SETLOWPOWERACTIVE:
2187 ret = set_entry( &entry_LOWPOWERACTIVE, uiParam, pvParam, fWinIni );
2188 break;
2189 case SPI_GETPOWEROFFACTIVE:
2190 ret = get_entry( &entry_POWEROFFACTIVE, uiParam, pvParam );
2191 break;
2192 case SPI_SETPOWEROFFACTIVE:
2193 ret = set_entry( &entry_POWEROFFACTIVE, uiParam, pvParam, fWinIni );
2194 break;
2196 WINE_SPI_FIXME(SPI_SETCURSORS); /* 87 WINVER >= 0x400 */
2197 WINE_SPI_FIXME(SPI_SETICONS); /* 88 WINVER >= 0x400 */
2199 case SPI_GETDEFAULTINPUTLANG: /* 89 WINVER >= 0x400 */
2200 ret = GetKeyboardLayout(0) != 0;
2201 break;
2203 WINE_SPI_FIXME(SPI_SETDEFAULTINPUTLANG); /* 90 WINVER >= 0x400 */
2205 WINE_SPI_FIXME(SPI_SETLANGTOGGLE); /* 91 WINVER >= 0x400 */
2207 case SPI_GETWINDOWSEXTENSION: /* 92 WINVER >= 0x400 */
2208 WARN("pretend no support for Win9x Plus! for now.\n");
2209 ret = FALSE; /* yes, this is the result value */
2210 break;
2211 case SPI_SETMOUSETRAILS:
2212 ret = set_entry( &entry_MOUSETRAILS, uiParam, pvParam, fWinIni );
2213 break;
2214 case SPI_GETMOUSETRAILS:
2215 ret = get_entry( &entry_MOUSETRAILS, uiParam, pvParam );
2216 break;
2217 case SPI_GETSNAPTODEFBUTTON:
2218 ret = get_entry( &entry_SNAPTODEFBUTTON, uiParam, pvParam );
2219 break;
2220 case SPI_SETSNAPTODEFBUTTON:
2221 ret = set_entry( &entry_SNAPTODEFBUTTON, uiParam, pvParam, fWinIni );
2222 break;
2223 case SPI_SETSCREENSAVERRUNNING:
2224 ret = set_entry( &entry_SCREENSAVERRUNNING, uiParam, pvParam, fWinIni );
2225 break;
2226 case SPI_GETMOUSEHOVERWIDTH:
2227 ret = get_entry( &entry_MOUSEHOVERWIDTH, uiParam, pvParam );
2228 break;
2229 case SPI_SETMOUSEHOVERWIDTH:
2230 ret = set_entry( &entry_MOUSEHOVERWIDTH, uiParam, pvParam, fWinIni );
2231 break;
2232 case SPI_GETMOUSEHOVERHEIGHT:
2233 ret = get_entry( &entry_MOUSEHOVERHEIGHT, uiParam, pvParam );
2234 break;
2235 case SPI_SETMOUSEHOVERHEIGHT:
2236 ret = set_entry( &entry_MOUSEHOVERHEIGHT, uiParam, pvParam, fWinIni );
2237 break;
2238 case SPI_GETMOUSEHOVERTIME:
2239 ret = get_entry( &entry_MOUSEHOVERTIME, uiParam, pvParam );
2240 break;
2241 case SPI_SETMOUSEHOVERTIME:
2242 ret = set_entry( &entry_MOUSEHOVERTIME, uiParam, pvParam, fWinIni );
2243 break;
2244 case SPI_GETWHEELSCROLLLINES:
2245 ret = get_entry( &entry_WHEELSCROLLLINES, uiParam, pvParam );
2246 break;
2247 case SPI_SETWHEELSCROLLLINES:
2248 ret = set_entry( &entry_WHEELSCROLLLINES, uiParam, pvParam, fWinIni );
2249 break;
2250 case SPI_GETMENUSHOWDELAY:
2251 ret = get_entry( &entry_MENUSHOWDELAY, uiParam, pvParam );
2252 break;
2253 case SPI_SETMENUSHOWDELAY:
2254 ret = set_entry( &entry_MENUSHOWDELAY, uiParam, pvParam, fWinIni );
2255 break;
2256 case SPI_GETWHEELSCROLLCHARS:
2257 ret = get_entry( &entry_WHEELSCROLLCHARS, uiParam, pvParam );
2258 break;
2259 case SPI_SETWHEELSCROLLCHARS:
2260 ret = set_entry( &entry_WHEELSCROLLCHARS, uiParam, pvParam, fWinIni );
2261 break;
2263 WINE_SPI_FIXME(SPI_GETSHOWIMEUI); /* 110 _WIN32_WINNT >= 0x400 || _WIN32_WINDOW > 0x400 */
2264 WINE_SPI_FIXME(SPI_SETSHOWIMEUI); /* 111 _WIN32_WINNT >= 0x400 || _WIN32_WINDOW > 0x400 */
2266 case SPI_GETMOUSESPEED:
2267 ret = get_entry( &entry_MOUSESPEED, uiParam, pvParam );
2268 break;
2269 case SPI_SETMOUSESPEED:
2270 ret = set_entry( &entry_MOUSESPEED, uiParam, pvParam, fWinIni );
2271 break;
2272 case SPI_GETSCREENSAVERRUNNING:
2273 ret = get_entry( &entry_SCREENSAVERRUNNING, uiParam, pvParam );
2274 break;
2275 case SPI_GETDESKWALLPAPER:
2276 ret = get_entry( &entry_DESKWALLPAPER, uiParam, pvParam );
2277 break;
2278 case SPI_GETACTIVEWINDOWTRACKING:
2279 ret = get_entry( &entry_ACTIVEWINDOWTRACKING, uiParam, pvParam );
2280 break;
2281 case SPI_SETACTIVEWINDOWTRACKING:
2282 ret = set_entry( &entry_ACTIVEWINDOWTRACKING, uiParam, pvParam, fWinIni );
2283 break;
2284 case SPI_GETMENUANIMATION:
2285 ret = get_entry( &entry_MENUANIMATION, uiParam, pvParam );
2286 break;
2287 case SPI_SETMENUANIMATION:
2288 ret = set_entry( &entry_MENUANIMATION, uiParam, pvParam, fWinIni );
2289 break;
2290 case SPI_GETCOMBOBOXANIMATION:
2291 ret = get_entry( &entry_COMBOBOXANIMATION, uiParam, pvParam );
2292 break;
2293 case SPI_SETCOMBOBOXANIMATION:
2294 ret = set_entry( &entry_COMBOBOXANIMATION, uiParam, pvParam, fWinIni );
2295 break;
2296 case SPI_GETLISTBOXSMOOTHSCROLLING:
2297 ret = get_entry( &entry_LISTBOXSMOOTHSCROLLING, uiParam, pvParam );
2298 break;
2299 case SPI_SETLISTBOXSMOOTHSCROLLING:
2300 ret = set_entry( &entry_LISTBOXSMOOTHSCROLLING, uiParam, pvParam, fWinIni );
2301 break;
2302 case SPI_GETGRADIENTCAPTIONS:
2303 ret = get_entry( &entry_GRADIENTCAPTIONS, uiParam, pvParam );
2304 break;
2305 case SPI_SETGRADIENTCAPTIONS:
2306 ret = set_entry( &entry_GRADIENTCAPTIONS, uiParam, pvParam, fWinIni );
2307 break;
2308 case SPI_GETKEYBOARDCUES:
2309 ret = get_entry( &entry_KEYBOARDCUES, uiParam, pvParam );
2310 break;
2311 case SPI_SETKEYBOARDCUES:
2312 ret = set_entry( &entry_KEYBOARDCUES, uiParam, pvParam, fWinIni );
2313 break;
2314 case SPI_GETACTIVEWNDTRKZORDER:
2315 ret = get_entry( &entry_ACTIVEWNDTRKZORDER, uiParam, pvParam );
2316 break;
2317 case SPI_SETACTIVEWNDTRKZORDER:
2318 ret = set_entry( &entry_ACTIVEWNDTRKZORDER, uiParam, pvParam, fWinIni );
2319 break;
2320 case SPI_GETHOTTRACKING:
2321 ret = get_entry( &entry_HOTTRACKING, uiParam, pvParam );
2322 break;
2323 case SPI_SETHOTTRACKING:
2324 ret = set_entry( &entry_HOTTRACKING, uiParam, pvParam, fWinIni );
2325 break;
2326 case SPI_GETMENUFADE:
2327 ret = get_entry( &entry_MENUFADE, uiParam, pvParam );
2328 break;
2329 case SPI_SETMENUFADE:
2330 ret = set_entry( &entry_MENUFADE, uiParam, pvParam, fWinIni );
2331 break;
2332 case SPI_GETSELECTIONFADE:
2333 ret = get_entry( &entry_SELECTIONFADE, uiParam, pvParam );
2334 break;
2335 case SPI_SETSELECTIONFADE:
2336 ret = set_entry( &entry_SELECTIONFADE, uiParam, pvParam, fWinIni );
2337 break;
2338 case SPI_GETTOOLTIPANIMATION:
2339 ret = get_entry( &entry_TOOLTIPANIMATION, uiParam, pvParam );
2340 break;
2341 case SPI_SETTOOLTIPANIMATION:
2342 ret = set_entry( &entry_TOOLTIPANIMATION, uiParam, pvParam, fWinIni );
2343 break;
2344 case SPI_GETTOOLTIPFADE:
2345 ret = get_entry( &entry_TOOLTIPFADE, uiParam, pvParam );
2346 break;
2347 case SPI_SETTOOLTIPFADE:
2348 ret = set_entry( &entry_TOOLTIPFADE, uiParam, pvParam, fWinIni );
2349 break;
2350 case SPI_GETCURSORSHADOW:
2351 ret = get_entry( &entry_CURSORSHADOW, uiParam, pvParam );
2352 break;
2353 case SPI_SETCURSORSHADOW:
2354 ret = set_entry( &entry_CURSORSHADOW, uiParam, pvParam, fWinIni );
2355 break;
2356 case SPI_GETMOUSESONAR:
2357 ret = get_entry( &entry_MOUSESONAR, uiParam, pvParam );
2358 break;
2359 case SPI_SETMOUSESONAR:
2360 ret = set_entry( &entry_MOUSESONAR, uiParam, pvParam, fWinIni );
2361 break;
2362 case SPI_GETMOUSECLICKLOCK:
2363 ret = get_entry( &entry_MOUSECLICKLOCK, uiParam, pvParam );
2364 break;
2365 case SPI_SETMOUSECLICKLOCK:
2366 ret = set_entry( &entry_MOUSECLICKLOCK, uiParam, pvParam, fWinIni );
2367 break;
2368 case SPI_GETMOUSEVANISH:
2369 ret = get_entry( &entry_MOUSEVANISH, uiParam, pvParam );
2370 break;
2371 case SPI_SETMOUSEVANISH:
2372 ret = set_entry( &entry_MOUSEVANISH, uiParam, pvParam, fWinIni );
2373 break;
2374 case SPI_GETFLATMENU:
2375 ret = get_entry( &entry_FLATMENU, uiParam, pvParam );
2376 break;
2377 case SPI_SETFLATMENU:
2378 ret = set_entry( &entry_FLATMENU, uiParam, pvParam, fWinIni );
2379 break;
2380 case SPI_GETDROPSHADOW:
2381 ret = get_entry( &entry_DROPSHADOW, uiParam, pvParam );
2382 break;
2383 case SPI_SETDROPSHADOW:
2384 ret = set_entry( &entry_DROPSHADOW, uiParam, pvParam, fWinIni );
2385 break;
2386 case SPI_GETBLOCKSENDINPUTRESETS:
2387 ret = get_entry( &entry_BLOCKSENDINPUTRESETS, uiParam, pvParam );
2388 break;
2389 case SPI_SETBLOCKSENDINPUTRESETS:
2390 ret = set_entry( &entry_BLOCKSENDINPUTRESETS, uiParam, pvParam, fWinIni );
2391 break;
2392 case SPI_GETUIEFFECTS:
2393 ret = get_entry( &entry_UIEFFECTS, uiParam, pvParam );
2394 break;
2395 case SPI_SETUIEFFECTS:
2396 /* FIXME: this probably should mask other UI effect values when unset */
2397 ret = set_entry( &entry_UIEFFECTS, uiParam, pvParam, fWinIni );
2398 break;
2399 case SPI_GETDISABLEOVERLAPPEDCONTENT:
2400 ret = get_entry( &entry_DISABLEOVERLAPPEDCONTENT, uiParam, pvParam );
2401 break;
2402 case SPI_SETDISABLEOVERLAPPEDCONTENT:
2403 ret = set_entry( &entry_DISABLEOVERLAPPEDCONTENT, uiParam, pvParam, fWinIni );
2404 break;
2405 case SPI_GETCLIENTAREAANIMATION:
2406 ret = get_entry( &entry_CLIENTAREAANIMATION, uiParam, pvParam );
2407 break;
2408 case SPI_SETCLIENTAREAANIMATION:
2409 ret = set_entry( &entry_CLIENTAREAANIMATION, uiParam, pvParam, fWinIni );
2410 break;
2411 case SPI_GETCLEARTYPE:
2412 ret = get_entry( &entry_CLEARTYPE, uiParam, pvParam );
2413 break;
2414 case SPI_SETCLEARTYPE:
2415 ret = set_entry( &entry_CLEARTYPE, uiParam, pvParam, fWinIni );
2416 break;
2417 case SPI_GETSPEECHRECOGNITION:
2418 ret = get_entry( &entry_SPEECHRECOGNITION, uiParam, pvParam );
2419 break;
2420 case SPI_SETSPEECHRECOGNITION:
2421 ret = set_entry( &entry_SPEECHRECOGNITION, uiParam, pvParam, fWinIni );
2422 break;
2423 case SPI_GETFOREGROUNDLOCKTIMEOUT:
2424 ret = get_entry( &entry_FOREGROUNDLOCKTIMEOUT, uiParam, pvParam );
2425 break;
2426 case SPI_SETFOREGROUNDLOCKTIMEOUT:
2427 /* FIXME: this should check that the calling thread
2428 * is able to change the foreground window */
2429 ret = set_entry( &entry_FOREGROUNDLOCKTIMEOUT, uiParam, pvParam, fWinIni );
2430 break;
2431 case SPI_GETACTIVEWNDTRKTIMEOUT:
2432 ret = get_entry( &entry_ACTIVEWNDTRKTIMEOUT, uiParam, pvParam );
2433 break;
2434 case SPI_SETACTIVEWNDTRKTIMEOUT:
2435 ret = get_entry( &entry_ACTIVEWNDTRKTIMEOUT, uiParam, pvParam );
2436 break;
2437 case SPI_GETFOREGROUNDFLASHCOUNT:
2438 ret = get_entry( &entry_FOREGROUNDFLASHCOUNT, uiParam, pvParam );
2439 break;
2440 case SPI_SETFOREGROUNDFLASHCOUNT:
2441 ret = set_entry( &entry_FOREGROUNDFLASHCOUNT, uiParam, pvParam, fWinIni );
2442 break;
2443 case SPI_GETCARETWIDTH:
2444 ret = get_entry( &entry_CARETWIDTH, uiParam, pvParam );
2445 break;
2446 case SPI_SETCARETWIDTH:
2447 ret = set_entry( &entry_CARETWIDTH, uiParam, pvParam, fWinIni );
2448 break;
2449 case SPI_GETMOUSECLICKLOCKTIME:
2450 ret = get_entry( &entry_MOUSECLICKLOCKTIME, uiParam, pvParam );
2451 break;
2452 case SPI_SETMOUSECLICKLOCKTIME:
2453 ret = set_entry( &entry_MOUSECLICKLOCKTIME, uiParam, pvParam, fWinIni );
2454 break;
2455 case SPI_GETFONTSMOOTHINGTYPE:
2456 ret = get_entry( &entry_FONTSMOOTHINGTYPE, uiParam, pvParam );
2457 break;
2458 case SPI_SETFONTSMOOTHINGTYPE:
2459 ret = set_entry( &entry_FONTSMOOTHINGTYPE, uiParam, pvParam, fWinIni );
2460 break;
2461 case SPI_GETFONTSMOOTHINGCONTRAST:
2462 ret = get_entry( &entry_FONTSMOOTHINGCONTRAST, uiParam, pvParam );
2463 break;
2464 case SPI_SETFONTSMOOTHINGCONTRAST:
2465 ret = set_entry( &entry_FONTSMOOTHINGCONTRAST, uiParam, pvParam, fWinIni );
2466 break;
2467 case SPI_GETFOCUSBORDERWIDTH:
2468 ret = get_entry( &entry_FOCUSBORDERWIDTH, uiParam, pvParam );
2469 break;
2470 case SPI_GETFOCUSBORDERHEIGHT:
2471 ret = get_entry( &entry_FOCUSBORDERHEIGHT, uiParam, pvParam );
2472 break;
2473 case SPI_SETFOCUSBORDERWIDTH:
2474 ret = set_entry( &entry_FOCUSBORDERWIDTH, uiParam, pvParam, fWinIni );
2475 break;
2476 case SPI_SETFOCUSBORDERHEIGHT:
2477 ret = set_entry( &entry_FOCUSBORDERHEIGHT, uiParam, pvParam, fWinIni );
2478 break;
2479 case SPI_GETFONTSMOOTHINGORIENTATION:
2480 ret = get_entry( &entry_FONTSMOOTHINGORIENTATION, uiParam, pvParam );
2481 break;
2482 case SPI_SETFONTSMOOTHINGORIENTATION:
2483 ret = set_entry( &entry_FONTSMOOTHINGORIENTATION, uiParam, pvParam, fWinIni );
2484 break;
2485 case SPI_GETAUDIODESCRIPTION:
2487 AUDIODESCRIPTION *audio = pvParam;
2488 if (audio && audio->cbSize == sizeof(AUDIODESCRIPTION) && uiParam == sizeof(AUDIODESCRIPTION) )
2490 ret = get_entry( &entry_AUDIODESC_ON, 0, &audio->Enabled ) &&
2491 get_entry( &entry_AUDIODESC_LOCALE, 0, &audio->Locale );
2493 break;
2495 case SPI_SETAUDIODESCRIPTION:
2497 AUDIODESCRIPTION *audio = pvParam;
2498 if (audio && audio->cbSize == sizeof(AUDIODESCRIPTION) && uiParam == sizeof(AUDIODESCRIPTION) )
2500 ret = set_entry( &entry_AUDIODESC_ON, 0, &audio->Enabled, fWinIni) &&
2501 set_entry( &entry_AUDIODESC_LOCALE, 0, &audio->Locale, fWinIni );
2503 break;
2505 default:
2506 FIXME( "Unknown action: %u\n", uiAction );
2507 SetLastError( ERROR_INVALID_SPI_VALUE );
2508 ret = FALSE;
2509 break;
2512 if (ret)
2513 SYSPARAMS_NotifyChange( uiAction, fWinIni );
2514 TRACE("(%u, %u, %p, %u) ret %d\n",
2515 uiAction, uiParam, pvParam, fWinIni, ret);
2516 return ret;
2518 #undef WINE_SPI_FIXME
2519 #undef WINE_SPI_WARN
2523 /***********************************************************************
2524 * SystemParametersInfoA (USER32.@)
2526 BOOL WINAPI SystemParametersInfoA( UINT uiAction, UINT uiParam,
2527 PVOID pvParam, UINT fuWinIni )
2529 BOOL ret;
2531 TRACE("(%u, %u, %p, %u)\n", uiAction, uiParam, pvParam, fuWinIni);
2533 switch (uiAction)
2535 case SPI_SETDESKWALLPAPER: /* 20 */
2536 case SPI_SETDESKPATTERN: /* 21 */
2538 WCHAR buffer[256];
2539 if (pvParam)
2540 if (!MultiByteToWideChar( CP_ACP, 0, pvParam, -1, buffer, ARRAY_SIZE( buffer )))
2541 buffer[ARRAY_SIZE(buffer)-1] = 0;
2542 ret = SystemParametersInfoW( uiAction, uiParam, pvParam ? buffer : NULL, fuWinIni );
2543 break;
2546 case SPI_GETICONTITLELOGFONT: /* 31 */
2548 LOGFONTW tmp;
2549 ret = SystemParametersInfoW( uiAction, uiParam, pvParam ? &tmp : NULL, fuWinIni );
2550 if (ret && pvParam)
2551 SYSPARAMS_LogFont32WTo32A( &tmp, pvParam );
2552 break;
2555 case SPI_GETNONCLIENTMETRICS: /* 41 WINVER >= 0x400 */
2557 NONCLIENTMETRICSW tmp;
2558 LPNONCLIENTMETRICSA lpnmA = pvParam;
2559 if (lpnmA && (lpnmA->cbSize == sizeof(NONCLIENTMETRICSA) ||
2560 lpnmA->cbSize == FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth)))
2562 tmp.cbSize = sizeof(NONCLIENTMETRICSW);
2563 ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2564 if (ret)
2565 SYSPARAMS_NonClientMetrics32WTo32A( &tmp, lpnmA );
2567 else
2568 ret = FALSE;
2569 break;
2572 case SPI_SETNONCLIENTMETRICS: /* 42 WINVER >= 0x400 */
2574 NONCLIENTMETRICSW tmp;
2575 LPNONCLIENTMETRICSA lpnmA = pvParam;
2576 if (lpnmA && (lpnmA->cbSize == sizeof(NONCLIENTMETRICSA) ||
2577 lpnmA->cbSize == FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth)))
2579 tmp.cbSize = sizeof(NONCLIENTMETRICSW);
2580 SYSPARAMS_NonClientMetrics32ATo32W( lpnmA, &tmp );
2581 ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2583 else
2584 ret = FALSE;
2585 break;
2588 case SPI_GETICONMETRICS: /* 45 WINVER >= 0x400 */
2590 ICONMETRICSW tmp;
2591 LPICONMETRICSA lpimA = pvParam;
2592 if (lpimA && lpimA->cbSize == sizeof(ICONMETRICSA))
2594 tmp.cbSize = sizeof(ICONMETRICSW);
2595 ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2596 if (ret)
2598 lpimA->iHorzSpacing = tmp.iHorzSpacing;
2599 lpimA->iVertSpacing = tmp.iVertSpacing;
2600 lpimA->iTitleWrap = tmp.iTitleWrap;
2601 SYSPARAMS_LogFont32WTo32A( &tmp.lfFont, &lpimA->lfFont );
2604 else
2605 ret = FALSE;
2606 break;
2609 case SPI_SETICONMETRICS: /* 46 WINVER >= 0x400 */
2611 ICONMETRICSW tmp;
2612 LPICONMETRICSA lpimA = pvParam;
2613 if (lpimA && lpimA->cbSize == sizeof(ICONMETRICSA))
2615 tmp.cbSize = sizeof(ICONMETRICSW);
2616 tmp.iHorzSpacing = lpimA->iHorzSpacing;
2617 tmp.iVertSpacing = lpimA->iVertSpacing;
2618 tmp.iTitleWrap = lpimA->iTitleWrap;
2619 SYSPARAMS_LogFont32ATo32W( &lpimA->lfFont, &tmp.lfFont);
2620 ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2622 else
2623 ret = FALSE;
2624 break;
2627 case SPI_GETHIGHCONTRAST: /* 66 WINVER >= 0x400 */
2629 HIGHCONTRASTW tmp;
2630 LPHIGHCONTRASTA lphcA = pvParam;
2631 if (lphcA && lphcA->cbSize == sizeof(HIGHCONTRASTA))
2633 tmp.cbSize = sizeof(HIGHCONTRASTW);
2634 ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2635 if (ret)
2637 lphcA->dwFlags = tmp.dwFlags;
2638 lphcA->lpszDefaultScheme = NULL; /* FIXME? */
2641 else
2642 ret = FALSE;
2643 break;
2646 case SPI_GETDESKWALLPAPER: /* 115 */
2648 WCHAR buffer[MAX_PATH];
2649 ret = (SystemParametersInfoW( SPI_GETDESKWALLPAPER, uiParam, buffer, fuWinIni ) &&
2650 WideCharToMultiByte(CP_ACP, 0, buffer, -1, pvParam, uiParam, NULL, NULL));
2651 break;
2654 default:
2655 ret = SystemParametersInfoW( uiAction, uiParam, pvParam, fuWinIni );
2656 break;
2658 return ret;
2662 /***********************************************************************
2663 * GetSystemMetrics (USER32.@)
2665 INT WINAPI GetSystemMetrics( INT index )
2667 struct monitor_info info;
2668 NONCLIENTMETRICSW ncm;
2669 MINIMIZEDMETRICS mm;
2670 ICONMETRICSW im;
2671 UINT ret;
2672 HDC hdc;
2674 /* some metrics are dynamic */
2675 switch (index)
2677 case SM_CXVSCROLL:
2678 case SM_CYHSCROLL:
2679 get_entry( &entry_SCROLLWIDTH, 0, &ret );
2680 return max( ret, 8 );
2681 case SM_CYCAPTION:
2682 ncm.cbSize = sizeof(ncm);
2683 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2684 return ncm.iCaptionHeight + 1;
2685 case SM_CXBORDER:
2686 case SM_CYBORDER:
2687 /* SM_C{X,Y}BORDER always returns 1 regardless of 'BorderWidth' value in registry */
2688 return 1;
2689 case SM_CXDLGFRAME:
2690 case SM_CYDLGFRAME:
2691 return 3;
2692 case SM_CYVTHUMB:
2693 case SM_CXHTHUMB:
2694 case SM_CYVSCROLL:
2695 case SM_CXHSCROLL:
2696 get_entry( &entry_SCROLLHEIGHT, 0, &ret );
2697 return max( ret, 8 );
2698 case SM_CXICON:
2699 case SM_CYICON:
2700 return map_to_dpi( 32, GetDpiForSystem() );
2701 case SM_CXCURSOR:
2702 case SM_CYCURSOR:
2703 ret = map_to_dpi( 32, GetDpiForSystem() );
2704 if (ret >= 64) return 64;
2705 if (ret >= 48) return 48;
2706 return 32;
2707 case SM_CYMENU:
2708 ncm.cbSize = sizeof(ncm);
2709 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2710 return ncm.iMenuHeight + 1;
2711 case SM_CXFULLSCREEN:
2712 /* see the remark for SM_CXMAXIMIZED, at least this formulation is
2713 * correct */
2714 return GetSystemMetrics( SM_CXMAXIMIZED) - 2 * GetSystemMetrics( SM_CXFRAME);
2715 case SM_CYFULLSCREEN:
2716 /* see the remark for SM_CYMAXIMIZED, at least this formulation is
2717 * correct */
2718 return GetSystemMetrics( SM_CYMAXIMIZED) - GetSystemMetrics( SM_CYMIN);
2719 case SM_CYKANJIWINDOW:
2720 return 0;
2721 case SM_MOUSEPRESENT:
2722 return 1;
2723 case SM_DEBUG:
2724 return 0;
2725 case SM_SWAPBUTTON:
2726 get_entry( &entry_MOUSEBUTTONSWAP, 0, &ret );
2727 return ret;
2728 case SM_RESERVED1:
2729 case SM_RESERVED2:
2730 case SM_RESERVED3:
2731 case SM_RESERVED4:
2732 return 0;
2733 case SM_CXMIN:
2734 ncm.cbSize = sizeof(ncm);
2735 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2736 hdc = get_display_dc();
2737 get_text_metr_size( hdc, &ncm.lfCaptionFont, NULL, &ret );
2738 release_display_dc( hdc );
2739 return 3 * ncm.iCaptionWidth + ncm.iCaptionHeight + 4 * ret + 2 * GetSystemMetrics(SM_CXFRAME) + 4;
2740 case SM_CYMIN:
2741 return GetSystemMetrics( SM_CYCAPTION) + 2 * GetSystemMetrics( SM_CYFRAME);
2742 case SM_CXSIZE:
2743 get_entry( &entry_CAPTIONWIDTH, 0, &ret );
2744 return max( ret, 8 );
2745 case SM_CYSIZE:
2746 ncm.cbSize = sizeof(ncm);
2747 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2748 return ncm.iCaptionHeight;
2749 case SM_CXFRAME:
2750 get_entry( &entry_BORDER, 0, &ret );
2751 ret = max( ret, 1 );
2752 return GetSystemMetrics(SM_CXDLGFRAME) + ret;
2753 case SM_CYFRAME:
2754 get_entry( &entry_BORDER, 0, &ret );
2755 ret = max( ret, 1 );
2756 return GetSystemMetrics(SM_CYDLGFRAME) + ret;
2757 case SM_CXMINTRACK:
2758 return GetSystemMetrics(SM_CXMIN);
2759 case SM_CYMINTRACK:
2760 return GetSystemMetrics(SM_CYMIN);
2761 case SM_CXDOUBLECLK:
2762 get_entry( &entry_DOUBLECLKWIDTH, 0, &ret );
2763 return ret;
2764 case SM_CYDOUBLECLK:
2765 get_entry( &entry_DOUBLECLKHEIGHT, 0, &ret );
2766 return ret;
2767 case SM_CXICONSPACING:
2768 im.cbSize = sizeof(im);
2769 SystemParametersInfoW( SPI_GETICONMETRICS, sizeof(im), &im, 0 );
2770 return im.iHorzSpacing;
2771 case SM_CYICONSPACING:
2772 im.cbSize = sizeof(im);
2773 SystemParametersInfoW( SPI_GETICONMETRICS, sizeof(im), &im, 0 );
2774 return im.iVertSpacing;
2775 case SM_MENUDROPALIGNMENT:
2776 SystemParametersInfoW( SPI_GETMENUDROPALIGNMENT, 0, &ret, 0 );
2777 return ret;
2778 case SM_PENWINDOWS:
2779 return 0;
2780 case SM_DBCSENABLED:
2782 CPINFO cpinfo;
2783 GetCPInfo( CP_ACP, &cpinfo );
2784 return (cpinfo.MaxCharSize > 1);
2786 case SM_CMOUSEBUTTONS:
2787 return 3;
2788 case SM_SECURE:
2789 return 0;
2790 case SM_CXEDGE:
2791 return GetSystemMetrics(SM_CXBORDER) + 1;
2792 case SM_CYEDGE:
2793 return GetSystemMetrics(SM_CYBORDER) + 1;
2794 case SM_CXMINSPACING:
2795 mm.cbSize = sizeof(mm);
2796 SystemParametersInfoW( SPI_GETMINIMIZEDMETRICS, sizeof(mm), &mm, 0 );
2797 return GetSystemMetrics(SM_CXMINIMIZED) + mm.iHorzGap;
2798 case SM_CYMINSPACING:
2799 mm.cbSize = sizeof(mm);
2800 SystemParametersInfoW( SPI_GETMINIMIZEDMETRICS, sizeof(mm), &mm, 0 );
2801 return GetSystemMetrics(SM_CYMINIMIZED) + mm.iVertGap;
2802 case SM_CXSMICON:
2803 case SM_CYSMICON:
2804 return map_to_dpi( 16, GetDpiForSystem() ) & ~1;
2805 case SM_CYSMCAPTION:
2806 ncm.cbSize = sizeof(ncm);
2807 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2808 return ncm.iSmCaptionHeight + 1;
2809 case SM_CXSMSIZE:
2810 get_entry( &entry_SMCAPTIONWIDTH, 0, &ret );
2811 return ret;
2812 case SM_CYSMSIZE:
2813 ncm.cbSize = sizeof(ncm);
2814 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2815 return ncm.iSmCaptionHeight;
2816 case SM_CXMENUSIZE:
2817 get_entry( &entry_MENUWIDTH, 0, &ret );
2818 return ret;
2819 case SM_CYMENUSIZE:
2820 ncm.cbSize = sizeof(ncm);
2821 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2822 return ncm.iMenuHeight;
2823 case SM_ARRANGE:
2824 mm.cbSize = sizeof(mm);
2825 SystemParametersInfoW( SPI_GETMINIMIZEDMETRICS, sizeof(mm), &mm, 0 );
2826 return mm.iArrange;
2827 case SM_CXMINIMIZED:
2828 mm.cbSize = sizeof(mm);
2829 SystemParametersInfoW( SPI_GETMINIMIZEDMETRICS, sizeof(mm), &mm, 0 );
2830 return mm.iWidth + 6;
2831 case SM_CYMINIMIZED:
2832 ncm.cbSize = sizeof(ncm);
2833 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2834 return ncm.iCaptionHeight + 6;
2835 case SM_CXMAXTRACK:
2836 return GetSystemMetrics(SM_CXVIRTUALSCREEN) + 4 + 2 * GetSystemMetrics(SM_CXFRAME);
2837 case SM_CYMAXTRACK:
2838 return GetSystemMetrics(SM_CYVIRTUALSCREEN) + 4 + 2 * GetSystemMetrics(SM_CYFRAME);
2839 case SM_CXMAXIMIZED:
2840 /* FIXME: subtract the width of any vertical application toolbars*/
2841 return GetSystemMetrics(SM_CXSCREEN) + 2 * GetSystemMetrics(SM_CXFRAME);
2842 case SM_CYMAXIMIZED:
2843 /* FIXME: subtract the width of any horizontal application toolbars*/
2844 return GetSystemMetrics(SM_CYSCREEN) + 2 * GetSystemMetrics(SM_CYCAPTION);
2845 case SM_NETWORK:
2846 return 3; /* FIXME */
2847 case SM_CLEANBOOT:
2848 return 0; /* 0 = ok, 1 = failsafe, 2 = failsafe + network */
2849 case SM_CXDRAG:
2850 get_entry( &entry_DRAGWIDTH, 0, &ret );
2851 return ret;
2852 case SM_CYDRAG:
2853 get_entry( &entry_DRAGHEIGHT, 0, &ret );
2854 return ret;
2855 case SM_SHOWSOUNDS:
2856 get_entry( &entry_SHOWSOUNDS, 0, &ret );
2857 return ret;
2858 case SM_CXMENUCHECK:
2859 case SM_CYMENUCHECK:
2861 TEXTMETRICW tm;
2862 ncm.cbSize = sizeof(ncm);
2863 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2864 hdc = get_display_dc();
2865 get_text_metr_size( hdc, &ncm.lfMenuFont, &tm, NULL);
2866 release_display_dc( hdc );
2867 return tm.tmHeight <= 0 ? 13 : ((tm.tmHeight + tm.tmExternalLeading + 1) / 2) * 2 - 1;
2869 case SM_SLOWMACHINE:
2870 return 0; /* Never true */
2871 case SM_MIDEASTENABLED:
2872 return 0; /* FIXME */
2873 case SM_MOUSEWHEELPRESENT:
2874 return 1;
2875 case SM_CXSCREEN:
2876 get_monitors_info( &info );
2877 return info.primary_rect.right - info.primary_rect.left;
2878 case SM_CYSCREEN:
2879 get_monitors_info( &info );
2880 return info.primary_rect.bottom - info.primary_rect.top;
2881 case SM_XVIRTUALSCREEN:
2882 get_monitors_info( &info );
2883 return info.virtual_rect.left;
2884 case SM_YVIRTUALSCREEN:
2885 get_monitors_info( &info );
2886 return info.virtual_rect.top;
2887 case SM_CXVIRTUALSCREEN:
2888 get_monitors_info( &info );
2889 return info.virtual_rect.right - info.virtual_rect.left;
2890 case SM_CYVIRTUALSCREEN:
2891 get_monitors_info( &info );
2892 return info.virtual_rect.bottom - info.virtual_rect.top;
2893 case SM_CMONITORS:
2894 get_monitors_info( &info );
2895 return info.count;
2896 case SM_SAMEDISPLAYFORMAT:
2897 return 1;
2898 case SM_IMMENABLED:
2899 return 0; /* FIXME */
2900 case SM_CXFOCUSBORDER:
2901 case SM_CYFOCUSBORDER:
2902 return 1;
2903 case SM_TABLETPC:
2904 case SM_MEDIACENTER:
2905 return 0;
2906 case SM_CMETRICS:
2907 return SM_CMETRICS;
2908 default:
2909 return 0;
2914 /***********************************************************************
2915 * GetSystemMetricsForDpi (USER32.@)
2917 INT WINAPI GetSystemMetricsForDpi( INT index, UINT dpi )
2919 NONCLIENTMETRICSW ncm;
2920 ICONMETRICSW im;
2921 UINT ret;
2922 HDC hdc;
2924 /* some metrics are dynamic */
2925 switch (index)
2927 case SM_CXVSCROLL:
2928 case SM_CYHSCROLL:
2929 get_entry_dpi( &entry_SCROLLWIDTH, 0, &ret, dpi );
2930 return max( ret, 8 );
2931 case SM_CYCAPTION:
2932 ncm.cbSize = sizeof(ncm);
2933 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2934 return ncm.iCaptionHeight + 1;
2935 case SM_CYVTHUMB:
2936 case SM_CXHTHUMB:
2937 case SM_CYVSCROLL:
2938 case SM_CXHSCROLL:
2939 get_entry_dpi( &entry_SCROLLHEIGHT, 0, &ret, dpi );
2940 return max( ret, 8 );
2941 case SM_CXICON:
2942 case SM_CYICON:
2943 return map_to_dpi( 32, dpi );
2944 case SM_CXCURSOR:
2945 case SM_CYCURSOR:
2946 ret = map_to_dpi( 32, dpi );
2947 if (ret >= 64) return 64;
2948 if (ret >= 48) return 48;
2949 return 32;
2950 case SM_CYMENU:
2951 ncm.cbSize = sizeof(ncm);
2952 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2953 return ncm.iMenuHeight + 1;
2954 case SM_CXSIZE:
2955 get_entry_dpi( &entry_CAPTIONWIDTH, 0, &ret, dpi );
2956 return max( ret, 8 );
2957 case SM_CYSIZE:
2958 ncm.cbSize = sizeof(ncm);
2959 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2960 return ncm.iCaptionHeight;
2961 case SM_CXFRAME:
2962 get_entry_dpi( &entry_BORDER, 0, &ret, dpi );
2963 ret = max( ret, 1 );
2964 return GetSystemMetricsForDpi( SM_CXDLGFRAME, dpi ) + ret;
2965 case SM_CYFRAME:
2966 get_entry_dpi( &entry_BORDER, 0, &ret, dpi );
2967 ret = max( ret, 1 );
2968 return GetSystemMetricsForDpi( SM_CYDLGFRAME, dpi ) + ret;
2969 case SM_CXICONSPACING:
2970 im.cbSize = sizeof(im);
2971 SystemParametersInfoForDpi( SPI_GETICONMETRICS, sizeof(im), &im, 0, dpi );
2972 return im.iHorzSpacing;
2973 case SM_CYICONSPACING:
2974 im.cbSize = sizeof(im);
2975 SystemParametersInfoForDpi( SPI_GETICONMETRICS, sizeof(im), &im, 0, dpi );
2976 return im.iVertSpacing;
2977 case SM_CXSMICON:
2978 case SM_CYSMICON:
2979 return map_to_dpi( 16, dpi ) & ~1;
2980 case SM_CYSMCAPTION:
2981 ncm.cbSize = sizeof(ncm);
2982 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2983 return ncm.iSmCaptionHeight + 1;
2984 case SM_CXSMSIZE:
2985 get_entry_dpi( &entry_SMCAPTIONWIDTH, 0, &ret, dpi );
2986 return ret;
2987 case SM_CYSMSIZE:
2988 ncm.cbSize = sizeof(ncm);
2989 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2990 return ncm.iSmCaptionHeight;
2991 case SM_CXMENUSIZE:
2992 get_entry_dpi( &entry_MENUWIDTH, 0, &ret, dpi );
2993 return ret;
2994 case SM_CYMENUSIZE:
2995 ncm.cbSize = sizeof(ncm);
2996 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2997 return ncm.iMenuHeight;
2998 case SM_CXMENUCHECK:
2999 case SM_CYMENUCHECK:
3001 TEXTMETRICW tm;
3002 ncm.cbSize = sizeof(ncm);
3003 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
3004 hdc = get_display_dc();
3005 get_text_metr_size( hdc, &ncm.lfMenuFont, &tm, NULL);
3006 release_display_dc( hdc );
3007 return tm.tmHeight <= 0 ? 13 : ((tm.tmHeight + tm.tmExternalLeading - 1) | 1);
3009 default:
3010 return GetSystemMetrics( index );
3015 /***********************************************************************
3016 * SwapMouseButton (USER32.@)
3017 * Reverse or restore the meaning of the left and right mouse buttons
3018 * fSwap [I ] TRUE - reverse, FALSE - original
3019 * RETURN
3020 * previous state
3022 BOOL WINAPI SwapMouseButton( BOOL fSwap )
3024 BOOL prev = GetSystemMetrics(SM_SWAPBUTTON);
3025 SystemParametersInfoW(SPI_SETMOUSEBUTTONSWAP, fSwap, 0, 0);
3026 return prev;
3030 /**********************************************************************
3031 * SetDoubleClickTime (USER32.@)
3033 BOOL WINAPI SetDoubleClickTime( UINT interval )
3035 return SystemParametersInfoW(SPI_SETDOUBLECLICKTIME, interval, 0, 0);
3039 /**********************************************************************
3040 * GetDoubleClickTime (USER32.@)
3042 UINT WINAPI GetDoubleClickTime(void)
3044 UINT time = 0;
3046 get_entry( &entry_DOUBLECLICKTIME, 0, &time );
3047 if (!time) time = 500;
3048 return time;
3052 /*************************************************************************
3053 * GetSysColor (USER32.@)
3055 COLORREF WINAPI DECLSPEC_HOTPATCH GetSysColor( INT nIndex )
3057 COLORREF ret = 0;
3059 if (nIndex >= 0 && nIndex < ARRAY_SIZE( system_colors ))
3060 get_entry( &system_colors[nIndex], 0, &ret );
3061 return ret;
3065 /*************************************************************************
3066 * SetSysColors (USER32.@)
3068 BOOL WINAPI SetSysColors( INT count, const INT *colors, const COLORREF *values )
3070 int i;
3072 if (IS_INTRESOURCE(colors)) return FALSE; /* stupid app passes a color instead of an array */
3074 for (i = 0; i < count; i++)
3075 if (colors[i] >= 0 && colors[i] <= ARRAY_SIZE( system_colors ))
3076 set_entry( &system_colors[colors[i]], values[i], 0, 0 );
3078 /* Send WM_SYSCOLORCHANGE message to all windows */
3080 SendMessageTimeoutW( HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0, SMTO_ABORTIFHUNG, 2000, NULL );
3082 /* Repaint affected portions of all visible windows */
3084 RedrawWindow( 0, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
3085 return TRUE;
3089 /*************************************************************************
3090 * SetSysColorsTemp (USER32.@)
3092 DWORD_PTR WINAPI SetSysColorsTemp( const COLORREF *pPens, const HBRUSH *pBrushes, DWORD_PTR n)
3094 FIXME( "no longer supported\n" );
3095 return FALSE;
3099 /***********************************************************************
3100 * GetSysColorBrush (USER32.@)
3102 HBRUSH WINAPI DECLSPEC_HOTPATCH GetSysColorBrush( INT index )
3104 if (index < 0 || index >= ARRAY_SIZE( system_colors )) return 0;
3106 if (!system_colors[index].brush)
3108 HBRUSH brush = CreateSolidBrush( GetSysColor( index ));
3109 __wine_make_gdi_object_system( brush, TRUE );
3110 if (InterlockedCompareExchangePointer( (void **)&system_colors[index].brush, brush, 0 ))
3112 __wine_make_gdi_object_system( brush, FALSE );
3113 DeleteObject( brush );
3116 return system_colors[index].brush;
3120 /***********************************************************************
3121 * SYSCOLOR_GetPen
3123 HPEN SYSCOLOR_GetPen( INT index )
3125 /* We can assert here, because this function is internal to Wine */
3126 assert (0 <= index && index < ARRAY_SIZE( system_colors ));
3128 if (!system_colors[index].pen)
3130 HPEN pen = CreatePen( PS_SOLID, 1, GetSysColor( index ));
3131 __wine_make_gdi_object_system( pen, TRUE );
3132 if (InterlockedCompareExchangePointer( (void **)&system_colors[index].pen, pen, 0 ))
3134 __wine_make_gdi_object_system( pen, FALSE );
3135 DeleteObject( pen );
3138 return system_colors[index].pen;
3142 /***********************************************************************
3143 * SYSCOLOR_Get55AABrush
3145 HBRUSH SYSCOLOR_Get55AABrush(void)
3147 static const WORD pattern[] = { 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa };
3148 static HBRUSH brush_55aa;
3150 if (!brush_55aa)
3152 HBITMAP bitmap = CreateBitmap( 8, 8, 1, 1, pattern );
3153 HBRUSH brush = CreatePatternBrush( bitmap );
3154 DeleteObject( bitmap );
3155 __wine_make_gdi_object_system( brush, TRUE );
3156 if (InterlockedCompareExchangePointer( (void **)&brush_55aa, brush, 0 ))
3158 __wine_make_gdi_object_system( brush, FALSE );
3159 DeleteObject( brush );
3162 return brush_55aa;
3165 /***********************************************************************
3166 * ChangeDisplaySettingsA (USER32.@)
3168 LONG WINAPI ChangeDisplaySettingsA( LPDEVMODEA devmode, DWORD flags )
3170 if (devmode) devmode->dmDriverExtra = 0;
3172 return ChangeDisplaySettingsExA(NULL,devmode,NULL,flags,NULL);
3176 /***********************************************************************
3177 * ChangeDisplaySettingsW (USER32.@)
3179 LONG WINAPI ChangeDisplaySettingsW( LPDEVMODEW devmode, DWORD flags )
3181 if (devmode) devmode->dmDriverExtra = 0;
3183 return ChangeDisplaySettingsExW(NULL,devmode,NULL,flags,NULL);
3187 /***********************************************************************
3188 * ChangeDisplaySettingsExA (USER32.@)
3190 LONG WINAPI ChangeDisplaySettingsExA( LPCSTR devname, LPDEVMODEA devmode, HWND hwnd,
3191 DWORD flags, LPVOID lparam )
3193 LONG ret;
3194 UNICODE_STRING nameW;
3196 if (devname) RtlCreateUnicodeStringFromAsciiz(&nameW, devname);
3197 else nameW.Buffer = NULL;
3199 if (devmode)
3201 DEVMODEW *devmodeW;
3203 devmodeW = GdiConvertToDevmodeW(devmode);
3204 if (devmodeW)
3206 ret = ChangeDisplaySettingsExW(nameW.Buffer, devmodeW, hwnd, flags, lparam);
3207 HeapFree(GetProcessHeap(), 0, devmodeW);
3209 else
3210 ret = DISP_CHANGE_SUCCESSFUL;
3212 else
3214 ret = ChangeDisplaySettingsExW(nameW.Buffer, NULL, hwnd, flags, lparam);
3217 if (devname) RtlFreeUnicodeString(&nameW);
3218 return ret;
3221 #define _X_FIELD(prefix, bits) \
3222 if ((fields) & prefix##_##bits) \
3224 p += sprintf(p, "%s%s", first ? "" : ",", #bits); \
3225 first = FALSE; \
3228 static const CHAR *_CDS_flags(DWORD fields)
3230 BOOL first = TRUE;
3231 CHAR buf[128];
3232 CHAR *p = buf;
3234 _X_FIELD(CDS, UPDATEREGISTRY)
3235 _X_FIELD(CDS, TEST)
3236 _X_FIELD(CDS, FULLSCREEN)
3237 _X_FIELD(CDS, GLOBAL)
3238 _X_FIELD(CDS, SET_PRIMARY)
3239 _X_FIELD(CDS, VIDEOPARAMETERS)
3240 _X_FIELD(CDS, ENABLE_UNSAFE_MODES)
3241 _X_FIELD(CDS, DISABLE_UNSAFE_MODES)
3242 _X_FIELD(CDS, RESET)
3243 _X_FIELD(CDS, RESET_EX)
3244 _X_FIELD(CDS, NORESET)
3246 *p = 0;
3247 return wine_dbg_sprintf("%s", buf);
3250 static const CHAR *_DM_fields(DWORD fields)
3252 BOOL first = TRUE;
3253 CHAR buf[128];
3254 CHAR *p = buf;
3256 _X_FIELD(DM, BITSPERPEL)
3257 _X_FIELD(DM, PELSWIDTH)
3258 _X_FIELD(DM, PELSHEIGHT)
3259 _X_FIELD(DM, DISPLAYFLAGS)
3260 _X_FIELD(DM, DISPLAYFREQUENCY)
3261 _X_FIELD(DM, POSITION)
3262 _X_FIELD(DM, DISPLAYORIENTATION)
3264 *p = 0;
3265 return wine_dbg_sprintf("%s", buf);
3268 #undef _X_FIELD
3270 static void trace_devmode(const DEVMODEW *devmode)
3272 TRACE("dmFields=%s ", _DM_fields(devmode->dmFields));
3273 if (devmode->dmFields & DM_BITSPERPEL)
3274 TRACE("dmBitsPerPel=%u ", devmode->dmBitsPerPel);
3275 if (devmode->dmFields & DM_PELSWIDTH)
3276 TRACE("dmPelsWidth=%u ", devmode->dmPelsWidth);
3277 if (devmode->dmFields & DM_PELSHEIGHT)
3278 TRACE("dmPelsHeight=%u ", devmode->dmPelsHeight);
3279 if (devmode->dmFields & DM_DISPLAYFREQUENCY)
3280 TRACE("dmDisplayFrequency=%u ", devmode->dmDisplayFrequency);
3281 if (devmode->dmFields & DM_POSITION)
3282 TRACE("dmPosition=(%d,%d) ", devmode->u1.s2.dmPosition.x, devmode->u1.s2.dmPosition.y);
3283 if (devmode->dmFields & DM_DISPLAYFLAGS)
3284 TRACE("dmDisplayFlags=%#x ", devmode->u2.dmDisplayFlags);
3285 if (devmode->dmFields & DM_DISPLAYORIENTATION)
3286 TRACE("dmDisplayOrientation=%u ", devmode->u1.s2.dmDisplayOrientation);
3287 TRACE("\n");
3290 /***********************************************************************
3291 * ChangeDisplaySettingsExW (USER32.@)
3293 LONG WINAPI ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode, HWND hwnd,
3294 DWORD flags, LPVOID lparam )
3296 WCHAR primary_adapter[CCHDEVICENAME];
3297 BOOL def_mode = TRUE;
3298 DEVMODEW dm;
3300 TRACE("%s %p %p %#x %p\n", debugstr_w(devname), devmode, hwnd, flags, lparam);
3301 TRACE("flags=%s\n", _CDS_flags(flags));
3303 if (!devname && devmode)
3305 if (!get_primary_adapter(primary_adapter))
3306 return DISP_CHANGE_FAILED;
3308 devname = primary_adapter;
3311 if (devmode)
3313 trace_devmode(devmode);
3315 if (devmode->dmSize < FIELD_OFFSET(DEVMODEW, dmICMMethod))
3316 return DISP_CHANGE_BADMODE;
3318 if (((devmode->dmFields & DM_BITSPERPEL) && devmode->dmBitsPerPel) ||
3319 ((devmode->dmFields & DM_PELSWIDTH) && devmode->dmPelsWidth) ||
3320 ((devmode->dmFields & DM_PELSHEIGHT) && devmode->dmPelsHeight) ||
3321 ((devmode->dmFields & DM_DISPLAYFREQUENCY) && devmode->dmDisplayFrequency))
3322 def_mode = FALSE;
3325 if (def_mode)
3327 dm.dmSize = sizeof(dm);
3328 if (!EnumDisplaySettingsExW(devname, ENUM_REGISTRY_SETTINGS, &dm, 0))
3330 ERR("Default mode not found!\n");
3331 return DISP_CHANGE_BADMODE;
3334 TRACE("Return to original display mode\n");
3335 devmode = &dm;
3338 if ((devmode->dmFields & (DM_PELSWIDTH | DM_PELSHEIGHT)) != (DM_PELSWIDTH | DM_PELSHEIGHT))
3340 WARN("devmode doesn't specify the resolution: %#x\n", devmode->dmFields);
3341 return DISP_CHANGE_BADMODE;
3344 return USER_Driver->pChangeDisplaySettingsEx(devname, devmode, hwnd, flags, lparam);
3348 /***********************************************************************
3349 * DisplayConfigGetDeviceInfo (USER32.@)
3351 LONG WINAPI DisplayConfigGetDeviceInfo(DISPLAYCONFIG_DEVICE_INFO_HEADER *packet)
3353 FIXME("stub: %p\n", packet);
3354 return ERROR_NOT_SUPPORTED;
3357 /***********************************************************************
3358 * EnumDisplaySettingsW (USER32.@)
3360 * RETURNS
3361 * TRUE if nth setting exists found (described in the LPDEVMODEW struct)
3362 * FALSE if we do not have the nth setting
3364 BOOL WINAPI EnumDisplaySettingsW( LPCWSTR name, DWORD n, LPDEVMODEW devmode )
3366 return EnumDisplaySettingsExW(name, n, devmode, 0);
3370 /***********************************************************************
3371 * EnumDisplaySettingsA (USER32.@)
3373 BOOL WINAPI EnumDisplaySettingsA(LPCSTR name,DWORD n,LPDEVMODEA devmode)
3375 return EnumDisplaySettingsExA(name, n, devmode, 0);
3379 /***********************************************************************
3380 * EnumDisplaySettingsExA (USER32.@)
3382 BOOL WINAPI EnumDisplaySettingsExA(LPCSTR lpszDeviceName, DWORD iModeNum,
3383 LPDEVMODEA lpDevMode, DWORD dwFlags)
3385 DEVMODEW devmodeW;
3386 BOOL ret;
3387 UNICODE_STRING nameW;
3389 if (lpszDeviceName) RtlCreateUnicodeStringFromAsciiz(&nameW, lpszDeviceName);
3390 else nameW.Buffer = NULL;
3392 ret = EnumDisplaySettingsExW(nameW.Buffer,iModeNum,&devmodeW,dwFlags);
3393 if (ret)
3395 lpDevMode->dmSize = FIELD_OFFSET(DEVMODEA, dmICMMethod);
3396 lpDevMode->dmSpecVersion = devmodeW.dmSpecVersion;
3397 lpDevMode->dmDriverVersion = devmodeW.dmDriverVersion;
3398 WideCharToMultiByte(CP_ACP, 0, devmodeW.dmDeviceName, -1,
3399 (LPSTR)lpDevMode->dmDeviceName, CCHDEVICENAME, NULL, NULL);
3400 lpDevMode->dmDriverExtra = 0; /* FIXME */
3401 lpDevMode->dmBitsPerPel = devmodeW.dmBitsPerPel;
3402 lpDevMode->dmPelsHeight = devmodeW.dmPelsHeight;
3403 lpDevMode->dmPelsWidth = devmodeW.dmPelsWidth;
3404 lpDevMode->u2.dmDisplayFlags = devmodeW.u2.dmDisplayFlags;
3405 lpDevMode->dmDisplayFrequency = devmodeW.dmDisplayFrequency;
3406 lpDevMode->dmFields = devmodeW.dmFields;
3408 lpDevMode->u1.s2.dmPosition.x = devmodeW.u1.s2.dmPosition.x;
3409 lpDevMode->u1.s2.dmPosition.y = devmodeW.u1.s2.dmPosition.y;
3410 lpDevMode->u1.s2.dmDisplayOrientation = devmodeW.u1.s2.dmDisplayOrientation;
3411 lpDevMode->u1.s2.dmDisplayFixedOutput = devmodeW.u1.s2.dmDisplayFixedOutput;
3413 if (lpszDeviceName) RtlFreeUnicodeString(&nameW);
3414 return ret;
3418 /***********************************************************************
3419 * EnumDisplaySettingsExW (USER32.@)
3421 BOOL WINAPI EnumDisplaySettingsExW(LPCWSTR lpszDeviceName, DWORD iModeNum,
3422 LPDEVMODEW lpDevMode, DWORD dwFlags)
3424 WCHAR primary_adapter[CCHDEVICENAME];
3426 TRACE("%s %u %p %#x\n", wine_dbgstr_w(lpszDeviceName), iModeNum, lpDevMode, dwFlags);
3428 if (!lpszDeviceName)
3430 if (!get_primary_adapter(primary_adapter))
3431 return FALSE;
3433 lpszDeviceName = primary_adapter;
3436 return USER_Driver->pEnumDisplaySettingsEx(lpszDeviceName, iModeNum, lpDevMode, dwFlags);
3440 /**********************************************************************
3441 * get_monitor_dpi
3443 UINT get_monitor_dpi( HMONITOR monitor )
3445 /* FIXME: use the monitor DPI instead */
3446 return system_dpi;
3449 /**********************************************************************
3450 * get_win_monitor_dpi
3452 UINT get_win_monitor_dpi( HWND hwnd )
3454 /* FIXME: use the monitor DPI instead */
3455 return system_dpi;
3458 /**********************************************************************
3459 * get_thread_dpi
3461 UINT get_thread_dpi(void)
3463 switch (GetAwarenessFromDpiAwarenessContext( GetThreadDpiAwarenessContext() ))
3465 case DPI_AWARENESS_UNAWARE: return USER_DEFAULT_SCREEN_DPI;
3466 case DPI_AWARENESS_SYSTEM_AWARE: return system_dpi;
3467 default: return 0; /* no scaling */
3471 /**********************************************************************
3472 * map_dpi_point
3474 POINT map_dpi_point( POINT pt, UINT dpi_from, UINT dpi_to )
3476 if (dpi_from && dpi_to && dpi_from != dpi_to)
3478 pt.x = MulDiv( pt.x, dpi_to, dpi_from );
3479 pt.y = MulDiv( pt.y, dpi_to, dpi_from );
3481 return pt;
3484 /**********************************************************************
3485 * point_win_to_phys_dpi
3487 POINT point_win_to_phys_dpi( HWND hwnd, POINT pt )
3489 return map_dpi_point( pt, GetDpiForWindow( hwnd ), get_win_monitor_dpi( hwnd ) );
3492 /**********************************************************************
3493 * point_phys_to_win_dpi
3495 POINT point_phys_to_win_dpi( HWND hwnd, POINT pt )
3497 return map_dpi_point( pt, get_win_monitor_dpi( hwnd ), GetDpiForWindow( hwnd ));
3500 /**********************************************************************
3501 * point_win_to_thread_dpi
3503 POINT point_win_to_thread_dpi( HWND hwnd, POINT pt )
3505 UINT dpi = get_thread_dpi();
3506 if (!dpi) dpi = get_win_monitor_dpi( hwnd );
3507 return map_dpi_point( pt, GetDpiForWindow( hwnd ), dpi );
3510 /**********************************************************************
3511 * point_thread_to_win_dpi
3513 POINT point_thread_to_win_dpi( HWND hwnd, POINT pt )
3515 UINT dpi = get_thread_dpi();
3516 if (!dpi) dpi = get_win_monitor_dpi( hwnd );
3517 return map_dpi_point( pt, dpi, GetDpiForWindow( hwnd ));
3520 /**********************************************************************
3521 * map_dpi_rect
3523 RECT map_dpi_rect( RECT rect, UINT dpi_from, UINT dpi_to )
3525 if (dpi_from && dpi_to && dpi_from != dpi_to)
3527 rect.left = MulDiv( rect.left, dpi_to, dpi_from );
3528 rect.top = MulDiv( rect.top, dpi_to, dpi_from );
3529 rect.right = MulDiv( rect.right, dpi_to, dpi_from );
3530 rect.bottom = MulDiv( rect.bottom, dpi_to, dpi_from );
3532 return rect;
3535 /**********************************************************************
3536 * rect_win_to_thread_dpi
3538 RECT rect_win_to_thread_dpi( HWND hwnd, RECT rect )
3540 UINT dpi = get_thread_dpi();
3541 if (!dpi) dpi = get_win_monitor_dpi( hwnd );
3542 return map_dpi_rect( rect, GetDpiForWindow( hwnd ), dpi );
3545 /**********************************************************************
3546 * rect_thread_to_win_dpi
3548 RECT rect_thread_to_win_dpi( HWND hwnd, RECT rect )
3550 UINT dpi = get_thread_dpi();
3551 if (!dpi) dpi = get_win_monitor_dpi( hwnd );
3552 return map_dpi_rect( rect, dpi, GetDpiForWindow( hwnd ) );
3555 /**********************************************************************
3556 * SetProcessDpiAwarenessContext (USER32.@)
3558 BOOL WINAPI SetProcessDpiAwarenessContext( DPI_AWARENESS_CONTEXT context )
3560 DPI_AWARENESS val = GetAwarenessFromDpiAwarenessContext( context );
3562 if (val == DPI_AWARENESS_INVALID)
3564 SetLastError( ERROR_INVALID_PARAMETER );
3565 return FALSE;
3567 val |= 0x10; /* avoid 0 value */
3568 if (InterlockedCompareExchange( &dpi_awareness, val, 0 ))
3570 SetLastError( ERROR_ACCESS_DENIED );
3571 return FALSE;
3573 TRACE( "set to %p\n", context );
3574 return TRUE;
3577 /**********************************************************************
3578 * GetProcessDpiAwarenessInternal (USER32.@)
3580 BOOL WINAPI GetProcessDpiAwarenessInternal( HANDLE process, DPI_AWARENESS *awareness )
3582 if (process && process != GetCurrentProcess())
3584 WARN( "not supported on other process %p\n", process );
3585 *awareness = DPI_AWARENESS_UNAWARE;
3587 else *awareness = dpi_awareness & 3;
3588 return TRUE;
3591 /**********************************************************************
3592 * SetProcessDpiAwarenessInternal (USER32.@)
3594 BOOL WINAPI SetProcessDpiAwarenessInternal( DPI_AWARENESS awareness )
3596 static const DPI_AWARENESS_CONTEXT contexts[3] = { DPI_AWARENESS_CONTEXT_UNAWARE,
3597 DPI_AWARENESS_CONTEXT_SYSTEM_AWARE,
3598 DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE };
3600 if (awareness < DPI_AWARENESS_UNAWARE || awareness > DPI_AWARENESS_PER_MONITOR_AWARE)
3602 SetLastError( ERROR_INVALID_PARAMETER );
3603 return FALSE;
3605 return SetProcessDpiAwarenessContext( contexts[awareness] );
3608 /***********************************************************************
3609 * AreDpiAwarenessContextsEqual (USER32.@)
3611 BOOL WINAPI AreDpiAwarenessContextsEqual( DPI_AWARENESS_CONTEXT ctx1, DPI_AWARENESS_CONTEXT ctx2 )
3613 DPI_AWARENESS aware1 = GetAwarenessFromDpiAwarenessContext( ctx1 );
3614 DPI_AWARENESS aware2 = GetAwarenessFromDpiAwarenessContext( ctx2 );
3615 return aware1 != DPI_AWARENESS_INVALID && aware1 == aware2;
3618 /***********************************************************************
3619 * GetAwarenessFromDpiAwarenessContext (USER32.@)
3621 DPI_AWARENESS WINAPI GetAwarenessFromDpiAwarenessContext( DPI_AWARENESS_CONTEXT context )
3623 switch ((ULONG_PTR)context)
3625 case 0x10:
3626 case 0x11:
3627 case 0x12:
3628 case 0x80000010:
3629 case 0x80000011:
3630 case 0x80000012:
3631 return (ULONG_PTR)context & 3;
3632 case (ULONG_PTR)DPI_AWARENESS_CONTEXT_UNAWARE:
3633 case (ULONG_PTR)DPI_AWARENESS_CONTEXT_SYSTEM_AWARE:
3634 case (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE:
3635 return ~(ULONG_PTR)context;
3636 default:
3637 return DPI_AWARENESS_INVALID;
3641 /***********************************************************************
3642 * IsValidDpiAwarenessContext (USER32.@)
3644 BOOL WINAPI IsValidDpiAwarenessContext( DPI_AWARENESS_CONTEXT context )
3646 return GetAwarenessFromDpiAwarenessContext( context ) != DPI_AWARENESS_INVALID;
3649 /***********************************************************************
3650 * SetProcessDPIAware (USER32.@)
3652 BOOL WINAPI SetProcessDPIAware(void)
3654 TRACE("\n");
3655 InterlockedCompareExchange( &dpi_awareness, 0x11, 0 );
3656 return TRUE;
3659 /***********************************************************************
3660 * IsProcessDPIAware (USER32.@)
3662 BOOL WINAPI IsProcessDPIAware(void)
3664 return GetAwarenessFromDpiAwarenessContext( GetThreadDpiAwarenessContext() ) != DPI_AWARENESS_UNAWARE;
3667 /**********************************************************************
3668 * EnableNonClientDpiScaling (USER32.@)
3670 BOOL WINAPI EnableNonClientDpiScaling( HWND hwnd )
3672 FIXME("(%p): stub\n", hwnd);
3673 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
3674 return FALSE;
3677 /***********************************************************************
3678 * GetDpiForSystem (USER32.@)
3680 UINT WINAPI GetDpiForSystem(void)
3682 if (!IsProcessDPIAware()) return USER_DEFAULT_SCREEN_DPI;
3683 return system_dpi;
3686 /***********************************************************************
3687 * GetDpiForMonitorInternal (USER32.@)
3689 BOOL WINAPI GetDpiForMonitorInternal( HMONITOR monitor, UINT type, UINT *x, UINT *y )
3691 if (type > 2)
3693 SetLastError( ERROR_BAD_ARGUMENTS );
3694 return FALSE;
3696 if (!x || !y)
3698 SetLastError( ERROR_INVALID_ADDRESS );
3699 return FALSE;
3701 switch (GetAwarenessFromDpiAwarenessContext( GetThreadDpiAwarenessContext() ))
3703 case DPI_AWARENESS_UNAWARE: *x = *y = USER_DEFAULT_SCREEN_DPI; break;
3704 case DPI_AWARENESS_SYSTEM_AWARE: *x = *y = system_dpi; break;
3705 default: *x = *y = get_monitor_dpi( monitor ); break;
3707 return TRUE;
3710 /**********************************************************************
3711 * GetThreadDpiAwarenessContext (USER32.@)
3713 DPI_AWARENESS_CONTEXT WINAPI GetThreadDpiAwarenessContext(void)
3715 struct user_thread_info *info = get_user_thread_info();
3717 if (info->dpi_awareness) return ULongToHandle( info->dpi_awareness );
3718 if (dpi_awareness) return ULongToHandle( dpi_awareness );
3719 return ULongToHandle( 0x10 | default_awareness );
3722 /**********************************************************************
3723 * SetThreadDpiAwarenessContext (USER32.@)
3725 DPI_AWARENESS_CONTEXT WINAPI SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT context )
3727 struct user_thread_info *info = get_user_thread_info();
3728 DPI_AWARENESS prev, val = GetAwarenessFromDpiAwarenessContext( context );
3730 if (val == DPI_AWARENESS_INVALID)
3732 SetLastError( ERROR_INVALID_PARAMETER );
3733 return 0;
3735 if (!(prev = info->dpi_awareness))
3737 prev = dpi_awareness;
3738 if (!prev) prev = 0x10 | DPI_AWARENESS_UNAWARE;
3739 prev |= 0x80000000; /* restore to process default */
3741 if (((ULONG_PTR)context & ~(ULONG_PTR)0x13) == 0x80000000) info->dpi_awareness = 0;
3742 else info->dpi_awareness = val | 0x10;
3743 return ULongToHandle( prev );
3746 /**********************************************************************
3747 * LogicalToPhysicalPointForPerMonitorDPI (USER32.@)
3749 BOOL WINAPI LogicalToPhysicalPointForPerMonitorDPI( HWND hwnd, POINT *pt )
3751 RECT rect;
3753 if (!GetWindowRect( hwnd, &rect )) return FALSE;
3754 if (pt->x < rect.left || pt->y < rect.top || pt->x > rect.right || pt->y > rect.bottom) return FALSE;
3755 *pt = point_win_to_phys_dpi( hwnd, *pt );
3756 return TRUE;
3759 /**********************************************************************
3760 * PhysicalToLogicalPointForPerMonitorDPI (USER32.@)
3762 BOOL WINAPI PhysicalToLogicalPointForPerMonitorDPI( HWND hwnd, POINT *pt )
3764 DPI_AWARENESS_CONTEXT context;
3765 RECT rect;
3766 BOOL ret = FALSE;
3768 context = SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE );
3769 if (GetWindowRect( hwnd, &rect ) &&
3770 pt->x >= rect.left && pt->y >= rect.top && pt->x <= rect.right && pt->y <= rect.bottom)
3772 *pt = point_phys_to_win_dpi( hwnd, *pt );
3773 ret = TRUE;
3775 SetThreadDpiAwarenessContext( context );
3776 return ret;
3779 struct monitor_enum_info
3781 RECT rect;
3782 UINT max_area;
3783 UINT min_distance;
3784 HMONITOR primary;
3785 HMONITOR nearest;
3786 HMONITOR ret;
3789 /* helper callback for MonitorFromRect */
3790 static BOOL CALLBACK monitor_enum( HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM lp )
3792 struct monitor_enum_info *info = (struct monitor_enum_info *)lp;
3793 RECT intersect;
3795 if (IntersectRect( &intersect, rect, &info->rect ))
3797 /* check for larger intersecting area */
3798 UINT area = (intersect.right - intersect.left) * (intersect.bottom - intersect.top);
3799 if (area > info->max_area)
3801 info->max_area = area;
3802 info->ret = monitor;
3805 else if (!info->max_area) /* if not intersecting, check for min distance */
3807 UINT distance;
3808 UINT x, y;
3810 if (info->rect.right <= rect->left) x = rect->left - info->rect.right;
3811 else if (rect->right <= info->rect.left) x = info->rect.left - rect->right;
3812 else x = 0;
3813 if (info->rect.bottom <= rect->top) y = rect->top - info->rect.bottom;
3814 else if (rect->bottom <= info->rect.top) y = info->rect.top - rect->bottom;
3815 else y = 0;
3816 distance = x * x + y * y;
3817 if (distance < info->min_distance)
3819 info->min_distance = distance;
3820 info->nearest = monitor;
3823 if (!info->primary)
3825 MONITORINFO mon_info;
3826 mon_info.cbSize = sizeof(mon_info);
3827 GetMonitorInfoW( monitor, &mon_info );
3828 if (mon_info.dwFlags & MONITORINFOF_PRIMARY) info->primary = monitor;
3830 return TRUE;
3833 /***********************************************************************
3834 * MonitorFromRect (USER32.@)
3836 HMONITOR WINAPI MonitorFromRect( const RECT *rect, DWORD flags )
3838 struct monitor_enum_info info;
3840 info.rect = *rect;
3841 info.max_area = 0;
3842 info.min_distance = ~0u;
3843 info.primary = 0;
3844 info.nearest = 0;
3845 info.ret = 0;
3847 if (IsRectEmpty(&info.rect))
3849 info.rect.right = info.rect.left + 1;
3850 info.rect.bottom = info.rect.top + 1;
3853 if (!EnumDisplayMonitors( 0, NULL, monitor_enum, (LPARAM)&info )) return 0;
3854 if (!info.ret)
3856 if (flags & MONITOR_DEFAULTTOPRIMARY) info.ret = info.primary;
3857 else if (flags & MONITOR_DEFAULTTONEAREST) info.ret = info.nearest;
3860 TRACE( "%s flags %x returning %p\n", wine_dbgstr_rect(rect), flags, info.ret );
3861 return info.ret;
3864 /***********************************************************************
3865 * MonitorFromPoint (USER32.@)
3867 HMONITOR WINAPI MonitorFromPoint( POINT pt, DWORD flags )
3869 RECT rect;
3871 SetRect( &rect, pt.x, pt.y, pt.x + 1, pt.y + 1 );
3872 return MonitorFromRect( &rect, flags );
3875 /***********************************************************************
3876 * MonitorFromWindow (USER32.@)
3878 HMONITOR WINAPI MonitorFromWindow(HWND hWnd, DWORD dwFlags)
3880 RECT rect;
3881 WINDOWPLACEMENT wp;
3883 TRACE("(%p, 0x%08x)\n", hWnd, dwFlags);
3885 wp.length = sizeof(wp);
3886 if (IsIconic(hWnd) && GetWindowPlacement(hWnd, &wp))
3887 return MonitorFromRect( &wp.rcNormalPosition, dwFlags );
3889 if (GetWindowRect( hWnd, &rect ))
3890 return MonitorFromRect( &rect, dwFlags );
3892 if (!(dwFlags & (MONITOR_DEFAULTTOPRIMARY|MONITOR_DEFAULTTONEAREST))) return 0;
3893 /* retrieve the primary */
3894 SetRect( &rect, 0, 0, 1, 1 );
3895 return MonitorFromRect( &rect, dwFlags );
3898 /* Return FALSE on failure and TRUE on success */
3899 static BOOL update_monitor_cache(void)
3901 SP_DEVINFO_DATA device_data = {sizeof(device_data)};
3902 HDEVINFO devinfo = INVALID_HANDLE_VALUE;
3903 MONITORINFOEXW *monitor_array;
3904 FILETIME filetime = {0};
3905 DWORD device_count = 0;
3906 HANDLE mutex = NULL;
3907 DWORD state_flags;
3908 BOOL ret = FALSE;
3909 BOOL mirrored_slave;
3910 DWORD i = 0, j;
3911 DWORD type;
3913 /* Update monitor cache from SetupAPI if it's outdated */
3914 if (!video_key && RegOpenKeyW( HKEY_LOCAL_MACHINE, VIDEO_KEY, &video_key ))
3915 return FALSE;
3916 if (RegQueryInfoKeyW( video_key, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &filetime ))
3917 return FALSE;
3918 if (CompareFileTime( &filetime, &last_query_monitors_time ) < 1)
3919 return TRUE;
3921 mutex = get_display_device_init_mutex();
3922 EnterCriticalSection( &monitors_section );
3923 devinfo = SetupDiGetClassDevsW( &GUID_DEVCLASS_MONITOR, DISPLAY, NULL, DIGCF_PRESENT );
3925 while (SetupDiEnumDeviceInfo( devinfo, i++, &device_data ))
3927 /* Inactive monitors don't get enumerated */
3928 if (!SetupDiGetDevicePropertyW( devinfo, &device_data, &WINE_DEVPROPKEY_MONITOR_STATEFLAGS, &type,
3929 (BYTE *)&state_flags, sizeof(DWORD), NULL, 0 ))
3930 goto fail;
3931 if (state_flags & DISPLAY_DEVICE_ACTIVE)
3932 device_count++;
3935 if (device_count && monitor_count < device_count)
3937 monitor_array = heap_alloc( device_count * sizeof(*monitor_array) );
3938 if (!monitor_array)
3939 goto fail;
3940 heap_free( monitors );
3941 monitors = monitor_array;
3944 for (i = 0, monitor_count = 0; SetupDiEnumDeviceInfo( devinfo, i, &device_data ); i++)
3946 if (!SetupDiGetDevicePropertyW( devinfo, &device_data, &WINE_DEVPROPKEY_MONITOR_STATEFLAGS, &type,
3947 (BYTE *)&state_flags, sizeof(DWORD), NULL, 0 ))
3948 goto fail;
3949 if (!(state_flags & DISPLAY_DEVICE_ACTIVE))
3950 continue;
3951 if (!SetupDiGetDevicePropertyW( devinfo, &device_data, &WINE_DEVPROPKEY_MONITOR_RCMONITOR, &type,
3952 (BYTE *)&monitors[monitor_count].rcMonitor, sizeof(RECT), NULL, 0 ))
3953 goto fail;
3955 /* Mirrored slave monitors also don't get enumerated */
3956 mirrored_slave = FALSE;
3957 for (j = 0; j < monitor_count; j++)
3959 if (EqualRect(&monitors[j].rcMonitor, &monitors[monitor_count].rcMonitor))
3961 mirrored_slave = TRUE;
3962 break;
3965 if (mirrored_slave)
3966 continue;
3968 if (!SetupDiGetDevicePropertyW( devinfo, &device_data, &WINE_DEVPROPKEY_MONITOR_RCWORK, &type,
3969 (BYTE *)&monitors[monitor_count].rcWork, sizeof(RECT), NULL, 0 ))
3970 goto fail;
3971 if (!SetupDiGetDevicePropertyW( devinfo, &device_data, &WINE_DEVPROPKEY_MONITOR_ADAPTERNAME, &type,
3972 (BYTE *)monitors[monitor_count].szDevice, CCHDEVICENAME * sizeof(WCHAR), NULL, 0))
3973 goto fail;
3974 monitors[monitor_count].dwFlags =
3975 !lstrcmpW( DEFAULT_ADAPTER_NAME, monitors[monitor_count].szDevice ) ? MONITORINFOF_PRIMARY : 0;
3977 monitor_count++;
3980 last_query_monitors_time = filetime;
3981 ret = TRUE;
3982 fail:
3983 SetupDiDestroyDeviceInfoList( devinfo );
3984 LeaveCriticalSection( &monitors_section );
3985 release_display_device_init_mutex( mutex );
3986 return ret;
3989 BOOL CDECL nulldrv_GetMonitorInfo( HMONITOR handle, MONITORINFO *info )
3991 UINT index = (UINT_PTR)handle - 1;
3993 TRACE("(%p, %p)\n", handle, info);
3995 /* Fallback to report one monitor */
3996 if (handle == NULLDRV_DEFAULT_HMONITOR)
3998 RECT default_rect = {0, 0, 640, 480};
3999 info->rcMonitor = default_rect;
4000 info->rcWork = default_rect;
4001 info->dwFlags = MONITORINFOF_PRIMARY;
4002 if (info->cbSize >= sizeof(MONITORINFOEXW))
4003 lstrcpyW( ((MONITORINFOEXW *)info)->szDevice, DEFAULT_ADAPTER_NAME );
4004 return TRUE;
4007 if (!update_monitor_cache())
4008 return FALSE;
4010 EnterCriticalSection( &monitors_section );
4011 if (index < monitor_count)
4013 info->rcMonitor = monitors[index].rcMonitor;
4014 info->rcWork = monitors[index].rcWork;
4015 info->dwFlags = monitors[index].dwFlags;
4016 if (info->cbSize >= sizeof(MONITORINFOEXW))
4017 lstrcpyW( ((MONITORINFOEXW *)info)->szDevice, monitors[index].szDevice );
4018 LeaveCriticalSection( &monitors_section );
4019 return TRUE;
4021 else
4023 LeaveCriticalSection( &monitors_section );
4024 SetLastError( ERROR_INVALID_MONITOR_HANDLE );
4025 return FALSE;
4029 /***********************************************************************
4030 * GetMonitorInfoA (USER32.@)
4032 BOOL WINAPI GetMonitorInfoA( HMONITOR monitor, LPMONITORINFO info )
4034 MONITORINFOEXW miW;
4035 BOOL ret;
4037 if (info->cbSize == sizeof(MONITORINFO)) return GetMonitorInfoW( monitor, info );
4038 if (info->cbSize != sizeof(MONITORINFOEXA)) return FALSE;
4040 miW.cbSize = sizeof(miW);
4041 ret = GetMonitorInfoW( monitor, (MONITORINFO *)&miW );
4042 if (ret)
4044 MONITORINFOEXA *miA = (MONITORINFOEXA *)info;
4045 miA->rcMonitor = miW.rcMonitor;
4046 miA->rcWork = miW.rcWork;
4047 miA->dwFlags = miW.dwFlags;
4048 WideCharToMultiByte(CP_ACP, 0, miW.szDevice, -1, miA->szDevice, sizeof(miA->szDevice), NULL, NULL);
4050 return ret;
4053 /***********************************************************************
4054 * GetMonitorInfoW (USER32.@)
4056 BOOL WINAPI GetMonitorInfoW( HMONITOR monitor, LPMONITORINFO info )
4058 BOOL ret;
4059 UINT dpi_from, dpi_to;
4061 if (info->cbSize != sizeof(MONITORINFOEXW) && info->cbSize != sizeof(MONITORINFO)) return FALSE;
4063 ret = USER_Driver->pGetMonitorInfo( monitor, info );
4064 if (ret)
4066 if ((dpi_to = get_thread_dpi()))
4068 dpi_from = get_monitor_dpi( monitor );
4069 info->rcMonitor = map_dpi_rect( info->rcMonitor, dpi_from, dpi_to );
4070 info->rcWork = map_dpi_rect( info->rcWork, dpi_from, dpi_to );
4072 TRACE( "flags %04x, monitor %s, work %s\n", info->dwFlags,
4073 wine_dbgstr_rect(&info->rcMonitor), wine_dbgstr_rect(&info->rcWork));
4075 return ret;
4078 struct enum_mon_data
4080 MONITORENUMPROC proc;
4081 LPARAM lparam;
4082 HDC hdc;
4083 POINT origin;
4084 RECT limit;
4087 #ifdef __i386__
4088 /* Some apps pass a non-stdcall callback to EnumDisplayMonitors,
4089 * so we need a small assembly wrapper to call it.
4090 * MJ's Help Diagnostic expects that %ecx contains the address to the rect.
4092 extern BOOL enum_mon_callback_wrapper( HMONITOR monitor, LPRECT rect, struct enum_mon_data *data );
4093 __ASM_GLOBAL_FUNC( enum_mon_callback_wrapper,
4094 "pushl %ebp\n\t"
4095 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
4096 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
4097 "movl %esp,%ebp\n\t"
4098 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
4099 "subl $8,%esp\n\t"
4100 "movl 16(%ebp),%eax\n\t" /* data */
4101 "movl 12(%ebp),%ecx\n\t" /* rect */
4102 "pushl 4(%eax)\n\t" /* data->lparam */
4103 "pushl %ecx\n\t" /* rect */
4104 "pushl 8(%eax)\n\t" /* data->hdc */
4105 "pushl 8(%ebp)\n\t" /* monitor */
4106 "call *(%eax)\n\t" /* data->proc */
4107 "leave\n\t"
4108 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
4109 __ASM_CFI(".cfi_same_value %ebp\n\t")
4110 "ret" )
4111 #endif /* __i386__ */
4113 static BOOL CALLBACK enum_mon_callback( HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM lp )
4115 struct enum_mon_data *data = (struct enum_mon_data *)lp;
4116 RECT monrect = map_dpi_rect( *rect, get_monitor_dpi( monitor ), get_thread_dpi() );
4118 OffsetRect( &monrect, -data->origin.x, -data->origin.y );
4119 if (!IntersectRect( &monrect, &monrect, &data->limit )) return TRUE;
4120 #ifdef __i386__
4121 return enum_mon_callback_wrapper( monitor, &monrect, data );
4122 #else
4123 return data->proc( monitor, data->hdc, &monrect, data->lparam );
4124 #endif
4127 BOOL CDECL nulldrv_EnumDisplayMonitors( HDC hdc, RECT *rect, MONITORENUMPROC proc, LPARAM lp )
4129 RECT default_rect = {0, 0, 640, 480};
4130 DWORD i;
4132 TRACE("(%p, %p, %p, 0x%lx)\n", hdc, rect, proc, lp);
4134 if (update_monitor_cache())
4136 EnterCriticalSection( &monitors_section );
4137 for (i = 0; i < monitor_count; i++)
4139 if (!proc( (HMONITOR)(UINT_PTR)(i + 1), hdc, &monitors[i].rcMonitor, lp ))
4141 LeaveCriticalSection( &monitors_section );
4142 return FALSE;
4145 LeaveCriticalSection( &monitors_section );
4146 return TRUE;
4149 /* Fallback to report one monitor if using SetupAPI failed */
4150 if (!proc( NULLDRV_DEFAULT_HMONITOR, hdc, &default_rect, lp ))
4151 return FALSE;
4152 return TRUE;
4155 /***********************************************************************
4156 * EnumDisplayMonitors (USER32.@)
4158 BOOL WINAPI EnumDisplayMonitors( HDC hdc, LPRECT rect, MONITORENUMPROC proc, LPARAM lp )
4160 struct enum_mon_data data;
4162 data.proc = proc;
4163 data.lparam = lp;
4164 data.hdc = hdc;
4166 if (hdc)
4168 if (!GetDCOrgEx( hdc, &data.origin )) return FALSE;
4169 if (GetClipBox( hdc, &data.limit ) == ERROR) return FALSE;
4171 else
4173 data.origin.x = data.origin.y = 0;
4174 data.limit.left = data.limit.top = INT_MIN;
4175 data.limit.right = data.limit.bottom = INT_MAX;
4177 if (rect && !IntersectRect( &data.limit, &data.limit, rect )) return TRUE;
4178 return USER_Driver->pEnumDisplayMonitors( 0, NULL, enum_mon_callback, (LPARAM)&data );
4181 /***********************************************************************
4182 * EnumDisplayDevicesA (USER32.@)
4184 BOOL WINAPI EnumDisplayDevicesA( LPCSTR device, DWORD index, DISPLAY_DEVICEA *info, DWORD flags )
4186 UNICODE_STRING deviceW;
4187 DISPLAY_DEVICEW ddW;
4188 BOOL ret;
4190 if (device)
4191 RtlCreateUnicodeStringFromAsciiz( &deviceW, device );
4192 else
4193 deviceW.Buffer = NULL;
4195 ddW.cb = sizeof(ddW);
4196 ret = EnumDisplayDevicesW( deviceW.Buffer, index, &ddW, flags );
4197 RtlFreeUnicodeString( &deviceW );
4199 if (!ret)
4200 return ret;
4202 WideCharToMultiByte( CP_ACP, 0, ddW.DeviceName, -1, info->DeviceName, sizeof(info->DeviceName), NULL, NULL );
4203 WideCharToMultiByte( CP_ACP, 0, ddW.DeviceString, -1, info->DeviceString, sizeof(info->DeviceString), NULL, NULL );
4204 info->StateFlags = ddW.StateFlags;
4206 if (info->cb >= offsetof(DISPLAY_DEVICEA, DeviceID) + sizeof(info->DeviceID))
4207 WideCharToMultiByte( CP_ACP, 0, ddW.DeviceID, -1, info->DeviceID, sizeof(info->DeviceID), NULL, NULL );
4208 if (info->cb >= offsetof(DISPLAY_DEVICEA, DeviceKey) + sizeof(info->DeviceKey))
4209 WideCharToMultiByte( CP_ACP, 0, ddW.DeviceKey, -1, info->DeviceKey, sizeof(info->DeviceKey), NULL, NULL );
4211 return TRUE;
4214 /***********************************************************************
4215 * EnumDisplayDevicesW (USER32.@)
4217 BOOL WINAPI EnumDisplayDevicesW( LPCWSTR device, DWORD index, DISPLAY_DEVICEW *info, DWORD flags )
4219 SP_DEVINFO_DATA device_data = {sizeof(device_data)};
4220 HDEVINFO set = INVALID_HANDLE_VALUE;
4221 WCHAR key_nameW[MAX_PATH];
4222 WCHAR instanceW[MAX_PATH];
4223 WCHAR bufferW[1024];
4224 LONG adapter_index;
4225 WCHAR *next_charW;
4226 HANDLE mutex;
4227 DWORD size;
4228 DWORD type;
4229 HKEY hkey;
4230 BOOL ret = FALSE;
4232 TRACE("%s %d %p %#x\n", debugstr_w( device ), index, info, flags);
4234 wait_graphics_driver_ready();
4235 mutex = get_display_device_init_mutex();
4237 /* Find adapter */
4238 if (!device)
4240 sprintfW( key_nameW, VIDEO_VALUE_FMT, index );
4241 size = sizeof(bufferW);
4242 if (RegGetValueW( HKEY_LOCAL_MACHINE, VIDEO_KEY, key_nameW, RRF_RT_REG_SZ, NULL, bufferW, &size ))
4243 goto done;
4245 /* DeviceKey */
4246 if (info->cb >= offsetof(DISPLAY_DEVICEW, DeviceKey) + sizeof(info->DeviceKey))
4247 lstrcpyW( info->DeviceKey, bufferW );
4249 /* DeviceName */
4250 sprintfW( info->DeviceName, ADAPTER_FMT, index + 1 );
4252 /* Strip \Registry\Machine\ */
4253 lstrcpyW( key_nameW, bufferW + 18 );
4255 /* DeviceString */
4256 size = sizeof(info->DeviceString);
4257 if (RegGetValueW( HKEY_LOCAL_MACHINE, key_nameW, DRIVER_DESC, RRF_RT_REG_SZ, NULL,
4258 info->DeviceString, &size ))
4259 goto done;
4261 /* StateFlags */
4262 size = sizeof(info->StateFlags);
4263 if (RegGetValueW( HKEY_CURRENT_CONFIG, key_nameW, STATE_FLAGS, RRF_RT_REG_DWORD, NULL,
4264 &info->StateFlags, &size ))
4265 goto done;
4267 /* DeviceID */
4268 if (info->cb >= offsetof(DISPLAY_DEVICEW, DeviceID) + sizeof(info->DeviceID))
4270 if (flags & EDD_GET_DEVICE_INTERFACE_NAME)
4271 info->DeviceID[0] = 0;
4272 else
4274 size = sizeof(bufferW);
4275 if (RegGetValueW( HKEY_CURRENT_CONFIG, key_nameW, GPU_ID, RRF_RT_REG_SZ | RRF_ZEROONFAILURE, NULL,
4276 bufferW, &size ))
4277 goto done;
4278 set = SetupDiCreateDeviceInfoList( &GUID_DEVCLASS_DISPLAY, NULL );
4279 if (!SetupDiOpenDeviceInfoW( set, bufferW, NULL, 0, &device_data )
4280 || !SetupDiGetDeviceRegistryPropertyW( set, &device_data, SPDRP_HARDWAREID, NULL, (BYTE *)bufferW,
4281 sizeof(bufferW), NULL ))
4282 goto done;
4283 lstrcpyW( info->DeviceID, bufferW );
4287 /* Find monitor */
4288 else
4290 /* Check adapter name */
4291 if (strncmpiW( device, ADAPTER_PREFIX, ARRAY_SIZE(ADAPTER_PREFIX) ))
4292 goto done;
4294 adapter_index = strtolW( device + ARRAY_SIZE(ADAPTER_PREFIX), NULL, 10 );
4295 sprintfW( key_nameW, VIDEO_VALUE_FMT, adapter_index - 1 );
4297 size = sizeof(bufferW);
4298 if (RegGetValueW( HKEY_LOCAL_MACHINE, VIDEO_KEY, key_nameW, RRF_RT_REG_SZ, NULL, bufferW, &size ))
4299 goto done;
4301 /* DeviceName */
4302 sprintfW( info->DeviceName, MONITOR_FMT, adapter_index, index );
4304 /* Get monitor instance */
4305 /* Strip \Registry\Machine\ first */
4306 lstrcpyW( key_nameW, bufferW + 18 );
4307 sprintfW( bufferW, MONITOR_ID_VALUE_FMT, index );
4309 size = sizeof(instanceW);
4310 if (RegGetValueW( HKEY_CURRENT_CONFIG, key_nameW, bufferW, RRF_RT_REG_SZ, NULL, instanceW, &size ))
4311 goto done;
4313 set = SetupDiCreateDeviceInfoList( &GUID_DEVCLASS_MONITOR, NULL );
4314 if (!SetupDiOpenDeviceInfoW( set, instanceW, NULL, 0, &device_data ))
4315 goto done;
4317 /* StateFlags */
4318 if (!SetupDiGetDevicePropertyW( set, &device_data, &WINE_DEVPROPKEY_MONITOR_STATEFLAGS, &type,
4319 (BYTE *)&info->StateFlags, sizeof(info->StateFlags), NULL, 0 ))
4320 goto done;
4322 /* DeviceString */
4323 if (!SetupDiGetDeviceRegistryPropertyW( set, &device_data, SPDRP_DEVICEDESC, NULL,
4324 (BYTE *)info->DeviceString,
4325 sizeof(info->DeviceString), NULL ))
4326 goto done;
4328 /* DeviceKey */
4329 if (info->cb >= offsetof(DISPLAY_DEVICEW, DeviceKey) + sizeof(info->DeviceKey))
4331 if (!SetupDiGetDeviceRegistryPropertyW( set, &device_data, SPDRP_DRIVER, NULL, (BYTE *)bufferW,
4332 sizeof(bufferW), NULL ))
4333 goto done;
4335 lstrcpyW( info->DeviceKey, NT_CLASS );
4336 lstrcatW( info->DeviceKey, bufferW );
4339 /* DeviceID */
4340 if (info->cb >= offsetof(DISPLAY_DEVICEW, DeviceID) + sizeof(info->DeviceID))
4342 if (flags & EDD_GET_DEVICE_INTERFACE_NAME)
4344 lstrcpyW( info->DeviceID, MONITOR_INTERFACE_PREFIX );
4345 lstrcatW( info->DeviceID, instanceW );
4346 lstrcatW( info->DeviceID, GUID_DEVINTERFACE_MONITOR );
4347 /* Replace '\\' with '#' after prefix */
4348 for (next_charW = info->DeviceID + strlenW( MONITOR_INTERFACE_PREFIX ); *next_charW;
4349 next_charW++)
4351 if (*next_charW == '\\')
4352 *next_charW = '#';
4355 else
4357 if (!SetupDiGetDeviceRegistryPropertyW( set, &device_data, SPDRP_HARDWAREID, NULL, (BYTE *)bufferW,
4358 sizeof(bufferW), NULL ))
4359 goto done;
4361 lstrcpyW( info->DeviceID, bufferW );
4362 lstrcatW( info->DeviceID, BACKSLASH );
4364 if (!SetupDiGetDeviceRegistryPropertyW( set, &device_data, SPDRP_DRIVER, NULL, (BYTE *)bufferW,
4365 sizeof(bufferW), NULL ))
4366 goto done;
4368 lstrcatW( info->DeviceID, bufferW );
4373 ret = TRUE;
4374 done:
4375 release_display_device_init_mutex( mutex );
4376 SetupDiDestroyDeviceInfoList( set );
4377 if (ret)
4378 return ret;
4380 /* Fallback to report at least one adapter and monitor, if user driver didn't initialize display device registry */
4381 if (index)
4382 return FALSE;
4384 /* If user driver did initialize the registry, then exit */
4385 if (!RegOpenKeyW( HKEY_LOCAL_MACHINE, VIDEO_KEY, &hkey ))
4387 RegCloseKey( hkey );
4388 return FALSE;
4390 WARN("Reporting fallback display devices\n");
4392 /* Adapter */
4393 if (!device)
4395 memcpy( info->DeviceName, DEFAULT_ADAPTER_NAME, sizeof(DEFAULT_ADAPTER_NAME) );
4396 memcpy( info->DeviceString, DEFAULT_ADAPTER_STRING, sizeof(DEFAULT_ADAPTER_STRING) );
4397 info->StateFlags =
4398 DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE;
4399 if (info->cb >= offsetof(DISPLAY_DEVICEW, DeviceID) + sizeof(info->DeviceID))
4401 if (flags & EDD_GET_DEVICE_INTERFACE_NAME)
4402 info->DeviceID[0] = 0;
4403 else
4404 memcpy( info->DeviceID, DEFAULT_ADAPTER_ID, sizeof(DEFAULT_ADAPTER_ID) );
4407 /* Monitor */
4408 else
4410 if (lstrcmpiW( DEFAULT_ADAPTER_NAME, device ))
4411 return FALSE;
4413 memcpy( info->DeviceName, DEFAULT_MONITOR_NAME, sizeof(DEFAULT_MONITOR_NAME) );
4414 memcpy( info->DeviceString, DEFAULT_MONITOR_STRING, sizeof(DEFAULT_MONITOR_STRING) );
4415 info->StateFlags = DISPLAY_DEVICE_ACTIVE | DISPLAY_DEVICE_ATTACHED;
4416 if (info->cb >= offsetof(DISPLAY_DEVICEW, DeviceID) + sizeof(info->DeviceID))
4418 if (flags & EDD_GET_DEVICE_INTERFACE_NAME)
4419 memcpy( info->DeviceID, DEFAULT_MONITOR_INTERFACE_ID, sizeof(DEFAULT_MONITOR_INTERFACE_ID) );
4420 else
4421 memcpy( info->DeviceID, DEFAULT_MONITOR_ID, sizeof(DEFAULT_MONITOR_ID) );
4425 if (info->cb >= offsetof(DISPLAY_DEVICEW, DeviceKey) + sizeof(info->DeviceKey))
4426 info->DeviceKey[0] = 0;
4428 return TRUE;
4431 /**********************************************************************
4432 * GetAutoRotationState [USER32.@]
4434 BOOL WINAPI GetAutoRotationState( AR_STATE *state )
4436 TRACE("(%p)\n", state);
4438 if (!state)
4440 SetLastError(ERROR_INVALID_PARAMETER);
4441 return FALSE;
4444 *state = AR_NOSENSOR;
4445 return TRUE;
4448 /**********************************************************************
4449 * GetDisplayAutoRotationPreferences [USER32.@]
4451 BOOL WINAPI GetDisplayAutoRotationPreferences( ORIENTATION_PREFERENCE *orientation )
4453 FIXME("(%p): stub\n", orientation);
4454 *orientation = ORIENTATION_PREFERENCE_NONE;
4455 return TRUE;
4458 /* physical<->logical mapping functions from win8 that are nops in later versions */
4460 /***********************************************************************
4461 * GetPhysicalCursorPos (USER32.@)
4463 BOOL WINAPI GetPhysicalCursorPos( POINT *point )
4465 return GetCursorPos( point );
4468 /***********************************************************************
4469 * SetPhysicalCursorPos (USER32.@)
4471 BOOL WINAPI SetPhysicalCursorPos( INT x, INT y )
4473 return SetCursorPos( x, y );
4476 /***********************************************************************
4477 * LogicalToPhysicalPoint (USER32.@)
4479 BOOL WINAPI LogicalToPhysicalPoint( HWND hwnd, POINT *point )
4481 return TRUE;
4484 /***********************************************************************
4485 * PhysicalToLogicalPoint (USER32.@)
4487 BOOL WINAPI PhysicalToLogicalPoint( HWND hwnd, POINT *point )
4489 return TRUE;