win32u: Move set_foreground_window implementation from user32.
[wine.git] / dlls / win32u / message.c
blob6eeef1f8d493e0f3d51f6d94ddc9c7db00f9572c
1 /*
2 * Window messaging support
4 * Copyright 2001 Alexandre Julliard
5 * Copyright 2008 Maarten Lankhorst
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #if 0
24 #pragma makedep unix
25 #endif
27 #include "win32u_private.h"
28 #include "ntuser_private.h"
29 #include "wine/server.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(msg);
35 /***********************************************************************
36 * handle_internal_message
38 * Handle an internal Wine message instead of calling the window proc.
40 LRESULT handle_internal_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
42 switch(msg)
44 case WM_WINE_SETACTIVEWINDOW:
45 if (!wparam && NtUserGetForegroundWindow() == hwnd) return 0;
46 return (LRESULT)NtUserSetActiveWindow( (HWND)wparam );
47 case WM_WINE_KEYBOARD_LL_HOOK:
48 case WM_WINE_MOUSE_LL_HOOK:
50 struct hook_extra_info *h_extra = (struct hook_extra_info *)lparam;
52 return call_current_hook( h_extra->handle, HC_ACTION, wparam, h_extra->lparam );
54 case WM_WINE_CLIPCURSOR:
55 if (wparam)
57 RECT rect;
58 get_clip_cursor( &rect );
59 return user_driver->pClipCursor( &rect );
61 return user_driver->pClipCursor( NULL );
62 case WM_WINE_UPDATEWINDOWSTATE:
63 update_window_state( hwnd );
64 return 0;
65 default:
66 if (msg >= WM_WINE_FIRST_DRIVER_MSG && msg <= WM_WINE_LAST_DRIVER_MSG)
67 return user_driver->pWindowMessage( hwnd, msg, wparam, lparam );
68 FIXME( "unknown internal message %x\n", msg );
69 return 0;
73 /***********************************************************************
74 * NtUserWaitForInputIdle (win32u.@)
76 DWORD WINAPI NtUserWaitForInputIdle( HANDLE process, DWORD timeout, BOOL wow )
78 if (!user_callbacks) return 0;
79 return user_callbacks->pWaitForInputIdle( process, timeout );
82 /**********************************************************************
83 * NtUserGetGUIThreadInfo (win32u.@)
85 BOOL WINAPI NtUserGetGUIThreadInfo( DWORD id, GUITHREADINFO *info )
87 BOOL ret;
89 if (info->cbSize != sizeof(*info))
91 SetLastError( ERROR_INVALID_PARAMETER );
92 return FALSE;
95 SERVER_START_REQ( get_thread_input )
97 req->tid = id;
98 if ((ret = !wine_server_call_err( req )))
100 info->flags = 0;
101 info->hwndActive = wine_server_ptr_handle( reply->active );
102 info->hwndFocus = wine_server_ptr_handle( reply->focus );
103 info->hwndCapture = wine_server_ptr_handle( reply->capture );
104 info->hwndMenuOwner = wine_server_ptr_handle( reply->menu_owner );
105 info->hwndMoveSize = wine_server_ptr_handle( reply->move_size );
106 info->hwndCaret = wine_server_ptr_handle( reply->caret );
107 info->rcCaret.left = reply->rect.left;
108 info->rcCaret.top = reply->rect.top;
109 info->rcCaret.right = reply->rect.right;
110 info->rcCaret.bottom = reply->rect.bottom;
111 if (reply->menu_owner) info->flags |= GUI_INMENUMODE;
112 if (reply->move_size) info->flags |= GUI_INMOVESIZE;
113 if (reply->caret) info->flags |= GUI_CARETBLINKING;
116 SERVER_END_REQ;
117 return ret;
120 /* see SendMessageW */
121 LRESULT send_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
123 /* FIXME: move implementation from user32 */
124 if (!user_callbacks) return 0;
125 return user_callbacks->pSendMessageW( hwnd, msg, wparam, lparam );
128 /* see SendNotifyMessageW */
129 static BOOL send_notify_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, BOOL ansi )
131 return user_callbacks && user_callbacks->pSendNotifyMessageW( hwnd, msg, wparam, lparam );
134 /* see PostMessageW */
135 LRESULT post_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
137 /* FIXME: move implementation from user32 */
138 if (!user_callbacks) return 0;
139 return user_callbacks->pPostMessageW( hwnd, msg, wparam, lparam );
142 BOOL WINAPI NtUserMessageCall( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
143 ULONG_PTR result_info, DWORD type, BOOL ansi )
145 switch (type)
147 case FNID_SENDNOTIFYMESSAGE:
148 return send_notify_message( hwnd, msg, wparam, lparam, ansi );
149 default:
150 FIXME( "%p %x %lx %lx %lx %x %x\n", hwnd, msg, wparam, lparam, result_info, type, ansi );
152 return 0;