2 * USER initialization code
11 #include "wine/winbase16.h"
12 #include "wine/winuser16.h"
22 #include "sysmetrics.h"
25 #include "debugtools.h"
27 DEFAULT_DEBUG_CHANNEL(graphics
);
29 USER_DRIVER USER_Driver
;
31 WINE_LOOK TWEAK_WineLook
= WIN31_LOOK
;
33 WORD USER_HeapSel
= 0; /* USER heap selector */
35 static HMODULE graphics_driver
;
37 #define GET_USER_FUNC(name) \
38 if (!(USER_Driver.p##name = (void*)GetProcAddress( graphics_driver, #name ))) \
39 FIXME("%s not found in graphics driver\n", #name)
41 /* load the graphics driver */
42 static BOOL
load_driver(void)
44 char buffer
[MAX_PATH
];
48 strcpy( buffer
, "x11drv" ); /* default value */
49 if (!RegOpenKeyA( HKEY_LOCAL_MACHINE
, "Software\\Wine\\Wine\\Config\\Wine", &hkey
))
51 count
= sizeof(buffer
);
52 RegQueryValueExA( hkey
, "GraphicsDriver", 0, &type
, buffer
, &count
);
56 if (!(graphics_driver
= LoadLibraryA( buffer
)))
58 MESSAGE( "Could not load graphics driver '%s'\n", buffer
);
62 GET_USER_FUNC(Synchronize
);
63 GET_USER_FUNC(CheckFocus
);
64 GET_USER_FUNC(UserRepaintDisable
);
65 GET_USER_FUNC(InitKeyboard
);
66 GET_USER_FUNC(VkKeyScan
);
67 GET_USER_FUNC(MapVirtualKey
);
68 GET_USER_FUNC(GetKeyNameText
);
69 GET_USER_FUNC(ToUnicode
);
70 GET_USER_FUNC(GetBeepActive
);
71 GET_USER_FUNC(SetBeepActive
);
73 GET_USER_FUNC(GetDIState
);
74 GET_USER_FUNC(GetDIData
);
75 GET_USER_FUNC(GetKeyboardConfig
);
76 GET_USER_FUNC(SetKeyboardConfig
);
77 GET_USER_FUNC(InitMouse
);
78 GET_USER_FUNC(SetCursor
);
79 GET_USER_FUNC(MoveCursor
);
80 GET_USER_FUNC(GetScreenSaveActive
);
81 GET_USER_FUNC(SetScreenSaveActive
);
82 GET_USER_FUNC(GetScreenSaveTimeout
);
83 GET_USER_FUNC(SetScreenSaveTimeout
);
84 GET_USER_FUNC(LoadOEMResource
);
85 GET_USER_FUNC(IsSingleWindow
);
86 GET_USER_FUNC(AcquireClipboard
);
87 GET_USER_FUNC(ReleaseClipboard
);
88 GET_USER_FUNC(SetClipboardData
);
89 GET_USER_FUNC(GetClipboardData
);
90 GET_USER_FUNC(IsClipboardFormatAvailable
);
91 GET_USER_FUNC(RegisterClipboardFormat
);
92 GET_USER_FUNC(IsSelectionOwner
);
93 GET_USER_FUNC(ResetSelectionOwner
);
99 /***********************************************************************
102 * Register the classes for the builtin controls
104 static void controls_init(void)
106 extern const struct builtin_class_descr BUTTON_builtin_class
;
107 extern const struct builtin_class_descr COMBO_builtin_class
;
108 extern const struct builtin_class_descr COMBOLBOX_builtin_class
;
109 extern const struct builtin_class_descr DIALOG_builtin_class
;
110 extern const struct builtin_class_descr DESKTOP_builtin_class
;
111 extern const struct builtin_class_descr EDIT_builtin_class
;
112 extern const struct builtin_class_descr ICONTITLE_builtin_class
;
113 extern const struct builtin_class_descr LISTBOX_builtin_class
;
114 extern const struct builtin_class_descr MDICLIENT_builtin_class
;
115 extern const struct builtin_class_descr MENU_builtin_class
;
116 extern const struct builtin_class_descr SCROLL_builtin_class
;
117 extern const struct builtin_class_descr STATIC_builtin_class
;
119 CLASS_RegisterBuiltinClass( &BUTTON_builtin_class
);
120 CLASS_RegisterBuiltinClass( &COMBO_builtin_class
);
121 CLASS_RegisterBuiltinClass( &COMBOLBOX_builtin_class
);
122 CLASS_RegisterBuiltinClass( &DIALOG_builtin_class
);
123 CLASS_RegisterBuiltinClass( &DESKTOP_builtin_class
);
124 CLASS_RegisterBuiltinClass( &EDIT_builtin_class
);
125 CLASS_RegisterBuiltinClass( &ICONTITLE_builtin_class
);
126 CLASS_RegisterBuiltinClass( &LISTBOX_builtin_class
);
127 CLASS_RegisterBuiltinClass( &MDICLIENT_builtin_class
);
128 CLASS_RegisterBuiltinClass( &MENU_builtin_class
);
129 CLASS_RegisterBuiltinClass( &SCROLL_builtin_class
);
130 CLASS_RegisterBuiltinClass( &STATIC_builtin_class
);
134 /***********************************************************************
137 * Patch the function pointers in GDI for SelectPalette and RealizePalette
139 static void palette_init(void)
142 HMODULE module
= GetModuleHandleA( "gdi32" );
145 ERR( "cannot get GDI32 handle\n" );
148 if ((ptr
= (void**)GetProcAddress( module
, "pfnSelectPalette" ))) *ptr
= SelectPalette16
;
149 else ERR( "cannot find pfnSelectPalette in GDI32\n" );
150 if ((ptr
= (void**)GetProcAddress( module
, "pfnRealizePalette" ))) *ptr
= UserRealizePalette
;
151 else ERR( "cannot find pfnRealizePalette in GDI32\n" );
155 /***********************************************************************
158 static void tweak_init(void)
160 static const char *OS
= "Win3.1";
163 DWORD type
, count
= sizeof(buffer
);
165 if (RegOpenKeyA( HKEY_LOCAL_MACHINE
, "Software\\Wine\\Wine\\Config\\Tweak.Layout", &hkey
))
167 if (RegQueryValueExA( hkey
, "WineLook", 0, &type
, buffer
, &count
))
168 strcpy( buffer
, "Win31" ); /* default value */
171 /* WIN31_LOOK is default */
172 if (!strncasecmp( buffer
, "Win95", 5 ))
174 TWEAK_WineLook
= WIN95_LOOK
;
177 else if (!strncasecmp( buffer
, "Win98", 5 ))
179 TWEAK_WineLook
= WIN98_LOOK
;
182 TRACE("Using %s look and feel.\n", OS
);
186 /***********************************************************************
187 * USER initialisation routine
189 BOOL WINAPI
USER_Init(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
191 HINSTANCE16 instance
;
194 if ( USER_HeapSel
) return TRUE
;
196 /* Create USER heap */
197 if ((instance
= LoadLibrary16( "USER.EXE" )) < 32) return FALSE
;
198 USER_HeapSel
= instance
| 7;
200 /* Global atom table initialisation */
201 if (!ATOM_Init( USER_HeapSel
)) return FALSE
;
203 /* Load the graphics driver */
205 if (!load_driver()) return FALSE
;
207 /* Initialize system colors and metrics*/
211 /* Setup palette function pointers */
214 /* Create the DCEs */
217 /* Initialize window procedures */
218 if (!WINPROC_Init()) return FALSE
;
220 /* Initialize built-in window classes */
223 /* Initialize dialog manager */
224 if (!DIALOG_Init()) return FALSE
;
226 /* Initialize menus */
227 if (!MENU_Init()) return FALSE
;
229 /* Initialize message spying */
230 if (!SPY_Init()) return FALSE
;
232 /* Create system message queue */
233 queueSize
= GetProfileIntA( "windows", "TypeAhead", 120 );
234 if (!QUEUE_CreateSysMsgQueue( queueSize
)) return FALSE
;
236 /* Set double click time */
237 SetDoubleClickTime( GetProfileIntA("windows","DoubleClickSpeed",452) );
239 /* Create message queue of initial thread */
240 InitThreadInput16( 0, 0 );
242 /* Create desktop window */
243 if (!WIN_CreateDesktopWindow()) return FALSE
;
245 /* Initialize keyboard driver */
246 KEYBOARD_Enable( keybd_event
, InputKeyStateTable
);
248 /* Initialize mouse driver */
249 MOUSE_Enable( mouse_event
);
251 /* Start processing X events */
252 USER_Driver
.pUserRepaintDisable( FALSE
);