Moved mouse capture handling into the server.
diff --git a/windows/input.c b/windows/input.c
index 8857879..a9d63c8 100644
--- a/windows/input.c
+++ b/windows/input.c
@@ -513,83 +513,27 @@
/**********************************************************************
- * EVENT_Capture
- *
- * We need this to be able to generate double click messages
- * when menu code captures mouse in the window without CS_DBLCLK style.
- */
-HWND EVENT_Capture(HWND hwnd, INT16 ht)
-{
- HWND capturePrev = 0, captureWnd = 0;
- MESSAGEQUEUE *pMsgQ = 0, *pCurMsgQ = 0;
- WND* wndPtr = 0;
- INT16 captureHT = 0;
-
- capturePrev = GetCapture();
-
- if (!hwnd)
- {
- captureWnd = 0;
- captureHT = 0;
- }
- else
- {
- wndPtr = WIN_FindWndPtr( hwnd );
- if (wndPtr)
- {
- TRACE_(win)("(0x%04x)\n", hwnd );
- captureWnd = wndPtr->hwndSelf;
- captureHT = ht;
- }
- }
-
- /* Get the messageQ for the current thread */
- if (!(pCurMsgQ = QUEUE_Current()))
- {
- WARN_(win)("\tCurrent message queue not found. Exiting!\n" );
- goto CLEANUP;
- }
-
- /* Update the perQ capture window and send messages */
- if( capturePrev != captureWnd )
- {
- if (wndPtr)
- {
- /* Retrieve the message queue associated with this window */
- pMsgQ = (MESSAGEQUEUE *)QUEUE_Lock( wndPtr->hmemTaskQ );
- if ( !pMsgQ )
- {
- WARN_(win)("\tMessage queue not found. Exiting!\n" );
- goto CLEANUP;
- }
-
- /* Make sure that message queue for the window we are setting capture to
- * shares the same perQ data as the current threads message queue.
- */
- if ( pCurMsgQ->pQData != pMsgQ->pQData )
- goto CLEANUP;
- }
-
- PERQDATA_SetCaptureWnd( captureWnd, captureHT );
- if (capturePrev) SendMessageA( capturePrev, WM_CAPTURECHANGED, 0, (LPARAM)hwnd );
- }
-
-CLEANUP:
- /* Unlock the queues before returning */
- if ( pMsgQ )
- QUEUE_Unlock( pMsgQ );
-
- WIN_ReleaseWndPtr(wndPtr);
- return capturePrev;
-}
-
-
-/**********************************************************************
* SetCapture (USER32.@)
*/
HWND WINAPI SetCapture( HWND hwnd )
{
- return EVENT_Capture( hwnd, HTCLIENT );
+ 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;
+
+ if (previous && previous != hwnd)
+ SendMessageW( previous, WM_CAPTURECHANGED, 0, (LPARAM)hwnd );
+ return previous;
}
@@ -598,7 +542,7 @@
*/
BOOL WINAPI ReleaseCapture(void)
{
- return (EVENT_Capture( 0, 0 ) != 0);
+ return (SetCapture(0) != 0);
}
@@ -607,10 +551,18 @@
*/
HWND WINAPI GetCapture(void)
{
- INT hittest;
- return PERQDATA_GetCaptureWnd( &hittest );
+ HWND ret = 0;
+
+ SERVER_START_REQ( get_thread_input )
+ {
+ req->tid = GetCurrentThreadId();
+ if (!wine_server_call_err( req )) ret = reply->capture;
+ }
+ SERVER_END_REQ;
+ return ret;
}
+
/**********************************************************************
* GetAsyncKeyState (USER32.@)
*
diff --git a/windows/message.c b/windows/message.c
index f789f26..5fe885f 100644
--- a/windows/message.c
+++ b/windows/message.c
@@ -384,12 +384,14 @@
static MSG clk_msg;
POINT pt;
- INT ht, hittest;
+ INT hittest;
+ GUITHREADINFO info;
/* find the window to dispatch this mouse message to */
hittest = HTCLIENT;
- if (!(msg->hwnd = PERQDATA_GetCaptureWnd( &ht )))
+ GetGUIThreadInfo( GetCurrentThreadId(), &info );
+ if (!(msg->hwnd = info.hwndCapture))
{
/* If no capture HWND, find window which contains the mouse position.
* Also find the position of the cursor hot spot (hittest) */
@@ -398,7 +400,6 @@
if (!IsWindow(hWndScope)) hWndScope = 0;
if (!(msg->hwnd = WINPOS_WindowFromPoint( hWndScope, msg->pt, &hittest )))
msg->hwnd = GetDesktopWindow();
- ht = hittest;
}
if (HOOK_IsHooked( WH_JOURNALRECORD ))
@@ -423,7 +424,9 @@
* note that ...MOUSEMOVEs can slip in between
* ...BUTTONDOWN and ...BUTTONDBLCLK messages */
- if (GetClassLongA( msg->hwnd, GCL_STYLE ) & CS_DBLCLKS || ht != HTCLIENT )
+ if ((info.flags & (GUI_INMENUMODE|GUI_INMOVESIZE)) ||
+ hittest != HTCLIENT ||
+ (GetClassLongA( msg->hwnd, GCL_STYLE ) & CS_DBLCLKS))
{
if ((msg->message == clk_msg.message) &&
(msg->hwnd == clk_msg.hwnd) &&
@@ -447,7 +450,12 @@
msg->message += WM_NCMOUSEMOVE - WM_MOUSEMOVE;
msg->wParam = hittest;
}
- else ScreenToClient( msg->hwnd, &pt );
+ else
+ {
+ /* coordinates don't get translated while tracking a menu */
+ /* FIXME: should differentiate popups and top-level menus */
+ if (!(info.flags & GUI_INMENUMODE)) ScreenToClient( msg->hwnd, &pt );
+ }
msg->lParam = MAKELONG( pt.x, pt.y );
return TRUE;
}