Append .DRV to name only if no extension present.
[wine/hacks.git] / dlls / user / user_main.c
blob3d717ee12972d3d187187539f7468cb8126c9841
1 /*
2 * USER initialization code
3 */
5 #include "windef.h"
6 #include "wingdi.h"
7 #include "winuser.h"
8 #include "winreg.h"
9 #include "wine/winbase16.h"
11 #include "dce.h"
12 #include "dialog.h"
13 #include "global.h"
14 #include "input.h"
15 #include "keyboard.h"
16 #include "menu.h"
17 #include "message.h"
18 #include "queue.h"
19 #include "spy.h"
20 #include "sysmetrics.h"
21 #include "user.h"
22 #include "win.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];
39 HKEY hkey;
40 DWORD type, count;
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" );
46 return FALSE;
48 count = sizeof(buffer);
49 if (RegQueryValueExA( hkey, "GraphicsDriver", 0, &type, buffer, &count ))
50 strcpy( buffer, "x11drv" ); /* default value */
51 RegCloseKey( hkey );
53 if (!(graphics_driver = LoadLibraryA( buffer )))
55 MESSAGE( "Could not load graphics driver '%s'\n", buffer );
56 return FALSE;
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);
69 GET_USER_FUNC(Beep);
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);
92 return TRUE;
96 /***********************************************************************
97 * USER initialisation routine
99 BOOL WINAPI USER_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
101 HINSTANCE16 instance;
102 int queueSize;
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) */
117 WIN_Init();
119 /* Initialize system colors and metrics*/
120 SYSMETRICS_Init();
121 SYSCOLOR_Init();
123 /* Create the DCEs */
124 DCE_Init();
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 );
163 return TRUE;