Reimplemented Get/SetActiveWindow, Get/SetFocus and
Get/SetForegroundWindow by storing the information in the
server. Implemented correct inter-process window activation.

diff --git a/include/user.h b/include/user.h
index 13fbbd7..69f75cf 100644
--- a/include/user.h
+++ b/include/user.h
@@ -57,7 +57,8 @@
     WM_WINE_SHOWWINDOW,
     WM_WINE_SETPARENT,
     WM_WINE_SETWINDOWLONG,
-    WM_WINE_ENABLEWINDOW
+    WM_WINE_ENABLEWINDOW,
+    WM_WINE_SETACTIVEWINDOW
 };
 
 /* internal SendInput codes (FIXME) */
diff --git a/include/win.h b/include/win.h
index 7c69f62..c83e9e1 100644
--- a/include/win.h
+++ b/include/win.h
@@ -143,6 +143,8 @@
 
 extern HBRUSH DEFWND_ControlColor( HDC hDC, UINT ctlType );  /* windows/defwnd.c */
 
+extern BOOL FOCUS_MouseActivate( HWND hwnd );
+
 /* Classes functions */
 struct tagCLASS;  /* opaque structure */
 struct builtin_class_descr;
@@ -153,7 +155,4 @@
 extern void CLASS_RemoveWindow( struct tagCLASS *cls );
 extern void CLASS_FreeModuleClasses( HMODULE16 hModule );
 
-/* windows/focus.c */
-extern void FOCUS_SwitchFocus( struct tagMESSAGEQUEUE *pMsgQ, HWND , HWND );
-
 #endif  /* __WINE_WIN_H */
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index 01b6e19..7e0457d 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -2507,6 +2507,7 @@
 {
     struct reply_header __header;
     user_handle_t  full_handle;
+    user_handle_t  last_active;
     process_id_t   pid;
     thread_id_t    tid;
     atom_t         atom;
@@ -2763,6 +2764,44 @@
 };
 
 
+struct set_foreground_window_request
+{
+    struct request_header __header;
+    user_handle_t  handle;
+};
+struct set_foreground_window_reply
+{
+    struct reply_header __header;
+    user_handle_t  previous;
+    int            send_msg_old;
+    int            send_msg_new;
+};
+
+
+struct set_focus_window_request
+{
+    struct request_header __header;
+    user_handle_t  handle;
+};
+struct set_focus_window_reply
+{
+    struct reply_header __header;
+    user_handle_t  previous;
+};
+
+
+struct set_active_window_request
+{
+    struct request_header __header;
+    user_handle_t  handle;
+};
+struct set_active_window_reply
+{
+    struct reply_header __header;
+    user_handle_t  previous;
+};
+
+
 enum request
 {
     REQ_new_process,
@@ -2923,6 +2962,9 @@
     REQ_get_window_properties,
     REQ_attach_thread_input,
     REQ_get_thread_input,
+    REQ_set_foreground_window,
+    REQ_set_focus_window,
+    REQ_set_active_window,
     REQ_NB_REQUESTS
 };
 
@@ -3088,6 +3130,9 @@
     struct get_window_properties_request get_window_properties_request;
     struct attach_thread_input_request attach_thread_input_request;
     struct get_thread_input_request get_thread_input_request;
+    struct set_foreground_window_request set_foreground_window_request;
+    struct set_focus_window_request set_focus_window_request;
+    struct set_active_window_request set_active_window_request;
 };
 union generic_reply
 {
@@ -3251,8 +3296,11 @@
     struct get_window_properties_reply get_window_properties_reply;
     struct attach_thread_input_reply attach_thread_input_reply;
     struct get_thread_input_reply get_thread_input_reply;
+    struct set_foreground_window_reply set_foreground_window_reply;
+    struct set_focus_window_reply set_focus_window_reply;
+    struct set_active_window_reply set_active_window_reply;
 };
 
-#define SERVER_PROTOCOL_VERSION 85
+#define SERVER_PROTOCOL_VERSION 86
 
 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
diff --git a/include/winpos.h b/include/winpos.h
index 3b05228..f972b55 100644
--- a/include/winpos.h
+++ b/include/winpos.h
@@ -39,8 +39,6 @@
 extern BOOL WINPOS_ShowIconTitle( HWND hwnd, BOOL bShow );
 extern void WINPOS_GetMinMaxInfo( HWND hwnd, POINT *maxSize, POINT *maxPos, POINT *minTrack,
                                   POINT *maxTrack );
-extern BOOL WINPOS_SetActiveWindow( HWND hWnd, BOOL fMouse,
-                                      BOOL fChangeFocus );
 extern LONG WINPOS_HandleWindowPosChanging16(HWND hwnd, struct tagWINDOWPOS16 *winpos);
 extern LONG WINPOS_HandleWindowPosChanging(HWND hwnd, WINDOWPOS *winpos);
 extern HWND WINPOS_WindowFromPoint( HWND hwndScope, POINT pt, INT *hittest );