Module: wine Branch: master Commit: 4e129f88d0e8e212702a33906d3ce9609837f4f5 URL: http://source.winehq.org/git/wine.git/?a=commit;h=4e129f88d0e8e212702a33906d...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Mar 12 14:54:03 2008 +0100
user32: Add a helper function to set the capture window.
---
dlls/user32/input.c | 62 ++++++++++++++++++++++++------------------- dlls/user32/menu.c | 33 +++-------------------- dlls/user32/user_private.h | 1 + 3 files changed, 41 insertions(+), 55 deletions(-)
diff --git a/dlls/user32/input.c b/dlls/user32/input.c index a24980b..b0fc9c5 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -76,6 +76,38 @@ static WORD get_key_state(void) }
+/********************************************************************** + * set_capture_window + */ +BOOL set_capture_window( HWND hwnd, UINT gui_flags, HWND *prev_ret ) +{ + HWND previous = 0; + UINT flags = 0; + BOOL ret; + + if (gui_flags & GUI_INMENUMODE) flags |= CAPTURE_MENU; + if (gui_flags & GUI_INMOVESIZE) flags |= CAPTURE_MOVESIZE; + + SERVER_START_REQ( set_capture_window ) + { + req->handle = hwnd; + req->flags = flags; + if ((ret = !wine_server_call_err( req ))) + { + previous = reply->previous; + hwnd = reply->full_handle; + } + } + SERVER_END_REQ; + + if (previous && previous != hwnd) + SendMessageW( previous, WM_CAPTURECHANGED, 0, (LPARAM)hwnd ); + + if (prev_ret) *prev_ret = previous; + return ret; +} + + /*********************************************************************** * SendInput (USER32.@) */ @@ -191,22 +223,9 @@ BOOL WINAPI SetCursorPos( INT x, INT y ) */ HWND WINAPI SetCapture( HWND hwnd ) { - HWND previous = 0; - - SERVER_START_REQ( set_capture_window ) - { - req->handle = hwnd; - req->flags = 0; - if (!wine_server_call_err( req )) - { - previous = reply->previous; - hwnd = reply->full_handle; - } - } - SERVER_END_REQ; + HWND previous;
- if (previous && previous != hwnd) - SendMessageW( previous, WM_CAPTURECHANGED, 0, (LPARAM)hwnd ); + set_capture_window( hwnd, 0, &previous ); return previous; }
@@ -216,18 +235,7 @@ HWND WINAPI SetCapture( HWND hwnd ) */ BOOL WINAPI ReleaseCapture(void) { - BOOL ret; - HWND previous = 0; - - SERVER_START_REQ( set_capture_window ) - { - req->handle = 0; - req->flags = 0; - if ((ret = !wine_server_call_err( req ))) previous = reply->previous; - } - SERVER_END_REQ; - - if (previous) SendMessageW( previous, WM_CAPTURECHANGED, 0, 0 ); + BOOL ret = set_capture_window( 0, 0, NULL );
/* Somebody may have missed some mouse movements */ mouse_event( MOUSEEVENTF_MOVE, 0, 0, 0, 0 ); diff --git a/dlls/user32/menu.c b/dlls/user32/menu.c index 660c5d5..17b2179 100644 --- a/dlls/user32/menu.c +++ b/dlls/user32/menu.c @@ -2636,30 +2636,6 @@ static BOOL MENU_MouseMove( MTRACKER* pmt, HMENU hPtMenu, UINT wFlags )
/*********************************************************************** - * MENU_SetCapture - */ -static void MENU_SetCapture( HWND hwnd ) -{ - HWND previous = 0; - - SERVER_START_REQ( set_capture_window ) - { - req->handle = hwnd; - req->flags = CAPTURE_MENU; - if (!wine_server_call_err( req )) - { - previous = reply->previous; - hwnd = reply->full_handle; - } - } - SERVER_END_REQ; - - if (previous && previous != hwnd) - SendMessageW( previous, WM_CAPTURECHANGED, 0, (LPARAM)hwnd ); -} - - -/*********************************************************************** * MENU_DoNextMenu * * NOTE: WM_NEXTMENU documented in Win32 is a bit different. @@ -2781,7 +2757,7 @@ static LRESULT MENU_DoNextMenu( MTRACKER* pmt, UINT vk ) if( hNewWnd != pmt->hOwnerWnd ) { pmt->hOwnerWnd = hNewWnd; - MENU_SetCapture( pmt->hOwnerWnd ); + set_capture_window( pmt->hOwnerWnd, GUI_INMENUMODE, NULL ); }
pmt->hTopMenu = pmt->hCurrentMenu = hNewMenu; /* all subpopups are hidden */ @@ -3015,7 +2991,7 @@ static BOOL MENU_TrackMenu( HMENU hmenu, UINT wFlags, INT x, INT y,
if (wFlags & TF_ENDMENU) fEndMenu = TRUE;
- MENU_SetCapture( mt.hOwnerWnd ); + set_capture_window( mt.hOwnerWnd, GUI_INMENUMODE, NULL );
while (!fEndMenu) { @@ -3239,7 +3215,7 @@ static BOOL MENU_TrackMenu( HMENU hmenu, UINT wFlags, INT x, INT y, else mt.trackFlags &= ~TF_SKIPREMOVE; }
- MENU_SetCapture(0); /* release the capture */ + set_capture_window( 0, GUI_INMENUMODE, NULL );
/* If dropdown is still painted and the close box is clicked on then the menu will be destroyed as part of the DispatchMessage above. @@ -4122,7 +4098,8 @@ BOOL MENU_SetMenu( HWND hWnd, HMENU hMenu ) return FALSE;
hWnd = WIN_GetFullHandle( hWnd ); - if (GetCapture() == hWnd) MENU_SetCapture(0); /* release the capture */ + if (GetCapture() == hWnd) + set_capture_window( 0, GUI_INMENUMODE, NULL ); /* release the capture */
if (hMenu != 0) { diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index 8292158..1131046 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -234,6 +234,7 @@ struct dce; extern BOOL CLIPBOARD_ReleaseOwner(void) DECLSPEC_HIDDEN; extern BOOL FOCUS_MouseActivate( HWND hwnd ) DECLSPEC_HIDDEN; extern BOOL HOOK_IsHooked( INT id ) DECLSPEC_HIDDEN; +extern BOOL set_capture_window( HWND hwnd, UINT gui_flags, HWND *prev_ret ); extern void free_dce( struct dce *dce, HWND hwnd ) DECLSPEC_HIDDEN; extern void invalidate_dce( HWND hwnd, const RECT *rect ) DECLSPEC_HIDDEN; extern void erase_now( HWND hwnd, UINT rdw_flags ) DECLSPEC_HIDDEN;