Commit 272f712b authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winex11: Replace the clipping message HWND with a BOOL flag.

We don't need the window anymore, it was only used to send ClipCursor notifications. This improves cursor clipping performance a lot as it avoids re-creating a window every time.
parent 1f90d03b
......@@ -348,11 +348,8 @@ static void disable_xinput2(void)
static BOOL grab_clipping_window( const RECT *clip )
{
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
static const WCHAR messageW[] = {'M','e','s','s','a','g','e',0};
struct x11drv_thread_data *data = x11drv_thread_data();
UNICODE_STRING class_name = RTL_CONSTANT_STRING( messageW );
Window clip_window;
HWND msg_hwnd = 0;
HCURSOR cursor;
POINT pos;
......@@ -364,11 +361,6 @@ static BOOL grab_clipping_window( const RECT *clip )
if (!data) return FALSE;
if (!(clip_window = init_clip_window())) return TRUE;
if (!(msg_hwnd = NtUserCreateWindowEx( 0, &class_name, &class_name, NULL, 0, 0, 0, 0, 0,
HWND_MESSAGE, 0, NtCurrentTeb()->Peb->ImageBaseAddress,
NULL, 0, NULL, 0, FALSE )))
return TRUE;
if (keyboard_grabbed)
{
WARN( "refusing to clip to %s\n", wine_dbgstr_rect(clip) );
......@@ -376,26 +368,25 @@ static BOOL grab_clipping_window( const RECT *clip )
}
/* enable XInput2 unless we are already clipping */
if (!data->clip_hwnd) enable_xinput2();
if (!data->clipping_cursor) enable_xinput2();
if (data->xi2_state != xi_enabled)
{
WARN( "XInput2 not supported, refusing to clip to %s\n", wine_dbgstr_rect(clip) );
NtUserDestroyWindow( msg_hwnd );
NtUserClipCursor( NULL );
return TRUE;
}
TRACE( "clipping to %s win %lx\n", wine_dbgstr_rect(clip), clip_window );
if (!data->clip_hwnd) XUnmapWindow( data->display, clip_window );
if (!data->clipping_cursor) XUnmapWindow( data->display, clip_window );
pos = virtual_screen_to_root( clip->left, clip->top );
XMoveResizeWindow( data->display, clip_window, pos.x, pos.y,
max( 1, clip->right - clip->left ), max( 1, clip->bottom - clip->top ) );
XMapWindow( data->display, clip_window );
/* if the rectangle is shrinking we may get a pointer warp */
if (!data->clip_hwnd || clip->left > clip_rect.left || clip->top > clip_rect.top ||
if (!data->clipping_cursor || clip->left > clip_rect.left || clip->top > clip_rect.top ||
clip->right < clip_rect.right || clip->bottom < clip_rect.bottom)
data->warp_serial = NextRequest( data->display );
......@@ -418,11 +409,10 @@ static BOOL grab_clipping_window( const RECT *clip )
if (!clipping_cursor)
{
disable_xinput2();
NtUserDestroyWindow( msg_hwnd );
return FALSE;
}
clip_rect = *clip;
data->clip_hwnd = msg_hwnd;
data->clipping_cursor = TRUE;
return TRUE;
#else
WARN( "XInput2 was not available at compile time\n" );
......@@ -446,8 +436,7 @@ void ungrab_clipping_window(void)
XUnmapWindow( data->display, clip_window );
if (clipping_cursor) XUngrabPointer( data->display, CurrentTime );
clipping_cursor = FALSE;
NtUserDestroyWindow( data->clip_hwnd );
data->clip_hwnd = 0;
data->clipping_cursor = FALSE;
disable_xinput2();
}
......@@ -495,7 +484,7 @@ static void map_event_coords( HWND hwnd, Window window, Window event_root, int x
if (!hwnd)
{
thread_data = x11drv_thread_data();
if (!thread_data->clip_hwnd) return;
if (!thread_data->clipping_cursor) return;
if (thread_data->clip_window != window) return;
pt.x += clip_rect.left;
pt.y += clip_rect.top;
......@@ -539,10 +528,7 @@ static void send_mouse_input( HWND hwnd, Window window, unsigned int state, INPU
if (!hwnd)
{
struct x11drv_thread_data *thread_data = x11drv_thread_data();
HWND clip_hwnd = thread_data->clip_hwnd;
if (!clip_hwnd) return;
if (thread_data->clip_window != window) return;
if (!thread_data->clipping_cursor || thread_data->clip_window != window) return;
__wine_send_input( hwnd, input, NULL );
return;
}
......
......@@ -388,7 +388,7 @@ struct x11drv_thread_data
Window selection_wnd; /* window used for selection interactions */
unsigned long warp_serial; /* serial number of last pointer warp request */
Window clip_window; /* window used for cursor clipping */
HWND clip_hwnd; /* message window stored in desktop while clipping is active */
BOOL clipping_cursor; /* whether thread is currently clipping the cursor */
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
enum { xi_unavailable = -1, xi_unknown, xi_disabled, xi_enabled } xi2_state; /* XInput2 state */
void *xi2_devices; /* list of XInput2 devices (valid when state is enabled) */
......
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