winex11.drv: Split clip cursor message in notify/request.

The message was sent to two different types of windows, with a different
semantic. We can now add parameters to the request without changing the
notify parameters semantics.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2020-10-01 22:24:30 +02:00 committed by Alexandre Julliard
parent 973b0e1dfc
commit 0120a1aa40
3 changed files with 33 additions and 16 deletions

View File

@ -445,7 +445,7 @@ static BOOL grab_clipping_window( const RECT *clip )
if (!data->clip_hwnd) sync_window_cursor( clip_window );
InterlockedExchangePointer( (void **)&cursor_window, msg_hwnd );
data->clip_hwnd = msg_hwnd;
SendNotifyMessageW( GetDesktopWindow(), WM_X11DRV_CLIP_CURSOR, 0, (LPARAM)msg_hwnd );
SendNotifyMessageW( GetDesktopWindow(), WM_X11DRV_CLIP_CURSOR_NOTIFY, 0, (LPARAM)msg_hwnd );
return TRUE;
}
@ -465,7 +465,7 @@ void ungrab_clipping_window(void)
XUnmapWindow( display, clip_window );
if (clipping_cursor) XUngrabPointer( display, CurrentTime );
clipping_cursor = FALSE;
SendNotifyMessageW( GetDesktopWindow(), WM_X11DRV_CLIP_CURSOR, 0, 0 );
SendNotifyMessageW( GetDesktopWindow(), WM_X11DRV_CLIP_CURSOR_NOTIFY, 0, 0 );
}
/***********************************************************************
@ -493,12 +493,10 @@ void retry_grab_clipping_window(void)
ClipCursor( &last_clip_rect );
}
BOOL CDECL X11DRV_ClipCursor( const RECT *clip );
/***********************************************************************
* clip_cursor_notify
*
* Notification function called upon receiving a WM_X11DRV_CLIP_CURSOR.
* Notification function called upon receiving a WM_X11DRV_CLIP_CURSOR_NOTIFY.
*/
LRESULT clip_cursor_notify( HWND hwnd, HWND prev_clip_hwnd, HWND new_clip_hwnd )
{
@ -511,7 +509,7 @@ LRESULT clip_cursor_notify( HWND hwnd, HWND prev_clip_hwnd, HWND new_clip_hwnd )
HWND prev = clip_hwnd;
clip_hwnd = new_clip_hwnd;
if (prev || new_clip_hwnd) TRACE( "clip hwnd changed from %p to %p\n", prev, new_clip_hwnd );
if (prev) SendNotifyMessageW( prev, WM_X11DRV_CLIP_CURSOR, (WPARAM)prev, 0 );
if (prev) SendNotifyMessageW( prev, WM_X11DRV_CLIP_CURSOR_NOTIFY, (WPARAM)prev, 0 );
}
else if (hwnd == data->clip_hwnd) /* this is a notification that clipping has been reset */
{
@ -521,13 +519,6 @@ LRESULT clip_cursor_notify( HWND hwnd, HWND prev_clip_hwnd, HWND new_clip_hwnd )
disable_xinput2();
DestroyWindow( hwnd );
}
else if (hwnd == GetForegroundWindow()) /* request to clip */
{
RECT clip;
GetClipCursor( &clip );
X11DRV_ClipCursor( &clip );
}
else if (prev_clip_hwnd)
{
/* This is a notification send by the desktop window to an old
@ -1539,7 +1530,7 @@ BOOL CDECL X11DRV_ClipCursor( LPCRECT clip )
if (tid && tid != GetCurrentThreadId() && pid == GetCurrentProcessId())
{
TRACE( "forwarding clip request to %p\n", foreground );
SendNotifyMessageW( foreground, WM_X11DRV_CLIP_CURSOR, 0, 0 );
SendNotifyMessageW( foreground, WM_X11DRV_CLIP_CURSOR_REQUEST, 0, 0 );
return TRUE;
}
@ -1563,6 +1554,28 @@ BOOL CDECL X11DRV_ClipCursor( LPCRECT clip )
return TRUE;
}
/***********************************************************************
* clip_cursor_request
*
* Function called upon receiving a WM_X11DRV_CLIP_CURSOR_REQUEST.
*/
LRESULT clip_cursor_request( HWND hwnd )
{
RECT clip;
if (hwnd == GetDesktopWindow())
WARN( "ignoring clip cursor request on desktop window.\n" );
else if (hwnd != GetForegroundWindow())
WARN( "ignoring clip cursor request on non-foreground window.\n" );
else
{
GetClipCursor( &clip );
X11DRV_ClipCursor( &clip );
}
return 0;
}
/***********************************************************************
* move_resize_window
*/

View File

@ -2781,8 +2781,10 @@ LRESULT CDECL X11DRV_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
else if (hwnd == x11drv_thread_data()->clip_hwnd)
set_window_cursor( x11drv_thread_data()->clip_window, (HCURSOR)lp );
return 0;
case WM_X11DRV_CLIP_CURSOR:
case WM_X11DRV_CLIP_CURSOR_NOTIFY:
return clip_cursor_notify( hwnd, (HWND)wp, (HWND)lp );
case WM_X11DRV_CLIP_CURSOR_REQUEST:
return clip_cursor_request( hwnd );
default:
FIXME( "got window msg %x hwnd %p wp %lx lp %lx\n", msg, hwnd, wp, lp );
return 0;

View File

@ -538,7 +538,8 @@ enum x11drv_window_messages
WM_X11DRV_SET_WIN_REGION,
WM_X11DRV_RESIZE_DESKTOP,
WM_X11DRV_SET_CURSOR,
WM_X11DRV_CLIP_CURSOR
WM_X11DRV_CLIP_CURSOR_NOTIFY,
WM_X11DRV_CLIP_CURSOR_REQUEST
};
/* _NET_WM_STATE properties that we keep track of */
@ -627,6 +628,7 @@ extern void CDECL X11DRV_SetFocus( HWND hwnd ) DECLSPEC_HIDDEN;
extern void set_window_cursor( Window window, HCURSOR handle ) DECLSPEC_HIDDEN;
extern void sync_window_cursor( Window window ) DECLSPEC_HIDDEN;
extern LRESULT clip_cursor_notify( HWND hwnd, HWND prev_clip_hwnd, HWND new_clip_hwnd ) DECLSPEC_HIDDEN;
extern LRESULT clip_cursor_request( HWND hwnd ) DECLSPEC_HIDDEN;
extern void ungrab_clipping_window(void) DECLSPEC_HIDDEN;
extern void reset_clipping_window(void) DECLSPEC_HIDDEN;
extern void retry_grab_clipping_window(void) DECLSPEC_HIDDEN;