ReactOS  0.4.13-dev-73-gcfe54aa
input.c File Reference
#include <stdarg.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "wingdi.h"
#include "winnls.h"
#include "wine/test.h"
Include dependency graph for input.c:

Go to the source code of this file.

Classes

struct  TEST_INPUT
 
struct  KMSG
 
struct  transition_s
 
struct  message
 
struct  sendinput_test_s
 
struct  tounicode_tests
 
struct  thread_data
 
struct  wnd_event
 

Macros

#define _WIN32_WINNT   0x401
 
#define _WIN32_IE   0x0500
 
#define MAXKEYEVENTS   12
 
#define MAXKEYMESSAGES
 
#define ADDTOINPUTS(kev)
 
#define GET_PROC(func)
 
#define STEP   3
 
#define BUFLIM   64
 
#define MYERROR   0xdeadbeef
 
#define shift   1
 
#define ctrl   2
 

Typedefs

typedef enum KEVtag KEV
 

Enumerations

enum  KEVtag {
  ALTDOWN = 1, ALTUP, XDOWN, XUP,
  SHIFTDOWN, SHIFTUP, CTRLDOWN, CTRLUP
}
 
enum  msg_flags_t {
  sent = 0x1, posted = 0x2, parent = 0x4, wparam = 0x8,
  lparam = 0x10, defwinproc = 0x20, beginpaint = 0x40, optional = 0x80,
  hook = 0x100, winevent_hook =0x200, id = 0x400, custdraw = 0x800,
  sent = 0x1, posted = 0x2, parent = 0x4, wparam = 0x8,
  lparam = 0x10, defwinproc = 0x20, beginpaint = 0x40, optional = 0x80,
  hook = 0x100, winevent_hook =0x200, id = 0x400, sent =0x1,
  posted =0x2, parent =0x4, wparam =0x8, lparam =0x10,
  defwinproc =0x20, beginpaint =0x40, optional =0x80, hook =0x100,
  winevent_hook =0x200, sent =0x1, posted =0x2, parent =0x4,
  wparam =0x8, lparam =0x10, defwinproc =0x20, beginpaint =0x40,
  optional =0x80, hook =0x100, winevent_hook =0x200, kbd_hook =0x400
}
 

Functions

static UINT (WINAPI *pSendInput)(UINT
 
static int (WINAPI *pGetMouseMovePointsEx)(UINT
 
static void init_function_pointers (void)
 
static int KbdMessage (KEV kev, WPARAM *pwParam, LPARAM *plParam)
 
static BOOL do_test (HWND hwnd, int seqnr, const KEV td[])
 
static BOOL TestASet (HWND hWnd, int nrkev, const KEV kevdwn[], const KEV kevup[])
 
static void TestSysKeys (HWND hWnd)
 
static LRESULT CALLBACK WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
static void test_Input_whitebox (void)
 
static BOOL is_keyboard_message (UINT message)
 
static BOOL is_mouse_message (UINT message)
 
static void empty_message_queue (void)
 
static void compare_and_check (int id, BYTE *ks1, BYTE *ks2, const struct sendinput_test_s *test)
 
static LRESULT CALLBACK WndProc2 (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK hook_proc (int code, WPARAM wparam, LPARAM lparam)
 
static void test_Input_blackbox (void)
 
static void reset_key_status (void)
 
static void test_unicode_keys (HWND hwnd, HHOOK hook)
 
static LRESULT CALLBACK unicode_wnd_proc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK llkbd_unicode_hook (int nCode, WPARAM wParam, LPARAM lParam)
 
static void test_Input_unicode (void)
 
static void test_keynames (void)
 
static LRESULT CALLBACK hook_proc1 (int code, WPARAM wparam, LPARAM lparam)
 
static LRESULT CALLBACK hook_proc2 (int code, WPARAM wparam, LPARAM lparam)
 
static LRESULT CALLBACK hook_proc3 (int code, WPARAM wparam, LPARAM lparam)
 
static void test_mouse_ll_hook (void)
 
static void test_GetMouseMovePointsEx (void)
 
static void test_GetRawInputDeviceList (void)
 
static void test_key_map (void)
 
static void test_ToUnicode (void)
 
static void test_ToAscii (void)
 
static void test_get_async_key_state (void)
 
static void test_keyboard_layout_name (void)
 
static void test_key_names (void)
 
static void simulate_click (BOOL left, int x, int y)
 
static BOOL wait_for_message (MSG *msg)
 
static BOOL wait_for_event (HANDLE event, int timeout)
 
static LRESULT WINAPI static_hook_proc (HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
 
static DWORD WINAPI create_static_win (void *arg)
 
static void get_dc_region (RECT *region, HWND hwnd, DWORD flags)
 
static void test_Input_mouse (void)
 
static LRESULT WINAPI MsgCheckProcA (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static DWORD WINAPI thread_proc (void *param)
 
static void test_attach_input (void)
 
static DWORD WINAPI get_key_state_thread (void *arg)
 
static void test_GetKeyState (void)
 
static void test_OemKeyScan (void)
 
 START_TEST (input)
 

Variables

static HWND hWndTest
 
static LONG timetag = 0x10000000
 
struct {
   LONG   last_key_down
 
   LONG   last_key_up
 
   LONG   last_syskey_down
 
   LONG   last_syskey_up
 
   LONG   last_char
 
   LONG   last_syschar
 
   LONG   last_hook_down
 
   LONG   last_hook_up
 
   LONG   last_hook_syskey_down
 
   LONG   last_hook_syskey_up
 
   BOOL   expect_alt
 
   BOOL   sendinput_broken
 
key_status
 
static INPUT size_t
 
static LPMOUSEMOVEPOINT
 
static int
 
static DWORD
 
static PUINT
 
static UINT
 
static LPRECT
 
static const charMSGNAME []
 
static const int GETVKEY [] ={0, VK_MENU, VK_MENU, 'X', 'X', VK_SHIFT, VK_SHIFT, VK_CONTROL, VK_CONTROL}
 
static const int GETSCAN [] ={0, 0x38, 0x38, 0x2D, 0x2D, 0x2A, 0x2A, 0x1D, 0x1D }
 
static const int GETFLAGS [] ={0, 0, KEYEVENTF_KEYUP, 0, KEYEVENTF_KEYUP, 0, KEYEVENTF_KEYUP, 0, KEYEVENTF_KEYUP}
 
static const chargetdesc [] ={"", "+alt","-alt","+X","-X","+shift","-shift","+ctrl","-ctrl"}
 
struct {
   int   nrkev
 
   KEV   keydwn [MAXKEYEVENTS]
 
   KEV   keyup [MAXKEYEVENTS]
 
testkeyset []
 
static BYTE InputKeyStateTable [256]
 
static BYTE AsyncKeyStateTable [256]
 
static BYTE TrackSysKey = 0
 
static const struct sendinput_test_s sendinput_test []
 
static struct message sent_messages [MAXKEYMESSAGES]
 
static UINT sent_messages_cnt
 
static POINT pt_old
 
static POINT pt_new
 
static BOOL clipped
 
static const struct tounicode_tests utests []
 
static WNDPROC def_static_proc
 
static DWORD hittest_no
 

Macro Definition Documentation

◆ _WIN32_IE

#define _WIN32_IE   0x0500

Definition at line 49 of file input.c.

◆ _WIN32_WINNT

#define _WIN32_WINNT   0x401

Definition at line 48 of file input.c.

◆ ADDTOINPUTS

#define ADDTOINPUTS (   kev)
Value:
inputs[evtctr].type = INPUT_KEYBOARD; \
((TEST_INPUT*)inputs)[evtctr].u.ki.wVk = GETVKEY[ kev]; \
((TEST_INPUT*)inputs)[evtctr].u.ki.wScan = GETSCAN[ kev]; \
((TEST_INPUT*)inputs)[evtctr].u.ki.dwFlags = GETFLAGS[ kev]; \
((TEST_INPUT*)inputs)[evtctr].u.ki.dwExtraInfo = 0; \
((TEST_INPUT*)inputs)[evtctr].u.ki.time = ++timetag; \
if( kev) evtctr++;
#define INPUT_KEYBOARD
Definition: winable.h:10
static const int GETFLAGS[]
Definition: input.c:107
static LONG timetag
Definition: input.c:69
static const int GETSCAN[]
Definition: input.c:105
static const int GETVKEY[]
Definition: input.c:103

Definition at line 123 of file input.c.

◆ BUFLIM

#define BUFLIM   64

◆ ctrl

#define ctrl   2

Definition at line 1669 of file input.c.

◆ GET_PROC

#define GET_PROC (   func)
Value:
p ## func = (void*)GetProcAddress(hdll, #func); \
if(!p ## func) \
trace("GetProcAddress(%s) failed\n", #func);
GLenum func
Definition: glext.h:6028
static PVOID hdll
Definition: shimdbg.c:126
#define GetProcAddress(x, y)
Definition: compat.h:410
GLfloat GLfloat p
Definition: glext.h:8902

◆ MAXKEYEVENTS

#define MAXKEYEVENTS   12

Definition at line 91 of file input.c.

◆ MAXKEYMESSAGES

#define MAXKEYMESSAGES
Value:
MAXKEYEVENTS /* assuming a key event generates one
and only one message */
#define MAXKEYEVENTS
Definition: input.c:91

Definition at line 92 of file input.c.

◆ MYERROR

#define MYERROR   0xdeadbeef

◆ shift

#define shift   1

Definition at line 1668 of file input.c.

◆ STEP

#define STEP   3

Definition at line 1238 of file input.c.

Typedef Documentation

◆ KEV

typedef enum KEVtag KEV

Enumeration Type Documentation

◆ KEVtag

Enumerator
ALTDOWN 
ALTUP 
XDOWN 
XUP 
SHIFTDOWN 
SHIFTUP 
CTRLDOWN 
CTRLUP 

Definition at line 100 of file input.c.

Definition: input.c:101
Definition: input.c:101
Definition: input.c:101
Definition: input.c:101
enum KEVtag KEV
Definition: input.c:101
Definition: input.c:101

◆ msg_flags_t

Enumerator
sent 
posted 
parent 
wparam 
lparam 
defwinproc 
beginpaint 
optional 
hook 
winevent_hook 
id 
custdraw 
sent 
posted 
parent 
wparam 
lparam 
defwinproc 
beginpaint 
optional 
hook 
winevent_hook 
id 
sent 
posted 
parent 
wparam 
lparam 
defwinproc 
beginpaint 
optional 
hook 
winevent_hook 
sent 
posted 
parent 
wparam 
lparam 
defwinproc 
beginpaint 
optional 
hook 
winevent_hook 
kbd_hook 

Definition at line 423 of file input.c.

423  {
424  sent=0x1,
425  posted=0x2,
426  parent=0x4,
427  wparam=0x8,
428  lparam=0x10,
429  defwinproc=0x20,
430  beginpaint=0x40,
431  optional=0x80,
432  hook=0x100,
433  winevent_hook=0x200
434 } msg_flags_t;
msg_flags_t
Definition: input.c:423
Definition: input.c:424
Definition: input.c:426
Definition: input.c:427
Definition: input.c:428
Definition: input.c:432
Definition: input.c:425

Function Documentation

◆ compare_and_check()

static void compare_and_check ( int  id,
BYTE ks1,
BYTE ks2,
const struct sendinput_test_s test 
)
static

Definition at line 703 of file input.c.

704 {
705  int i, failcount = 0;
706  const struct transition_s *t = test->expected_transitions;
707  UINT actual_cnt = 0;
708  const struct message *expected = test->expected_messages;
709 
710  while (t->wVk) {
711  BOOL matched = ((ks1[t->wVk]&0x80) == (t->before_state&0x80)
712  && (ks2[t->wVk]&0x80) == (~t->before_state&0x80));
713 
714  if (!matched && !t->optional && test->_todo_wine)
715  {
716  failcount++;
717  todo_wine {
718  ok(matched, "%2d (%x/%x): %02x from %02x -> %02x "
719  "instead of %02x -> %02x\n", id, test->wVk, test->dwFlags,
720  t->wVk, ks1[t->wVk]&0x80, ks2[t->wVk]&0x80, t->before_state,
721  ~t->before_state&0x80);
722  }
723  } else {
724  ok(matched || t->optional, "%2d (%x/%x): %02x from %02x -> %02x "
725  "instead of %02x -> %02x\n", id, test->wVk, test->dwFlags,
726  t->wVk, ks1[t->wVk]&0x80, ks2[t->wVk]&0x80, t->before_state,
727  ~t->before_state&0x80);
728  }
729  ks2[t->wVk] = ks1[t->wVk]; /* clear the match */
730  t++;
731  }
732  for (i = 0; i < 256; i++)
733  if (ks2[i] != ks1[i] && test->_todo_wine)
734  {
735  failcount++;
736  todo_wine
737  ok(FALSE, "%2d (%x/%x): %02x from %02x -> %02x unexpected\n",
738  id, test->wVk, test->dwFlags, i, ks1[i], ks2[i]);
739  }
740  else
741  ok(ks2[i] == ks1[i], "%2d (%x/%x): %02x from %02x -> %02x unexpected\n",
742  id, test->wVk, test->dwFlags, i, ks1[i], ks2[i]);
743 
744  while (expected->message && actual_cnt < sent_messages_cnt)
745  {
746  const struct message *actual = &sent_messages[actual_cnt];
747 
748  if (expected->message == actual->message)
749  {
750  if (expected->flags & wparam)
751  {
752  if ((expected->flags & optional) && (expected->wParam != actual->wParam))
753  {
754  expected++;
755  continue;
756  }
757  if (expected->wParam != actual->wParam && test->_todo_wine)
758  {
759  failcount++;
760  todo_wine
761  ok(FALSE, "%2d (%x/%x): in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
762  id, test->wVk, test->dwFlags, expected->message, expected->wParam, actual->wParam);
763  }
764  else
765  ok(expected->wParam == actual->wParam,
766  "%2d (%x/%x): in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
767  id, test->wVk, test->dwFlags, expected->message, expected->wParam, actual->wParam);
768  }
769  if (expected->flags & lparam)
770  {
771  if (expected->lParam != actual->lParam && test->_todo_wine)
772  {
773  failcount++;
774  todo_wine
775  ok(FALSE, "%2d (%x/%x): in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
776  id, test->wVk, test->dwFlags, expected->message, expected->lParam, actual->lParam);
777  }
778  else
779  ok(expected->lParam == actual->lParam,
780  "%2d (%x/%x): in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
781  id, test->wVk, test->dwFlags, expected->message, expected->lParam, actual->lParam);
782  }
783  ok((expected->flags & hook) == (actual->flags & hook),
784  "%2d (%x/%x): the msg 0x%04x should have been sent by a hook\n",
785  id, test->wVk, test->dwFlags, expected->message);
786 
787  }
788  else if (expected->flags & optional)
789  {
790  expected++;
791  continue;
792  }
793  /* NT4 doesn't send SYSKEYDOWN/UP to hooks, only KEYDOWN/UP */
794  else if ((expected->flags & hook) &&
795  (expected->message == WM_SYSKEYDOWN || expected->message == WM_SYSKEYUP) &&
796  (actual->message == expected->message - 4))
797  {
798  ok((expected->flags & hook) == (actual->flags & hook),
799  "%2d (%x/%x): the msg 0x%04x should have been sent by a hook\n",
800  id, test->wVk, test->dwFlags, expected->message);
801  }
802  /* For VK_RMENU, at least localized Win2k/XP sends KEYDOWN/UP
803  * instead of SYSKEYDOWN/UP to the WNDPROC */
804  else if (test->wVk == VK_RMENU && !(expected->flags & hook) &&
805  (expected->message == WM_SYSKEYDOWN || expected->message == WM_SYSKEYUP) &&
806  (actual->message == expected->message - 4))
807  {
808  ok(expected->wParam == actual->wParam && expected->lParam == actual->lParam,
809  "%2d (%x/%x): the msg 0x%04x was expected, but got msg 0x%04x instead\n",
810  id, test->wVk, test->dwFlags, expected->message, actual->message);
811  }
812  else if (test->_todo_wine)
813  {
814  failcount++;
815  todo_wine
816  ok(FALSE,
817  "%2d (%x/%x): the msg 0x%04x was expected, but got msg 0x%04x instead\n",
818  id, test->wVk, test->dwFlags, expected->message, actual->message);
819  }
820  else
821  ok(FALSE,
822  "%2d (%x/%x): the msg 0x%04x was expected, but got msg 0x%04x instead\n",
823  id, test->wVk, test->dwFlags, expected->message, actual->message);
824 
825  actual_cnt++;
826  expected++;
827  }
828  /* skip all optional trailing messages */
829  while (expected->message && (expected->flags & optional))
830  expected++;
831 
832 
833  if (expected->message || actual_cnt < sent_messages_cnt)
834  {
835  if (test->_todo_wine)
836  {
837  failcount++;
838  todo_wine
839  ok(FALSE, "%2d (%x/%x): the msg sequence is not complete: expected %04x - actual %04x\n",
840  id, test->wVk, test->dwFlags, expected->message, sent_messages[actual_cnt].message);
841  }
842  else
843  ok(FALSE, "%2d (%x/%x): the msg sequence is not complete: expected %04x - actual %04x\n",
844  id, test->wVk, test->dwFlags, expected->message, sent_messages[actual_cnt].message);
845  }
846 
847  if( test->_todo_wine && !failcount) /* succeeded yet marked todo */
848  todo_wine
849  ok(TRUE, "%2d (%x/%x): marked \"todo_wine\" but succeeds\n", id, test->wVk, test->dwFlags);
850 
851  sent_messages_cnt = 0;
852 }
static struct message sent_messages[MAXKEYMESSAGES]
Definition: input.c:699
UINT message
Definition: msg.h:50
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define VK_RMENU
Definition: winuser.h:2241
GLdouble GLdouble t
Definition: gl.h:2047
#define test
Definition: rosglue.h:37
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
Definition: input.c:427
Definition: input.c:428
#define todo_wine
Definition: test.h:154
#define WM_SYSKEYUP
Definition: winuser.h:1696
Definition: input.c:432
unsigned int UINT
Definition: ndis.h:50
static UINT sent_messages_cnt
Definition: input.c:700
#define WM_SYSKEYDOWN
Definition: winuser.h:1695
msg_flags_t flags
Definition: msg.h:51
BOOL expected
Definition: store.c:2063

Referenced by test_Input_blackbox().

◆ create_static_win()

static DWORD WINAPI create_static_win ( void arg)
static

Definition at line 1983 of file input.c.

1984 {
1985  struct thread_data *thread_data = arg;
1986  HWND win;
1987 
1988  win = CreateWindowA("static", "static", WS_VISIBLE | WS_POPUP,
1989  100, 100, 100, 100, 0, NULL, NULL, NULL);
1990  ok(win != 0, "CreateWindow failed\n");
1993  thread_data->win = win;
1994 
1997  return 0;
1998 }
static WNDPROC def_static_proc
Definition: input.c:1962
HWND win
Definition: input.c:1980
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
void * arg
Definition: msvc.h:12
static BOOL wait_for_event(HANDLE event, int timeout)
Definition: input.c:1946
#define ok(value,...)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4184
smooth NULL
Definition: ftsmooth.c:416
static LRESULT WINAPI static_hook_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: input.c:1964
HANDLE end_event
Definition: input.c:1979
#define SetWindowLongPtrA
Definition: winuser.h:5214
#define GWLP_WNDPROC
Definition: treelist.c:66
static real win[4][36]
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WS_POPUP
Definition: pedump.c:616
#define WS_VISIBLE
Definition: pedump.c:620
HANDLE start_event
Definition: input.c:1978

Referenced by test_Input_mouse().

◆ do_test()

static BOOL do_test ( HWND  hwnd,
int  seqnr,
const KEV  td[] 
)
static

Definition at line 233 of file input.c.

234 {
235  INPUT inputs[MAXKEYEVENTS];
236  KMSG expmsg[MAXKEYEVENTS];
237  MSG msg;
238  char buf[100];
239  UINT evtctr=0;
240  int kmctr, i;
241 
242  buf[0]='\0';
243  TrackSysKey=0; /* see input.c */
244  for( i = 0; i < MAXKEYEVENTS; i++) {
245  ADDTOINPUTS(td[i])
246  strcat(buf, getdesc[td[i]]);
247  if(td[i])
248  expmsg[i].message = KbdMessage(td[i], &(expmsg[i].wParam), &(expmsg[i].lParam));
249  else
250  expmsg[i].message = 0;
251  }
252  for( kmctr = 0; kmctr < MAXKEYEVENTS && expmsg[kmctr].message; kmctr++)
253  ;
254  ok( evtctr <= MAXKEYEVENTS, "evtctr is above MAXKEYEVENTS\n" );
255  if( evtctr != pSendInput(evtctr, &inputs[0], sizeof(INPUT)))
256  ok (FALSE, "SendInput failed to send some events\n");
257  i = 0;
258  if (winetest_debug > 1)
259  trace("======== key stroke sequence #%d: %s =============\n",
260  seqnr + 1, buf);
262  if (winetest_debug > 1)
263  trace("message[%d] %-15s wParam %04lx lParam %08lx time %x\n", i,
264  MSGNAME[msg.message - WM_KEYFIRST], msg.wParam, msg.lParam, msg.time);
265  if( i < kmctr ) {
266  ok( msg.message == expmsg[i].message &&
267  msg.wParam == expmsg[i].wParam &&
268  msg.lParam == expmsg[i].lParam,
269  "%u/%u: wrong message %x/%08lx/%08lx expected %s/%08lx/%08lx\n",
270  seqnr, i, msg.message, msg.wParam, msg.lParam,
271  MSGNAME[(expmsg[i]).message - WM_KEYFIRST], expmsg[i].wParam, expmsg[i].lParam );
272  }
273  i++;
274  }
275  if (winetest_debug > 1)
276  trace("%d messages retrieved\n", i);
277  if (!i && kmctr)
278  {
279  skip( "simulated keyboard input doesn't work\n" );
280  return FALSE;
281  }
282  ok( i == kmctr, "message count is wrong: got %d expected: %d\n", i, kmctr);
283  return TRUE;
284 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define trace(...)
Definition: kmt_test.h:217
#define ADDTOINPUTS(kev)
Definition: input.c:123
#define TRUE
Definition: types.h:120
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static const char * getdesc[]
Definition: input.c:109
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define MAXKEYEVENTS
Definition: input.c:91
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
int winetest_debug
WPARAM wParam
Definition: combotst.c:138
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static int KbdMessage(KEV kev, WPARAM *pwParam, LPARAM *plParam)
Definition: input.c:179
#define WM_KEYFIRST
Definition: winuser.h:1690
static const char * MSGNAME[]
Definition: input.c:96
#define ok(value,...)
Definition: input.c:132
#define WM_KEYLAST
Definition: winuser.h:1704
UINT message
Definition: input.c:133
static BYTE TrackSysKey
Definition: input.c:159
unsigned int UINT
Definition: ndis.h:50
#define skip(...)
#define msg(x)
Definition: auth_time.c:54
#define PM_REMOVE
Definition: winuser.h:1182
LPARAM lParam
Definition: combotst.c:139

Referenced by TestASet().

◆ empty_message_queue()

static void empty_message_queue ( void  )
static

Definition at line 395 of file input.c.

396 {
397  MSG msg;
398  int diff = 200;
399  int min_timeout = 50;
400  DWORD time = GetTickCount() + diff;
401 
402  while (diff > 0)
403  {
404  if (MsgWaitForMultipleObjects(0, NULL, FALSE, min_timeout, QS_ALLINPUT) == WAIT_TIMEOUT) break;
405  while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
406  {
407  if (is_keyboard_message(msg.message) || is_mouse_message(msg.message))
408  ok(msg.time != 0, "message %#x has time set to 0\n", msg.message);
409 
412  }
413  diff = time - GetTickCount();
414  }
415 }
BOOL WINAPI TranslateMessage(_In_ const MSG *)
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
__u16 time
Definition: mkdosfs.c:366
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WAIT_TIMEOUT
Definition: dderror.h:14
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
#define QS_ALLINPUT
Definition: winuser.h:874
#define msg(x)
Definition: auth_time.c:54
static BOOL is_keyboard_message(UINT message)
Definition: input.c:384
#define PM_REMOVE
Definition: winuser.h:1182
static BOOL is_mouse_message(UINT message)
Definition: input.c:389

Referenced by test_Input_blackbox().

◆ get_dc_region()

static void get_dc_region ( RECT region,
HWND  hwnd,
DWORD  flags 
)
static

Definition at line 2000 of file input.c.

2001 {
2002  int region_type;
2003  HRGN hregion;
2004  HDC hdc;
2005 
2006  hdc = GetDCEx(hwnd, 0, flags);
2007  ok(hdc != NULL, "GetDCEx failed\n");
2008  hregion = CreateRectRgn(40, 40, 60, 60);
2009  ok(hregion != NULL, "CreateRectRgn failed\n");
2010  GetRandomRgn(hdc, hregion, SYSRGN);
2011  region_type = GetRgnBox(hregion, region);
2012  ok(region_type == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", region_type);
2013  DeleteObject(hregion);
2014  ReleaseDC(hwnd, hdc);
2015 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
static HDC
Definition: imagelist.c:92
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
GLbitfield flags
Definition: glext.h:7161
HDC hdc
Definition: main.c:9
int WINAPI GetRgnBox(_In_ HRGN, _Out_ LPRECT)
#define SIMPLEREGION
Definition: wingdi.h:361
int WINAPI GetRandomRgn(_In_ HDC, _In_ HRGN, _In_ INT)
#define SYSRGN
Definition: GetRandomRgn.c:13

Referenced by test_Input_mouse().

◆ get_key_state_thread()

static DWORD WINAPI get_key_state_thread ( void arg)
static

Definition at line 2791 of file input.c.

2792 {
2793  HANDLE *semaphores = arg;
2794  DWORD result;
2795 
2796  ReleaseSemaphore(semaphores[0], 1, NULL);
2797  result = WaitForSingleObject(semaphores[1], 1000);
2798  ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
2799 
2800  result = GetKeyState('X');
2801  ok((result & 0x8000) || broken(!(result & 0x8000)), /* > Win 2003 */
2802  "expected that highest bit is set, got %x\n", result);
2803 
2804  ReleaseSemaphore(semaphores[0], 1, NULL);
2805  result = WaitForSingleObject(semaphores[1], 1000);
2806  ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
2807 
2808  result = GetKeyState('X');
2809  ok(!(result & 0x8000), "expected that highest bit is unset, got %x\n", result);
2810 
2811  return 0;
2812 }
void * arg
Definition: msvc.h:12
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
SHORT WINAPI DECLSPEC_HOTPATCH GetKeyState(int nVirtKey)
Definition: input.c:183
#define WAIT_OBJECT_0
Definition: winbase.h:387
unsigned long DWORD
Definition: ntddk_ex.h:95
#define broken(x)
Definition: _sntprintf.h:21
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:488
GLuint64EXT * result
Definition: glext.h:11304

Referenced by test_GetKeyState().

◆ hook_proc()

static LRESULT CALLBACK hook_proc ( int  code,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 883 of file input.c.

884 {
885  KBDLLHOOKSTRUCT *hook_info = (KBDLLHOOKSTRUCT *)lparam;
886 
887  if (code == HC_ACTION)
888  {
889  ok(sent_messages_cnt < MAXKEYMESSAGES, "Too many messages\n");
891  {
894  sent_messages[sent_messages_cnt].wParam = hook_info->vkCode;
895  sent_messages[sent_messages_cnt++].lParam = hook_info->flags & (LLKHF_UP|LLKHF_EXTENDED);
896  }
897 
898 if(0) /* For some reason not stable on Wine */
899 {
900  if (wparam == WM_KEYDOWN || wparam == WM_SYSKEYDOWN)
901  ok(!(GetAsyncKeyState(hook_info->vkCode) & 0x8000), "key %x should be up\n", hook_info->vkCode);
902  else if (wparam == WM_KEYUP || wparam == WM_SYSKEYUP)
903  ok(GetAsyncKeyState(hook_info->vkCode) & 0x8000, "key %x should be down\n", hook_info->vkCode);
904 }
905 
906  if (winetest_debug > 1)
907  trace("Hook: w=%lx vk:%8x sc:%8x fl:%8x %lx\n", wparam,
908  hook_info->vkCode, hook_info->scanCode, hook_info->flags, hook_info->dwExtraInfo);
909  }
910  return CallNextHookEx( 0, code, wparam, lparam );
911 }
static struct message sent_messages[MAXKEYMESSAGES]
Definition: input.c:699
#define trace(...)
Definition: kmt_test.h:217
int winetest_debug
#define ok(value,...)
#define LLKHF_UP
Definition: winuser.h:2602
#define WM_KEYDOWN
Definition: winuser.h:1691
Definition: input.c:427
#define WM_KEYUP
Definition: winuser.h:1692
Definition: input.c:428
#define MAXKEYMESSAGES
Definition: input.c:92
#define LLKHF_EXTENDED
Definition: winuser.h:2599
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
#define HC_ACTION
Definition: winuser.h:48
#define WM_SYSKEYUP
Definition: winuser.h:1696
Definition: input.c:432
static UINT sent_messages_cnt
Definition: input.c:700
#define WM_SYSKEYDOWN
Definition: winuser.h:1695
ULONG_PTR dwExtraInfo
Definition: winuser.h:3754
SHORT WINAPI DECLSPEC_HOTPATCH GetAsyncKeyState(int vKey)
Definition: input.c:110

Referenced by test_Input_blackbox().

◆ hook_proc1()

static LRESULT CALLBACK hook_proc1 ( int  code,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 1240 of file input.c.

1241 {
1243  POINT pt, pt1;
1244 
1245  if (code == HC_ACTION)
1246  {
1247  /* This is our new cursor position */
1248  pt_new = hook->pt;
1249  /* Should return previous position */
1250  GetCursorPos(&pt);
1251  ok(pt.x == pt_old.x && pt.y == pt_old.y, "GetCursorPos: (%d,%d)\n", pt.x, pt.y);
1252 
1253  /* Should set new position until hook chain is finished. */
1254  pt.x = pt_old.x + STEP;
1255  pt.y = pt_old.y + STEP;
1256  SetCursorPos(pt.x, pt.y);
1257  GetCursorPos(&pt1);
1258  if (clipped)
1259  ok(pt1.x == pt_old.x && pt1.y == pt_old.y, "Wrong set pos: (%d,%d)\n", pt1.x, pt1.y);
1260  else
1261  ok(pt1.x == pt.x && pt1.y == pt.y, "Wrong set pos: (%d,%d)\n", pt1.x, pt1.y);
1262  }
1263  return CallNextHookEx( 0, code, wparam, lparam );
1264 }
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define pt(x, y)
Definition: drawing.c:79
static BOOL clipped
Definition: input.c:1237
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
#define STEP
Definition: input.c:1238
#define ok(value,...)
Definition: input.c:427
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2627
Definition: input.c:428
static POINT pt_old
Definition: input.c:1236
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
#define HC_ACTION
Definition: winuser.h:48
Definition: input.c:432
static POINT pt_new
Definition: input.c:1236

Referenced by test_mouse_ll_hook().

◆ hook_proc2()

static LRESULT CALLBACK hook_proc2 ( int  code,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 1266 of file input.c.

1267 {
1269  POINT pt;
1270 
1271  if (code == HC_ACTION)
1272  {
1273  ok(hook->pt.x == pt_new.x && hook->pt.y == pt_new.y,
1274  "Wrong hook coords: (%d %d) != (%d,%d)\n", hook->pt.x, hook->pt.y, pt_new.x, pt_new.y);
1275 
1276  /* Should match position set above */
1277  GetCursorPos(&pt);
1278  if (clipped)
1279  ok(pt.x == pt_old.x && pt.y == pt_old.y, "GetCursorPos: (%d,%d)\n", pt.x, pt.y);
1280  else
1281  ok(pt.x == pt_old.x +STEP && pt.y == pt_old.y +STEP, "GetCursorPos: (%d,%d)\n", pt.x, pt.y);
1282  }
1283  return CallNextHookEx( 0, code, wparam, lparam );
1284 }
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define pt(x, y)
Definition: drawing.c:79
static BOOL clipped
Definition: input.c:1237
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
#define STEP
Definition: input.c:1238
#define ok(value,...)
Definition: input.c:427
Definition: input.c:428
static POINT pt_old
Definition: input.c:1236
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
#define HC_ACTION
Definition: winuser.h:48
Definition: input.c:432
static POINT pt_new
Definition: input.c:1236

Referenced by test_mouse_ll_hook().

◆ hook_proc3()

static LRESULT CALLBACK hook_proc3 ( int  code,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 1286 of file input.c.

1287 {
1288  POINT pt;
1289 
1290  if (code == HC_ACTION)
1291  {
1292  /* MSLLHOOKSTRUCT does not seem to be reliable and contains different data on each run. */
1293  GetCursorPos(&pt);
1294  ok(pt.x == pt_old.x && pt.y == pt_old.y, "GetCursorPos: (%d,%d)\n", pt.x, pt.y);
1295  }
1296  return CallNextHookEx( 0, code, wparam, lparam );
1297 }
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define pt(x, y)
Definition: drawing.c:79
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
#define ok(value,...)
Definition: input.c:427
Definition: input.c:428
static POINT pt_old
Definition: input.c:1236
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
#define HC_ACTION
Definition: winuser.h:48

Referenced by test_mouse_ll_hook().

◆ init_function_pointers()

static void init_function_pointers ( void  )
static

Definition at line 162 of file input.c.

163 {
164  HMODULE hdll = GetModuleHandleA("user32");
165 
166 #define GET_PROC(func) \
167  p ## func = (void*)GetProcAddress(hdll, #func); \
168  if(!p ## func) \
169  trace("GetProcAddress(%s) failed\n", #func);
170 
172  GET_PROC(GetMouseMovePointsEx)
175 
176 #undef GET_PROC
177 }
#define GET_PROC(func)
int WINAPI GetWindowRgnBox(HWND hWnd, LPRECT lprc)
Definition: paint.c:299
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
static PVOID hdll
Definition: shimdbg.c:126
UINT WINAPI GetRawInputDeviceList(PRAWINPUTDEVICELIST pRawInputDeviceList, PUINT puiNumDevices, UINT cbSize)
Definition: stubs.c:329
UINT WINAPI SendInput(UINT, LPINPUT, int)
Definition: ntwrapper.h:344

Referenced by START_TEST().

◆ int()

static int ( WINAPI pGetMouseMovePointsEx)
static

◆ is_keyboard_message()

static BOOL is_keyboard_message ( UINT  message)
inlinestatic

Definition at line 384 of file input.c.

385 {
386  return (message >= WM_KEYFIRST && message <= WM_KEYLAST);
387 }
Definition: tftpd.h:59
#define WM_KEYFIRST
Definition: winuser.h:1690
#define WM_KEYLAST
Definition: winuser.h:1704

Referenced by empty_message_queue().

◆ is_mouse_message()

static BOOL is_mouse_message ( UINT  message)
inlinestatic

Definition at line 389 of file input.c.

390 {
391  return (message >= WM_MOUSEFIRST && message <= WM_MOUSELAST);
392 }
Definition: tftpd.h:59
#define WM_MOUSEFIRST
Definition: winuser.h:1750
#define WM_MOUSELAST
Definition: winuser.h:1777

Referenced by empty_message_queue().

◆ KbdMessage()

static int KbdMessage ( KEV  kev,
WPARAM pwParam,
LPARAM plParam 
)
static

Definition at line 179 of file input.c.

180 {
181  UINT message;
182  int VKey = GETVKEY[kev];
183  WORD flags;
184 
185  flags = LOBYTE(GETSCAN[kev]);
187 
188  if (GETFLAGS[kev] & KEYEVENTF_KEYUP )
189  {
190  message = WM_KEYUP;
191  if( (InputKeyStateTable[VK_MENU] & 0x80) && (
192  (VKey == VK_MENU) || (VKey == VK_CONTROL) ||
193  !(InputKeyStateTable[VK_CONTROL] & 0x80))) {
194  if( TrackSysKey == VK_MENU || /* <ALT>-down/<ALT>-up sequence */
195  (VKey != VK_MENU)) /* <ALT>-down...<something else>-up */
197  TrackSysKey = 0;
198  }
199  InputKeyStateTable[VKey] &= ~0x80;
200  flags |= KF_REPEAT | KF_UP;
201  }
202  else
203  {
204  if (InputKeyStateTable[VKey] & 0x80) flags |= KF_REPEAT;
205  if (!(InputKeyStateTable[VKey] & 0x80)) InputKeyStateTable[VKey] ^= 0x01;
206  InputKeyStateTable[VKey] |= 0x80;
207  AsyncKeyStateTable[VKey] |= 0x80;
208 
210  if( (InputKeyStateTable[VK_MENU] & 0x80) &&
211  !(InputKeyStateTable[VK_CONTROL] & 0x80)) {
213  TrackSysKey = VKey;
214  }
215  }
216 
217  if (InputKeyStateTable[VK_MENU] & 0x80) flags |= KF_ALTDOWN;
218 
219  if( plParam) *plParam = MAKELPARAM( 1, flags );
220  if( pwParam) *pwParam = VKey;
221  return message;
222 }
Definition: tftpd.h:59
static BYTE AsyncKeyStateTable[256]
Definition: input.c:158
#define LOBYTE(W)
Definition: jmemdos.c:487
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
#define MAKELPARAM(l, h)
Definition: winuser.h:3915
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glext.h:5579
#define KF_UP
Definition: winuser.h:2405
#define VK_MENU
Definition: winuser.h:2158
static BYTE InputKeyStateTable[256]
Definition: input.c:157
static const int GETFLAGS[]
Definition: input.c:107
#define WM_KEYDOWN
Definition: winuser.h:1691
#define KF_EXTENDED
Definition: winuser.h:2400
#define KF_REPEAT
Definition: winuser.h:2404
#define WM_KEYUP
Definition: winuser.h:1692
unsigned short WORD
Definition: ntddk_ex.h:93
GLbitfield flags
Definition: glext.h:7161
static BYTE TrackSysKey
Definition: input.c:159
#define WM_SYSKEYUP
Definition: winuser.h:1696
unsigned int UINT
Definition: ndis.h:50
#define KEYEVENTF_EXTENDEDKEY
Definition: winuser.h:1091
#define KF_ALTDOWN
Definition: winuser.h:2403
#define VK_CONTROL
Definition: winuser.h:2157
#define WM_SYSKEYDOWN
Definition: winuser.h:1695
static const int GETSCAN[]
Definition: input.c:105
static const int GETVKEY[]
Definition: input.c:103

Referenced by do_test().

◆ llkbd_unicode_hook()

static LRESULT CALLBACK llkbd_unicode_hook ( int  nCode,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1125 of file input.c.

1126 {
1127  if(nCode == HC_ACTION){
1129  if(!info->vkCode){
1130  key_status.sendinput_broken = TRUE;
1131  win_skip("SendInput doesn't support unicode on this platform\n");
1132  }else{
1133  if(key_status.expect_alt){
1134  ok(info->vkCode == VK_LMENU, "vkCode should have been VK_LMENU[0x%04x], was: 0x%x\n", VK_LMENU, info->vkCode);
1135  key_status.expect_alt = FALSE;
1136  }else
1137  ok(info->vkCode == VK_PACKET, "vkCode should have been VK_PACKET[0x%04x], was: 0x%x\n", VK_PACKET, info->vkCode);
1138  }
1139  switch(wParam){
1140  case WM_KEYDOWN:
1141  key_status.last_hook_down = info->scanCode;
1142  break;
1143  case WM_KEYUP:
1144  key_status.last_hook_up = info->scanCode;
1145  break;
1146  case WM_SYSKEYDOWN:
1147  key_status.last_hook_syskey_down = info->scanCode;
1148  break;
1149  case WM_SYSKEYUP:
1150  key_status.last_hook_syskey_up = info->scanCode;
1151  break;
1152  }
1153  }
1154  return CallNextHookEx(NULL, nCode, wParam, lParam);
1155 }
#define TRUE
Definition: types.h:120
static struct @1648 key_status
WPARAM wParam
Definition: combotst.c:138
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
#define WM_KEYDOWN
Definition: winuser.h:1691
struct tagKBDLLHOOKSTRUCT * LPKBDLLHOOKSTRUCT
#define WM_KEYUP
Definition: winuser.h:1692
#define VK_LMENU
Definition: winuser.h:2240
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
#define HC_ACTION
Definition: winuser.h:48
#define WM_SYSKEYUP
Definition: winuser.h:1696
#define WM_SYSKEYDOWN
Definition: winuser.h:1695
#define win_skip
Definition: test.h:141
LPARAM lParam
Definition: combotst.c:139

Referenced by test_Input_unicode().

◆ MsgCheckProcA()

static LRESULT WINAPI MsgCheckProcA ( HWND  hwnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 2491 of file input.c.

2492 {
2493  if (message == WM_USER+1)
2494  {
2495  HWND hwnd = (HWND)lParam;
2496  ok(GetFocus() == hwnd, "thread expected focus %p, got %p\n", hwnd, GetFocus());
2497  ok(GetActiveWindow() == hwnd, "thread expected active %p, got %p\n", hwnd, GetActiveWindow());
2498  }
2500 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: tftpd.h:59
HANDLE HWND
Definition: compat.h:13
WPARAM wParam
Definition: combotst.c:138
#define ok(value,...)
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_USER
Definition: winuser.h:1856
HWND WINAPI GetFocus(void)
Definition: window.c:1875
LPARAM lParam
Definition: combotst.c:139
HWND WINAPI GetActiveWindow(void)
Definition: winpos.c:138

Referenced by test_attach_input().

◆ reset_key_status()

static void reset_key_status ( void  )
static

Definition at line 976 of file input.c.

977 {
978  key_status.last_key_down = -1;
979  key_status.last_key_up = -1;
980  key_status.last_syskey_down = -1;
981  key_status.last_syskey_up = -1;
982  key_status.last_char = -1;
983  key_status.last_syschar = -1;
984  key_status.last_hook_down = -1;
985  key_status.last_hook_up = -1;
986  key_status.last_hook_syskey_down = -1;
987  key_status.last_hook_syskey_up = -1;
988  key_status.expect_alt = FALSE;
989  key_status.sendinput_broken = FALSE;
990 }
static struct @1648 key_status

Referenced by test_unicode_keys().

◆ simulate_click()

static void simulate_click ( BOOL  left,
int  x,
int  y 
)
static

Definition at line 1909 of file input.c.

1910 {
1911  INPUT input[2];
1912  UINT events_no;
1913 
1914  SetCursorPos(x, y);
1915  memset(input, 0, sizeof(input));
1916  input[0].type = INPUT_MOUSE;
1917  U(input[0]).mi.dx = x;
1918  U(input[0]).mi.dy = y;
1919  U(input[0]).mi.dwFlags = left ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_RIGHTDOWN;
1920  input[1].type = INPUT_MOUSE;
1921  U(input[1]).mi.dx = x;
1922  U(input[1]).mi.dy = y;
1923  U(input[1]).mi.dwFlags = left ? MOUSEEVENTF_LEFTUP : MOUSEEVENTF_RIGHTUP;
1924  events_no = SendInput(2, input, sizeof(input[0]));
1925  ok(events_no == 2, "SendInput returned %d\n", events_no);
1926 }
#define MOUSEEVENTF_LEFTDOWN
Definition: winuser.h:1170
#define U(x)
Definition: wordpad.c:44
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define ok(value,...)
#define INPUT_MOUSE
Definition: winable.h:9
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2627
GLint left
Definition: glext.h:7726
#define MOUSEEVENTF_LEFTUP
Definition: winuser.h:1171
#define MOUSEEVENTF_RIGHTUP
Definition: winuser.h:1173
GLenum GLenum GLenum input
Definition: glext.h:9031
unsigned int UINT
Definition: ndis.h:50
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define memset(x, y, z)
Definition: compat.h:39
UINT WINAPI SendInput(UINT, LPINPUT, int)
Definition: ntwrapper.h:344
#define MOUSEEVENTF_RIGHTDOWN
Definition: winuser.h:1172

Referenced by test_Input_mouse().

◆ START_TEST()

START_TEST ( input  )

Definition at line 2888 of file input.c.

2889 {
2891 
2892  if (pSendInput)
2893  {
2897  test_Input_mouse();
2898  }
2899  else win_skip("SendInput is not available\n");
2900 
2901  test_keynames();
2903  test_key_map();
2904  test_ToUnicode();
2905  test_ToAscii();
2908  test_key_names();
2910  test_GetKeyState();
2911  test_OemKeyScan();
2912 
2913  if(pGetMouseMovePointsEx)
2915  else
2916  win_skip("GetMouseMovePointsEx is not available\n");
2917 
2918  if(pGetRawInputDeviceList)
2920  else
2921  win_skip("GetRawInputDeviceList is not available\n");
2922 }
static void test_keynames(void)
Definition: input.c:1223
static void test_GetMouseMovePointsEx(void)
Definition: input.c:1433
static void test_get_async_key_state(void)
Definition: input.c:1841
static void test_mouse_ll_hook(void)
Definition: input.c:1299
static void test_Input_whitebox(void)
Definition: input.c:349
static void test_ToAscii(void)
Definition: input.c:1794
static void test_Input_unicode(void)
Definition: input.c:1157
static void test_key_names(void)
Definition: input.c:1869
static void test_OemKeyScan(void)
Definition: input.c:2854
static void test_key_map(void)
Definition: input.c:1616
static void test_Input_blackbox(void)
Definition: input.c:912
static void test_GetKeyState(void)
Definition: input.c:2814
static void test_ToUnicode(void)
Definition: input.c:1721
static void test_keyboard_layout_name(void)
Definition: input.c:1848
static void init_function_pointers(void)
Definition: input.c:162
static void test_GetRawInputDeviceList(void)
Definition: input.c:1569
#define win_skip
Definition: test.h:141
static void test_Input_mouse(void)
Definition: input.c:2017
static void test_attach_input(void)
Definition: input.c:2558

◆ static_hook_proc()

static LRESULT WINAPI static_hook_proc ( HWND  hwnd,
UINT  msg,
WPARAM  wp,
LPARAM  lp 
)
static

Definition at line 1964 of file input.c.

1965 {
1966  if (msg == WM_NCHITTEST)
1967  {
1968  /* break infinite hittest loop */
1969  if(hittest_no > 50) return HTCLIENT;
1970  hittest_no++;
1971  }
1972 
1973  return def_static_proc(hwnd, msg, wp, lp);
1974 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static WNDPROC def_static_proc
Definition: input.c:1962
#define WM_NCHITTEST
Definition: winuser.h:1668
static DWORD hittest_no
Definition: input.c:1963
#define msg(x)
Definition: auth_time.c:54
#define HTCLIENT
Definition: winuser.h:2429

Referenced by create_static_win(), and test_Input_mouse().

◆ test_attach_input()

static void test_attach_input ( void  )
static

Definition at line 2558 of file input.c.

2559 {
2560  HANDLE hThread;
2561  HWND ourWnd, Wnd2;
2562  DWORD ret, tid;
2563  struct wnd_event wnd_event;
2564  WNDCLASSA cls;
2565 
2566  cls.style = 0;
2567  cls.lpfnWndProc = MsgCheckProcA;
2568  cls.cbClsExtra = 0;
2569  cls.cbWndExtra = 0;
2570  cls.hInstance = GetModuleHandleA(0);
2571  cls.hIcon = 0;
2572  cls.hCursor = LoadCursorW( NULL, (LPCWSTR)IDC_ARROW);
2573  cls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
2574  cls.lpszMenuName = NULL;
2575  cls.lpszClassName = "TestWindowClass";
2576  if(!RegisterClassA(&cls)) return;
2577 
2580  wnd_event.attach_from = 0;
2581  wnd_event.attach_to = 0;
2583  if (!wnd_event.start_event)
2584  {
2585  win_skip("skipping interthread message test under win9x\n");
2586  return;
2587  }
2588 
2590  ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
2591 
2592  ok(WaitForSingleObject(wnd_event.start_event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2594 
2595  ourWnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
2596  0, 0, 0, 0, 0, 0, 0, NULL);
2597  ok(ourWnd!= 0, "failed to create ourWnd window\n");
2598 
2599  Wnd2 = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
2600  0, 0, 0, 0, 0, 0, 0, NULL);
2601  ok(Wnd2!= 0, "failed to create Wnd2 window\n");
2602 
2603  SetFocus(ourWnd);
2604  SetActiveWindow(ourWnd);
2605 
2607  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2608 
2609  ok(GetActiveWindow() == ourWnd, "expected active %p, got %p\n", ourWnd, GetActiveWindow());
2610  ok(GetFocus() == ourWnd, "expected focus %p, got %p\n", ourWnd, GetFocus());
2611 
2612  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, (LPARAM)ourWnd);
2613 
2615  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2616  ok(GetActiveWindow() == ourWnd, "expected active %p, got %p\n", ourWnd, GetActiveWindow());
2617  ok(GetFocus() == ourWnd, "expected focus %p, got %p\n", ourWnd, GetFocus());
2618 
2619  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, 0);
2620 
2622  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2623 
2624  ok(GetActiveWindow() == ourWnd, "expected active %p, got %p\n", ourWnd, GetActiveWindow());
2625  ok(GetFocus() == ourWnd, "expected focus %p, got %p\n", ourWnd, GetFocus());
2626  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, (LPARAM)ourWnd);
2627 
2628  SetActiveWindow(Wnd2);
2629  SetFocus(Wnd2);
2630  ok(GetActiveWindow() == Wnd2, "expected active %p, got %p\n", Wnd2, GetActiveWindow());
2631  ok(GetFocus() == Wnd2, "expected focus %p, got %p\n", Wnd2, GetFocus());
2632 
2633  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, (LPARAM)Wnd2);
2634 
2636  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2637  ok(GetActiveWindow() == Wnd2, "expected active %p, got %p\n", Wnd2, GetActiveWindow());
2638  ok(GetFocus() == Wnd2, "expected focus %p, got %p\n", Wnd2, GetFocus());
2639 
2640  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, 0);
2641 
2643  ok(ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
2644 
2645  ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2647 
2650  wnd_event.attach_from = 0;
2651  wnd_event.attach_to = 0;
2653 
2655  ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
2656 
2657  ok(WaitForSingleObject(wnd_event.start_event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2659 
2660  SetFocus(ourWnd);
2661  SetActiveWindow(ourWnd);
2662 
2664  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2665 
2666  ok(GetActiveWindow() == wnd_event.hwnd, "expected active %p, got %p\n", wnd_event.hwnd, GetActiveWindow());
2667  ok(GetFocus() == wnd_event.hwnd, "expected focus %p, got %p\n", wnd_event.hwnd, GetFocus());
2668 
2670 
2672  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2673 
2674  ok(GetActiveWindow() == 0, "expected active 0, got %p\n", GetActiveWindow());
2675  ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
2676 
2678 
2680  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2681 
2682  ok(GetActiveWindow() == wnd_event.hwnd, "expected active %p, got %p\n", wnd_event.hwnd, GetActiveWindow());
2683  ok(GetFocus() == wnd_event.hwnd, "expected focus %p, got %p\n", wnd_event.hwnd, GetFocus());
2684 
2686 
2687  SetFocus(Wnd2);
2688  SetActiveWindow(Wnd2);
2689  ok(GetActiveWindow() == Wnd2, "expected active %p, got %p\n", Wnd2, GetActiveWindow());
2690  ok(GetFocus() == Wnd2, "expected focus %p, got %p\n", Wnd2, GetFocus());
2691 
2692  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, (LPARAM)Wnd2);
2693 
2695  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2696 
2697  ok(GetActiveWindow() == Wnd2, "expected active %p, got %p\n", Wnd2, GetActiveWindow());
2698  ok(GetFocus() == Wnd2, "expected focus %p, got %p\n", Wnd2, GetFocus());
2699 
2700  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, 0);
2701 
2703  ok(ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
2704 
2705  ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2707 
2710  wnd_event.attach_from = 0;
2711  wnd_event.attach_to = 0;
2713 
2715  ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
2716 
2717  SetLastError(0xdeadbeef);
2719  ok(!ret, "AttachThreadInput succeeded\n");
2720  ok(GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef) /* <= Win XP */,
2721  "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
2722 
2723  SetLastError(0xdeadbeef);
2725  ok(!ret, "AttachThreadInput succeeded\n");
2726  ok(GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef) /* <= Win XP */,
2727  "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
2728 
2730 
2731  ok(WaitForSingleObject(wnd_event.start_event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2733 
2735  ok(ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
2736 
2737  ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2739 
2743  wnd_event.attach_to = 0;
2745 
2746  SetFocus(ourWnd);
2747  SetActiveWindow(ourWnd);
2748 
2750  ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
2751 
2752  ok(WaitForSingleObject(wnd_event.start_event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2754 
2755  ok(GetActiveWindow() == ourWnd, "expected active %p, got %p\n", ourWnd, GetActiveWindow());
2756  ok(GetFocus() == ourWnd, "expected focus %p, got %p\n", ourWnd, GetFocus());
2757 
2759  ok(ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
2760 
2761  ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2763 
2766  wnd_event.attach_from = 0;
2769 
2770  SetFocus(ourWnd);
2771  SetActiveWindow(ourWnd);
2772 
2774  ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
2775 
2776  ok(WaitForSingleObject(wnd_event.start_event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2778 
2779  ok(GetActiveWindow() == ourWnd, "expected active %p, got %p\n", ourWnd, GetActiveWindow());
2780  ok(GetFocus() == ourWnd, "expected focus %p, got %p\n", ourWnd, GetFocus());
2781 
2783  ok(ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
2784 
2785  ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2787  DestroyWindow(ourWnd);
2788  DestroyWindow(Wnd2);
2789 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
DWORD attach_to
Definition: input.c:2508
#define CloseHandle
Definition: compat.h:398
static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: input.c:2491
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
BOOL WINAPI AttachThreadInput(_In_ DWORD, _In_ DWORD, _In_ BOOL)
DWORD attach_from
Definition: input.c:2507
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_QUIT
Definition: winuser.h:1605
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI DestroyWindow(_In_ HWND)
#define COLOR_WINDOW
Definition: winuser.h:908
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:597
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HWND WINAPI SetActiveWindow(_In_ HWND)
static DWORD WINAPI thread_proc(void *param)
Definition: input.c:2512
HWND hwnd
Definition: input.c:2504
#define ok(value,...)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:112
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:421
#define WAIT_OBJECT_0
Definition: winbase.h:387
unsigned long DWORD
Definition: ntddk_ex.h:95
HANDLE start_event
Definition: input.c:2506
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
#define SetLastError(x)
Definition: compat.h:409
HANDLE wait_event
Definition: input.c:2505
int ret
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
BOOL setWindows
Definition: input.c:2509
#define WM_USER
Definition: winuser.h:1856
#define broken(x)
Definition: _sntprintf.h:21
UINT style
Definition: winuser.h:3116
HANDLE hThread
Definition: wizard.c:27
HWND WINAPI GetFocus(void)
Definition: window.c:1875
#define IDC_ARROW
Definition: winuser.h:682
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define INFINITE
Definition: serial.h:102
#define win_skip
Definition: test.h:141
static TfClientId tid
HWND WINAPI GetActiveWindow(void)
Definition: winpos.c:138
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)

Referenced by START_TEST().

◆ test_get_async_key_state()

static void test_get_async_key_state ( void  )
static

Definition at line 1841 of file input.c.

1842 {
1843  /* input value sanity checks */
1844  ok(0 == GetAsyncKeyState(1000000), "GetAsyncKeyState did not return 0\n");
1845  ok(0 == GetAsyncKeyState(-1000000), "GetAsyncKeyState did not return 0\n");
1846 }
#define ok(value,...)
SHORT WINAPI DECLSPEC_HOTPATCH GetAsyncKeyState(int vKey)
Definition: input.c:110

Referenced by START_TEST().

◆ test_GetKeyState()

static void test_GetKeyState ( void  )
static

Definition at line 2814 of file input.c.

2815 {
2816  HANDLE semaphores[2];
2817  HANDLE thread;
2818  DWORD result;
2819  HWND hwnd;
2820 
2821  semaphores[0] = CreateSemaphoreA(NULL, 0, 1, NULL);
2822  ok(semaphores[0] != NULL, "CreateSemaphoreA failed %u\n", GetLastError());
2823  semaphores[1] = CreateSemaphoreA(NULL, 0, 1, NULL);
2824  ok(semaphores[1] != NULL, "CreateSemaphoreA failed %u\n", GetLastError());
2825 
2826  hwnd = CreateWindowA("static", "Title", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
2827  10, 10, 200, 200, NULL, NULL, NULL, NULL);
2828  ok(hwnd != NULL, "CreateWindowA failed %u\n", GetLastError());
2829 
2830  thread = CreateThread(NULL, 0, get_key_state_thread, semaphores, 0, NULL);
2831  ok(thread != NULL, "CreateThread failed %u\n", GetLastError());
2832  result = WaitForSingleObject(semaphores[0], 1000);
2833  ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
2834 
2835  SetFocus(hwnd);
2836  keybd_event('X', 0, 0, 0);
2837 
2838  ReleaseSemaphore(semaphores[1], 1, NULL);
2839  result = WaitForSingleObject(semaphores[0], 1000);
2840  ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
2841 
2842  keybd_event('X', 0, KEYEVENTF_KEYUP, 0);
2843 
2844  ReleaseSemaphore(semaphores[1], 1, NULL);
2846  ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
2848 
2850  CloseHandle(semaphores[0]);
2851  CloseHandle(semaphores[1]);
2852 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define CloseHandle
Definition: compat.h:398
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreA(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:430
static DWORD WINAPI get_key_state_thread(void *arg)
Definition: input.c:2791
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI DestroyWindow(_In_ HWND)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define ok(value,...)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4184
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:112
smooth NULL
Definition: ftsmooth.c:416
#define WAIT_OBJECT_0
Definition: winbase.h:387
unsigned long DWORD
Definition: ntddk_ex.h:95
static HANDLE thread
Definition: service.c:33
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:488
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VISIBLE
Definition: pedump.c:620
GLuint64EXT * result
Definition: glext.h:11304
VOID WINAPI keybd_event(BYTE bVk, BYTE bScan, DWORD dwFlags, ULONG_PTR dwExtraInfo)
Definition: input.c:554

Referenced by START_TEST().

◆ test_GetMouseMovePointsEx()

static void test_GetMouseMovePointsEx ( void  )
static

Definition at line 1433 of file input.c.

1434 {
1435 #define BUFLIM 64
1436 #define MYERROR 0xdeadbeef
1437  int count, retval;
1438  MOUSEMOVEPOINT in;
1439  MOUSEMOVEPOINT out[200];
1440  POINT point;
1441 
1442  /* Get a valid content for the input struct */
1443  if(!GetCursorPos(&point)) {
1444  win_skip("GetCursorPos() failed with error %u\n", GetLastError());
1445  return;
1446  }
1447  memset(&in, 0, sizeof(MOUSEMOVEPOINT));
1448  in.x = point.x;
1449  in.y = point.y;
1450 
1451  /* test first parameter
1452  * everything different than sizeof(MOUSEMOVEPOINT)
1453  * is expected to fail with ERROR_INVALID_PARAMETER
1454  */
1456  retval = pGetMouseMovePointsEx(0, &in, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1457  if (retval == ERROR_INVALID_PARAMETER)
1458  {
1459  win_skip( "GetMouseMovePointsEx broken on WinME\n" );
1460  return;
1461  }
1462  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1464  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1465 
1467  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT)-1, &in, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1468  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1470  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1471 
1473  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT)+1, &in, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1474  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1476  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1477 
1478  /* test second and third parameter
1479  */
1481  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), NULL, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1482  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1484  "expected error ERROR_NOACCESS, got %u\n", GetLastError());
1485 
1487  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, NULL, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1488  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1490  "expected error ERROR_NOACCESS, got %u\n", GetLastError());
1491 
1493  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), NULL, NULL, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1494  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1496  "expected error ERROR_NOACCESS, got %u\n", GetLastError());
1497 
1499  count = 0;
1500  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, NULL, count, GMMP_USE_DISPLAY_POINTS);
1501  if (retval == -1)
1502  ok(GetLastError() == ERROR_POINT_NOT_FOUND, "unexpected error %u\n", GetLastError());
1503  else
1504  ok(retval == count, "expected GetMouseMovePointsEx to succeed, got %d\n", retval);
1505 
1506  /* test fourth parameter
1507  * a value higher than 64 is expected to fail with ERROR_INVALID_PARAMETER
1508  */
1510  count = -1;
1511  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, out, count, GMMP_USE_DISPLAY_POINTS);
1512  ok(retval == count, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1514  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1515 
1517  count = 0;
1518  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, out, count, GMMP_USE_DISPLAY_POINTS);
1519  if (retval == -1)
1520  ok(GetLastError() == ERROR_POINT_NOT_FOUND, "unexpected error %u\n", GetLastError());
1521  else
1522  ok(retval == count, "expected GetMouseMovePointsEx to succeed, got %d\n", retval);
1523 
1525  count = BUFLIM;
1526  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, out, count, GMMP_USE_DISPLAY_POINTS);
1527  if (retval == -1)
1528  ok(GetLastError() == ERROR_POINT_NOT_FOUND, "unexpected error %u\n", GetLastError());
1529  else
1530  ok((0 <= retval) && (retval <= count), "expected GetMouseMovePointsEx to succeed, got %d\n", retval);
1531 
1533  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, out, BUFLIM+1, GMMP_USE_DISPLAY_POINTS);
1534  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1536  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1537 
1538  /* it was not possible to force an error with the fifth parameter on win2k */
1539 
1540  /* test combinations of wrong parameters to see which error wins */
1542  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT)-1, NULL, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1543  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1545  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1546 
1548  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT)-1, &in, NULL, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1549  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1551  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1552 
1554  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), NULL, out, BUFLIM+1, GMMP_USE_DISPLAY_POINTS);
1555  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1557  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1558 
1560  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, NULL, BUFLIM+1, GMMP_USE_DISPLAY_POINTS);
1561  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1563  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1564 
1565 #undef BUFLIM
1566 #undef MYERROR
1567 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
GLuint GLuint GLsizei count
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
POINTL point
Definition: edittest.c:50
LONG y
Definition: windef.h:315
#define ERROR_NOACCESS
Definition: winerror.h:578
#define ok(value,...)
#define MYERROR
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_POINT_NOT_FOUND
Definition: winerror.h:693
static FILE * out
Definition: regtests2xml.c:44
LONG x
Definition: windef.h:314
#define SetLastError(x)
Definition: compat.h:409
#define BUFLIM
GLuint in
Definition: glext.h:9616
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_GetRawInputDeviceList()

static void test_GetRawInputDeviceList ( void  )
static

Definition at line 1569 of file input.c.

1570 {
1571  RAWINPUTDEVICELIST devices[32];
1572  UINT ret, oret, devcount, odevcount;
1573  DWORD err;
1574 
1575  SetLastError(0xdeadbeef);
1576  ret = pGetRawInputDeviceList(NULL, NULL, 0);
1577  err = GetLastError();
1578  ok(ret == -1, "expected -1, got %d\n", ret);
1579  ok(err == ERROR_INVALID_PARAMETER, "expected 87, got %d\n", err);
1580 
1581  SetLastError(0xdeadbeef);
1582  ret = pGetRawInputDeviceList(NULL, NULL, sizeof(devices[0]));
1583  err = GetLastError();
1584  ok(ret == -1, "expected -1, got %d\n", ret);
1585  ok(err == ERROR_NOACCESS, "expected 998, got %d\n", err);
1586 
1587  devcount = 0;
1588  ret = pGetRawInputDeviceList(NULL, &devcount, sizeof(devices[0]));
1589  ok(ret == 0, "expected 0, got %d\n", ret);
1590  ok(devcount > 0, "expected non-zero\n");
1591 
1592  SetLastError(0xdeadbeef);
1593  devcount = 0;
1594  ret = pGetRawInputDeviceList(devices, &devcount, sizeof(devices[0]));
1595  err = GetLastError();
1596  ok(ret == -1, "expected -1, got %d\n", ret);
1597  ok(err == ERROR_INSUFFICIENT_BUFFER, "expected 122, got %d\n", err);
1598  ok(devcount > 0, "expected non-zero\n");
1599 
1600  /* devcount contains now the correct number of devices */
1601  ret = pGetRawInputDeviceList(devices, &devcount, sizeof(devices[0]));
1602  ok(ret > 0, "expected non-zero\n");
1603 
1604  /* check if variable changes from larger to smaller value */
1605  devcount = odevcount = sizeof(devices) / sizeof(devices[0]);
1606  oret = ret = pGetRawInputDeviceList(devices, &odevcount, sizeof(devices[0]));
1607  ok(ret > 0, "expected non-zero\n");
1608  ok(devcount == odevcount, "expected %d, got %d\n", devcount, odevcount);
1609  devcount = odevcount;
1610  odevcount = sizeof(devices) / sizeof(devices[0]);
1611  ret = pGetRawInputDeviceList(NULL, &odevcount, sizeof(devices[0]));
1612  ok(ret == 0, "expected 0, got %d\n", ret);
1613  ok(odevcount == oret, "expected %d, got %d\n", oret, odevcount);
1614 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
const char * devices
Definition: diskspace.c:793
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ERROR_NOACCESS
Definition: winerror.h:578
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
int ret
#define err(...)
unsigned int UINT
Definition: ndis.h:50
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by START_TEST().

◆ test_Input_blackbox()

static void test_Input_blackbox ( void  )
static

Definition at line 912 of file input.c.

913 {
914  TEST_INPUT i;
915  int ii;
916  BYTE ks1[256], ks2[256];
917  LONG_PTR prevWndProc;
918  HWND window;
919  HHOOK hook;
920 
921  if (GetKeyboardLayout(0) != (HKL)(ULONG_PTR)0x04090409)
922  {
923  skip("Skipping Input_blackbox test on non-US keyboard\n");
924  return;
925  }
927  |WS_VISIBLE, 0, 0, 200, 60, NULL, NULL,
928  NULL, NULL);
929  ok(window != NULL, "error: %d\n", (int) GetLastError());
932 
934  {
936  win_skip("WH_KEYBOARD_LL is not supported\n");
937  return;
938  }
939 
940  /* must process all initial messages, otherwise X11DRV_KeymapNotify unsets
941  * key state set by SendInput(). */
943 
945  ok(prevWndProc != 0 || GetLastError() == 0, "error: %d\n", (int) GetLastError());
946 
947  i.type = INPUT_KEYBOARD;
948  i.u.ki.time = 0;
949  i.u.ki.dwExtraInfo = 0;
950 
951  for (ii = 0; ii < sizeof(sendinput_test)/sizeof(struct sendinput_test_s)-1;
952  ii++) {
953  GetKeyboardState(ks1);
954  i.u.ki.wScan = ii+1 /* useful for debugging */;
955  i.u.ki.dwFlags = sendinput_test[ii].dwFlags;
956  i.u.ki.wVk = sendinput_test[ii].wVk;
957  pSendInput(1, (INPUT*)&i, sizeof(TEST_INPUT));
959  GetKeyboardState(ks2);
960  if (!ii && sent_messages_cnt <= 1 && !memcmp( ks1, ks2, sizeof(ks1) ))
961  {
962  win_skip( "window doesn't receive the queued input\n" );
963  /* release the key */
964  i.u.ki.dwFlags |= KEYEVENTF_KEYUP;
965  pSendInput(1, (INPUT*)&i, sizeof(TEST_INPUT));
966  break;
967  }
968  compare_and_check(ii, ks1, ks2, &sendinput_test[ii]);
969  }
970 
974 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define HWND_TOPMOST
Definition: winuser.h:1194
BOOL WINAPI DestroyWindow(_In_ HWND)
uint32_t ULONG_PTR
Definition: typedefs.h:63
HHOOK WINAPI SetWindowsHookExA(_In_ int, _In_ HOOKPROC, _In_opt_ HINSTANCE, _In_ DWORD)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HKL WINAPI GetKeyboardLayout(DWORD idThread)
Definition: input.c:122
#define INPUT_KEYBOARD
Definition: winable.h:10
static LRESULT CALLBACK WndProc2(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: input.c:855
#define ok(value,...)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4184
smooth NULL
Definition: ftsmooth.c:416
#define WH_KEYBOARD_LL
Definition: winuser.h:43
static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, const struct sendinput_test_s *test)
Definition: input.c:703
_Check_return_ BOOL WINAPI GetKeyboardState(_Out_writes_(256) PBYTE lpKeyState)
#define WS_HSCROLL
Definition: pedump.c:628
static LRESULT CALLBACK hook_proc(int code, WPARAM wparam, LPARAM lparam)
Definition: input.c:883
#define SetWindowLongPtrA
Definition: winuser.h:5214
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
unsigned char BYTE
Definition: mem.h:68
UINT_PTR HKL
Definition: msctf.idl:101
static IHTMLWindow2 * window
Definition: events.c:77
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
#define GWLP_WNDPROC
Definition: treelist.c:66
#define SWP_NOSIZE
Definition: winuser.h:1230
static const struct sendinput_test_s sendinput_test[]
Definition: input.c:432
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WS_POPUP
Definition: pedump.c:616
static UINT sent_messages_cnt
Definition: input.c:700
#define WS_VSCROLL
Definition: pedump.c:627
#define skip(...)
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
static void empty_message_queue(void)
Definition: input.c:395
#define WS_VISIBLE
Definition: pedump.c:620
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_Input_mouse()

static void test_Input_mouse ( void  )
static

Definition at line 2017 of file input.c.

2018 {
2019  BOOL got_button_down, got_button_up;
2020  HWND hwnd, button_win, static_win;
2021  struct thread_data thread_data;
2022  HANDLE thread;
2023  DWORD thread_id;
2024  WNDCLASSA wclass;
2025  POINT pt, pt_org;
2026  int region_type;
2027  HRGN hregion;
2028  RECT region;
2029  MSG msg;
2030  BOOL ret;
2031 
2032  SetLastError(0xdeadbeef);
2033  ret = GetCursorPos(NULL);
2034  ok(!ret, "GetCursorPos succeed\n");
2035  ok(GetLastError() == 0xdeadbeef || GetLastError() == ERROR_NOACCESS, "error %u\n", GetLastError());
2036 
2037  SetLastError(0xdeadbeef);
2038  ret = GetCursorPos(&pt_org);
2039  ok(ret, "GetCursorPos failed\n");
2040  ok(GetLastError() == 0xdeadbeef, "error %u\n", GetLastError());
2041 
2042  button_win = CreateWindowA("button", "button", WS_VISIBLE | WS_POPUP,
2043  100, 100, 100, 100, 0, NULL, NULL, NULL);
2044  ok(button_win != 0, "CreateWindow failed\n");
2045 
2046  pt.x = pt.y = 150;
2047  hwnd = WindowFromPoint(pt);
2048  if (hwnd != button_win)
2049  {
2050  skip("there's another window covering test window\n");
2051  DestroyWindow(button_win);
2052  return;
2053  }
2054 
2055  /* simple button click test */
2056  simulate_click(TRUE, 150, 150);
2057  got_button_down = got_button_up = FALSE;
2058  while (wait_for_message(&msg))
2059  {
2061 
2062  if (msg.message == WM_LBUTTONDOWN)
2063  {
2064  got_button_down = TRUE;
2065  }
2066  else if (msg.message == WM_LBUTTONUP)
2067  {
2068  got_button_up = TRUE;
2069  break;
2070  }
2071  }
2072  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2073  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2074 
2075  /* click through HTTRANSPARENT child window */
2076  static_win = CreateWindowA("static", "static", WS_VISIBLE | WS_CHILD,
2077  0, 0, 100, 100, button_win, NULL, NULL, NULL);
2078  ok(static_win != 0, "CreateWindow failed\n");
2079  def_static_proc = (void*)SetWindowLongPtrA(static_win,
2081  simulate_click(FALSE, 150, 150);
2082  hittest_no = 0;
2083  got_button_down = got_button_up = FALSE;
2084  while (wait_for_message(&msg))
2085  {
2087 
2088  if (msg.message == WM_RBUTTONDOWN)
2089  {
2090  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2091  got_button_down = TRUE;
2092  }
2093  else if (msg.message == WM_RBUTTONUP)
2094  {
2095  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2096  got_button_up = TRUE;
2097  break;
2098  }
2099  }
2100  ok(hittest_no && hittest_no<50, "expected WM_NCHITTEST message\n");
2101  ok(got_button_down, "expected WM_RBUTTONDOWN message\n");
2102  ok(got_button_up, "expected WM_RBUTTONUP message\n");
2103  DestroyWindow(static_win);
2104 
2105  /* click through HTTRANSPARENT top-level window */
2106  static_win = CreateWindowA("static", "static", WS_VISIBLE | WS_POPUP,
2107  100, 100, 100, 100, 0, NULL, NULL, NULL);
2108  ok(static_win != 0, "CreateWindow failed\n");
2109  def_static_proc = (void*)SetWindowLongPtrA(static_win,
2111  simulate_click(TRUE, 150, 150);
2112  hittest_no = 0;
2113  got_button_down = got_button_up = FALSE;
2114  while (wait_for_message(&msg))
2115  {
2117 
2118  if (msg.message == WM_LBUTTONDOWN)
2119  {
2120  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2121  got_button_down = TRUE;
2122  }
2123  else if (msg.message == WM_LBUTTONUP)
2124  {
2125  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2126  got_button_up = TRUE;
2127  break;
2128  }
2129  }
2130  ok(hittest_no && hittest_no<50, "expected WM_NCHITTEST message\n");
2131  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2132  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2133  DestroyWindow(static_win);
2134 
2135  /* click on HTTRANSPARENT top-level window that belongs to other thread */
2137  ok(thread_data.start_event != NULL, "CreateEvent failed\n");
2139  ok(thread_data.end_event != NULL, "CreateEvent failed\n");
2141  ok(thread != NULL, "CreateThread failed\n");
2142  hittest_no = 0;
2143  got_button_down = got_button_up = FALSE;
2145  simulate_click(FALSE, 150, 150);
2146  while (wait_for_message(&msg))
2147  {
2149 
2150  if (msg.message == WM_RBUTTONDOWN)
2151  got_button_down = TRUE;
2152  else if (msg.message == WM_RBUTTONUP)
2153  got_button_up = TRUE;
2154  }
2158  ok(hittest_no && hittest_no<50, "expected WM_NCHITTEST message\n");
2159  ok(!got_button_down, "unexpected WM_RBUTTONDOWN message\n");
2160  ok(!got_button_up, "unexpected WM_RBUTTONUP message\n");
2161 
2162  /* click on HTTRANSPARENT top-level window that belongs to other thread,
2163  * thread input queues are attached */
2165  ok(thread != NULL, "CreateThread failed\n");
2166  hittest_no = 0;
2167  got_button_down = got_button_up = FALSE;
2170  "AttachThreadInput failed\n");
2172  SetWindowPos(thread_data.win, button_win, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
2173  simulate_click(TRUE, 150, 150);
2174  while (wait_for_message(&msg))
2175  {
2177 
2178  if (msg.message == WM_LBUTTONDOWN)
2179  got_button_down = TRUE;
2180  else if (msg.message == WM_LBUTTONUP)
2181  got_button_up = TRUE;
2182  }
2185  todo_wine ok(hittest_no > 50, "expected loop with WM_NCHITTEST messages\n");
2186  ok(!got_button_down, "unexpected WM_LBUTTONDOWN message\n");
2187  ok(!got_button_up, "unexpected WM_LBUTTONUP message\n");
2188 
2189  /* click after SetCapture call */
2190  hwnd = CreateWindowA("button", "button", WS_VISIBLE | WS_POPUP,
2191  0, 0, 100, 100, 0, NULL, NULL, NULL);
2192  ok(hwnd != 0, "CreateWindow failed\n");
2193  SetCapture(button_win);
2194  got_button_down = got_button_up = FALSE;
2195  simulate_click(FALSE, 50, 50);
2196  while (wait_for_message(&msg))
2197  {
2199 
2200  if (msg.message == WM_RBUTTONDOWN)
2201  {
2202  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2203  got_button_down = TRUE;
2204  }
2205  else if (msg.message == WM_RBUTTONUP)
2206  {
2207  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2208  got_button_up = TRUE;
2209  break;
2210  }
2211  }
2212  ok(got_button_down, "expected WM_RBUTTONDOWN message\n");
2213  ok(got_button_up, "expected WM_RBUTTONUP message\n");
2215 
2216  /* click on child window after SetCapture call */
2217  hwnd = CreateWindowA("button", "button2", WS_VISIBLE | WS_CHILD,
2218  0, 0, 100, 100, button_win, NULL, NULL, NULL);
2219  ok(hwnd != 0, "CreateWindow failed\n");
2220  got_button_down = got_button_up = FALSE;
2221  simulate_click(TRUE, 150, 150);
2222  while (wait_for_message(&msg))
2223  {
2225 
2226  if (msg.message == WM_LBUTTONDOWN)
2227  {
2228  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2229  got_button_down = TRUE;
2230  }
2231  else if (msg.message == WM_LBUTTONUP)
2232  {
2233  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2234  got_button_up = TRUE;
2235  break;
2236  }
2237  }
2238  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2239  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2241  ok(ReleaseCapture(), "ReleaseCapture failed\n");
2242 
2243  wclass.style = 0;
2244  wclass.lpfnWndProc = WndProc;
2245  wclass.cbClsExtra = 0;
2246  wclass.cbWndExtra = 0;
2247  wclass.hInstance = GetModuleHandleA(NULL);
2248  wclass.hIcon = LoadIconA(0, (LPCSTR)IDI_APPLICATION);
2249  wclass.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW);
2250  wclass.hbrBackground = CreateSolidBrush(RGB(128, 128, 128));
2251  wclass.lpszMenuName = NULL;
2252  wclass.lpszClassName = "InputLayeredTestClass";
2253  RegisterClassA( &wclass );
2254 
2255  /* click through layered window with alpha channel / color key */
2256  hwnd = CreateWindowA(wclass.lpszClassName, "InputLayeredTest",
2257  WS_VISIBLE | WS_POPUP, 100, 100, 100, 100, button_win, NULL, NULL, NULL);
2258  ok(hwnd != NULL, "CreateWindowEx failed\n");
2259 
2260  static_win = CreateWindowA("static", "Title", WS_VISIBLE | WS_CHILD,
2261  10, 10, 20, 20, hwnd, NULL, NULL, NULL);
2262  ok(static_win != NULL, "CreateWindowA failed %u\n", GetLastError());
2263 
2266  ret = SetLayeredWindowAttributes(hwnd, 0, 255, LWA_ALPHA);
2267  ok(ret, "SetLayeredWindowAttributes failed\n");
2269  Sleep(100);
2270 
2271  if (pGetWindowRgnBox)
2272  {
2273  region_type = pGetWindowRgnBox(hwnd, &region);
2274  ok(region_type == ERROR, "expected ERROR, got %d\n", region_type);
2275  }
2276 
2277  got_button_down = got_button_up = FALSE;
2278  simulate_click(TRUE, 150, 150);
2279  while (wait_for_message(&msg))
2280  {
2282 
2283  if (msg.message == WM_LBUTTONDOWN)
2284  {
2285  ok(msg.hwnd == hwnd, "msg.hwnd = %p\n", msg.hwnd);
2286  got_button_down = TRUE;
2287  }
2288  else if (msg.message == WM_LBUTTONUP)
2289  {
2290  ok(msg.hwnd == hwnd, "msg.hwnd = %p\n", msg.hwnd);
2291  got_button_up = TRUE;
2292  break;
2293  }
2294  }
2295  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2296  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2297 
2298  ret = SetLayeredWindowAttributes(hwnd, 0, 0, LWA_ALPHA);
2299  ok(ret, "SetLayeredWindowAttributes failed\n");
2301  Sleep(100);
2302 
2303  if (pGetWindowRgnBox)
2304  {
2305  region_type = pGetWindowRgnBox(hwnd, &region);
2306  ok(region_type == ERROR, "expected ERROR, got %d\n", region_type);
2307  }
2308 
2309  got_button_down = got_button_up = FALSE;
2310  simulate_click(TRUE, 150, 150);
2311  while (wait_for_message(&msg))
2312  {
2314 
2315  if (msg.message == WM_LBUTTONDOWN)
2316  {
2317  todo_wine
2318  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2319  got_button_down = TRUE;
2320  }
2321  else if (msg.message == WM_LBUTTONUP)
2322  {
2323  todo_wine
2324  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2325  got_button_up = TRUE;
2326  break;
2327  }
2328  }
2329  ok(got_button_down || broken(!got_button_down), "expected WM_LBUTTONDOWN message\n");
2330  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2331 
2332  ret = SetLayeredWindowAttributes(hwnd, RGB(0, 255, 0), 255, LWA_ALPHA | LWA_COLORKEY);
2333  ok(ret, "SetLayeredWindowAttributes failed\n");
2335  Sleep(100);
2336 
2337  if (pGetWindowRgnBox)
2338  {
2339  region_type = pGetWindowRgnBox(hwnd, &region);
2340  ok(region_type == ERROR, "expected ERROR, got %d\n", region_type);
2341  }
2342 
2343  got_button_down = got_button_up = FALSE;
2344  simulate_click(TRUE, 150, 150);
2345  while (wait_for_message(&msg))
2346  {
2348 
2349  if (msg.message == WM_LBUTTONDOWN)
2350  {
2351  ok(msg.hwnd == hwnd, "msg.hwnd = %p\n", msg.hwnd);
2352  got_button_down = TRUE;
2353  }
2354  else if (msg.message == WM_LBUTTONUP)
2355  {
2356  ok(msg.hwnd == hwnd, "msg.hwnd = %p\n", msg.hwnd);
2357  got_button_up = TRUE;
2358  break;
2359  }
2360  }
2361  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2362  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2363 
2364  ret = SetLayeredWindowAttributes(hwnd, RGB(128, 128, 128), 0, LWA_COLORKEY);
2365  ok(ret, "SetLayeredWindowAttributes failed\n");
2367  Sleep(100);
2368 
2369  if (pGetWindowRgnBox)
2370  {
2371  region_type = pGetWindowRgnBox(hwnd, &region);
2372  ok(region_type == ERROR, "expected ERROR, got %d\n", region_type);
2373  }
2374 
2375  get_dc_region(&region, hwnd, DCX_PARENTCLIP);
2376  ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200,
2377  "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region));
2379  ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200,
2380  "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region));
2381  get_dc_region(&region, hwnd, DCX_USESTYLE);
2382  ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200,
2383  "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region));
2384  get_dc_region(&region, static_win, DCX_PARENTCLIP);
2385  ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200,
2386  "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region));
2387  get_dc_region(&region, static_win, DCX_WINDOW | DCX_USESTYLE);
2388  ok(region.left == 110 && region.top == 110 && region.right == 130 && region.bottom == 130,
2389  "expected region (110,110)-(130,130), got %s\n", wine_dbgstr_rect(&region));
2390  get_dc_region(&region, static_win, DCX_USESTYLE);
2391  ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200,
2392  "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region));
2393 
2394  got_button_down = got_button_up = FALSE;
2395  simulate_click(TRUE, 150, 150);
2396  while (wait_for_message(&msg))
2397  {
2399 
2400  if (msg.message == WM_LBUTTONDOWN)
2401  {
2402  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2403  got_button_down = TRUE;
2404  }
2405  else if (msg.message == WM_LBUTTONUP)
2406  {
2407  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2408  got_button_up = TRUE;
2409  break;
2410  }
2411  }
2412  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2413  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2414 
2417  Sleep(100);
2418 
2419  if (pGetWindowRgnBox)
2420  {
2421  region_type = pGetWindowRgnBox(hwnd, &region);
2422  ok(region_type == ERROR, "expected ERROR, got %d\n", region_type);
2423  }
2424 
2425  got_button_down = got_button_up = FALSE;
2426  simulate_click(TRUE, 150, 150);
2427  while (wait_for_message(&msg))
2428  {
2430 
2431  if (msg.message == WM_LBUTTONDOWN)
2432  {
2433  ok(msg.hwnd == hwnd, "msg.hwnd = %p\n", msg.hwnd);
2434  got_button_down = TRUE;
2435  }
2436  else if (msg.message == WM_LBUTTONUP)
2437  {
2438  ok(msg.hwnd == hwnd, "msg.hwnd = %p\n", msg.hwnd);
2439  got_button_up = TRUE;
2440  break;
2441  }
2442  }
2443  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2444  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2445 
2446  hregion = CreateRectRgn(0, 0, 10, 10);
2447  ok(hregion != NULL, "CreateRectRgn failed\n");
2448  ret = SetWindowRgn(hwnd, hregion, TRUE);
2449  ok(ret, "SetWindowRgn failed\n");
2450  DeleteObject(hregion);
2452  Sleep(1000);
2453 
2454  if (pGetWindowRgnBox)
2455  {
2456  region_type = pGetWindowRgnBox(hwnd, &region);
2457  ok(region_type == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", region_type);
2458  }
2459 
2460  got_button_down = got_button_up = FALSE;
2461  simulate_click(TRUE, 150, 150);
2462  while (wait_for_message(&msg))
2463  {
2465 
2466  if (msg.message == WM_LBUTTONDOWN)
2467  {
2468  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2469  got_button_down = TRUE;
2470  }
2471  else if (msg.message == WM_LBUTTONUP)
2472  {
2473  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2474  got_button_up = TRUE;
2475  break;
2476  }
2477  }
2478  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2479  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2480 
2481  DestroyWindow(static_win);
2483  SetCursorPos(pt_org.x, pt_org.y);
2484 
2487  DestroyWindow(button_win);
2488 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:736
long y
Definition: polytest.cpp:48
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
BOOL WINAPI AttachThreadInput(_In_ DWORD, _In_ DWORD, _In_ BOOL)
long x
Definition: polytest.cpp:48
#define pt(x, y)
Definition: drawing.c:79
static WNDPROC def_static_proc
Definition: input.c:1962
#define ERROR(name)
Definition: error_private.h:53
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
HWND win
Definition: input.c:1980
LONG top
Definition: windef.h:292
#define DCX_USESTYLE
Definition: GetDCEx.c:10
int cbClsExtra
Definition: winuser.h:3118
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
LPCSTR lpszMenuName
Definition: winuser.h:3124
#define GWL_EXSTYLE
Definition: winuser.h:845
#define HWND_TOPMOST
Definition: winuser.h:1194
#define IDI_APPLICATION
Definition: winuser.h:699
HBRUSH hbrBackground
Definition: winuser.h:3123
#define WS_CHILD
Definition: pedump.c:617
LONG left
Definition: windef.h:291
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
LONG right
Definition: windef.h:293
BOOL WINAPI DestroyWindow(_In_ HWND)
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2029
#define DCX_WINDOW
Definition: winuser.h:2074
int WINAPI SetWindowRgn(_In_ HWND, _In_opt_ HRGN, _In_ BOOL)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
int cbWndExtra
Definition: winuser.h:3119
#define ERROR_NOACCESS
Definition: winerror.h:578
LONG WINAPI GetWindowLongA(_In_ HWND, _In_ int)
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4184
HCURSOR hCursor
Definition: winuser.h:3122
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:112
smooth NULL
Definition: ftsmooth.c:416
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:583
static LRESULT WINAPI static_hook_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: input.c:1964
const char * LPCSTR
Definition: xmlstorage.h:183
static DWORD hittest_no
Definition: input.c:1963
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:421
#define WM_RBUTTONDOWN
Definition: winuser.h:1755
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
HANDLE end_event
Definition: input.c:1979
#define RGB(r, g, b)
Definition: wingdi.h:2918
#define WS_EX_LAYERED
Definition: winuser.h:389
const char * wine_dbgstr_rect(const RECT *rect)
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2627
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define WM_RBUTTONUP
Definition: winuser.h:1756
static HANDLE thread
Definition: service.c:33
static void get_dc_region(RECT *region, HWND hwnd, DWORD flags)
Definition: input.c:2000
int ret
#define todo_wine
Definition: test.h:154
#define SetWindowLongPtrA
Definition: winuser.h:5214
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
LPCSTR lpszClassName
Definition: winuser.h:3125
static DWORD WINAPI create_static_win(void *arg)
Definition: input.c:1983
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2059
#define GWLP_WNDPROC
Definition: treelist.c:66
#define broken(x)
Definition: _sntprintf.h:21
#define SIMPLEREGION
Definition: wingdi.h:361
UINT style
Definition: winuser.h:3116
#define SWP_NOSIZE
Definition: winuser.h:1230
#define DCX_PARENTCLIP
Definition: winuser.h:2076
HWND WINAPI SetCapture(_In_ HWND hWnd)
HINSTANCE hInstance
Definition: winuser.h:3120
static DWORD thread_id
Definition: protocol.c:158
#define WM_LBUTTONUP
Definition: winuser.h:1753
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WS_POPUP
Definition: pedump.c:616
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
LONG WINAPI SetWindowLongA(_In_ HWND, _In_ int, _In_ LONG)
HWND WINAPI WindowFromPoint(_In_ POINT)
WNDPROC lpfnWndProc
Definition: winuser.h:3117
static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: input.c:343
#define skip(...)
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2888
LONG bottom
Definition: windef.h:294
static void simulate_click(BOOL left, int x, int y)
Definition: input.c:1909
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define INFINITE
Definition: serial.h:102
#define WS_VISIBLE
Definition: pedump.c:620
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
static BOOL wait_for_message(MSG *msg)
Definition: input.c:1928
HICON hIcon
Definition: winuser.h:3121
HANDLE start_event
Definition: input.c:1978

Referenced by START_TEST().

◆ test_Input_unicode()

static void test_Input_unicode ( void  )
static

Definition at line 1157 of file input.c.

1158 {
1159  WCHAR classNameW[] = {'I','n','p','u','t','U','n','i','c','o','d','e',
1160  'K','e','y','T','e','s','t','C','l','a','s','s',0};
1161  WCHAR windowNameW[] = {'I','n','p','u','t','U','n','i','c','o','d','e',
1162  'K','e','y','T','e','s','t',0};
1163  MSG msg;
1164  WNDCLASSW wclass;
1166  HHOOK hook;
1167  HMODULE hModuleImm32;
1168  BOOL (WINAPI *pImmDisableIME)(DWORD);
1169 
1170  wclass.lpszClassName = classNameW;
1171  wclass.style = CS_HREDRAW | CS_VREDRAW;
1172  wclass.lpfnWndProc = unicode_wnd_proc;
1173  wclass.hInstance = hInstance;
1174  wclass.hIcon = LoadIconW(0, (LPCWSTR)IDI_APPLICATION);
1175  wclass.hCursor = LoadCursorW( NULL, (LPCWSTR)IDC_ARROW);
1176  wclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
1177  wclass.lpszMenuName = 0;
1178  wclass.cbClsExtra = 0;
1179  wclass.cbWndExtra = 0;
1180  if(!RegisterClassW(&wclass)){
1181  win_skip("Unicode functions not supported\n");
1182  return;
1183  }
1184 
1185  hModuleImm32 = LoadLibraryA("imm32.dll");
1186  if (hModuleImm32) {
1187  pImmDisableIME = (void *)GetProcAddress(hModuleImm32, "ImmDisableIME");
1188  if (pImmDisableIME)
1189  pImmDisableIME(0);
1190  }
1191  pImmDisableIME = NULL;
1192  FreeLibrary(hModuleImm32);
1193 
1194  /* create the test window that will receive the keystrokes */
1195  hWndTest = CreateWindowW(wclass.lpszClassName, windowNameW,
1196  WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, 100, 100,
1197  NULL, NULL, hInstance, NULL);
1198 
1199  assert(hWndTest);
1201 
1203  if(!hook)
1204  win_skip("unable to set WH_KEYBOARD_LL hook\n");
1205 
1210 
1211  /* flush pending messages */
1212  while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageW(&msg);
1213 
1214  SetFocus(hWndTest);
1215 
1217 
1218  if(hook)
1221 }
static DWORD
Definition: input.c:87
UINT style
Definition: winuser.h:3129
LPCWSTR lpszMenuName
Definition: winuser.h:3137
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI UpdateWindow(_In_ HWND)
#define assert(x)
Definition: debug.h:53
#define CS_HREDRAW
Definition: winuser.h:648
#define HWND_TOPMOST
Definition: winuser.h:1194
int cbClsExtra
Definition: winuser.h:3131
HWND WINAPI SetFocus(_In_opt_ HWND)
#define IDI_APPLICATION
Definition: winuser.h:699
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define BOOL
Definition: nt_native.h:43
BOOL WINAPI DestroyWindow(_In_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4185
#define COLOR_WINDOW
Definition: winuser.h:908
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
HINSTANCE hInstance
Definition: charmap.c:20
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
WNDPROC lpfnWndProc
Definition: winuser.h:3130
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
static void test_unicode_keys(HWND hwnd, HHOOK hook)
Definition: input.c:992
LPCWSTR lpszClassName
Definition: winuser.h:3138
#define SW_SHOW
Definition: winuser.h:769
BOOL WINAPI IsWindowUnicode(_In_ HWND)
static HWND hWndTest
Definition: input.c:68
#define CS_VREDRAW
Definition: winuser.h:653
#define FreeLibrary(x)
Definition: compat.h:405
#define WH_KEYBOARD_LL
Definition: winuser.h:43
int cbWndExtra
Definition: winuser.h:3132
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define WINAPI
Definition: msvc.h:8
HICON hIcon
Definition: winuser.h:3134
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
#define SWP_NOSIZE
Definition: winuser.h:1230
HCURSOR hCursor
Definition: winuser.h:3135
HBRUSH hbrBackground
Definition: winuser.h:3136
Definition: input.c:432
HINSTANCE hInstance
Definition: winuser.h:3133
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
HHOOK WINAPI SetWindowsHookExW(_In_ int, _In_ HOOKPROC, _In_opt_ HINSTANCE, _In_ DWORD)
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:845
BOOL WINAPI SetForegroundWindow(_In_ HWND)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define GetProcAddress(x, y)
Definition: compat.h:410
#define SWP_NOMOVE
Definition: winuser.h:1229
static LRESULT CALLBACK llkbd_unicode_hook(int nCode, WPARAM wParam, LPARAM lParam)
Definition: input.c:1125
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1182
#define win_skip
Definition: test.h:141
static LRESULT CALLBACK unicode_wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: input.c:1099

Referenced by START_TEST().

◆ test_Input_whitebox()

static void test_Input_whitebox ( void  )
static

Definition at line 349 of file input.c.

350 {
351  MSG msg;
352  WNDCLASSA wclass;
354 
355  wclass.lpszClassName = "InputSysKeyTestClass";
356  wclass.style = CS_HREDRAW | CS_VREDRAW;
357  wclass.lpfnWndProc = WndProc;
358  wclass.hInstance = hInstance;
359  wclass.hIcon = LoadIconA( 0, (LPCSTR)IDI_APPLICATION );
360  wclass.hCursor = LoadCursorA( NULL, (LPCSTR)IDC_ARROW );
361  wclass.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 );
362  wclass.lpszMenuName = 0;
363  wclass.cbClsExtra = 0;
364  wclass.cbWndExtra = 0;
365  RegisterClassA( &wclass );
366  /* create the test window that will receive the keystrokes */
367  hWndTest = CreateWindowA( wclass.lpszClassName, "InputSysKeyTest",
368  WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, 100, 100,
369  NULL, NULL, hInstance, NULL);
370  assert( hWndTest );
375 
376  /* flush pending messages */
377  while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
378 
379  SetFocus( hWndTest );
382 }
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
static void TestSysKeys(HWND hWnd)
Definition: input.c:336
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI UpdateWindow(_In_ HWND)
int cbClsExtra
Definition: winuser.h:3118
#define assert(x)
Definition: debug.h:53
#define CS_HREDRAW
Definition: winuser.h:648
LPCSTR lpszMenuName
Definition: winuser.h:3124
#define HWND_TOPMOST
Definition: winuser.h:1194
HWND WINAPI SetFocus(_In_opt_ HWND)
#define IDI_APPLICATION
Definition: winuser.h:699
HBRUSH hbrBackground
Definition: winuser.h:3123
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
BOOL WINAPI DestroyWindow(_In_ HWND)
#define COLOR_WINDOW
Definition: winuser.h:908
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2029
int cbWndExtra
Definition: winuser.h:3119
HINSTANCE hInstance
Definition: charmap.c:20
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4184
HCURSOR hCursor
Definition: winuser.h:3122
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
#define SW_SHOW
Definition: winuser.h:769
static HWND hWndTest
Definition: input.c:68
#define CS_VREDRAW
Definition: winuser.h:653
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
LPCSTR lpszClassName
Definition: winuser.h:3125
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2059
UINT style
Definition: winuser.h:3116
#define SWP_NOSIZE
Definition: winuser.h:1230
HINSTANCE hInstance
Definition: winuser.h:3120
WNDPROC lpfnWndProc
Definition: winuser.h:3117
static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: input.c:343
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1182
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
HICON hIcon
Definition: winuser.h:3121

Referenced by START_TEST().

◆ test_key_map()

static void test_key_map ( void  )
static

Definition at line 1616 of file input.c.

1617 {
1618  HKL kl = GetKeyboardLayout(0);
1619  UINT kL, kR, s, sL;
1620  int i;
1621  static const UINT numpad_collisions[][2] = {
1622  { VK_NUMPAD0, VK_INSERT },
1623  { VK_NUMPAD1, VK_END },
1624  { VK_NUMPAD2, VK_DOWN },
1625  { VK_NUMPAD3, VK_NEXT },
1626  { VK_NUMPAD4, VK_LEFT },
1627  { VK_NUMPAD6, VK_RIGHT },
1628  { VK_NUMPAD7, VK_HOME },
1629  { VK_NUMPAD8, VK_UP },
1630  { VK_NUMPAD9, VK_PRIOR },
1631  };
1632 
1634  ok(s != 0, "MapVirtualKeyEx(VK_SHIFT) should return non-zero\n");
1636  ok(s == sL || broken(sL == 0), /* win9x */
1637  "%x != %x\n", s, sL);
1638 
1639  kL = MapVirtualKeyExA(0x2a, MAPVK_VSC_TO_VK, kl);
1640  ok(kL == VK_SHIFT, "Scan code -> vKey = %x (not VK_SHIFT)\n", kL);
1641  kR = MapVirtualKeyExA(0x36, MAPVK_VSC_TO_VK, kl);
1642  ok(kR == VK_SHIFT, "Scan code -> vKey = %x (not VK_SHIFT)\n", kR);
1643 
1644  kL = MapVirtualKeyExA(0x2a, MAPVK_VSC_TO_VK_EX, kl);
1645  ok(kL == VK_LSHIFT || broken(kL == 0), /* win9x */
1646  "Scan code -> vKey = %x (not VK_LSHIFT)\n", kL);
1647  kR = MapVirtualKeyExA(0x36, MAPVK_VSC_TO_VK_EX, kl);
1648  ok(kR == VK_RSHIFT || broken(kR == 0), /* win9x */
1649  "Scan code -> vKey = %x (not VK_RSHIFT)\n", kR);
1650 
1651  /* test that MAPVK_VSC_TO_VK prefers the non-numpad vkey if there's ambiguity */
1652  for (i = 0; i < sizeof(numpad_collisions)/sizeof(numpad_collisions[0]); i++)
1653  {
1654  UINT numpad_scan = MapVirtualKeyExA(numpad_collisions[i][0], MAPVK_VK_TO_VSC, kl);
1655  UINT other_scan = MapVirtualKeyExA(numpad_collisions[i][1], MAPVK_VK_TO_VSC, kl);
1656 
1657  /* do they really collide for this layout? */
1658  if (numpad_scan && other_scan == numpad_scan)
1659  {
1660  UINT vkey = MapVirtualKeyExA(numpad_scan, MAPVK_VSC_TO_VK, kl);
1661  ok(vkey != numpad_collisions[i][0],
1662  "Got numpad vKey %x for scan code %x when there was another choice\n",
1663  vkey, numpad_scan);
1664  }
1665  }
1666 }
#define VK_NUMPAD8
Definition: winuser.h:2201
#define VK_NUMPAD0
Definition: winuser.h:2193
UINT WINAPI MapVirtualKeyExA(UINT uCode, UINT uMapType, HKL dwhkl)
Definition: input.c:347
#define VK_NUMPAD6
Definition: winuser.h:2199
#define VK_LSHIFT
Definition: winuser.h:2236
#define VK_LEFT
Definition: winuser.h:2178
#define VK_DOWN
Definition: winuser.h:2181
#define VK_INSERT
Definition: winuser.h:2186
#define VK_PRIOR
Definition: winuser.h:2174
#define VK_NUMPAD9
Definition: winuser.h:2202
#define MAPVK_VSC_TO_VK_EX
Definition: winuser.h:2312
#define VK_NEXT
Definition: winuser.h:2175
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define VK_HOME
Definition: winuser.h:2177
HKL WINAPI GetKeyboardLayout(DWORD idThread)
Definition: input.c:122
#define VK_UP
Definition: winuser.h:2179
#define ok(value,...)
#define VK_SHIFT
Definition: winuser.h:2156
#define VK_NUMPAD3
Definition: winuser.h:2196
#define MAPVK_VSC_TO_VK
Definition: winuser.h:2310
#define MAPVK_VK_TO_VSC
Definition: winuser.h:2309
#define VK_NUMPAD4
Definition: winuser.h:2197
#define VK_RSHIFT
Definition: winuser.h:2237
GLdouble s
Definition: gl.h:2039
UINT_PTR HKL
Definition: msctf.idl:101
#define broken(x)
Definition: _sntprintf.h:21
#define VK_RIGHT
Definition: winuser.h:2180
#define VK_NUMPAD7
Definition: winuser.h:2200
#define VK_NUMPAD2
Definition: winuser.h:2195
unsigned int UINT
Definition: ndis.h:50
#define VK_NUMPAD1
Definition: winuser.h:2194
#define VK_END
Definition: winuser.h:2176

Referenced by START_TEST().

◆ test_key_names()

static void test_key_names ( void  )
static

Definition at line 1869 of file input.c.

1870 {
1871  char buffer[40];
1872  WCHAR bufferW[40];
1873  int ret, prev;
1874  LONG lparam = 0x1d << 16;
1875 
1876  memset( buffer, 0xcc, sizeof(buffer) );
1877  ret = GetKeyNameTextA( lparam, buffer, sizeof(buffer) );
1878  ok( ret > 0, "wrong len %u for '%s'\n", ret, buffer );
1879  ok( ret == strlen(buffer), "wrong len %u for '%s'\n", ret, buffer );
1880 
1881  memset( buffer, 0xcc, sizeof(buffer) );
1882  prev = ret;
1883  ret = GetKeyNameTextA( lparam, buffer, prev );
1884  ok( ret == prev - 1, "wrong len %u for '%s'\n", ret, buffer );
1885  ok( ret == strlen(buffer), "wrong len %u for '%s'\n", ret, buffer );
1886 
1887  memset( buffer, 0xcc, sizeof(buffer) );
1888  ret = GetKeyNameTextA( lparam, buffer, 0 );
1889  ok( ret == 0, "wrong len %u for '%s'\n", ret, buffer );
1890  ok( buffer[0] == 0, "wrong string '%s'\n", buffer );
1891 
1892  memset( bufferW, 0xcc, sizeof(bufferW) );
1893  ret = GetKeyNameTextW( lparam, bufferW, sizeof(bufferW)/sizeof(WCHAR) );
1894  ok( ret > 0, "wrong len %u for %s\n", ret, wine_dbgstr_w(bufferW) );
1895  ok( ret == lstrlenW(bufferW), "wrong len %u for %s\n", ret, wine_dbgstr_w(bufferW) );
1896 
1897  memset( bufferW, 0xcc, sizeof(bufferW) );
1898  prev = ret;
1899  ret = GetKeyNameTextW( lparam, bufferW, prev );
1900  ok( ret == prev - 1, "wrong len %u for %s\n", ret, wine_dbgstr_w(bufferW) );
1901  ok( ret == lstrlenW(bufferW), "wrong len %u for %s\n", ret, wine_dbgstr_w(bufferW) );
1902 
1903  memset( bufferW, 0xcc, sizeof(bufferW) );
1904  ret = GetKeyNameTextW( lparam, bufferW, 0 );
1905  ok( ret == 0, "wrong len %u for %s\n", ret, wine_dbgstr_w(bufferW) );
1906  ok( bufferW[0] == 0xcccc, "wrong string %s\n", wine_dbgstr_w(bufferW) );
1907 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define wine_dbgstr_w
Definition: kernel32.h:34
GLuint buffer
Definition: glext.h:5915
#define lstrlenW
Definition: compat.h:407
long LONG
Definition: pedump.c:60
#define ok(value,...)
int WINAPI GetKeyNameTextW(LONG lParam, LPWSTR lpString, int nSize)
Definition: input.c:170
int WINAPI GetKeyNameTextA(LONG lParam, LPSTR lpString, int nSize)
Definition: input.c:142
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: input.c:428
int ret
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST().

◆ test_keyboard_layout_name()

static void test_keyboard_layout_name ( void  )
static

Definition at line 1848 of file input.c.

1849 {
1850  BOOL ret;
1851  char klid[KL_NAMELENGTH];
1852 
1853  if (0) /* crashes on native system */
1855 
1856  SetLastError(0xdeadbeef);
1858  ok(!ret, "got %d\n", ret);
1859  ok(GetLastError() == ERROR_NOACCESS, "got %d\n", GetLastError());
1860 
1861  if (GetKeyboardLayout(0) != (HKL)(ULONG_PTR)0x04090409) return;
1862 
1863  klid[0] = 0;
1864  ret = GetKeyboardLayoutNameA(klid);
1865  ok(ret, "GetKeyboardLayoutNameA failed %u\n", GetLastError());
1866  ok(!strcmp(klid, "00000409"), "expected 00000409, got %s\n", klid);
1867 }
#define KL_NAMELENGTH
Definition: winuser.h:122
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define ERROR_NOACCESS
Definition: winerror.h:578
HKL WINAPI GetKeyboardLayout(DWORD idThread)
Definition: input.c:122
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI GetKeyboardLayoutNameA(LPSTR pwszKLID)
Definition: input.c:192
BOOL WINAPI GetKeyboardLayoutNameW(LPWSTR pwszKLID)
Definition: input.c:209
#define SetLastError(x)
Definition: compat.h:409
int ret
UINT_PTR HKL
Definition: msctf.idl:101
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by START_TEST().

◆ test_keynames()

static void test_keynames ( void  )
static

Definition at line 1223 of file input.c.

1224 {
1225  int i, len;
1226  char buff[256];
1227 
1228  for (i = 0; i < 512; i++)
1229  {
1230  strcpy(buff, "----");
1231  len = GetKeyNameTextA(i << 16, buff, sizeof(buff));
1232  ok(len || !buff[0], "%d: Buffer is not zeroed\n", i);
1233  }
1234 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ok(value,...)
int WINAPI GetKeyNameTextA(LONG lParam, LPSTR lpString, int nSize)
Definition: input.c:142
GLenum GLsizei len
Definition: glext.h:6722
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
static unsigned char buff[32768]
Definition: fatten.c:17

Referenced by START_TEST().

◆ test_mouse_ll_hook()

static void test_mouse_ll_hook ( void  )
static

Definition at line 1299 of file input.c.

1300 {
1301  HWND hwnd;
1302  HHOOK hook1, hook2;
1303  POINT pt_org, pt;
1304  RECT rc;
1305 
1306  GetCursorPos(&pt_org);
1307  hwnd = CreateWindowA("static", "Title", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
1308  10, 10, 200, 200, NULL, NULL, NULL, NULL);
1309  SetCursorPos(100, 100);
1310 
1311  if (!(hook2 = SetWindowsHookExA(WH_MOUSE_LL, hook_proc2, GetModuleHandleA(0), 0)))
1312  {
1313  win_skip( "cannot set MOUSE_LL hook\n" );
1314  goto done;
1315  }
1317 
1318  GetCursorPos(&pt_old);
1319  mouse_event(MOUSEEVENTF_MOVE, -STEP, 0, 0, 0);
1320  GetCursorPos(&pt_old);
1321  ok(pt_old.x == pt_new.x && pt_old.y == pt_new.y, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y);
1322  mouse_event(MOUSEEVENTF_MOVE, +STEP, 0, 0, 0);
1323  GetCursorPos(&pt_old);
1324  ok(pt_old.x == pt_new.x && pt_old.y == pt_new.y, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y);
1325  mouse_event(MOUSEEVENTF_MOVE, 0, -STEP, 0, 0);
1326  GetCursorPos(&pt_old);
1327  ok(pt_old.x == pt_new.x && pt_old.y == pt_new.y, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y);
1328  mouse_event(MOUSEEVENTF_MOVE, 0, +STEP, 0, 0);
1329  GetCursorPos(&pt_old);
1330  ok(pt_old.x == pt_new.x && pt_old.y == pt_new.y, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y);
1331 
1332  SetRect(&rc, 50, 50, 151, 151);
1333  ClipCursor(&rc);
1334  clipped = TRUE;
1335 
1336  SetCursorPos(40, 40);
1337  GetCursorPos(&pt_old);
1338  ok(pt_old.x == 50 && pt_old.y == 50, "Wrong new pos: (%d,%d)\n", pt_new.x, pt_new.y);
1339  SetCursorPos(160, 160);
1340  GetCursorPos(&pt_old);
1341  ok(pt_old.x == 150 && pt_old.y == 150, "Wrong new pos: (%d,%d)\n", pt_new.x, pt_new.y);
1343  GetCursorPos(&pt_old);
1344  ok(pt_old.x == 150 && pt_old.y == 150, "Wrong new pos: (%d,%d)\n", pt_new.x, pt_new.y);
1345 
1346  clipped = FALSE;
1347  pt_new.x = pt_new.y = 150;
1348  ClipCursor(NULL);
1349  UnhookWindowsHookEx(hook1);
1350 
1351  /* Now check that mouse buttons do not change mouse position
1352  if we don't have MOUSEEVENTF_MOVE flag specified. */
1353 
1354  /* We reusing the same hook callback, so make it happy */
1355  pt_old.x = pt_new.x - STEP;
1356  pt_old.y = pt_new.y - STEP;
1357  mouse_event(MOUSEEVENTF_LEFTUP, 123, 456, 0, 0);
1358  GetCursorPos(&pt);
1359  ok(pt.x == pt_new.x && pt.y == pt_new.y, "Position changed: (%d,%d)\n", pt.x, pt.y);
1360  mouse_event(MOUSEEVENTF_RIGHTUP, 456, 123, 0, 0);
1361  GetCursorPos(&pt);
1362  ok(pt.x == pt_new.x && pt.y == pt_new.y, "Position changed: (%d,%d)\n", pt.x, pt.y);
1363 
1365  GetCursorPos(&pt);
1366  ok(pt.x == pt_new.x && pt.y == pt_new.y, "Position changed: (%d,%d)\n", pt.x, pt.y);
1368  GetCursorPos(&pt);
1369  ok(pt.x == pt_new.x && pt.y == pt_new.y, "Position changed: (%d,%d)\n", pt.x, pt.y);
1370 
1371  UnhookWindowsHookEx(hook2);
1373 
1374  SetRect(&rc, 150, 150, 150, 150);
1375  ClipCursor(&rc);
1376  clipped = TRUE;
1377 
1378  SetCursorPos(140, 140);
1379  GetCursorPos(&pt_old);
1380  ok(pt_old.x == 150 && pt_old.y == 150, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y);
1381  SetCursorPos(160, 160);
1382  GetCursorPos(&pt_old);
1383  todo_wine
1384  ok(pt_old.x == 149 && pt_old.y == 149, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y);
1386  GetCursorPos(&pt_old);
1387  ok(pt_old.x == 150 && pt_old.y == 150, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y);
1389  GetCursorPos(&pt_old);
1390  todo_wine
1391  ok(pt_old.x == 149 && pt_old.y == 149, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y);
1392  mouse_event(MOUSEEVENTF_MOVE, 0, 0, 0, 0);
1393  GetCursorPos(&pt_old);
1394  ok(pt_old.x == 150 && pt_old.y == 150, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y);
1395  mouse_event(MOUSEEVENTF_MOVE, 0, 0, 0, 0);
1396  GetCursorPos(&pt_old);
1397  todo_wine
1398  ok(pt_old.x == 149 && pt_old.y == 149, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y);
1399 
1400  clipped = FALSE;
1401  ClipCursor(NULL);
1402 
1403  SetCursorPos(140, 140);
1404  SetRect(&rc, 150, 150, 150, 150);
1405  ClipCursor(&rc);
1406  GetCursorPos(&pt_old);
1407  ok(pt_old.x == 150 && pt_old.y == 150, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y);
1408  ClipCursor(NULL);
1409 
1410  SetCursorPos(160, 160);
1411  SetRect(&rc, 150, 150, 150, 150);
1412  ClipCursor(&rc);
1413  GetCursorPos(&pt_old);
1414  todo_wine
1415  ok(pt_old.x == 149 && pt_old.y == 149, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y);
1416  ClipCursor(NULL);
1417 
1418  SetCursorPos(150, 150);
1419  SetRect(&rc, 150, 150, 150, 150);
1420  ClipCursor(&rc);
1421  GetCursorPos(&pt_old);
1422  todo_wine
1423  ok(pt_old.x == 149 && pt_old.y == 149, "Wrong new pos: (%d,%d)\n", pt_old.x, pt_old.y);
1424  ClipCursor(NULL);
1425 
1426  UnhookWindowsHookEx(hook1);
1427 
1428 done:
1430  SetCursorPos(pt_org.x, pt_org.y);
1431 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define MOUSEEVENTF_ABSOLUTE
Definition: winuser.h:1180
long y
Definition: polytest.cpp:48
BOOL WINAPI ClipCursor(_In_opt_ LPCRECT)
static LRESULT CALLBACK hook_proc2(int code, WPARAM wparam, LPARAM lparam)
Definition: input.c:1266
long x
Definition: polytest.cpp:48
#define pt(x, y)
Definition: drawing.c:79
static BOOL clipped
Definition: input.c:1237
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
BOOL WINAPI DestroyWindow(_In_ HWND)
VOID WINAPI mouse_event(DWORD dwFlags, DWORD dx, DWORD dy, DWORD dwData, ULONG_PTR dwExtraInfo)
Definition: input.c:578
HHOOK WINAPI SetWindowsHookExA(_In_ int, _In_ HOOKPROC, _In_opt_ HINSTANCE, _In_ DWORD)
#define WH_MOUSE_LL
Definition: winuser.h:44
#define STEP
Definition: input.c:1238
#define ok(value,...)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4184
smooth NULL
Definition: ftsmooth.c:416
static LRESULT CALLBACK hook_proc3(int code, WPARAM wparam, LPARAM lparam)
Definition: input.c:1286
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2627
static POINT pt_old
Definition: input.c:1236
#define todo_wine
Definition: test.h:154
#define MOUSEEVENTF_LEFTUP
Definition: winuser.h:1171
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
#define MOUSEEVENTF_RIGHTUP
Definition: winuser.h:1173
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)