2 * USER initialization code
9 #include "wine/winbase16.h"
20 #include "sysmetrics.h"
23 #include "debugtools.h"
25 DEFAULT_DEBUG_CHANNEL(graphics);
27 USER_DRIVER USER_Driver;
29 static HMODULE graphics_driver;
31 #define GET_USER_FUNC(name) \
32 if (!(USER_Driver.p##name = (void*)GetProcAddress( graphics_driver, #name ))) \
33 FIXME("%s not found in graphics driver\n", #name)
35 /* load the graphics driver */
36 static BOOL load_driver(void)
38 char buffer[MAX_PATH];
42 if (RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Wine", 0, NULL,
43 REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL ))
45 MESSAGE("load_driver: Cannot create config registry key\n" );
48 count = sizeof(buffer);
49 if (RegQueryValueExA( hkey, "GraphicsDriver", 0, &type, buffer, &count ))
50 strcpy( buffer, "x11drv" ); /* default value */
53 if (!(graphics_driver = LoadLibraryA( buffer )))
55 MESSAGE( "Could not load graphics driver '%s'\n", buffer );
59 GET_USER_FUNC(Synchronize);
60 GET_USER_FUNC(CheckFocus);
61 GET_USER_FUNC(UserRepaintDisable);
62 GET_USER_FUNC(InitKeyboard);
63 GET_USER_FUNC(VkKeyScan);
64 GET_USER_FUNC(MapVirtualKey);
65 GET_USER_FUNC(GetKeyNameText);
66 GET_USER_FUNC(ToAscii);
67 GET_USER_FUNC(GetBeepActive);
68 GET_USER_FUNC(SetBeepActive);
70 GET_USER_FUNC(GetDIState);
71 GET_USER_FUNC(GetDIData);
72 GET_USER_FUNC(GetKeyboardConfig);
73 GET_USER_FUNC(SetKeyboardConfig);
74 GET_USER_FUNC(InitMouse);
75 GET_USER_FUNC(SetCursor);
76 GET_USER_FUNC(MoveCursor);
77 GET_USER_FUNC(GetScreenSaveActive);
78 GET_USER_FUNC(SetScreenSaveActive);
79 GET_USER_FUNC(GetScreenSaveTimeout);
80 GET_USER_FUNC(SetScreenSaveTimeout);
81 GET_USER_FUNC(LoadOEMResource);
82 GET_USER_FUNC(IsSingleWindow);
83 GET_USER_FUNC(AcquireClipboard);
84 GET_USER_FUNC(ReleaseClipboard);
85 GET_USER_FUNC(SetClipboardData);
86 GET_USER_FUNC(GetClipboardData);
87 GET_USER_FUNC(IsClipboardFormatAvailable);
88 GET_USER_FUNC(RegisterClipboardFormat);
89 GET_USER_FUNC(IsSelectionOwner);
90 GET_USER_FUNC(ResetSelectionOwner);
96 /***********************************************************************
97 * USER initialisation routine
99 BOOL WINAPI USER_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
101 HINSTANCE16 instance;
104 if ( USER_HeapSel ) return TRUE;
106 /* Create USER heap */
107 if ((instance = LoadLibrary16( "USER.EXE" )) < 32) return FALSE;
108 USER_HeapSel = GlobalHandleToSel16( instance );
110 /* Global atom table initialisation */
111 if (!ATOM_Init( USER_HeapSel )) return FALSE;
113 /* Load the graphics driver */
114 if (!load_driver()) return FALSE;
116 /* Initialize window handling (critical section) */
119 /* Initialize system colors and metrics*/
123 /* Create the DCEs */
126 /* Initialize window procedures */
127 if (!WINPROC_Init()) return FALSE;
129 /* Initialize built-in window classes */
130 if (!WIDGETS_Init()) return FALSE;
132 /* Initialize dialog manager */
133 if (!DIALOG_Init()) return FALSE;
135 /* Initialize menus */
136 if (!MENU_Init()) return FALSE;
138 /* Initialize message spying */
139 if (!SPY_Init()) return FALSE;
141 /* Create system message queue */
142 queueSize = GetProfileIntA( "windows", "TypeAhead", 120 );
143 if (!QUEUE_CreateSysMsgQueue( queueSize )) return FALSE;
145 /* Set double click time */
146 SetDoubleClickTime( GetProfileIntA("windows","DoubleClickSpeed",452) );
148 /* Create message queue of initial thread */
149 InitThreadInput16( 0, 0 );
151 /* Create desktop window */
152 if (!WIN_CreateDesktopWindow()) return FALSE;
154 /* Initialize keyboard driver */
155 KEYBOARD_Enable( keybd_event, InputKeyStateTable );
157 /* Initialize mouse driver */
158 MOUSE_Enable( mouse_event );
160 /* Start processing X events */
161 USER_Driver.pUserRepaintDisable( FALSE );