2 * USER initialization code
9 #include "wine/winbase16.h"
10 #include "wine/winuser16.h"
21 #include "sysmetrics.h"
24 #include "debugtools.h"
26 DEFAULT_DEBUG_CHANNEL(graphics);
28 USER_DRIVER USER_Driver;
30 static HMODULE graphics_driver;
32 #define GET_USER_FUNC(name) \
33 if (!(USER_Driver.p##name = (void*)GetProcAddress( graphics_driver, #name ))) \
34 FIXME("%s not found in graphics driver\n", #name)
36 /* load the graphics driver */
37 static BOOL load_driver(void)
39 char buffer[MAX_PATH];
43 if (RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\Wine", 0, NULL,
44 REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL ))
46 MESSAGE("load_driver: Cannot create config registry key\n" );
49 count = sizeof(buffer);
50 if (RegQueryValueExA( hkey, "GraphicsDriver", 0, &type, buffer, &count ))
51 strcpy( buffer, "x11drv" ); /* default value */
54 if (!(graphics_driver = LoadLibraryA( buffer )))
56 MESSAGE( "Could not load graphics driver '%s'\n", buffer );
60 GET_USER_FUNC(Synchronize);
61 GET_USER_FUNC(CheckFocus);
62 GET_USER_FUNC(UserRepaintDisable);
63 GET_USER_FUNC(InitKeyboard);
64 GET_USER_FUNC(VkKeyScan);
65 GET_USER_FUNC(MapVirtualKey);
66 GET_USER_FUNC(GetKeyNameText);
67 GET_USER_FUNC(ToAscii);
68 GET_USER_FUNC(GetBeepActive);
69 GET_USER_FUNC(SetBeepActive);
71 GET_USER_FUNC(GetDIState);
72 GET_USER_FUNC(GetDIData);
73 GET_USER_FUNC(GetKeyboardConfig);
74 GET_USER_FUNC(SetKeyboardConfig);
75 GET_USER_FUNC(InitMouse);
76 GET_USER_FUNC(SetCursor);
77 GET_USER_FUNC(MoveCursor);
78 GET_USER_FUNC(GetScreenSaveActive);
79 GET_USER_FUNC(SetScreenSaveActive);
80 GET_USER_FUNC(GetScreenSaveTimeout);
81 GET_USER_FUNC(SetScreenSaveTimeout);
82 GET_USER_FUNC(LoadOEMResource);
83 GET_USER_FUNC(IsSingleWindow);
84 GET_USER_FUNC(AcquireClipboard);
85 GET_USER_FUNC(ReleaseClipboard);
86 GET_USER_FUNC(SetClipboardData);
87 GET_USER_FUNC(GetClipboardData);
88 GET_USER_FUNC(IsClipboardFormatAvailable);
89 GET_USER_FUNC(RegisterClipboardFormat);
90 GET_USER_FUNC(IsSelectionOwner);
91 GET_USER_FUNC(ResetSelectionOwner);
97 /***********************************************************************
100 * Patch the function pointers in GDI for SelectPalette and RealizePalette
102 static void palette_init(void)
105 HMODULE module = GetModuleHandleA( "gdi32" );
108 ERR( "cannot get GDI32 handle\n" );
111 if ((ptr = (void**)GetProcAddress( module, "pfnSelectPalette" ))) *ptr = SelectPalette16;
112 else ERR( "cannot find pfnSelectPalette in GDI32\n" );
113 if ((ptr = (void**)GetProcAddress( module, "pfnRealizePalette" ))) *ptr = UserRealizePalette;
114 else ERR( "cannot find pfnRealizePalette in GDI32\n" );
118 /***********************************************************************
119 * USER initialisation routine
121 BOOL WINAPI USER_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
123 HINSTANCE16 instance;
126 if ( USER_HeapSel ) return TRUE;
128 /* Create USER heap */
129 if ((instance = LoadLibrary16( "USER.EXE" )) < 32) return FALSE;
130 USER_HeapSel = GlobalHandleToSel16( instance );
132 /* Global atom table initialisation */
133 if (!ATOM_Init( USER_HeapSel )) return FALSE;
135 /* Load the graphics driver */
136 if (!load_driver()) return FALSE;
138 /* Initialize window handling (critical section) */
141 /* Initialize system colors and metrics*/
145 /* Setup palette function pointers */
148 /* Create the DCEs */
151 /* Initialize window procedures */
152 if (!WINPROC_Init()) return FALSE;
154 /* Initialize built-in window classes */
155 if (!WIDGETS_Init()) return FALSE;
157 /* Initialize dialog manager */
158 if (!DIALOG_Init()) return FALSE;
160 /* Initialize menus */
161 if (!MENU_Init()) return FALSE;
163 /* Initialize message spying */
164 if (!SPY_Init()) return FALSE;
166 /* Create system message queue */
167 queueSize = GetProfileIntA( "windows", "TypeAhead", 120 );
168 if (!QUEUE_CreateSysMsgQueue( queueSize )) return FALSE;
170 /* Set double click time */
171 SetDoubleClickTime( GetProfileIntA("windows","DoubleClickSpeed",452) );
173 /* Create message queue of initial thread */
174 InitThreadInput16( 0, 0 );
176 /* Create desktop window */
177 if (!WIN_CreateDesktopWindow()) return FALSE;
179 /* Initialize keyboard driver */
180 KEYBOARD_Enable( keybd_event, InputKeyStateTable );
182 /* Initialize mouse driver */
183 MOUSE_Enable( mouse_event );
185 /* Start processing X events */
186 USER_Driver.pUserRepaintDisable( FALSE );