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

win32u: Move NtUserSetActiveWindow implementation from user32.

parent b88f06fd
...@@ -235,36 +235,6 @@ BOOL FOCUS_MouseActivate( HWND hwnd ) ...@@ -235,36 +235,6 @@ BOOL FOCUS_MouseActivate( HWND hwnd )
} }
/*******************************************************************
* SetActiveWindow (USER32.@)
*/
HWND WINAPI SetActiveWindow( HWND hwnd )
{
HWND prev;
TRACE( "%p\n", hwnd );
if (hwnd)
{
LONG style;
hwnd = WIN_GetFullHandle( hwnd );
if (!IsWindow( hwnd ))
{
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0;
}
style = GetWindowLongW( hwnd, GWL_STYLE );
if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD)
return GetActiveWindow(); /* Windows doesn't seem to return an error here */
}
if (!set_active_window( hwnd, &prev, FALSE, TRUE )) return 0;
return prev;
}
/***************************************************************** /*****************************************************************
* SetFocus (USER32.@) * SetFocus (USER32.@)
*/ */
......
...@@ -184,7 +184,7 @@ LRESULT WINAPI IconTitleWndProc( HWND hWnd, UINT msg, ...@@ -184,7 +184,7 @@ LRESULT WINAPI IconTitleWndProc( HWND hWnd, UINT msg,
case WM_NCLBUTTONDBLCLK: case WM_NCLBUTTONDBLCLK:
return SendMessageW( owner, msg, wParam, lParam ); return SendMessageW( owner, msg, wParam, lParam );
case WM_ACTIVATE: case WM_ACTIVATE:
if( wParam ) SetActiveWindow( owner ); if (wParam) NtUserSetActiveWindow( owner );
return 0; return 0;
case WM_CLOSE: case WM_CLOSE:
return 0; return 0;
......
...@@ -1875,9 +1875,6 @@ LRESULT handle_internal_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar ...@@ -1875,9 +1875,6 @@ LRESULT handle_internal_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar
case WM_WINE_SETSTYLE: case WM_WINE_SETSTYLE:
if (is_desktop_window( hwnd )) return 0; if (is_desktop_window( hwnd )) return 0;
return WIN_SetStyle(hwnd, wparam, lparam); return WIN_SetStyle(hwnd, wparam, lparam);
case WM_WINE_SETACTIVEWINDOW:
if (!wparam && NtUserGetForegroundWindow() == hwnd) return 0;
return (LRESULT)SetActiveWindow( (HWND)wparam );
default: default:
{ {
MSG m; MSG m;
......
...@@ -644,7 +644,7 @@ ...@@ -644,7 +644,7 @@
@ stdcall SendNotifyMessageA(long long long long) @ stdcall SendNotifyMessageA(long long long long)
@ stdcall SendNotifyMessageW(long long long long) @ stdcall SendNotifyMessageW(long long long long)
@ stub ServerSetFunctionPointers @ stub ServerSetFunctionPointers
@ stdcall SetActiveWindow(long) @ stdcall SetActiveWindow(long) NtUserSetActiveWindow
@ stdcall SetCapture(long) @ stdcall SetCapture(long)
@ stdcall SetCaretBlinkTime(long) @ stdcall SetCaretBlinkTime(long)
@ stdcall SetCaretPos(long long) @ stdcall SetCaretPos(long long)
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "winbase.h" #include "winbase.h"
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h" #include "winuser.h"
#include "imm.h"
#include "controls.h" #include "controls.h"
#include "user_private.h" #include "user_private.h"
...@@ -133,6 +134,12 @@ static void dpiaware_init(void) ...@@ -133,6 +134,12 @@ static void dpiaware_init(void)
} }
} }
static void CDECL notify_ime( HWND hwnd, UINT param )
{
HWND ime_default = ImmGetDefaultIMEWnd( hwnd );
if (ime_default) SendMessageW( ime_default, WM_IME_INTERNAL, param, HandleToUlong(hwnd) );
}
static const struct user_callbacks user_funcs = static const struct user_callbacks user_funcs =
{ {
CopyImage, CopyImage,
...@@ -144,6 +151,7 @@ static const struct user_callbacks user_funcs = ...@@ -144,6 +151,7 @@ static const struct user_callbacks user_funcs =
WaitForInputIdle, WaitForInputIdle,
WindowFromDC, WindowFromDC,
free_dce, free_dce,
notify_ime,
register_builtin_classes, register_builtin_classes,
MSG_SendInternalMessageTimeout, MSG_SendInternalMessageTimeout,
(void *)__wine_set_user_driver, (void *)__wine_set_user_driver,
......
...@@ -82,9 +82,6 @@ struct rawinput_thread_data ...@@ -82,9 +82,6 @@ struct rawinput_thread_data
extern BOOL (WINAPI *imm_register_window)(HWND) DECLSPEC_HIDDEN; extern BOOL (WINAPI *imm_register_window)(HWND) DECLSPEC_HIDDEN;
extern void (WINAPI *imm_unregister_window)(HWND) DECLSPEC_HIDDEN; extern void (WINAPI *imm_unregister_window)(HWND) DECLSPEC_HIDDEN;
#define WM_IME_INTERNAL 0x287
#define IME_INTERNAL_ACTIVATE 0x17
#define IME_INTERNAL_DEACTIVATE 0x18
static inline struct user_thread_info *get_user_thread_info(void) static inline struct user_thread_info *get_user_thread_info(void)
{ {
......
...@@ -1458,7 +1458,7 @@ void WINPOS_ActivateOtherWindow(HWND hwnd) ...@@ -1458,7 +1458,7 @@ void WINPOS_ActivateOtherWindow(HWND hwnd)
{ {
if (SetForegroundWindow( hwndTo )) return; if (SetForegroundWindow( hwndTo )) return;
} }
if (!SetActiveWindow( hwndTo )) SetActiveWindow(0); if (!NtUserSetActiveWindow( hwndTo )) NtUserSetActiveWindow( 0 );
} }
......
...@@ -195,7 +195,7 @@ NTSTATUS WINAPI NtUserInitializeClientPfnArrays( const struct user_client_procs ...@@ -195,7 +195,7 @@ NTSTATUS WINAPI NtUserInitializeClientPfnArrays( const struct user_client_procs
/*********************************************************************** /***********************************************************************
* get_int_atom_value * get_int_atom_value
*/ */
static ATOM get_int_atom_value( UNICODE_STRING *name ) ATOM get_int_atom_value( UNICODE_STRING *name )
{ {
const WCHAR *ptr = name->Buffer; const WCHAR *ptr = name->Buffer;
const WCHAR *end = ptr + name->Length / sizeof(WCHAR); const WCHAR *end = ptr + name->Length / sizeof(WCHAR);
......
...@@ -1189,6 +1189,7 @@ static const struct user_driver_funcs lazy_load_driver = ...@@ -1189,6 +1189,7 @@ static const struct user_driver_funcs lazy_load_driver =
.pSetWindowRgn = loaderdrv_SetWindowRgn, .pSetWindowRgn = loaderdrv_SetWindowRgn,
.pMsgWaitForMultipleObjectsEx = nulldrv_MsgWaitForMultipleObjectsEx, .pMsgWaitForMultipleObjectsEx = nulldrv_MsgWaitForMultipleObjectsEx,
.pScrollDC = nulldrv_ScrollDC, .pScrollDC = nulldrv_ScrollDC,
.pSetFocus = nulldrv_SetFocus,
.pUpdateLayeredWindow = loaderdrv_UpdateLayeredWindow, .pUpdateLayeredWindow = loaderdrv_UpdateLayeredWindow,
.pWindowMessage = nulldrv_WindowMessage, .pWindowMessage = nulldrv_WindowMessage,
/* system parameters */ /* system parameters */
......
...@@ -1182,6 +1182,7 @@ static struct unix_funcs unix_funcs = ...@@ -1182,6 +1182,7 @@ static struct unix_funcs unix_funcs =
NtUserRegisterHotKey, NtUserRegisterHotKey,
NtUserScrollDC, NtUserScrollDC,
NtUserSelectPalette, NtUserSelectPalette,
NtUserSetActiveWindow,
NtUserSetClassLong, NtUserSetClassLong,
NtUserSetClassLongPtr, NtUserSetClassLongPtr,
NtUserSetClassWord, NtUserSetClassWord,
......
...@@ -1086,3 +1086,187 @@ HWND get_active_window(void) ...@@ -1086,3 +1086,187 @@ HWND get_active_window(void)
info.cbSize = sizeof(info); info.cbSize = sizeof(info);
return NtUserGetGUIThreadInfo( GetCurrentThreadId(), &info ) ? info.hwndActive : 0; return NtUserGetGUIThreadInfo( GetCurrentThreadId(), &info ) ? info.hwndActive : 0;
} }
/* see GetFocus */
static HWND get_focus(void)
{
GUITHREADINFO info;
info.cbSize = sizeof(info);
return NtUserGetGUIThreadInfo( GetCurrentThreadId(), &info ) ? info.hwndFocus : 0;
}
/*****************************************************************
* set_focus_window
*
* Change the focus window, sending the WM_SETFOCUS and WM_KILLFOCUS messages
*/
static HWND set_focus_window( HWND hwnd )
{
HWND previous = 0;
BOOL ret;
SERVER_START_REQ( set_focus_window )
{
req->handle = wine_server_user_handle( hwnd );
if ((ret = !wine_server_call_err( req )))
previous = wine_server_ptr_handle( reply->previous );
}
SERVER_END_REQ;
if (!ret) return 0;
if (previous == hwnd) return previous;
if (previous)
{
send_message( previous, WM_KILLFOCUS, (WPARAM)hwnd, 0 );
if (user_callbacks) user_callbacks->notify_ime( previous, IME_INTERNAL_DEACTIVATE );
if (hwnd != get_focus()) return previous; /* changed by the message */
}
if (is_window(hwnd))
{
user_driver->pSetFocus(hwnd);
if (user_callbacks) user_callbacks->notify_ime( hwnd, IME_INTERNAL_ACTIVATE );
if (previous)
NtUserNotifyWinEvent( EVENT_OBJECT_FOCUS, hwnd, OBJID_CLIENT, 0 );
send_message( hwnd, WM_SETFOCUS, (WPARAM)previous, 0 );
}
return previous;
}
/*******************************************************************
* set_active_window
*/
static BOOL set_active_window( HWND hwnd, HWND *prev, BOOL mouse, BOOL focus )
{
HWND previous = get_active_window();
BOOL ret;
DWORD old_thread, new_thread;
CBTACTIVATESTRUCT cbt;
if (previous == hwnd)
{
if (prev) *prev = hwnd;
return TRUE;
}
/* call CBT hook chain */
cbt.fMouse = mouse;
cbt.hWndActive = previous;
if (call_hooks( WH_CBT, HCBT_ACTIVATE, (WPARAM)hwnd, (LPARAM)&cbt, TRUE )) return FALSE;
if (is_window( previous ))
{
send_message( previous, WM_NCACTIVATE, FALSE, (LPARAM)hwnd );
send_message( previous, WM_ACTIVATE,
MAKEWPARAM( WA_INACTIVE, is_iconic(previous) ), (LPARAM)hwnd );
}
SERVER_START_REQ( set_active_window )
{
req->handle = wine_server_user_handle( hwnd );
if ((ret = !wine_server_call_err( req )))
previous = wine_server_ptr_handle( reply->previous );
}
SERVER_END_REQ;
if (!ret) return FALSE;
if (prev) *prev = previous;
if (previous == hwnd) return TRUE;
if (hwnd)
{
/* send palette messages */
if (send_message( hwnd, WM_QUERYNEWPALETTE, 0, 0 ) && user_callbacks)
user_callbacks->pSendMessageTimeoutW( HWND_BROADCAST, WM_PALETTEISCHANGING, (WPARAM)hwnd, 0,
SMTO_ABORTIFHUNG, 2000, NULL );
if (!is_window(hwnd)) return FALSE;
}
old_thread = previous ? get_window_thread( previous, NULL ) : 0;
new_thread = hwnd ? get_window_thread( hwnd, NULL ) : 0;
if (old_thread != new_thread)
{
HWND *list, *phwnd;
if ((list = list_window_children( NULL, get_desktop_window(), NULL, 0 )))
{
if (old_thread)
{
for (phwnd = list; *phwnd; phwnd++)
{
if (get_window_thread( *phwnd, NULL ) == old_thread)
send_message( *phwnd, WM_ACTIVATEAPP, 0, new_thread );
}
}
if (new_thread)
{
for (phwnd = list; *phwnd; phwnd++)
{
if (get_window_thread( *phwnd, NULL ) == new_thread)
send_message( *phwnd, WM_ACTIVATEAPP, 1, old_thread );
}
}
free( list );
}
}
if (is_window(hwnd))
{
send_message( hwnd, WM_NCACTIVATE, hwnd == NtUserGetForegroundWindow(), (LPARAM)previous );
send_message( hwnd, WM_ACTIVATE,
MAKEWPARAM( mouse ? WA_CLICKACTIVE : WA_ACTIVE, is_iconic(hwnd) ),
(LPARAM)previous );
if (NtUserGetAncestor( hwnd, GA_PARENT ) == get_desktop_window())
post_message( get_desktop_window(), WM_PARENTNOTIFY, WM_NCACTIVATE, (LPARAM)hwnd );
}
/* now change focus if necessary */
if (focus)
{
GUITHREADINFO info;
info.cbSize = sizeof(info);
NtUserGetGUIThreadInfo( GetCurrentThreadId(), &info );
/* Do not change focus if the window is no more active */
if (hwnd == info.hwndActive)
{
if (!info.hwndFocus || !hwnd || NtUserGetAncestor( info.hwndFocus, GA_ROOT ) != hwnd)
set_focus_window( hwnd );
}
}
return TRUE;
}
/**********************************************************************
* NtUserSetActiveWindow (win32u.@)
*/
HWND WINAPI NtUserSetActiveWindow( HWND hwnd )
{
HWND prev;
TRACE( "%p\n", hwnd );
if (hwnd)
{
LONG style;
hwnd = get_full_window_handle( hwnd );
if (!is_window( hwnd ))
{
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0;
}
style = get_window_long( hwnd, GWL_STYLE );
if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD)
return get_active_window(); /* Windows doesn't seem to return an error here */
}
if (!set_active_window( hwnd, &prev, FALSE, TRUE )) return 0;
return prev;
}
...@@ -41,6 +41,9 @@ LRESULT handle_internal_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar ...@@ -41,6 +41,9 @@ LRESULT handle_internal_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpar
{ {
switch(msg) switch(msg)
{ {
case WM_WINE_SETACTIVEWINDOW:
if (!wparam && NtUserGetForegroundWindow() == hwnd) return 0;
return (LRESULT)NtUserSetActiveWindow( (HWND)wparam );
case WM_WINE_KEYBOARD_LL_HOOK: case WM_WINE_KEYBOARD_LL_HOOK:
case WM_WINE_MOUSE_LL_HOOK: case WM_WINE_MOUSE_LL_HOOK:
{ {
......
...@@ -38,6 +38,7 @@ struct user_callbacks ...@@ -38,6 +38,7 @@ struct user_callbacks
DWORD (WINAPI *pWaitForInputIdle)( HANDLE, DWORD ); DWORD (WINAPI *pWaitForInputIdle)( HANDLE, DWORD );
HWND (WINAPI *pWindowFromDC)( HDC ); HWND (WINAPI *pWindowFromDC)( HDC );
void (WINAPI *free_dce)( struct dce *dce, HWND hwnd ); void (WINAPI *free_dce)( struct dce *dce, HWND hwnd );
void (CDECL *notify_ime)( HWND hwnd, UINT param );
void (CDECL *register_builtin_classes)(void); void (CDECL *register_builtin_classes)(void);
LRESULT (WINAPI *send_ll_message)( DWORD, DWORD, UINT, WPARAM, LPARAM, UINT, UINT, PDWORD_PTR ); LRESULT (WINAPI *send_ll_message)( DWORD, DWORD, UINT, WPARAM, LPARAM, UINT, UINT, PDWORD_PTR );
void (CDECL *set_user_driver)( void *, UINT ); void (CDECL *set_user_driver)( void *, UINT );
...@@ -112,6 +113,10 @@ typedef struct tagWND ...@@ -112,6 +113,10 @@ typedef struct tagWND
WND *next_thread_window_ptr( HWND *hwnd ); WND *next_thread_window_ptr( HWND *hwnd );
#define WM_IME_INTERNAL 0x287
#define IME_INTERNAL_ACTIVATE 0x17
#define IME_INTERNAL_DEACTIVATE 0x18
/* this is the structure stored in TEB->Win32ClientInfo */ /* this is the structure stored in TEB->Win32ClientInfo */
/* no attempt is made to keep the layout compatible with the Windows one */ /* no attempt is made to keep the layout compatible with the Windows one */
struct user_thread_info struct user_thread_info
...@@ -223,6 +228,7 @@ WINDOWPROC *get_winproc_ptr( WNDPROC handle ) DECLSPEC_HIDDEN; ...@@ -223,6 +228,7 @@ WINDOWPROC *get_winproc_ptr( WNDPROC handle ) DECLSPEC_HIDDEN;
DWORD get_class_long( HWND hwnd, INT offset, BOOL ansi ) DECLSPEC_HIDDEN; DWORD get_class_long( HWND hwnd, INT offset, BOOL ansi ) DECLSPEC_HIDDEN;
ULONG_PTR get_class_long_ptr( HWND hwnd, INT offset, BOOL ansi ) DECLSPEC_HIDDEN; ULONG_PTR get_class_long_ptr( HWND hwnd, INT offset, BOOL ansi ) DECLSPEC_HIDDEN;
WORD get_class_word( HWND hwnd, INT offset ) DECLSPEC_HIDDEN; WORD get_class_word( HWND hwnd, INT offset ) DECLSPEC_HIDDEN;
ATOM get_int_atom_value( UNICODE_STRING *name ) DECLSPEC_HIDDEN;
WNDPROC get_winproc( WNDPROC proc, BOOL ansi ) DECLSPEC_HIDDEN; WNDPROC get_winproc( WNDPROC proc, BOOL ansi ) DECLSPEC_HIDDEN;
/* cursoricon.c */ /* cursoricon.c */
......
...@@ -1163,7 +1163,7 @@ ...@@ -1163,7 +1163,7 @@
@ stub NtUserSendInteractiveControlHapticsReport @ stub NtUserSendInteractiveControlHapticsReport
@ stub NtUserSetActivationFilter @ stub NtUserSetActivationFilter
@ stub NtUserSetActiveProcessForMonitor @ stub NtUserSetActiveProcessForMonitor
@ stub NtUserSetActiveWindow @ stdcall NtUserSetActiveWindow(long)
@ stub NtUserSetAppImeLevel @ stub NtUserSetAppImeLevel
@ stub NtUserSetAutoRotation @ stub NtUserSetAutoRotation
@ stub NtUserSetBridgeWindowChild @ stub NtUserSetBridgeWindowChild
......
...@@ -227,6 +227,7 @@ struct unix_funcs ...@@ -227,6 +227,7 @@ struct unix_funcs
BOOL (WINAPI *pNtUserScrollDC)( HDC hdc, INT dx, INT dy, const RECT *scroll, const RECT *clip, BOOL (WINAPI *pNtUserScrollDC)( HDC hdc, INT dx, INT dy, const RECT *scroll, const RECT *clip,
HRGN ret_update_rgn, RECT *update_rect ); HRGN ret_update_rgn, RECT *update_rect );
HPALETTE (WINAPI *pNtUserSelectPalette)( HDC hdc, HPALETTE hpal, WORD bkg ); HPALETTE (WINAPI *pNtUserSelectPalette)( HDC hdc, HPALETTE hpal, WORD bkg );
HWND (WINAPI *pNtUserSetActiveWindow)( HWND hwnd );
DWORD (WINAPI *pNtUserSetClassLong)( HWND hwnd, INT offset, LONG newval, BOOL ansi ); DWORD (WINAPI *pNtUserSetClassLong)( HWND hwnd, INT offset, LONG newval, BOOL ansi );
ULONG_PTR (WINAPI *pNtUserSetClassLongPtr)( HWND hwnd, INT offset, LONG_PTR newval, BOOL ansi ); ULONG_PTR (WINAPI *pNtUserSetClassLongPtr)( HWND hwnd, INT offset, LONG_PTR newval, BOOL ansi );
WORD (WINAPI *pNtUserSetClassWord)( HWND hwnd, INT offset, WORD newval ); WORD (WINAPI *pNtUserSetClassWord)( HWND hwnd, INT offset, WORD newval );
...@@ -315,12 +316,16 @@ extern void user_check_not_lock(void) DECLSPEC_HIDDEN; ...@@ -315,12 +316,16 @@ extern void user_check_not_lock(void) DECLSPEC_HIDDEN;
/* window.c */ /* window.c */
struct tagWND; struct tagWND;
extern HWND get_desktop_window(void) DECLSPEC_HIDDEN; extern HWND get_desktop_window(void) DECLSPEC_HIDDEN;
extern HWND get_full_window_handle( HWND hwnd ) DECLSPEC_HIDDEN;
extern BOOL get_window_placement( HWND hwnd, WINDOWPLACEMENT *placement ) DECLSPEC_HIDDEN; extern BOOL get_window_placement( HWND hwnd, WINDOWPLACEMENT *placement ) DECLSPEC_HIDDEN;
extern DWORD get_window_thread( HWND hwnd, DWORD *process ) DECLSPEC_HIDDEN;
extern HWND is_current_thread_window( HWND hwnd ) DECLSPEC_HIDDEN; extern HWND is_current_thread_window( HWND hwnd ) DECLSPEC_HIDDEN;
extern BOOL is_iconic( HWND hwnd ) DECLSPEC_HIDDEN; extern BOOL is_iconic( HWND hwnd ) DECLSPEC_HIDDEN;
extern void flush_window_surfaces( BOOL idle ) DECLSPEC_HIDDEN; extern void flush_window_surfaces( BOOL idle ) DECLSPEC_HIDDEN;
extern DWORD get_window_long( HWND hwnd, INT offset ) DECLSPEC_HIDDEN; extern DWORD get_window_long( HWND hwnd, INT offset ) DECLSPEC_HIDDEN;
extern BOOL get_window_rect( HWND hwnd, RECT *rect, UINT dpi ) DECLSPEC_HIDDEN; extern BOOL get_window_rect( HWND hwnd, RECT *rect, UINT dpi ) DECLSPEC_HIDDEN;
extern HWND *list_window_children( HDESK desktop, HWND hwnd, UNICODE_STRING *class,
DWORD tid ) DECLSPEC_HIDDEN;
extern void register_window_surface( struct window_surface *old, extern void register_window_surface( struct window_surface *old,
struct window_surface *new ) DECLSPEC_HIDDEN; struct window_surface *new ) DECLSPEC_HIDDEN;
extern void update_window_state( HWND hwnd ) DECLSPEC_HIDDEN; extern void update_window_state( HWND hwnd ) DECLSPEC_HIDDEN;
......
...@@ -172,7 +172,7 @@ static HWND get_hwnd_message_parent(void) ...@@ -172,7 +172,7 @@ static HWND get_hwnd_message_parent(void)
* *
* Convert a possibly truncated window handle to a full 32-bit handle. * Convert a possibly truncated window handle to a full 32-bit handle.
*/ */
static HWND get_full_window_handle( HWND hwnd ) HWND get_full_window_handle( HWND hwnd )
{ {
WND *win; WND *win;
...@@ -325,7 +325,7 @@ BOOL is_window( HWND hwnd ) ...@@ -325,7 +325,7 @@ BOOL is_window( HWND hwnd )
} }
/* see GetWindowThreadProcessId */ /* see GetWindowThreadProcessId */
static DWORD get_window_thread( HWND hwnd, DWORD *process ) DWORD get_window_thread( HWND hwnd, DWORD *process )
{ {
WND *ptr; WND *ptr;
DWORD tid = 0; DWORD tid = 0;
...@@ -521,6 +521,53 @@ empty: ...@@ -521,6 +521,53 @@ empty:
return NULL; return NULL;
} }
/*******************************************************************
* list_window_children
*
* Build an array of the children of a given window. The array must be
* freed with HeapFree. Returns NULL when no windows are found.
*/
HWND *list_window_children( HDESK desktop, HWND hwnd, UNICODE_STRING *class, DWORD tid )
{
HWND *list;
int i, size = 128;
ATOM atom = class ? get_int_atom_value( class ) : 0;
/* empty class is not the same as NULL class */
if (!atom && class && !class->Length) return NULL;
for (;;)
{
int count = 0;
if (!(list = malloc( size * sizeof(HWND) ))) break;
SERVER_START_REQ( get_window_children )
{
req->desktop = wine_server_obj_handle( desktop );
req->parent = wine_server_user_handle( hwnd );
req->tid = tid;
req->atom = atom;
if (!atom && class) wine_server_add_data( req, class->Buffer, class->Length );
wine_server_set_reply( req, list, (size-1) * sizeof(user_handle_t) );
if (!wine_server_call( req )) count = reply->count;
}
SERVER_END_REQ;
if (count && count < size)
{
/* start from the end since HWND is potentially larger than user_handle_t */
for (i = count - 1; i >= 0; i--)
list[i] = wine_server_ptr_handle( ((user_handle_t *)list)[i] );
list[count] = 0;
return list;
}
free( list );
if (!count) break;
size = count + 1; /* restart with a large enough buffer */
}
return NULL;
}
/***************************************************************** /*****************************************************************
* NtUserGetAncestor (win32u.@) * NtUserGetAncestor (win32u.@)
*/ */
......
...@@ -903,6 +903,12 @@ HPALETTE WINAPI NtUserSelectPalette( HDC hdc, HPALETTE hpal, WORD bkg ) ...@@ -903,6 +903,12 @@ HPALETTE WINAPI NtUserSelectPalette( HDC hdc, HPALETTE hpal, WORD bkg )
return unix_funcs->pNtUserSelectPalette( hdc, hpal, bkg ); return unix_funcs->pNtUserSelectPalette( hdc, hpal, bkg );
} }
HWND WINAPI NtUserSetActiveWindow( HWND hwnd )
{
if (!unix_funcs) return 0;
return unix_funcs->pNtUserSetActiveWindow( hwnd );
}
HCURSOR WINAPI NtUserSetCursor( HCURSOR cursor ) HCURSOR WINAPI NtUserSetCursor( HCURSOR cursor )
{ {
if (!unix_funcs) return 0; if (!unix_funcs) return 0;
......
...@@ -359,6 +359,7 @@ HANDLE WINAPI NtUserRemoveProp( HWND hwnd, const WCHAR *str ); ...@@ -359,6 +359,7 @@ HANDLE WINAPI NtUserRemoveProp( HWND hwnd, const WCHAR *str );
BOOL WINAPI NtUserScrollDC( HDC hdc, INT dx, INT dy, const RECT *scroll, const RECT *clip, BOOL WINAPI NtUserScrollDC( HDC hdc, INT dx, INT dy, const RECT *scroll, const RECT *clip,
HRGN ret_update_rgn, RECT *update_rect ); HRGN ret_update_rgn, RECT *update_rect );
HPALETTE WINAPI NtUserSelectPalette( HDC hdc, HPALETTE palette, WORD force_background ); HPALETTE WINAPI NtUserSelectPalette( HDC hdc, HPALETTE palette, WORD force_background );
HWND WINAPI NtUserSetActiveWindow( HWND hwnd );
DWORD WINAPI NtUserSetClassLong( HWND hwnd, INT offset, LONG newval, BOOL ansi ); DWORD WINAPI NtUserSetClassLong( HWND hwnd, INT offset, LONG newval, BOOL ansi );
ULONG_PTR WINAPI NtUserSetClassLongPtr( HWND hwnd, INT offset, LONG_PTR newval, BOOL ansi ); ULONG_PTR WINAPI NtUserSetClassLongPtr( HWND hwnd, INT offset, LONG_PTR newval, BOOL ansi );
WORD WINAPI NtUserSetClassWord( HWND hwnd, INT offset, WORD newval ); WORD WINAPI NtUserSetClassWord( HWND hwnd, INT offset, WORD newval );
......
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