winex11.drv: Forward clip_fullscreen_window to foreground thread.
If the current thread isn't the foreground thread. Otherwise we may clip the cursor in the wrong thread, that isn't expecting mouse messages or may not be checking its messages. Red Faction has some race condition where this can happen for instance, with clip_fullscreen_window called from X11DRV_DisplayDevices_Update callback in a background thread. This thread starts clipping the cursor, and the foreground thread isn't receiving MotionNotify events anymore. Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0120a1aa40
commit
16984895f0
|
@ -372,14 +372,14 @@ static BOOL CALLBACK update_windows_on_display_change(HWND hwnd, LPARAM lparam)
|
||||||
XReconfigureWMWindow(data->display, data->whole_window, data->vis.screen, mask, &changes);
|
XReconfigureWMWindow(data->display, data->whole_window, data->vis.screen, mask, &changes);
|
||||||
}
|
}
|
||||||
release_win_data(data);
|
release_win_data(data);
|
||||||
if (hwnd == GetForegroundWindow())
|
|
||||||
clip_fullscreen_window(hwnd, TRUE);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void X11DRV_DisplayDevices_Update(BOOL send_display_change)
|
void X11DRV_DisplayDevices_Update(BOOL send_display_change)
|
||||||
{
|
{
|
||||||
RECT old_virtual_rect, new_virtual_rect;
|
RECT old_virtual_rect, new_virtual_rect;
|
||||||
|
DWORD tid, pid;
|
||||||
|
HWND foreground;
|
||||||
UINT mask = 0;
|
UINT mask = 0;
|
||||||
|
|
||||||
old_virtual_rect = get_virtual_screen_rect();
|
old_virtual_rect = get_virtual_screen_rect();
|
||||||
|
@ -394,6 +394,13 @@ void X11DRV_DisplayDevices_Update(BOOL send_display_change)
|
||||||
|
|
||||||
X11DRV_resize_desktop(send_display_change);
|
X11DRV_resize_desktop(send_display_change);
|
||||||
EnumWindows(update_windows_on_display_change, (LPARAM)mask);
|
EnumWindows(update_windows_on_display_change, (LPARAM)mask);
|
||||||
|
|
||||||
|
/* forward clip_fullscreen_window request to the foreground window */
|
||||||
|
if ((foreground = GetForegroundWindow()) && (tid = GetWindowThreadProcessId( foreground, &pid )) && pid == GetCurrentProcessId())
|
||||||
|
{
|
||||||
|
if (tid == GetCurrentThreadId()) clip_fullscreen_window( foreground, TRUE );
|
||||||
|
else SendNotifyMessageW( foreground, WM_X11DRV_CLIP_CURSOR_REQUEST, TRUE, TRUE );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize a GPU instance.
|
/* Initialize a GPU instance.
|
||||||
|
|
|
@ -1530,7 +1530,7 @@ BOOL CDECL X11DRV_ClipCursor( LPCRECT clip )
|
||||||
if (tid && tid != GetCurrentThreadId() && pid == GetCurrentProcessId())
|
if (tid && tid != GetCurrentThreadId() && pid == GetCurrentProcessId())
|
||||||
{
|
{
|
||||||
TRACE( "forwarding clip request to %p\n", foreground );
|
TRACE( "forwarding clip request to %p\n", foreground );
|
||||||
SendNotifyMessageW( foreground, WM_X11DRV_CLIP_CURSOR_REQUEST, 0, 0 );
|
SendNotifyMessageW( foreground, WM_X11DRV_CLIP_CURSOR_REQUEST, FALSE, FALSE );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1559,7 +1559,7 @@ BOOL CDECL X11DRV_ClipCursor( LPCRECT clip )
|
||||||
*
|
*
|
||||||
* Function called upon receiving a WM_X11DRV_CLIP_CURSOR_REQUEST.
|
* Function called upon receiving a WM_X11DRV_CLIP_CURSOR_REQUEST.
|
||||||
*/
|
*/
|
||||||
LRESULT clip_cursor_request( HWND hwnd )
|
LRESULT clip_cursor_request( HWND hwnd, BOOL fullscreen, BOOL reset )
|
||||||
{
|
{
|
||||||
RECT clip;
|
RECT clip;
|
||||||
|
|
||||||
|
@ -1567,6 +1567,8 @@ LRESULT clip_cursor_request( HWND hwnd )
|
||||||
WARN( "ignoring clip cursor request on desktop window.\n" );
|
WARN( "ignoring clip cursor request on desktop window.\n" );
|
||||||
else if (hwnd != GetForegroundWindow())
|
else if (hwnd != GetForegroundWindow())
|
||||||
WARN( "ignoring clip cursor request on non-foreground window.\n" );
|
WARN( "ignoring clip cursor request on non-foreground window.\n" );
|
||||||
|
else if (fullscreen)
|
||||||
|
clip_fullscreen_window( hwnd, reset );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GetClipCursor( &clip );
|
GetClipCursor( &clip );
|
||||||
|
|
|
@ -2784,7 +2784,7 @@ LRESULT CDECL X11DRV_WindowMessage( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
|
||||||
case WM_X11DRV_CLIP_CURSOR_NOTIFY:
|
case WM_X11DRV_CLIP_CURSOR_NOTIFY:
|
||||||
return clip_cursor_notify( hwnd, (HWND)wp, (HWND)lp );
|
return clip_cursor_notify( hwnd, (HWND)wp, (HWND)lp );
|
||||||
case WM_X11DRV_CLIP_CURSOR_REQUEST:
|
case WM_X11DRV_CLIP_CURSOR_REQUEST:
|
||||||
return clip_cursor_request( hwnd );
|
return clip_cursor_request( hwnd, (BOOL)wp, (BOOL)lp );
|
||||||
default:
|
default:
|
||||||
FIXME( "got window msg %x hwnd %p wp %lx lp %lx\n", msg, hwnd, wp, lp );
|
FIXME( "got window msg %x hwnd %p wp %lx lp %lx\n", msg, hwnd, wp, lp );
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -628,7 +628,7 @@ extern void CDECL X11DRV_SetFocus( HWND hwnd ) DECLSPEC_HIDDEN;
|
||||||
extern void set_window_cursor( Window window, HCURSOR handle ) DECLSPEC_HIDDEN;
|
extern void set_window_cursor( Window window, HCURSOR handle ) DECLSPEC_HIDDEN;
|
||||||
extern void sync_window_cursor( Window window ) 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_notify( HWND hwnd, HWND prev_clip_hwnd, HWND new_clip_hwnd ) DECLSPEC_HIDDEN;
|
||||||
extern LRESULT clip_cursor_request( HWND hwnd ) DECLSPEC_HIDDEN;
|
extern LRESULT clip_cursor_request( HWND hwnd, BOOL fullscreen, BOOL reset ) DECLSPEC_HIDDEN;
|
||||||
extern void ungrab_clipping_window(void) DECLSPEC_HIDDEN;
|
extern void ungrab_clipping_window(void) DECLSPEC_HIDDEN;
|
||||||
extern void reset_clipping_window(void) DECLSPEC_HIDDEN;
|
extern void reset_clipping_window(void) DECLSPEC_HIDDEN;
|
||||||
extern void retry_grab_clipping_window(void) DECLSPEC_HIDDEN;
|
extern void retry_grab_clipping_window(void) DECLSPEC_HIDDEN;
|
||||||
|
|
Loading…
Reference in New Issue