Commit f5b3283e authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

win32u: Move window input context handling from imm32.

parent 3e8a4b67
......@@ -146,3 +146,72 @@ UINT_PTR WINAPI NtUserQueryInputContext( HIMC handle, UINT attr )
release_imc_ptr( imc );
return ret;
}
/******************************************************************************
* NtUserAssociateInputContext (win32u.@)
*/
UINT WINAPI NtUserAssociateInputContext( HWND hwnd, HIMC ctx, ULONG flags )
{
WND *win;
UINT ret = AICR_OK;
TRACE( "%p %p %x\n", hwnd, ctx, flags );
switch (flags)
{
case 0:
case IACE_IGNORENOCONTEXT:
case IACE_DEFAULT:
break;
default:
FIXME( "unknown flags 0x%x\n", flags );
return AICR_FAILED;
}
if (flags == IACE_DEFAULT)
{
if (!(ctx = get_default_input_context())) return AICR_FAILED;
}
else if (ctx)
{
if (NtUserQueryInputContext( ctx, NtUserInputContextThreadId ) != GetCurrentThreadId())
return AICR_FAILED;
}
if (!(win = get_win_ptr( hwnd )) || win == WND_OTHER_PROCESS || win == WND_DESKTOP)
return AICR_FAILED;
if (ctx && win->tid != GetCurrentThreadId()) ret = AICR_FAILED;
else if (flags != IACE_IGNORENOCONTEXT || win->imc)
{
if (win->imc != ctx && get_focus() == hwnd) ret = AICR_FOCUS_CHANGED;
win->imc = ctx;
}
release_win_ptr( win );
return ret;
}
HIMC get_default_input_context(void)
{
struct ntuser_thread_info *thread_info = NtUserGetThreadInfo();
if (!thread_info->default_imc) thread_info->default_imc = NtUserCreateInputContext( 0 );
return thread_info->default_imc;
}
HIMC get_window_input_context( HWND hwnd )
{
WND *win;
HIMC ret;
if (!(win = get_win_ptr( hwnd )) || win == WND_OTHER_PROCESS || win == WND_DESKTOP)
{
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0;
}
ret = win->imc;
release_win_ptr( win );
return ret;
}
......@@ -105,6 +105,7 @@ typedef struct tagWND
HICON hIcon; /* window's icon */
HICON hIconSmall; /* window's small icon */
HICON hIconSmall2; /* window's secondary small icon, derived from hIcon */
HIMC imc; /* window's input context */
UINT dpi; /* window DPI */
DPI_AWARENESS dpi_awareness; /* DPI awareness */
struct window_surface *surface; /* Window surface if any */
......
......@@ -101,6 +101,7 @@ static void * const syscalls[] =
NtGdiSwapBuffers,
NtGdiTransformPoints,
NtUserAddClipboardFormatListener,
NtUserAssociateInputContext,
NtUserAttachThreadInput,
NtUserBuildHwndList,
NtUserCallMsgFilter,
......
......@@ -4818,6 +4818,7 @@ static void thread_detach(void)
free( thread_info->rawinput );
destroy_thread_windows();
NtUserDestroyInputContext( thread_info->client_info.default_imc );
NtClose( thread_info->server_queue );
exiting_thread_id = 0;
......
......@@ -753,7 +753,7 @@
@ stdcall -syscall NtUserAddClipboardFormatListener(long)
@ stub NtUserAddVisualIdentifier
@ stub NtUserAlterWindowStyle
@ stub NtUserAssociateInputContext
@ stdcall -syscall NtUserAssociateInputContext(long long long)
@ stdcall -syscall NtUserAttachThreadInput(long long long)
@ stub NtUserAutoPromoteMouseInPointer
@ stub NtUserAutoRotateScreen
......
......@@ -392,6 +392,10 @@ extern LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM l
extern LRESULT call_hooks( INT id, INT code, WPARAM wparam, LPARAM lparam, BOOL unicode ) DECLSPEC_HIDDEN;
extern BOOL unhook_windows_hook( INT id, HOOKPROC proc ) DECLSPEC_HIDDEN;
/* imm.c */
extern HIMC get_default_input_context(void) DECLSPEC_HIDDEN;
extern HIMC get_window_input_context( HWND hwnd ) DECLSPEC_HIDDEN;
/* input.c */
extern BOOL destroy_caret(void) DECLSPEC_HIDDEN;
extern LONG global_key_state_counter DECLSPEC_HIDDEN;
......
......@@ -5163,6 +5163,8 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name,
if (win->dwStyle & WS_SYSMENU) NtUserSetSystemMenu( hwnd, 0 );
win->imc = get_default_input_context();
/* call the WH_CBT hook */
release_win_ptr( win );
......@@ -5387,6 +5389,9 @@ ULONG_PTR WINAPI NtUserCallHwnd( HWND hwnd, DWORD code )
case NtUserCallHwnd_GetWindowDpiAwarenessContext:
return (ULONG_PTR)get_window_dpi_awareness_context( hwnd );
case NtUserCallHwnd_GetWindowInputContext:
return HandleToUlong( get_window_input_context( hwnd ));
case NtUserCallHwnd_GetWindowTextLength:
return get_server_window_text( hwnd, NULL, 0 );
......
......@@ -88,6 +88,7 @@
SYSCALL_ENTRY( NtGdiSwapBuffers ) \
SYSCALL_ENTRY( NtGdiTransformPoints ) \
SYSCALL_ENTRY( NtUserAddClipboardFormatListener ) \
SYSCALL_ENTRY( NtUserAssociateInputContext ) \
SYSCALL_ENTRY( NtUserAttachThreadInput ) \
SYSCALL_ENTRY( NtUserBuildHwndList ) \
SYSCALL_ENTRY( NtUserCallMsgFilter ) \
......
......@@ -111,6 +111,15 @@ NTSTATUS WINAPI wow64_NtUserAddClipboardFormatListener( UINT *args )
return NtUserAddClipboardFormatListener( hwnd );
}
NTSTATUS WINAPI wow64_NtUserAssociateInputContext( UINT *args )
{
HWND hwnd = get_handle( &args );
HIMC ctx = get_handle( &args );
ULONG flags = get_ulong( &args );
return NtUserAssociateInputContext( hwnd, ctx, flags );
}
NTSTATUS WINAPI wow64_NtUserAttachThreadInput( UINT *args )
{
DWORD from = get_ulong( &args );
......
......@@ -63,6 +63,7 @@ struct ntuser_thread_info
ULONG_PTR message_extra; /* value for GetMessageExtraInfo */
HWND top_window; /* desktop window */
HWND msg_window; /* HWND_MESSAGE parent window */
HIMC default_imc; /* default input context */
void *client_imm; /* client IMM thread info */
};
......@@ -368,6 +369,14 @@ enum input_context_attr
NtUserInputContextThreadId,
};
/* NtUserAssociateInputContext result */
enum associate_input_context_result
{
AICR_OK,
AICR_FOCUS_CHANGED,
AICR_FAILED,
};
/* internal messages codes */
enum wine_internal_message
{
......@@ -546,6 +555,7 @@ struct packed_MDICREATESTRUCTW
HKL WINAPI NtUserActivateKeyboardLayout( HKL layout, UINT flags );
BOOL WINAPI NtUserAddClipboardFormatListener( HWND hwnd );
UINT WINAPI NtUserAssociateInputContext( HWND hwnd, HIMC ctx, ULONG flags );
BOOL WINAPI NtUserAttachThreadInput( DWORD from, DWORD to, BOOL attach );
HDC WINAPI NtUserBeginPaint( HWND hwnd, PAINTSTRUCT *ps );
NTSTATUS WINAPI NtUserBuildHwndList( HDESK desktop, ULONG unk2, ULONG unk3, ULONG unk4,
......@@ -1049,6 +1059,7 @@ enum
NtUserCallHwnd_GetParent,
NtUserCallHwnd_GetWindowContextHelpId,
NtUserCallHwnd_GetWindowDpiAwarenessContext,
NtUserCallHwnd_GetWindowInputContext,
NtUserCallHwnd_GetWindowTextLength,
NtUserCallHwnd_IsWindow,
NtUserCallHwnd_IsWindowEnabled,
......@@ -1088,6 +1099,11 @@ static inline DPI_AWARENESS_CONTEXT NtUserGetWindowDpiAwarenessContext( HWND hwn
NtUserCallHwnd_GetWindowDpiAwarenessContext );
}
static inline HIMC NtUserGetWindowInputContext( HWND hwnd )
{
return UlongToHandle( NtUserCallHwnd( hwnd, NtUserCallHwnd_GetWindowInputContext ));
}
static inline INT NtUserGetWindowTextLength( HWND hwnd )
{
return NtUserCallHwnd( hwnd, NtUserCallHwnd_GetWindowTextLength );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment