winex11: Get rid of the ClipCursor and SendInput entry points.

This commit is contained in:
Alexandre Julliard 2011-03-02 16:28:23 +01:00
parent f1a3480068
commit f46bd50a80
5 changed files with 26 additions and 251 deletions

View File

@ -1549,32 +1549,3 @@ static void X11DRV_ClientMessage( HWND hwnd, XEvent *xev )
} }
TRACE( "no handler found for %ld\n", event->message_type ); TRACE( "no handler found for %ld\n", event->message_type );
} }
/***********************************************************************
* X11DRV_SendInput (X11DRV.@)
*/
UINT CDECL X11DRV_SendInput( UINT count, LPINPUT inputs, int size )
{
UINT i;
for (i = 0; i < count; i++, inputs++)
{
switch(inputs->type)
{
case INPUT_MOUSE:
X11DRV_send_mouse_input( 0, inputs->u.mi.dwFlags, inputs->u.mi.dx, inputs->u.mi.dy,
inputs->u.mi.mouseData, inputs->u.mi.time,
inputs->u.mi.dwExtraInfo, LLMHF_INJECTED );
break;
case INPUT_KEYBOARD:
X11DRV_send_keyboard_input( 0, inputs->u.ki.wVk, inputs->u.ki.wScan, inputs->u.ki.dwFlags,
inputs->u.ki.time, inputs->u.ki.dwExtraInfo, LLKHF_INJECTED );
break;
case INPUT_HARDWARE:
FIXME( "INPUT_HARDWARE not supported\n" );
break;
}
}
return count;
}

View File

@ -60,16 +60,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(keyboard); WINE_DEFAULT_DEBUG_CHANNEL(keyboard);
WINE_DECLARE_DEBUG_CHANNEL(key); WINE_DECLARE_DEBUG_CHANNEL(key);
/* key state table bits:
0x80 -> key is pressed
0x40 -> key got pressed since last time
0x01 -> key is toggled
*/
static BYTE key_state_table[256];
static BYTE TrackSysKey = 0; /* determine whether ALT key up will cause a WM_SYSKEYUP
or a WM_KEYUP message */
static int min_keycode, max_keycode, keysyms_per_keycode; static int min_keycode, max_keycode, keysyms_per_keycode;
static WORD keyc2vkey[256], keyc2scan[256]; static WORD keyc2vkey[256], keyc2scan[256];
@ -1150,106 +1140,18 @@ static WORD EVENT_event_to_vkey( XIC xic, XKeyEvent *e)
/*********************************************************************** /***********************************************************************
* X11DRV_send_keyboard_input * X11DRV_send_keyboard_input
*/ */
void X11DRV_send_keyboard_input( HWND hwnd, WORD wVk, WORD wScan, DWORD event_flags, DWORD time, static void X11DRV_send_keyboard_input( HWND hwnd, WORD vkey, WORD scan, DWORD flags, DWORD time )
DWORD dwExtraInfo, UINT injected_flags )
{ {
UINT message;
INPUT input; INPUT input;
WORD flags, wVkStripped, wVkL, wVkR, vk_hook = wVk;
if (!time) time = GetTickCount(); TRACE_(key)( "vkey=%04x scan=%04x flags=%04x\n", vkey, scan, flags );
wVk = LOBYTE(wVk);
flags = LOBYTE(wScan);
if (event_flags & KEYEVENTF_EXTENDEDKEY) flags |= KF_EXTENDED;
/* FIXME: set KF_DLGMODE and KF_MENUMODE when needed */
/* strip left/right for menu, control, shift */
switch (wVk)
{
case VK_MENU:
case VK_LMENU:
case VK_RMENU:
wVk = (event_flags & KEYEVENTF_EXTENDEDKEY) ? VK_RMENU : VK_LMENU;
wVkStripped = VK_MENU;
wVkL = VK_LMENU;
wVkR = VK_RMENU;
break;
case VK_CONTROL:
case VK_LCONTROL:
case VK_RCONTROL:
wVk = (event_flags & KEYEVENTF_EXTENDEDKEY) ? VK_RCONTROL : VK_LCONTROL;
wVkStripped = VK_CONTROL;
wVkL = VK_LCONTROL;
wVkR = VK_RCONTROL;
break;
case VK_SHIFT:
case VK_LSHIFT:
case VK_RSHIFT:
wVk = (event_flags & KEYEVENTF_EXTENDEDKEY) ? VK_RSHIFT : VK_LSHIFT;
wVkStripped = VK_SHIFT;
wVkL = VK_LSHIFT;
wVkR = VK_RSHIFT;
break;
default:
wVkStripped = wVkL = wVkR = wVk;
}
if (event_flags & KEYEVENTF_KEYUP)
{
message = WM_KEYUP;
if (((key_state_table[VK_MENU] & 0x80) &&
((wVkStripped == VK_MENU) || (wVkStripped == VK_CONTROL)
|| !(key_state_table[VK_CONTROL] & 0x80)))
|| (wVkStripped == VK_F10))
{
if( TrackSysKey == VK_MENU || /* <ALT>-down/<ALT>-up sequence */
(wVkStripped != VK_MENU)) /* <ALT>-down...<something else>-up */
message = WM_SYSKEYUP;
TrackSysKey = 0;
}
flags |= KF_REPEAT | KF_UP;
}
else
{
message = WM_KEYDOWN;
if (((key_state_table[VK_MENU] & 0x80 || wVkStripped == VK_MENU) &&
!(key_state_table[VK_CONTROL] & 0x80 || wVkStripped == VK_CONTROL)) ||
(wVkStripped == VK_F10))
{
message = WM_SYSKEYDOWN;
TrackSysKey = wVkStripped;
}
if (!(event_flags & KEYEVENTF_UNICODE) && key_state_table[wVk] & 0x80) flags |= KF_REPEAT;
}
if (event_flags & KEYEVENTF_UNICODE) vk_hook = wVk = VK_PACKET;
input.type = INPUT_KEYBOARD; input.type = INPUT_KEYBOARD;
input.u.ki.wVk = vk_hook; input.u.ki.wVk = vkey;
input.u.ki.wScan = wScan; input.u.ki.wScan = scan;
input.u.ki.dwFlags = event_flags; input.u.ki.dwFlags = flags;
input.u.ki.time = time; input.u.ki.time = time;
input.u.ki.dwExtraInfo = dwExtraInfo; input.u.ki.dwExtraInfo = 0;
if (!(event_flags & KEYEVENTF_UNICODE))
{
if (event_flags & KEYEVENTF_KEYUP)
{
key_state_table[wVk] &= ~0x80;
key_state_table[wVkStripped] = key_state_table[wVkL] | key_state_table[wVkR];
}
else
{
if (!(key_state_table[wVk] & 0x80)) key_state_table[wVk] ^= 0x01;
key_state_table[wVk] |= 0xc0;
key_state_table[wVkStripped] = key_state_table[wVkL] | key_state_table[wVkR];
}
}
TRACE_(key)("message=0x%04x wParam=0x%04x InputKeyState=0x%x\n",
message, wVk, key_state_table[wVk]);
__wine_send_input( hwnd, &input ); __wine_send_input( hwnd, &input );
} }
@ -1317,7 +1219,7 @@ void X11DRV_KeymapNotify( HWND hwnd, XEvent *event )
vkey, keystate[vkey & 0xff]); vkey, keystate[vkey & 0xff]);
/* Fake key being pressed inside wine */ /* Fake key being pressed inside wine */
X11DRV_send_keyboard_input( hwnd, vkey & 0xff, scan & 0xff, flags, time, 0, 0 ); X11DRV_send_keyboard_input( hwnd, vkey & 0xff, scan & 0xff, flags, time );
} }
break; break;
} }
@ -1340,8 +1242,8 @@ static void update_lock_state( HWND hwnd, WORD vkey, UINT state, DWORD time )
DWORD flags = 0; DWORD flags = 0;
if (keystate[VK_CAPITAL] & 0x80) flags ^= KEYEVENTF_KEYUP; if (keystate[VK_CAPITAL] & 0x80) flags ^= KEYEVENTF_KEYUP;
TRACE("Adjusting CapsLock state (%#.2x)\n", keystate[VK_CAPITAL]); TRACE("Adjusting CapsLock state (%#.2x)\n", keystate[VK_CAPITAL]);
X11DRV_send_keyboard_input( hwnd, VK_CAPITAL, 0x3a, flags, time, 0, 0 ); X11DRV_send_keyboard_input( hwnd, VK_CAPITAL, 0x3a, flags, time );
X11DRV_send_keyboard_input( hwnd, VK_CAPITAL, 0x3a, flags ^ KEYEVENTF_KEYUP, time, 0, 0 ); X11DRV_send_keyboard_input( hwnd, VK_CAPITAL, 0x3a, flags ^ KEYEVENTF_KEYUP, time );
} }
/* Adjust the NUMLOCK state if it has been changed outside wine */ /* Adjust the NUMLOCK state if it has been changed outside wine */
@ -1350,8 +1252,8 @@ static void update_lock_state( HWND hwnd, WORD vkey, UINT state, DWORD time )
DWORD flags = KEYEVENTF_EXTENDEDKEY; DWORD flags = KEYEVENTF_EXTENDEDKEY;
if (keystate[VK_NUMLOCK] & 0x80) flags ^= KEYEVENTF_KEYUP; if (keystate[VK_NUMLOCK] & 0x80) flags ^= KEYEVENTF_KEYUP;
TRACE("Adjusting NumLock state (%#.2x)\n", keystate[VK_NUMLOCK]); TRACE("Adjusting NumLock state (%#.2x)\n", keystate[VK_NUMLOCK]);
X11DRV_send_keyboard_input( hwnd, VK_NUMLOCK, 0x45, flags, time, 0, 0 ); X11DRV_send_keyboard_input( hwnd, VK_NUMLOCK, 0x45, flags, time );
X11DRV_send_keyboard_input( hwnd, VK_NUMLOCK, 0x45, flags ^ KEYEVENTF_KEYUP, time, 0, 0 ); X11DRV_send_keyboard_input( hwnd, VK_NUMLOCK, 0x45, flags ^ KEYEVENTF_KEYUP, time );
} }
/* Adjust the SCROLLLOCK state if it has been changed outside wine */ /* Adjust the SCROLLLOCK state if it has been changed outside wine */
@ -1360,8 +1262,8 @@ static void update_lock_state( HWND hwnd, WORD vkey, UINT state, DWORD time )
DWORD flags = 0; DWORD flags = 0;
if (keystate[VK_SCROLL] & 0x80) flags ^= KEYEVENTF_KEYUP; if (keystate[VK_SCROLL] & 0x80) flags ^= KEYEVENTF_KEYUP;
TRACE("Adjusting ScrLock state (%#.2x)\n", keystate[VK_SCROLL]); TRACE("Adjusting ScrLock state (%#.2x)\n", keystate[VK_SCROLL]);
X11DRV_send_keyboard_input( hwnd, VK_SCROLL, 0x46, flags, time, 0, 0 ); X11DRV_send_keyboard_input( hwnd, VK_SCROLL, 0x46, flags, time );
X11DRV_send_keyboard_input( hwnd, VK_SCROLL, 0x46, flags ^ KEYEVENTF_KEYUP, time, 0, 0 ); X11DRV_send_keyboard_input( hwnd, VK_SCROLL, 0x46, flags ^ KEYEVENTF_KEYUP, time );
} }
} }
@ -1467,7 +1369,7 @@ void X11DRV_KeyEvent( HWND hwnd, XEvent *xev )
bScan = keyc2scan[event->keycode] & 0xFF; bScan = keyc2scan[event->keycode] & 0xFF;
TRACE_(key)("bScan = 0x%02x.\n", bScan); TRACE_(key)("bScan = 0x%02x.\n", bScan);
X11DRV_send_keyboard_input( hwnd, vkey & 0xff, bScan, dwFlags, event_time, 0, 0 ); X11DRV_send_keyboard_input( hwnd, vkey & 0xff, bScan, dwFlags, event_time );
} }
/********************************************************************** /**********************************************************************

View File

@ -92,10 +92,8 @@ static const UINT button_up_flags[NB_BUTTONS] =
MOUSEEVENTF_XUP MOUSEEVENTF_XUP
}; };
static POINT cursor_pos;
static HWND cursor_window; static HWND cursor_window;
static DWORD last_time_modified; static DWORD last_time_modified;
static RECT cursor_clip; /* Cursor clipping rect */
static XContext cursor_context; static XContext cursor_context;
static Cursor create_cursor( HANDLE handle ); static Cursor create_cursor( HANDLE handle );
@ -131,19 +129,6 @@ void X11DRV_Xcursor_Init(void)
} }
/***********************************************************************
* clip_point_to_rect
*
* Clip point to the provided rectangle
*/
static inline void clip_point_to_rect( LPCRECT rect, LPPOINT pt )
{
if (pt->x < rect->left) pt->x = rect->left;
else if (pt->x >= rect->right) pt->x = rect->right - 1;
if (pt->y < rect->top) pt->y = rect->top;
else if (pt->y >= rect->bottom) pt->y = rect->bottom - 1;
}
/*********************************************************************** /***********************************************************************
* get_empty_cursor * get_empty_cursor
*/ */
@ -288,57 +273,10 @@ static HWND update_mouse_state( HWND hwnd, Window window, int x, int y, unsigned
/*********************************************************************** /***********************************************************************
* X11DRV_send_mouse_input * X11DRV_send_mouse_input
*/ */
void X11DRV_send_mouse_input( HWND hwnd, DWORD flags, DWORD x, DWORD y, static void X11DRV_send_mouse_input( HWND hwnd, DWORD flags, int x, int y, DWORD data, DWORD time )
DWORD data, DWORD time, DWORD extra_info, UINT injected_flags )
{ {
POINT pt;
INPUT input; INPUT input;
if (!time) time = GetTickCount();
if (flags & MOUSEEVENTF_MOVE && flags & MOUSEEVENTF_ABSOLUTE)
{
if (injected_flags & LLMHF_INJECTED)
{
pt.x = (x * screen_width) >> 16;
pt.y = (y * screen_height) >> 16;
}
else
{
pt.x = x;
pt.y = y;
}
}
else if (flags & MOUSEEVENTF_MOVE)
{
int accel[3];
/* dx and dy can be negative numbers for relative movements */
SystemParametersInfoW(SPI_GETMOUSE, 0, accel, 0);
if (abs(x) > accel[0] && accel[2] != 0)
{
x = (int)x * 2;
if ((abs(x) > accel[1]) && (accel[2] == 2)) x = (int)x * 2;
}
if (abs(y) > accel[0] && accel[2] != 0)
{
y = (int)y * 2;
if ((abs(y) > accel[1]) && (accel[2] == 2)) y = (int)y * 2;
}
wine_tsx11_lock();
pt.x = cursor_pos.x + x;
pt.y = cursor_pos.y + y;
wine_tsx11_unlock();
}
else
{
wine_tsx11_lock();
pt = cursor_pos;
wine_tsx11_unlock();
}
last_time_modified = GetTickCount(); last_time_modified = GetTickCount();
input.type = INPUT_MOUSE; input.type = INPUT_MOUSE;
@ -347,20 +285,9 @@ void X11DRV_send_mouse_input( HWND hwnd, DWORD flags, DWORD x, DWORD y,
input.u.mi.mouseData = data; input.u.mi.mouseData = data;
input.u.mi.dwFlags = flags; input.u.mi.dwFlags = flags;
input.u.mi.time = time; input.u.mi.time = time;
input.u.mi.dwExtraInfo = extra_info; input.u.mi.dwExtraInfo = 0;
__wine_send_input( hwnd, &input ); __wine_send_input( hwnd, &input );
if (injected_flags & LLMHF_INJECTED)
{
if ((flags & MOUSEEVENTF_MOVE) &&
((flags & MOUSEEVENTF_ABSOLUTE) || x || y)) /* we have to actually move the cursor */
{
GetCursorPos( &pt );
if (!(flags & MOUSEEVENTF_ABSOLUTE) || pt.x != x || pt.y != y)
X11DRV_SetCursorPos( pt.x, pt.y );
}
}
} }
#ifdef SONAME_LIBXCURSOR #ifdef SONAME_LIBXCURSOR
@ -964,8 +891,6 @@ BOOL CDECL X11DRV_SetCursorPos( INT x, INT y )
XWarpPointer( display, root_window, root_window, 0, 0, 0, 0, XWarpPointer( display, root_window, root_window, 0, 0, 0, 0,
x - virtual_screen_rect.left, y - virtual_screen_rect.top ); x - virtual_screen_rect.left, y - virtual_screen_rect.top );
XFlush( display ); /* avoids bad mouse lag in games that do their own mouse warping */ XFlush( display ); /* avoids bad mouse lag in games that do their own mouse warping */
cursor_pos.x = x;
cursor_pos.y = y;
wine_tsx11_unlock(); wine_tsx11_unlock();
return TRUE; return TRUE;
} }
@ -979,38 +904,21 @@ BOOL CDECL X11DRV_GetCursorPos(LPPOINT pos)
Window root, child; Window root, child;
int rootX, rootY, winX, winY; int rootX, rootY, winX, winY;
unsigned int xstate; unsigned int xstate;
BOOL ret = FALSE; BOOL ret;
wine_tsx11_lock(); wine_tsx11_lock();
if ((GetTickCount() - last_time_modified > 100) && ret = XQueryPointer( display, root_window, &root, &child, &rootX, &rootY, &winX, &winY, &xstate );
XQueryPointer( display, root_window, &root, &child, if (ret)
&rootX, &rootY, &winX, &winY, &xstate ))
{ {
winX += virtual_screen_rect.left; pos->x = winX + virtual_screen_rect.left;
winY += virtual_screen_rect.top; pos->y = winY + virtual_screen_rect.top;
TRACE("pointer at (%d,%d)\n", winX, winY ); TRACE("pointer at (%d,%d)\n", pos->x, pos->y );
pos->x = winX;
pos->y = winY;
ret = TRUE;
} }
wine_tsx11_unlock(); wine_tsx11_unlock();
return ret; return ret;
} }
/***********************************************************************
* ClipCursor (X11DRV.@)
*
* Set the cursor clipping rectangle.
*/
BOOL CDECL X11DRV_ClipCursor( LPCRECT clip )
{
if (!IntersectRect( &cursor_clip, &virtual_screen_rect, clip ))
cursor_clip = virtual_screen_rect;
return TRUE;
}
/*********************************************************************** /***********************************************************************
* X11DRV_ButtonPress * X11DRV_ButtonPress
*/ */
@ -1050,7 +958,7 @@ void X11DRV_ButtonPress( HWND hwnd, XEvent *xev )
if (!hwnd) return; if (!hwnd) return;
X11DRV_send_mouse_input( hwnd, button_down_flags[buttonNum] | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, X11DRV_send_mouse_input( hwnd, button_down_flags[buttonNum] | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE,
pt.x, pt.y, wData, EVENT_x11_time_to_win32_time(event->time), 0, 0 ); pt.x, pt.y, wData, EVENT_x11_time_to_win32_time(event->time) );
} }
@ -1086,7 +994,7 @@ void X11DRV_ButtonRelease( HWND hwnd, XEvent *xev )
if (!hwnd) return; if (!hwnd) return;
X11DRV_send_mouse_input( hwnd, button_up_flags[buttonNum] | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, X11DRV_send_mouse_input( hwnd, button_up_flags[buttonNum] | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE,
pt.x, pt.y, wData, EVENT_x11_time_to_win32_time(event->time), 0, 0 ); pt.x, pt.y, wData, EVENT_x11_time_to_win32_time(event->time) );
} }
@ -1104,7 +1012,7 @@ void X11DRV_MotionNotify( HWND hwnd, XEvent *xev )
if (!hwnd) return; if (!hwnd) return;
X11DRV_send_mouse_input( hwnd, MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, X11DRV_send_mouse_input( hwnd, MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE,
pt.x, pt.y, 0, EVENT_x11_time_to_win32_time(event->time), 0, 0 ); pt.x, pt.y, 0, EVENT_x11_time_to_win32_time(event->time) );
} }
@ -1126,5 +1034,5 @@ void X11DRV_EnterNotify( HWND hwnd, XEvent *xev )
if (!hwnd) return; if (!hwnd) return;
X11DRV_send_mouse_input( hwnd, MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, X11DRV_send_mouse_input( hwnd, MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE,
pt.x, pt.y, 0, EVENT_x11_time_to_win32_time(event->time), 0, 0 ); pt.x, pt.y, 0, EVENT_x11_time_to_win32_time(event->time) );
} }

View File

@ -69,7 +69,6 @@
@ cdecl GetKeyboardLayoutName(ptr) X11DRV_GetKeyboardLayoutName @ cdecl GetKeyboardLayoutName(ptr) X11DRV_GetKeyboardLayoutName
@ cdecl LoadKeyboardLayout(wstr long) X11DRV_LoadKeyboardLayout @ cdecl LoadKeyboardLayout(wstr long) X11DRV_LoadKeyboardLayout
@ cdecl MapVirtualKeyEx(long long long) X11DRV_MapVirtualKeyEx @ cdecl MapVirtualKeyEx(long long long) X11DRV_MapVirtualKeyEx
@ cdecl SendInput(long ptr long) X11DRV_SendInput
@ cdecl ToUnicodeEx(long long ptr ptr long long long) X11DRV_ToUnicodeEx @ cdecl ToUnicodeEx(long long ptr ptr long long long) X11DRV_ToUnicodeEx
@ cdecl UnloadKeyboardLayout(long) X11DRV_UnloadKeyboardLayout @ cdecl UnloadKeyboardLayout(long) X11DRV_UnloadKeyboardLayout
@ cdecl VkKeyScanEx(long long) X11DRV_VkKeyScanEx @ cdecl VkKeyScanEx(long long) X11DRV_VkKeyScanEx
@ -77,7 +76,6 @@
@ cdecl SetCursor(long) X11DRV_SetCursor @ cdecl SetCursor(long) X11DRV_SetCursor
@ cdecl GetCursorPos(ptr) X11DRV_GetCursorPos @ cdecl GetCursorPos(ptr) X11DRV_GetCursorPos
@ cdecl SetCursorPos(long long) X11DRV_SetCursorPos @ cdecl SetCursorPos(long long) X11DRV_SetCursorPos
@ cdecl ClipCursor(ptr) X11DRV_ClipCursor
@ cdecl GetScreenSaveActive() X11DRV_GetScreenSaveActive @ cdecl GetScreenSaveActive() X11DRV_GetScreenSaveActive
@ cdecl SetScreenSaveActive(long) X11DRV_SetScreenSaveActive @ cdecl SetScreenSaveActive(long) X11DRV_SetScreenSaveActive
@ cdecl ChangeDisplaySettingsEx(ptr ptr long long long) X11DRV_ChangeDisplaySettingsEx @ cdecl ChangeDisplaySettingsEx(ptr ptr long long long) X11DRV_ChangeDisplaySettingsEx

View File

@ -804,10 +804,6 @@ extern void set_window_cursor( struct x11drv_win_data *data, HCURSOR handle );
extern void sync_window_cursor( struct x11drv_win_data *data ); extern void sync_window_cursor( struct x11drv_win_data *data );
extern BOOL CDECL X11DRV_ClipCursor( LPCRECT clip ); extern BOOL CDECL X11DRV_ClipCursor( LPCRECT clip );
extern void X11DRV_InitKeyboard( Display *display ); extern void X11DRV_InitKeyboard( Display *display );
extern void X11DRV_send_keyboard_input( HWND hwnd, WORD wVk, WORD wScan, DWORD dwFlags, DWORD time,
DWORD dwExtraInfo, UINT injected_flags );
extern void X11DRV_send_mouse_input( HWND hwnd, DWORD flags, DWORD x, DWORD y,
DWORD data, DWORD time, DWORD extra_info, UINT injected_flags );
extern DWORD CDECL X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout, extern DWORD CDECL X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout,
DWORD mask, DWORD flags ); DWORD mask, DWORD flags );