ReactOS  0.4.15-dev-1049-g1062a29
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 MAXKEYEVENTS   12
 
#define MAXKEYMESSAGES
 
#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 BOOL (WINAPI *pGetCurrentInputMessageSource)(INPUT_MESSAGE_SOURCE *source)
 
static POINTER_INPUT_TYPE *static int (WINAPI *pGetMouseMovePointsEx)(UINT
 
static UINT (WINAPI *pGetRawInputDeviceList)(PRAWINPUTDEVICELIST
 
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, BOOL foreground)
 
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 (WORD vk)
 
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_GetRawInputData (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)
 
static LRESULT WINAPI msg_source_proc (HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
 
static void test_input_message_source (void)
 
static void test_GetPointerType (void)
 
static void test_GetKeyboardLayoutList (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
 
   WORD   vk
 
   BOOL   expect_alt
 
   BOOL   sendinput_broken
 
key_status
 
static POINTER_INPUT_TYPE *static LPMOUSEMOVEPOINT
 
static POINTER_INPUT_TYPE *static int
 
static POINTER_INPUT_TYPE *static DWORD
 
static PUINT
 
static UINT
 
static void UINT *static void 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
 
static INPUT_MESSAGE_SOURCE expect_src
 

Macro Definition Documentation

◆ BUFLIM

#define BUFLIM   64

◆ ctrl

#define ctrl   2

Definition at line 1757 of file input.c.

◆ GET_PROC

#define GET_PROC (   func)
Value:
if (!(p ## func = (void*)GetProcAddress(hdll, #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:501
GLfloat GLfloat p
Definition: glext.h:8902

◆ MAXKEYEVENTS

#define MAXKEYEVENTS   12

Definition at line 90 of file input.c.

◆ MAXKEYMESSAGES

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

Definition at line 91 of file input.c.

◆ MYERROR

#define MYERROR   0xdeadbeef

◆ shift

#define shift   1

Definition at line 1756 of file input.c.

◆ STEP

#define STEP   3

Definition at line 1260 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 99 of file input.c.

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

◆ 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 422 of file input.c.

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

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pGetCurrentInputMessageSource)
static

Referenced by test_Input_unicode().

◆ compare_and_check()

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

Definition at line 702 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 && foreground) {
711  /* We won't receive any information from GetKeyboardState() if we're
712  * not the foreground window. */
713  BOOL matched = ((ks1[t->wVk]&0x80) == (t->before_state&0x80)
714  && (ks2[t->wVk]&0x80) == (~t->before_state&0x80));
715 
716  if (!matched && !t->optional && test->_todo_wine)
717  {
718  failcount++;
719  todo_wine {
720  ok(matched, "%2d (%x/%x): %02x from %02x -> %02x "
721  "instead of %02x -> %02x\n", id, test->wVk, test->dwFlags,
722  t->wVk, ks1[t->wVk]&0x80, ks2[t->wVk]&0x80, t->before_state,
723  ~t->before_state&0x80);
724  }
725  } else {
726  ok(matched || t->optional, "%2d (%x/%x): %02x from %02x -> %02x "
727  "instead of %02x -> %02x\n", id, test->wVk, test->dwFlags,
728  t->wVk, ks1[t->wVk]&0x80, ks2[t->wVk]&0x80, t->before_state,
729  ~t->before_state&0x80);
730  }
731  ks2[t->wVk] = ks1[t->wVk]; /* clear the match */
732  t++;
733  }
734  for (i = 0; i < 256; i++)
735  if (ks2[i] != ks1[i] && test->_todo_wine)
736  {
737  failcount++;
738  todo_wine
739  ok(FALSE, "%2d (%x/%x): %02x from %02x -> %02x unexpected\n",
740  id, test->wVk, test->dwFlags, i, ks1[i], ks2[i]);
741  }
742  else
743  ok(ks2[i] == ks1[i], "%2d (%x/%x): %02x from %02x -> %02x unexpected\n",
744  id, test->wVk, test->dwFlags, i, ks1[i], ks2[i]);
745 
746  while (expected->message && actual_cnt < sent_messages_cnt)
747  {
748  const struct message *actual = &sent_messages[actual_cnt];
749 
750  if (expected->message == actual->message)
751  {
752  if (expected->flags & wparam)
753  {
754  if ((expected->flags & optional) && (expected->wParam != actual->wParam))
755  {
756  expected++;
757  continue;
758  }
759  if (expected->wParam != actual->wParam && test->_todo_wine)
760  {
761  failcount++;
762  todo_wine
763  ok(FALSE, "%2d (%x/%x): in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
764  id, test->wVk, test->dwFlags, expected->message, expected->wParam, actual->wParam);
765  }
766  else
767  ok(expected->wParam == actual->wParam,
768  "%2d (%x/%x): in msg 0x%04x expecting wParam 0x%lx got 0x%lx\n",
769  id, test->wVk, test->dwFlags, expected->message, expected->wParam, actual->wParam);
770  }
771  if (expected->flags & lparam)
772  {
773  if (expected->lParam != actual->lParam && test->_todo_wine)
774  {
775  failcount++;
776  todo_wine
777  ok(FALSE, "%2d (%x/%x): in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
778  id, test->wVk, test->dwFlags, expected->message, expected->lParam, actual->lParam);
779  }
780  else
781  ok(expected->lParam == actual->lParam,
782  "%2d (%x/%x): in msg 0x%04x expecting lParam 0x%lx got 0x%lx\n",
783  id, test->wVk, test->dwFlags, expected->message, expected->lParam, actual->lParam);
784  }
785  ok((expected->flags & hook) == (actual->flags & hook),
786  "%2d (%x/%x): the msg 0x%04x should have been sent by a hook\n",
787  id, test->wVk, test->dwFlags, expected->message);
788 
789  }
790  else if (expected->flags & optional)
791  {
792  expected++;
793  continue;
794  }
795  else if (!(expected->flags & hook) && !foreground)
796  {
797  /* If we weren't able to receive foreground status, we won't get
798  * any window messages. */
799  expected++;
800  continue;
801  }
802  /* NT4 doesn't send SYSKEYDOWN/UP to hooks, only KEYDOWN/UP */
803  else if ((expected->flags & hook) &&
804  (expected->message == WM_SYSKEYDOWN || expected->message == WM_SYSKEYUP) &&
805  (actual->message == expected->message - 4))
806  {
807  ok((expected->flags & hook) == (actual->flags & hook),
808  "%2d (%x/%x): the msg 0x%04x should have been sent by a hook\n",
809  id, test->wVk, test->dwFlags, expected->message);
810  }
811  /* For VK_RMENU, at least localized Win2k/XP sends KEYDOWN/UP
812  * instead of SYSKEYDOWN/UP to the WNDPROC */
813  else if (test->wVk == VK_RMENU && !(expected->flags & hook) &&
814  (expected->message == WM_SYSKEYDOWN || expected->message == WM_SYSKEYUP) &&
815  (actual->message == expected->message - 4))
816  {
817  ok(expected->wParam == actual->wParam && expected->lParam == actual->lParam,
818  "%2d (%x/%x): the msg 0x%04x was expected, but got msg 0x%04x instead\n",
819  id, test->wVk, test->dwFlags, expected->message, actual->message);
820  }
821  else if (test->_todo_wine)
822  {
823  failcount++;
824  todo_wine
825  ok(FALSE,
826  "%2d (%x/%x): the msg 0x%04x was expected, but got msg 0x%04x instead\n",
827  id, test->wVk, test->dwFlags, expected->message, actual->message);
828  }
829  else
830  ok(FALSE,
831  "%2d (%x/%x): the msg 0x%04x was expected, but got msg 0x%04x instead\n",
832  id, test->wVk, test->dwFlags, expected->message, actual->message);
833 
834  actual_cnt++;
835  expected++;
836  }
837  /* skip all optional trailing messages */
838  while (expected->message && ((expected->flags & optional) || (!(expected->flags & hook) && !foreground)))
839  expected++;
840 
841 
842  if (expected->message || actual_cnt < sent_messages_cnt)
843  {
844  if (test->_todo_wine)
845  {
846  failcount++;
847  todo_wine
848  ok(FALSE, "%2d (%x/%x): the msg sequence is not complete: expected %04x - actual %04x\n",
849  id, test->wVk, test->dwFlags, expected->message, sent_messages[actual_cnt].message);
850  }
851  else
852  ok(FALSE, "%2d (%x/%x): the msg sequence is not complete: expected %04x - actual %04x\n",
853  id, test->wVk, test->dwFlags, expected->message, sent_messages[actual_cnt].message);
854  }
855 
856  if( test->_todo_wine && !failcount) /* succeeded yet marked todo */
857  todo_wine
858  ok(TRUE, "%2d (%x/%x): marked \"todo_wine\" but succeeds\n", id, test->wVk, test->dwFlags);
859 
860  sent_messages_cnt = 0;
861 }
static struct message sent_messages[MAXKEYMESSAGES]
Definition: input.c:698
UINT message
Definition: msg.h:50
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define VK_RMENU
Definition: winuser.h:2262
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
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: input.c:426
Definition: input.c:427
#define todo_wine
Definition: test.h:162
#define WM_SYSKEYUP
Definition: winuser.h:1702
#define ok(value,...)
Definition: atltest.h:57
Definition: input.c:431
unsigned int UINT
Definition: ndis.h:50
static UINT sent_messages_cnt
Definition: input.c:699
#define WM_SYSKEYDOWN
Definition: winuser.h:1701
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 2071 of file input.c.

2072 {
2073  struct thread_data *thread_data = arg;
2074  HWND win;
2075 
2076  win = CreateWindowA("static", "static", WS_VISIBLE | WS_POPUP,
2077  100, 100, 100, 100, 0, NULL, NULL, NULL);
2078  ok(win != 0, "CreateWindow failed\n");
2081  thread_data->win = win;
2082 
2085  return 0;
2086 }
static WNDPROC def_static_proc
Definition: input.c:2050
HWND win
Definition: input.c:2068
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
void * arg
Definition: msvc.h:10
static BOOL wait_for_event(HANDLE event, int timeout)
Definition: input.c:2034
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4290
smooth NULL
Definition: ftsmooth.c:416
static LRESULT WINAPI static_hook_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: input.c:2052
HANDLE end_event
Definition: input.c:2067
#define SetWindowLongPtrA
Definition: winuser.h:5320
#define GWLP_WNDPROC
Definition: treelist.c:66
static real win[4][36]
#define ok(value,...)
Definition: atltest.h:57
__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:2066

Referenced by test_Input_mouse().

◆ do_test()

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

Definition at line 224 of file input.c.

225 {
226  TEST_INPUT inputs[MAXKEYEVENTS];
227  KMSG expmsg[MAXKEYEVENTS];
228  MSG msg;
229  char buf[100];
230  UINT evtctr=0, ret;
231  int kmctr, i;
232 
233  buf[0]='\0';
234  TrackSysKey=0; /* see input.c */
235  for (i = 0; i < MAXKEYEVENTS; i++)
236  {
237  inputs[evtctr].type = INPUT_KEYBOARD;
238  inputs[evtctr].u.ki.wVk = GETVKEY[td[i]];
239  inputs[evtctr].u.ki.wScan = GETSCAN[td[i]];
240  inputs[evtctr].u.ki.dwFlags = GETFLAGS[td[i]];
241  inputs[evtctr].u.ki.dwExtraInfo = 0;
242  inputs[evtctr].u.ki.time = ++timetag;
243  if (td[i]) evtctr++;
244 
245  strcat(buf, getdesc[td[i]]);
246  if(td[i])
247  expmsg[i].message = KbdMessage(td[i], &(expmsg[i].wParam), &(expmsg[i].lParam));
248  else
249  expmsg[i].message = 0;
250  }
251  for( kmctr = 0; kmctr < MAXKEYEVENTS && expmsg[kmctr].message; kmctr++)
252  ;
253  ok( evtctr <= MAXKEYEVENTS, "evtctr is above MAXKEYEVENTS\n" );
254  ret = SendInput(evtctr, (INPUT *)inputs, sizeof(INPUT));
255  ok(ret == evtctr, "SendInput failed to send some events\n");
256  i = 0;
257  if (winetest_debug > 1)
258  trace("======== key stroke sequence #%d: %s =============\n",
259  seqnr + 1, buf);
261  if (winetest_debug > 1)
262  trace("message[%d] %-15s wParam %04lx lParam %08lx time %x\n", i,
263  MSGNAME[msg.message - WM_KEYFIRST], msg.wParam, msg.lParam, msg.time);
264  if( i < kmctr ) {
265  ok( msg.message == expmsg[i].message &&
266  msg.wParam == expmsg[i].wParam &&
267  msg.lParam == expmsg[i].lParam,
268  "%u/%u: wrong message %x/%08lx/%08lx expected %s/%08lx/%08lx\n",
269  seqnr, i, msg.message, msg.wParam, msg.lParam,
270  MSGNAME[(expmsg[i]).message - WM_KEYFIRST], expmsg[i].wParam, expmsg[i].lParam );
271  }
272  i++;
273  }
274  if (winetest_debug > 1)
275  trace("%d messages retrieved\n", i);
276  if (!i && kmctr)
277  {
278  skip( "simulated keyboard input doesn't work\n" );
279  return FALSE;
280  }
281  ok( i == kmctr, "message count is wrong: got %d expected: %d\n", i, kmctr);
282  return TRUE;
283 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
DWORD type
Definition: imm32.c:51
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:108
#define TRUE
Definition: types.h:120
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define MAXKEYEVENTS
Definition: input.c:90
DWORD time
Definition: winable.h:50
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:170
#define INPUT_KEYBOARD
Definition: winable.h:10
#define WM_KEYFIRST
Definition: winuser.h:1696
static const char * MSGNAME[]
Definition: input.c:95
#define FALSE
Definition: types.h:117
static const int GETFLAGS[]
Definition: input.c:106
DWORD dwFlags
Definition: winable.h:49
#define trace
Definition: atltest.h:70
Definition: input.c:122
#define WM_KEYLAST
Definition: winuser.h:1710
int ret
union TEST_INPUT::@1640 u
UINT message
Definition: input.c:123
static LONG timetag
Definition: input.c:64
static BYTE TrackSysKey
Definition: input.c:149
WORD wScan
Definition: winable.h:48
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
#define skip(...)
Definition: atltest.h:64
#define msg(x)
Definition: auth_time.c:54
ULONG_PTR dwExtraInfo
Definition: winable.h:51
#define PM_REMOVE
Definition: winuser.h:1182
static const int GETSCAN[]
Definition: input.c:104
KEYBDINPUT ki
Definition: imm32.c:55
LPARAM lParam
Definition: combotst.c:139
WORD wVk
Definition: winable.h:47
UINT WINAPI SendInput(UINT, LPINPUT, int)
Definition: ntwrapper.h:344
static const int GETVKEY[]
Definition: input.c:102

Referenced by TestASet().

◆ empty_message_queue()

static void empty_message_queue ( void  )
static

Definition at line 394 of file input.c.

395 {
396  MSG msg;
397  int diff = 200;
398  int min_timeout = 50;
399  DWORD time = GetTickCount() + diff;
400 
401  while (diff > 0)
402  {
403  if (MsgWaitForMultipleObjects(0, NULL, FALSE, min_timeout, QS_ALLINPUT) == WAIT_TIMEOUT) break;
404  while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
405  {
406  if (is_keyboard_message(msg.message) || is_mouse_message(msg.message))
407  ok(msg.time != 0, "message %#x has time set to 0\n", msg.message);
408 
411  }
412  diff = time - GetTickCount();
413  }
414 }
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:455
__u16 time
Definition: mkdosfs.c:366
BOOL WINAPI PeekMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define FALSE
Definition: types.h:117
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 ok(value,...)
Definition: atltest.h:57
#define msg(x)
Definition: auth_time.c:54
static BOOL is_keyboard_message(UINT message)
Definition: input.c:383
#define PM_REMOVE
Definition: winuser.h:1182
static BOOL is_mouse_message(UINT message)
Definition: input.c:388

Referenced by test_Input_blackbox().

◆ get_dc_region()

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

Definition at line 2088 of file input.c.

2089 {
2090  int region_type;
2091  HRGN hregion;
2092  HDC hdc;
2093 
2094  hdc = GetDCEx(hwnd, 0, flags);
2095  ok(hdc != NULL, "GetDCEx failed\n");
2096  hregion = CreateRectRgn(40, 40, 60, 60);
2097  ok(hregion != NULL, "CreateRectRgn failed\n");
2098  GetRandomRgn(hdc, hregion, SYSRGN);
2099  region_type = GetRgnBox(hregion, region);
2100  ok(region_type == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", region_type);
2101  DeleteObject(hregion);
2102  ReleaseDC(hwnd, hdc);
2103 }
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)
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
#define ok(value,...)
Definition: atltest.h:57
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 2879 of file input.c.

2880 {
2881  HANDLE *semaphores = arg;
2882  DWORD result;
2883 
2884  ReleaseSemaphore(semaphores[0], 1, NULL);
2885  result = WaitForSingleObject(semaphores[1], 1000);
2886  ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
2887 
2888  result = GetKeyState('X');
2889  ok((result & 0x8000) || broken(!(result & 0x8000)), /* > Win 2003 */
2890  "expected that highest bit is set, got %x\n", result);
2891 
2892  ReleaseSemaphore(semaphores[0], 1, NULL);
2893  result = WaitForSingleObject(semaphores[1], 1000);
2894  ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
2895 
2896  result = GetKeyState('X');
2897  ok(!(result & 0x8000), "expected that highest bit is unset, got %x\n", result);
2898 
2899  return 0;
2900 }
void * arg
Definition: msvc.h:10
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
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
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:542
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:698
int winetest_debug
#define LLKHF_UP
Definition: winuser.h:2623
#define WM_KEYDOWN
Definition: winuser.h:1697
Definition: input.c:426
#define trace
Definition: atltest.h:70
#define WM_KEYUP
Definition: winuser.h:1698
Definition: input.c:427
#define MAXKEYMESSAGES
Definition: input.c:91
#define LLKHF_EXTENDED
Definition: winuser.h:2620
Definition: inflate.c:139
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:1702
#define ok(value,...)
Definition: atltest.h:57
Definition: input.c:431
static UINT sent_messages_cnt
Definition: input.c:699
#define WM_SYSKEYDOWN
Definition: winuser.h:1701
ULONG_PTR dwExtraInfo
Definition: winuser.h:3787
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 1262 of file input.c.

1263 {
1265  POINT pt, pt1;
1266 
1267  if (code == HC_ACTION)
1268  {
1269  /* This is our new cursor position */
1270  pt_new = hook->pt;
1271  /* Should return previous position */
1272  GetCursorPos(&pt);
1273  ok(pt.x == pt_old.x && pt.y == pt_old.y, "GetCursorPos: (%d,%d)\n", pt.x, pt.y);
1274 
1275  /* Should set new position until hook chain is finished. */
1276  pt.x = pt_old.x + STEP;
1277  pt.y = pt_old.y + STEP;
1278  SetCursorPos(pt.x, pt.y);
1279  GetCursorPos(&pt1);
1280  if (clipped)
1281  ok(pt1.x == pt_old.x && pt1.y == pt_old.y, "Wrong set pos: (%d,%d)\n", pt1.x, pt1.y);
1282  else
1283  ok(pt1.x == pt.x && pt1.y == pt.y, "Wrong set pos: (%d,%d)\n", pt1.x, pt1.y);
1284  }
1285  return CallNextHookEx( 0, code, wparam, lparam );
1286 }
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:1259
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
#define STEP
Definition: input.c:1260
Definition: input.c:426
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2627
Definition: input.c:427
static POINT pt_old
Definition: input.c:1258
Definition: inflate.c:139
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
#define HC_ACTION
Definition: winuser.h:48
#define ok(value,...)
Definition: atltest.h:57
Definition: input.c:431
static POINT pt_new
Definition: input.c:1258

Referenced by test_mouse_ll_hook().

◆ hook_proc2()

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

Definition at line 1288 of file input.c.

1289 {
1291  POINT pt;
1292 
1293  if (code == HC_ACTION)
1294  {
1295  ok(hook->pt.x == pt_new.x && hook->pt.y == pt_new.y,
1296  "Wrong hook coords: (%d %d) != (%d,%d)\n", hook->pt.x, hook->pt.y, pt_new.x, pt_new.y);
1297 
1298  /* Should match position set above */
1299  GetCursorPos(&pt);
1300  if (clipped)
1301  ok(pt.x == pt_old.x && pt.y == pt_old.y, "GetCursorPos: (%d,%d)\n", pt.x, pt.y);
1302  else
1303  ok(pt.x == pt_old.x +STEP && pt.y == pt_old.y +STEP, "GetCursorPos: (%d,%d)\n", pt.x, pt.y);
1304  }
1305  return CallNextHookEx( 0, code, wparam, lparam );
1306 }
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:1259
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
#define STEP
Definition: input.c:1260
Definition: input.c:426
Definition: input.c:427
static POINT pt_old
Definition: input.c:1258
Definition: inflate.c:139
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
#define HC_ACTION
Definition: winuser.h:48
#define ok(value,...)
Definition: atltest.h:57
Definition: input.c:431
static POINT pt_new
Definition: input.c:1258

Referenced by test_mouse_ll_hook().

◆ hook_proc3()

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

Definition at line 1308 of file input.c.

1309 {
1310  POINT pt;
1311 
1312  if (code == HC_ACTION)
1313  {
1314  /* MSLLHOOKSTRUCT does not seem to be reliable and contains different data on each run. */
1315  GetCursorPos(&pt);
1316  ok(pt.x == pt_old.x && pt.y == pt_old.y, "GetCursorPos: (%d,%d)\n", pt.x, pt.y);
1317  }
1318  return CallNextHookEx( 0, code, wparam, lparam );
1319 }
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
Definition: input.c:426
Definition: input.c:427
static POINT pt_old
Definition: input.c:1258
Definition: inflate.c:139
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
#define HC_ACTION
Definition: winuser.h:48
#define ok(value,...)
Definition: atltest.h:57

Referenced by test_mouse_ll_hook().

◆ init_function_pointers()

static void init_function_pointers ( void  )
static

Definition at line 152 of file input.c.

153 {
154  HMODULE hdll = GetModuleHandleA("user32");
155 
156 #define GET_PROC(func) \
157  if (!(p ## func = (void*)GetProcAddress(hdll, #func))) \
158  trace("GetProcAddress(%s) failed\n", #func)
159 
160  GET_PROC(GetCurrentInputMessageSource);
161  GET_PROC(GetMouseMovePointsEx);
162  GET_PROC(GetPointerType);
167 #undef GET_PROC
168 }
UINT WINAPI GetRawInputDeviceInfoW(HANDLE hDevice, UINT uiCommand, LPVOID pData, PUINT pcbSize)
Definition: stubs.c:225
UINT WINAPI GetRawInputDeviceInfoA(HANDLE hDevice, UINT uiCommand, LPVOID pData, PUINT pcbSize)
Definition: stubs.c:257
#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:812
static PVOID hdll
Definition: shimdbg.c:126
UINT WINAPI GetRawInputDeviceList(PRAWINPUTDEVICELIST pRawInputDeviceList, PUINT puiNumDevices, UINT cbSize)
Definition: stubs.c:329

Referenced by START_TEST().

◆ int()

static POINTER_INPUT_TYPE* static int ( WINAPI pGetMouseMovePointsEx)
static

◆ is_keyboard_message()

static BOOL is_keyboard_message ( UINT  message)
inlinestatic

Definition at line 383 of file input.c.

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

Referenced by empty_message_queue().

◆ is_mouse_message()

static BOOL is_mouse_message ( UINT  message)
inlinestatic

Definition at line 388 of file input.c.

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

Referenced by empty_message_queue().

◆ KbdMessage()

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

Definition at line 170 of file input.c.

171 {
172  UINT message;
173  int VKey = GETVKEY[kev];
174  WORD flags;
175 
176  flags = LOBYTE(GETSCAN[kev]);
178 
179  if (GETFLAGS[kev] & KEYEVENTF_KEYUP )
180  {
181  message = WM_KEYUP;
182  if( (InputKeyStateTable[VK_MENU] & 0x80) && (
183  (VKey == VK_MENU) || (VKey == VK_CONTROL) ||
184  !(InputKeyStateTable[VK_CONTROL] & 0x80))) {
185  if( TrackSysKey == VK_MENU || /* <ALT>-down/<ALT>-up sequence */
186  (VKey != VK_MENU)) /* <ALT>-down...<something else>-up */
188  TrackSysKey = 0;
189  }
190  InputKeyStateTable[VKey] &= ~0x80;
191  flags |= KF_REPEAT | KF_UP;
192  }
193  else
194  {
195  if (InputKeyStateTable[VKey] & 0x80) flags |= KF_REPEAT;
196  if (!(InputKeyStateTable[VKey] & 0x80)) InputKeyStateTable[VKey] ^= 0x01;
197  InputKeyStateTable[VKey] |= 0x80;
198  AsyncKeyStateTable[VKey] |= 0x80;
199 
201  if( (InputKeyStateTable[VK_MENU] & 0x80) &&
202  !(InputKeyStateTable[VK_CONTROL] & 0x80)) {
204  TrackSysKey = VKey;
205  }
206  }
207 
208  if (InputKeyStateTable[VK_MENU] & 0x80) flags |= KF_ALTDOWN;
209 
210  if( plParam) *plParam = MAKELPARAM( 1, flags );
211  if( pwParam) *pwParam = VKey;
212  return message;
213 }
Definition: tftpd.h:59
static BYTE AsyncKeyStateTable[256]
Definition: input.c:148
#define LOBYTE(W)
Definition: jmemdos.c:487
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
#define MAKELPARAM(l, h)
Definition: winuser.h:3983
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glext.h:5579
#define KF_UP
Definition: winuser.h:2426
#define VK_MENU
Definition: winuser.h:2179
static BYTE InputKeyStateTable[256]
Definition: input.c:147
static const int GETFLAGS[]
Definition: input.c:106
#define WM_KEYDOWN
Definition: winuser.h:1697
#define KF_EXTENDED
Definition: winuser.h:2421
#define KF_REPEAT
Definition: winuser.h:2425
#define WM_KEYUP
Definition: winuser.h:1698
unsigned short WORD
Definition: ntddk_ex.h:93
GLbitfield flags
Definition: glext.h:7161
static BYTE TrackSysKey
Definition: input.c:149
#define WM_SYSKEYUP
Definition: winuser.h:1702
unsigned int UINT
Definition: ndis.h:50
#define KEYEVENTF_EXTENDEDKEY
Definition: winuser.h:1091
#define KF_ALTDOWN
Definition: winuser.h:2424
#define VK_CONTROL
Definition: winuser.h:2178
#define WM_SYSKEYDOWN
Definition: winuser.h:1701
static const int GETSCAN[]
Definition: input.c:104
static const int GETVKEY[]
Definition: input.c:102

Referenced by do_test().

◆ llkbd_unicode_hook()

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

Definition at line 1146 of file input.c.

1147 {
1148  if(nCode == HC_ACTION){
1150  if(!info->vkCode){
1151  key_status.sendinput_broken = TRUE;
1152  win_skip("SendInput doesn't support unicode on this platform\n");
1153  }else{
1154  if(key_status.expect_alt){
1155  ok(info->vkCode == VK_LMENU, "vkCode should have been VK_LMENU[0x%04x], was: 0x%x\n", VK_LMENU, info->vkCode);
1156  key_status.expect_alt = FALSE;
1157  }else
1158  todo_wine_if(key_status.vk != VK_PACKET)
1159  ok(info->vkCode == key_status.vk, "Unexpected vkCode %#x, expected %#x.\n", info->vkCode, key_status.vk);
1160  }
1161  switch(wParam){
1162  case WM_KEYDOWN:
1163  key_status.last_hook_down = info->scanCode;
1164  break;
1165  case WM_KEYUP:
1166  key_status.last_hook_up = info->scanCode;
1167  break;
1168  case WM_SYSKEYDOWN:
1169  key_status.last_hook_syskey_down = info->scanCode;
1170  break;
1171  case WM_SYSKEYUP:
1172  key_status.last_hook_syskey_up = info->scanCode;
1173  break;
1174  }
1175  }
1176  return CallNextHookEx(NULL, nCode, wParam, lParam);
1177 }
#define TRUE
Definition: types.h:120
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define WM_KEYDOWN
Definition: winuser.h:1697
#define todo_wine_if(is_todo)
Definition: test.h:163
struct tagKBDLLHOOKSTRUCT * LPKBDLLHOOKSTRUCT
#define WM_KEYUP
Definition: winuser.h:1698
#define VK_LMENU
Definition: winuser.h:2261
static struct @1699 key_status
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:1702
#define ok(value,...)
Definition: atltest.h:57
#define WM_SYSKEYDOWN
Definition: winuser.h:1701
#define win_skip
Definition: test.h:149
LPARAM lParam
Definition: combotst.c:139

Referenced by test_Input_unicode().

◆ msg_source_proc()

static LRESULT WINAPI msg_source_proc ( HWND  hwnd,
UINT  message,
WPARAM  wp,
LPARAM  lp 
)
static

Definition at line 2979 of file input.c.

2980 {
2981  INPUT_MESSAGE_SOURCE source;
2982  MSG msg;
2983 
2984  ok( pGetCurrentInputMessageSource( &source ), "GetCurrentInputMessageSource failed\n" );
2985  switch (message)
2986  {
2987  case WM_KEYDOWN:
2988  case WM_KEYUP:
2989  case WM_SYSKEYDOWN:
2990  case WM_SYSKEYUP:
2991  case WM_MOUSEMOVE:
2992  case WM_LBUTTONDOWN:
2993  case WM_LBUTTONUP:
2994  case WM_RBUTTONDOWN:
2995  case WM_RBUTTONUP:
2996  ok( source.deviceType == expect_src.deviceType || /* also accept system-generated WM_MOUSEMOVE */
2997  (message == WM_MOUSEMOVE && source.deviceType == IMDT_UNAVAILABLE),
2998  "%x: wrong deviceType %x/%x\n", message, source.deviceType, expect_src.deviceType );
2999  ok( source.originId == expect_src.originId ||
3000  (message == WM_MOUSEMOVE && source.originId == IMO_SYSTEM),
3001  "%x: wrong originId %x/%x\n", message, source.originId, expect_src.originId );
3002  SendMessageA( hwnd, WM_USER, 0, 0 );
3003  PostMessageA( hwnd, WM_USER, 0, 0 );
3005  ok( source.deviceType == expect_src.deviceType || /* also accept system-generated WM_MOUSEMOVE */
3006  (message == WM_MOUSEMOVE && source.deviceType == IMDT_UNAVAILABLE),
3007  "%x: wrong deviceType %x/%x\n", message, source.deviceType, expect_src.deviceType );
3008  ok( source.originId == expect_src.originId ||
3009  (message == WM_MOUSEMOVE && source.originId == IMO_SYSTEM),
3010  "%x: wrong originId %x/%x\n", message, source.originId, expect_src.originId );
3011  break;
3012  default:
3013  ok( source.deviceType == IMDT_UNAVAILABLE, "%x: wrong deviceType %x\n",
3014  message, source.deviceType );
3015  ok( source.originId == 0, "%x: wrong originId %x\n", message, source.originId );
3016  break;
3017  }
3018 
3019  return DefWindowProcA( hwnd, message, wp, lp );
3020 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: tftpd.h:59
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
static INPUT_MESSAGE_SOURCE expect_src
Definition: input.c:2977
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define WM_KEYDOWN
Definition: winuser.h:1697
#define WM_RBUTTONDOWN
Definition: winuser.h:1761
#define WM_KEYUP
Definition: winuser.h:1698
#define WM_RBUTTONUP
Definition: winuser.h:1762
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_USER
Definition: winuser.h:1877
GLsizei GLsizei GLchar * source
Definition: glext.h:6048
#define WM_SYSKEYUP
Definition: winuser.h:1702
#define ok(value,...)
Definition: atltest.h:57
#define WM_LBUTTONUP
Definition: winuser.h:1759
#define WM_MOUSEMOVE
Definition: winuser.h:1757
#define msg(x)
Definition: auth_time.c:54
#define WM_SYSKEYDOWN
Definition: winuser.h:1701
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1182

Referenced by test_input_message_source().

◆ MsgCheckProcA()

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

Definition at line 2579 of file input.c.

2580 {
2581  if (message == WM_USER+1)
2582  {
2583  HWND hwnd = (HWND)lParam;
2584  ok(GetFocus() == hwnd, "thread expected focus %p, got %p\n", hwnd, GetFocus());
2585  ok(GetActiveWindow() == hwnd, "thread expected active %p, got %p\n", hwnd, GetActiveWindow());
2586  }
2588 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: tftpd.h:59
HANDLE HWND
Definition: compat.h:19
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_USER
Definition: winuser.h:1877
#define ok(value,...)
Definition: atltest.h:57
HWND WINAPI GetFocus(void)
Definition: window.c:1909
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 ( WORD  vk)
static

Definition at line 970 of file input.c.

971 {
972  key_status.last_key_down = -1;
973  key_status.last_key_up = -1;
974  key_status.last_syskey_down = -1;
975  key_status.last_syskey_up = -1;
976  key_status.last_char = -1;
977  key_status.last_syschar = -1;
978  key_status.last_hook_down = -1;
979  key_status.last_hook_up = -1;
980  key_status.last_hook_syskey_down = -1;
981  key_status.last_hook_syskey_up = -1;
982  key_status.vk = vk;
983  key_status.expect_alt = FALSE;
984  key_status.sendinput_broken = FALSE;
985 }
WORD vk
Definition: input.c:77
#define FALSE
Definition: types.h:117
static struct @1699 key_status

Referenced by test_unicode_keys().

◆ simulate_click()

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

Definition at line 1997 of file input.c.

1998 {
1999  INPUT input[2];
2000  UINT events_no;
2001 
2002  SetCursorPos(x, y);
2003  memset(input, 0, sizeof(input));
2004  input[0].type = INPUT_MOUSE;
2005  U(input[0]).mi.dx = x;
2006  U(input[0]).mi.dy = y;
2007  U(input[0]).mi.dwFlags = left ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_RIGHTDOWN;
2008  input[1].type = INPUT_MOUSE;
2009  U(input[1]).mi.dx = x;
2010  U(input[1]).mi.dy = y;
2011  U(input[1]).mi.dwFlags = left ? MOUSEEVENTF_LEFTUP : MOUSEEVENTF_RIGHTUP;
2012  events_no = SendInput(2, input, sizeof(input[0]));
2013  ok(events_no == 2, "SendInput returned %d\n", events_no);
2014 }
#define MOUSEEVENTF_LEFTDOWN
Definition: winuser.h:1170
#define U(x)
Definition: wordpad.c:45
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#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
#define ok(value,...)
Definition: atltest.h:57
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_message_source(), and test_Input_mouse().

◆ START_TEST()

START_TEST ( input  )

Definition at line 3165 of file input.c.

3166 {
3167  POINT pos;
3168 
3170  GetCursorPos( &pos );
3171 
3175  test_Input_mouse();
3176  test_keynames();
3178  test_key_map();
3179  test_ToUnicode();
3180  test_ToAscii();
3183  test_key_names();
3185  test_GetKeyState();
3186  test_OemKeyScan();
3189 
3190  if(pGetMouseMovePointsEx)
3192  else
3193  win_skip("GetMouseMovePointsEx is not available\n");
3194 
3195  if(pGetRawInputDeviceList)
3197  else
3198  win_skip("GetRawInputDeviceList is not available\n");
3199 
3200  if (pGetCurrentInputMessageSource)
3202  else
3203  win_skip("GetCurrentInputMessageSource is not available\n");
3204 
3205  SetCursorPos( pos.x, pos.y );
3206 
3207  if(pGetPointerType)
3209  else
3210  win_skip("GetPointerType is not available\n");
3211 }
static void test_keynames(void)
Definition: input.c:1245
static void test_GetRawInputData(void)
Definition: input.c:1694
static void test_GetMouseMovePointsEx(void)
Definition: input.c:1455
static void test_get_async_key_state(void)
Definition: input.c:1929
static void test_GetPointerType(void)
Definition: input.c:3106
static void test_mouse_ll_hook(void)
Definition: input.c:1321
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
static void test_Input_whitebox(void)
Definition: input.c:348
static void test_GetKeyboardLayoutList(void)
Definition: input.c:3131
static void test_ToAscii(void)
Definition: input.c:1882
static void test_Input_unicode(void)
Definition: input.c:1179
static void test_key_names(void)
Definition: input.c:1957
static void test_input_message_source(void)
Definition: input.c:3022
static void test_OemKeyScan(void)
Definition: input.c:2943
static void test_key_map(void)
Definition: input.c:1704
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2627
static void test_Input_blackbox(void)
Definition: input.c:912
static void test_GetKeyState(void)
Definition: input.c:2902
static void test_ToUnicode(void)
Definition: input.c:1809
static void test_keyboard_layout_name(void)
Definition: input.c:1936
static void init_function_pointers(void)
Definition: input.c:152
static void test_GetRawInputDeviceList(void)
Definition: input.c:1591
#define win_skip
Definition: test.h:149
static void test_Input_mouse(void)
Definition: input.c:2105
static void test_attach_input(void)
Definition: input.c:2646

◆ static_hook_proc()

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

Definition at line 2052 of file input.c.

2053 {
2054  if (msg == WM_NCHITTEST)
2055  {
2056  /* break infinite hittest loop */
2057  if(hittest_no > 50) return HTCLIENT;
2058  hittest_no++;
2059  }
2060 
2061  return def_static_proc(hwnd, msg, wp, lp);
2062 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static WNDPROC def_static_proc
Definition: input.c:2050
#define WM_NCHITTEST
Definition: winuser.h:1668
static DWORD hittest_no
Definition: input.c:2051
#define msg(x)
Definition: auth_time.c:54
#define HTCLIENT
Definition: winuser.h:2450

Referenced by create_static_win(), and test_Input_mouse().

◆ test_attach_input()

static void test_attach_input ( void  )
static

Definition at line 2646 of file input.c.

2647 {
2648  HANDLE hThread;
2649  HWND ourWnd, Wnd2;
2650  DWORD ret, tid;
2651  struct wnd_event wnd_event;
2652  WNDCLASSA cls;
2653 
2654  cls.style = 0;
2655  cls.lpfnWndProc = MsgCheckProcA;
2656  cls.cbClsExtra = 0;
2657  cls.cbWndExtra = 0;
2658  cls.hInstance = GetModuleHandleA(0);
2659  cls.hIcon = 0;
2660  cls.hCursor = LoadCursorW( NULL, (LPCWSTR)IDC_ARROW);
2661  cls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
2662  cls.lpszMenuName = NULL;
2663  cls.lpszClassName = "TestWindowClass";
2664  if(!RegisterClassA(&cls)) return;
2665 
2668  wnd_event.attach_from = 0;
2669  wnd_event.attach_to = 0;
2671  if (!wnd_event.start_event)
2672  {
2673  win_skip("skipping interthread message test under win9x\n");
2674  return;
2675  }
2676 
2678  ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
2679 
2680  ok(WaitForSingleObject(wnd_event.start_event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2682 
2683  ourWnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
2684  0, 0, 0, 0, 0, 0, 0, NULL);
2685  ok(ourWnd!= 0, "failed to create ourWnd window\n");
2686 
2687  Wnd2 = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
2688  0, 0, 0, 0, 0, 0, 0, NULL);
2689  ok(Wnd2!= 0, "failed to create Wnd2 window\n");
2690 
2691  SetFocus(ourWnd);
2692  SetActiveWindow(ourWnd);
2693 
2695  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2696 
2697  ok(GetActiveWindow() == ourWnd, "expected active %p, got %p\n", ourWnd, GetActiveWindow());
2698  ok(GetFocus() == ourWnd, "expected focus %p, got %p\n", ourWnd, GetFocus());
2699 
2700  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, (LPARAM)ourWnd);
2701 
2703  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2704  ok(GetActiveWindow() == ourWnd, "expected active %p, got %p\n", ourWnd, GetActiveWindow());
2705  ok(GetFocus() == ourWnd, "expected focus %p, got %p\n", ourWnd, GetFocus());
2706 
2707  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, 0);
2708 
2710  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2711 
2712  ok(GetActiveWindow() == ourWnd, "expected active %p, got %p\n", ourWnd, GetActiveWindow());
2713  ok(GetFocus() == ourWnd, "expected focus %p, got %p\n", ourWnd, GetFocus());
2714  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, (LPARAM)ourWnd);
2715 
2716  SetActiveWindow(Wnd2);
2717  SetFocus(Wnd2);
2718  ok(GetActiveWindow() == Wnd2, "expected active %p, got %p\n", Wnd2, GetActiveWindow());
2719  ok(GetFocus() == Wnd2, "expected focus %p, got %p\n", Wnd2, GetFocus());
2720 
2721  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, (LPARAM)Wnd2);
2722 
2724  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2725  ok(GetActiveWindow() == Wnd2, "expected active %p, got %p\n", Wnd2, GetActiveWindow());
2726  ok(GetFocus() == Wnd2, "expected focus %p, got %p\n", Wnd2, GetFocus());
2727 
2728  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, 0);
2729 
2731  ok(ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
2732 
2733  ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2735 
2738  wnd_event.attach_from = 0;
2739  wnd_event.attach_to = 0;
2741 
2743  ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
2744 
2745  ok(WaitForSingleObject(wnd_event.start_event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2747 
2748  SetFocus(ourWnd);
2749  SetActiveWindow(ourWnd);
2750 
2752  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2753 
2754  ok(GetActiveWindow() == wnd_event.hwnd, "expected active %p, got %p\n", wnd_event.hwnd, GetActiveWindow());
2755  ok(GetFocus() == wnd_event.hwnd, "expected focus %p, got %p\n", wnd_event.hwnd, GetFocus());
2756 
2758 
2760  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2761 
2762  ok(GetActiveWindow() == 0, "expected active 0, got %p\n", GetActiveWindow());
2763  ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
2764 
2766 
2768  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2769 
2770  ok(GetActiveWindow() == wnd_event.hwnd, "expected active %p, got %p\n", wnd_event.hwnd, GetActiveWindow());
2771  ok(GetFocus() == wnd_event.hwnd, "expected focus %p, got %p\n", wnd_event.hwnd, GetFocus());
2772 
2774 
2775  SetFocus(Wnd2);
2776  SetActiveWindow(Wnd2);
2777  ok(GetActiveWindow() == Wnd2, "expected active %p, got %p\n", Wnd2, GetActiveWindow());
2778  ok(GetFocus() == Wnd2, "expected focus %p, got %p\n", Wnd2, GetFocus());
2779 
2780  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, (LPARAM)Wnd2);
2781 
2783  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2784 
2785  ok(GetActiveWindow() == Wnd2, "expected active %p, got %p\n", Wnd2, GetActiveWindow());
2786  ok(GetFocus() == Wnd2, "expected focus %p, got %p\n", Wnd2, GetFocus());
2787 
2788  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, 0);
2789 
2791  ok(ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
2792 
2793  ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2795 
2798  wnd_event.attach_from = 0;
2799  wnd_event.attach_to = 0;
2801 
2803  ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
2804 
2805  SetLastError(0xdeadbeef);
2807  ok(!ret, "AttachThreadInput succeeded\n");
2808  ok(GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef) /* <= Win XP */,
2809  "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
2810 
2811  SetLastError(0xdeadbeef);
2813  ok(!ret, "AttachThreadInput succeeded\n");
2814  ok(GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef) /* <= Win XP */,
2815  "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
2816 
2818 
2819  ok(WaitForSingleObject(wnd_event.start_event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2821 
2823  ok(ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
2824 
2825  ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2827 
2831  wnd_event.attach_to = 0;
2833 
2834  SetFocus(ourWnd);
2835  SetActiveWindow(ourWnd);
2836 
2838  ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
2839 
2840  ok(WaitForSingleObject(wnd_event.start_event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2842 
2843  ok(GetActiveWindow() == ourWnd, "expected active %p, got %p\n", ourWnd, GetActiveWindow());
2844  ok(GetFocus() == ourWnd, "expected focus %p, got %p\n", ourWnd, GetFocus());
2845 
2847  ok(ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
2848 
2849  ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2851 
2854  wnd_event.attach_from = 0;
2857 
2858  SetFocus(ourWnd);
2859  SetActiveWindow(ourWnd);
2860 
2862  ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
2863 
2864  ok(WaitForSingleObject(wnd_event.start_event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2866 
2867  ok(GetActiveWindow() == ourWnd, "expected active %p, got %p\n", ourWnd, GetActiveWindow());
2868  ok(GetFocus() == ourWnd, "expected focus %p, got %p\n", ourWnd, GetFocus());
2869 
2871  ok(ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
2872 
2873  ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2875  DestroyWindow(ourWnd);
2876  DestroyWindow(Wnd2);
2877 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
DWORD attach_to
Definition: input.c:2596
#define CloseHandle
Definition: compat.h:487
static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: input.c:2579
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
BOOL WINAPI AttachThreadInput(_In_ DWORD, _In_ DWORD, _In_ BOOL)
DWORD attach_from
Definition: input.c:2595
#define TRUE
Definition: types.h:120
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:733
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
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:651
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define FALSE
Definition: types.h:117
HWND WINAPI SetActiveWindow(_In_ HWND)
static DWORD WINAPI thread_proc(void *param)
Definition: input.c:2600
HWND hwnd
Definition: input.c:2592
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:136
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:458
#define WAIT_OBJECT_0
Definition: winbase.h:387
unsigned long DWORD
Definition: ntddk_ex.h:95
HANDLE start_event
Definition: input.c:2594
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
#define SetLastError(x)
Definition: compat.h:500
HANDLE wait_event
Definition: input.c:2593
int ret
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
BOOL setWindows
Definition: input.c:2597
#define WM_USER
Definition: winuser.h:1877
#define broken(x)
Definition: _sntprintf.h:21
UINT style
Definition: winuser.h:3138
#define ok(value,...)
Definition: atltest.h:57
HANDLE hThread
Definition: wizard.c:27
HWND WINAPI GetFocus(void)
Definition: window.c:1909
#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:149
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 1929 of file input.c.

1930 {
1931  /* input value sanity checks */
1932  ok(0 == GetAsyncKeyState(1000000), "GetAsyncKeyState did not return 0\n");
1933  ok(0 == GetAsyncKeyState(-1000000), "GetAsyncKeyState did not return 0\n");
1934 }
#define ok(value,...)
Definition: atltest.h:57
SHORT WINAPI DECLSPEC_HOTPATCH GetAsyncKeyState(int vKey)
Definition: input.c:110

Referenced by START_TEST().

◆ test_GetKeyboardLayoutList()

static void test_GetKeyboardLayoutList ( void  )
static

Definition at line 3131 of file input.c.

3132 {
3133  int cnt, cnt2;
3134  HKL *layouts;
3135  ULONG_PTR baselayout;
3136  LANGID langid;
3137 
3138  baselayout = GetUserDefaultLCID();
3139  langid = PRIMARYLANGID(LANGIDFROMLCID(baselayout));
3141  baselayout = MAKELONG( baselayout, 0xe001 ); /* IME */
3142  else
3143  baselayout |= baselayout << 16;
3144 
3145  cnt = GetKeyboardLayoutList(0, NULL);
3146  /* Most users will not have more than a few keyboard layouts installed at a time. */
3147  ok(cnt > 0 && cnt < 10, "Layout count %d\n", cnt);
3148  if (cnt > 0)
3149  {
3150  layouts = HeapAlloc(GetProcessHeap(), 0, sizeof(*layouts) * cnt );
3151 
3152  cnt2 = GetKeyboardLayoutList(cnt, layouts);
3153  ok(cnt == cnt2, "wrong value %d!=%d\n", cnt, cnt2);
3154  for(cnt = 0; cnt < cnt2; cnt++)
3155  {
3156  if(layouts[cnt] == (HKL)baselayout)
3157  break;
3158  }
3159  ok(cnt < cnt2, "Didnt find current keyboard\n");
3160 
3161  HeapFree(GetProcessHeap(), 0, layouts);
3162  }
3163 }
WORD LANGID
Definition: typedefs.h:81
LCID WINAPI GetUserDefaultLCID(void)
Definition: lang.c:768
LANGID langid
Definition: msctf.idl:605
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define LANG_JAPANESE
Definition: nls.h:76
#define MAKELONG(a, b)
Definition: typedefs.h:249
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
UINT WINAPI GetKeyboardLayoutList(_In_ int nBuff, _Out_writes_to_opt_(nBuff, return) HKL FAR *lpList)
#define LANGIDFROMLCID(l)
Definition: nls.h:18
UINT_PTR HKL
Definition: msctf.idl:101
#define ok(value,...)
Definition: atltest.h:57
#define LANG_CHINESE
Definition: nls.h:42
#define LANG_KOREAN
Definition: nls.h:84
#define HeapFree(x, y, z)
Definition: compat.h:483
#define PRIMARYLANGID(l)
Definition: nls.h:16

Referenced by START_TEST().

◆ test_GetKeyState()

static void test_GetKeyState ( void  )
static

Definition at line 2902 of file input.c.

2903 {
2904  HANDLE semaphores[2];
2905  HANDLE thread;
2906  DWORD result;
2907  HWND hwnd;
2908 
2909  semaphores[0] = CreateSemaphoreA(NULL, 0, 1, NULL);
2910  ok(semaphores[0] != NULL, "CreateSemaphoreA failed %u\n", GetLastError());
2911  semaphores[1] = CreateSemaphoreA(NULL, 0, 1, NULL);
2912  ok(semaphores[1] != NULL, "CreateSemaphoreA failed %u\n", GetLastError());
2913 
2914  hwnd = CreateWindowA("static", "Title", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
2915  10, 10, 200, 200, NULL, NULL, NULL, NULL);
2916  ok(hwnd != NULL, "CreateWindowA failed %u\n", GetLastError());
2917 
2918  thread = CreateThread(NULL, 0, get_key_state_thread, semaphores, 0, NULL);
2919  ok(thread != NULL, "CreateThread failed %u\n", GetLastError());
2920  result = WaitForSingleObject(semaphores[0], 1000);
2921  ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
2922 
2924  SetFocus(hwnd);
2925  keybd_event('X', 0, 0, 0);
2926 
2927  ReleaseSemaphore(semaphores[1], 1, NULL);
2928  result = WaitForSingleObject(semaphores[0], 1000);
2929  ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
2930 
2931  keybd_event('X', 0, KEYEVENTF_KEYUP, 0);
2932 
2933  ReleaseSemaphore(semaphores[1], 1, NULL);
2935  ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
2937 
2939  CloseHandle(semaphores[0]);
2940  CloseHandle(semaphores[1]);
2941 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define CloseHandle
Definition: compat.h:487
#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:2879
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
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 CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4290
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:136
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
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore(IN HANDLE hSemaphore, IN LONG lReleaseCount, IN LPLONG lpPreviousCount)
Definition: synch.c:542
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#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 1455 of file input.c.

1456 {
1457 #define BUFLIM 64
1458 #define MYERROR 0xdeadbeef
1459  int count, retval;
1460  MOUSEMOVEPOINT in;
1461  MOUSEMOVEPOINT out[200];
1462  POINT point;
1463 
1464  /* Get a valid content for the input struct */
1465  if(!GetCursorPos(&point)) {
1466  win_skip("GetCursorPos() failed with error %u\n", GetLastError());
1467  return;
1468  }
1469  memset(&in, 0, sizeof(MOUSEMOVEPOINT));
1470  in.x = point.x;
1471  in.y = point.y;
1472 
1473  /* test first parameter
1474  * everything different than sizeof(MOUSEMOVEPOINT)
1475  * is expected to fail with ERROR_INVALID_PARAMETER
1476  */
1478  retval = pGetMouseMovePointsEx(0, &in, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1479  if (retval == ERROR_INVALID_PARAMETER)
1480  {
1481  win_skip( "GetMouseMovePointsEx broken on WinME\n" );
1482  return;
1483  }
1484  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1486  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1487 
1489  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT)-1, &in, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1490  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1492  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1493 
1495  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT)+1, &in, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1496  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1498  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1499 
1500  /* test second and third parameter
1501  */
1503  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), NULL, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1504  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1506  "expected error ERROR_NOACCESS, got %u\n", GetLastError());
1507 
1509  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, NULL, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1510  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1512  "expected error ERROR_NOACCESS, got %u\n", GetLastError());
1513 
1515  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), NULL, NULL, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1516  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1518  "expected error ERROR_NOACCESS, got %u\n", GetLastError());
1519 
1521  count = 0;
1522  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, NULL, count, GMMP_USE_DISPLAY_POINTS);
1523  if (retval == -1)
1524  ok(GetLastError() == ERROR_POINT_NOT_FOUND, "unexpected error %u\n", GetLastError());
1525  else
1526  ok(retval == count, "expected GetMouseMovePointsEx to succeed, got %d\n", retval);
1527 
1528  /* test fourth parameter
1529  * a value higher than 64 is expected to fail with ERROR_INVALID_PARAMETER
1530  */
1532  count = -1;
1533  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, out, count, GMMP_USE_DISPLAY_POINTS);
1534  ok(retval == count, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1536  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1537 
1539  count = 0;
1540  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, out, count, GMMP_USE_DISPLAY_POINTS);
1541  if (retval == -1)
1542  ok(GetLastError() == ERROR_POINT_NOT_FOUND, "unexpected error %u\n", GetLastError());
1543  else
1544  ok(retval == count, "expected GetMouseMovePointsEx to succeed, got %d\n", retval);
1545 
1547  count = BUFLIM;
1548  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, out, count, GMMP_USE_DISPLAY_POINTS);
1549  if (retval == -1)
1550  ok(GetLastError() == ERROR_POINT_NOT_FOUND, "unexpected error %u\n", GetLastError());
1551  else
1552  ok((0 <= retval) && (retval <= count), "expected GetMouseMovePointsEx to succeed, got %d\n", retval);
1553 
1555  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, out, BUFLIM+1, GMMP_USE_DISPLAY_POINTS);
1556  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1558  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1559 
1560  /* it was not possible to force an error with the fifth parameter on win2k */
1561 
1562  /* test combinations of wrong parameters to see which error wins */
1564  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT)-1, NULL, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1565  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1567  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1568 
1570  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT)-1, &in, NULL, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1571  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1573  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1574 
1576  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), NULL, out, BUFLIM+1, GMMP_USE_DISPLAY_POINTS);
1577  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1579  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1580 
1582  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, NULL, BUFLIM+1, GMMP_USE_DISPLAY_POINTS);
1583  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1585  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1586 
1587 #undef BUFLIM
1588 #undef MYERROR
1589 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
GLuint GLuint GLsizei count
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
POINTL point
Definition: edittest.c:50
LONG y
Definition: windef.h:330
#define ERROR_NOACCESS
Definition: winerror.h:578
#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:329
#define SetLastError(x)
Definition: compat.h:500
#define BUFLIM
GLuint in
Definition: glext.h:9616
#define ok(value,...)
Definition: atltest.h:57
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:149

Referenced by START_TEST().

◆ test_GetPointerType()

static void test_GetPointerType ( void  )
static

Definition at line 3106 of file input.c.

3107 {
3108  BOOL ret;
3109  POINTER_INPUT_TYPE type = -1;
3110  UINT id = 0;
3111 
3112  SetLastError(0xdeadbeef);
3113  ret = pGetPointerType(id, NULL);
3114  ok(!ret, "GetPointerType should have failed.\n");
3116  "expected error ERROR_INVALID_PARAMETER, got %u.\n", GetLastError());
3117 
3118  SetLastError(0xdeadbeef);
3119  ret = pGetPointerType(id, &type);
3121  "expected error ERROR_INVALID_PARAMETER, got %u.\n", GetLastError());
3122  ok(!ret, "GetPointerType failed, got type %d for %u.\n", type, id );
3123  ok(type == -1, " type %d\n", type );
3124 
3125  id = 1;
3126  ret = pGetPointerType(id, &type);
3127  ok(ret, "GetPointerType failed, got type %d for %u.\n", type, id );
3128  ok(type == PT_MOUSE, " type %d\n", type );
3129 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:500
int ret
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50

Referenced by START_TEST().

◆ test_GetRawInputData()

static void test_GetRawInputData ( void  )
static

Definition at line 1694 of file input.c.

1695 {
1696  UINT size;
1697  UINT ret;
1698 
1699  /* Null raw input handle */
1700  ret = GetRawInputData(NULL, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
1701  ok(ret == ~0U, "Expect ret %u, got %u\n", ~0U, ret);
1702 }
#define U(x)
Definition: wordpad.c:45
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
int ret
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
UINT WINAPI GetRawInputData(HRAWINPUT hRawInput, UINT uiCommand, LPVOID pData, PUINT pcbSize, UINT cbSizeHeader)
Definition: stubs.c:313

Referenced by START_TEST().

◆ test_GetRawInputDeviceList()

static void test_GetRawInputDeviceList ( void  )
static

Definition at line 1591 of file input.c.

1592 {
1593  RAWINPUTDEVICELIST devices[32];
1594  UINT ret, oret, devcount, odevcount, i;
1595  DWORD err;
1596 
1597  SetLastError(0xdeadbeef);
1598  ret = pGetRawInputDeviceList(NULL, NULL, 0);
1599  err = GetLastError();
1600  ok(ret == -1, "expected -1, got %d\n", ret);
1601  ok(err == ERROR_INVALID_PARAMETER, "expected 87, got %d\n", err);
1602 
1603  SetLastError(0xdeadbeef);
1604  ret = pGetRawInputDeviceList(NULL, NULL, sizeof(devices[0]));
1605  err = GetLastError();
1606  ok(ret == -1, "expected -1, got %d\n", ret);
1607  ok(err == ERROR_NOACCESS, "expected 998, got %d\n", err);
1608 
1609  devcount = 0;
1610  ret = pGetRawInputDeviceList(NULL, &devcount, sizeof(devices[0]));
1611  ok(ret == 0, "expected 0, got %d\n", ret);
1612  ok(devcount > 0, "expected non-zero\n");
1613 
1614  SetLastError(0xdeadbeef);
1615  devcount = 0;
1616  ret = pGetRawInputDeviceList(devices, &devcount, sizeof(devices[0]));
1617  err = GetLastError();
1618  ok(ret == -1, "expected -1, got %d\n", ret);
1619  ok(err == ERROR_INSUFFICIENT_BUFFER, "expected 122, got %d\n", err);
1620  ok(devcount > 0, "expected non-zero\n");
1621 
1622  /* devcount contains now the correct number of devices */
1623  ret = pGetRawInputDeviceList(devices, &devcount, sizeof(devices[0]));
1624  ok(ret > 0, "expected non-zero\n");
1625 
1626  for(i = 0; i < devcount; ++i)
1627  {
1628  WCHAR name[128];
1629  char nameA[128];
1630  UINT sz, len;
1631  RID_DEVICE_INFO info;
1632  HANDLE file;
1633 
1634  /* get required buffer size */
1635  name[0] = '\0';
1636  sz = 5;
1637  ret = pGetRawInputDeviceInfoW(devices[i].hDevice, RIDI_DEVICENAME, name, &sz);
1638  ok(ret == -1, "GetRawInputDeviceInfo gave wrong failure: %d\n", err);
1639  ok(sz > 5 && sz < ARRAY_SIZE(name), "Size should have been set and not too large (got: %u)\n", sz);
1640 
1641  /* buffer size for RIDI_DEVICENAME is in CHARs, not BYTEs */
1642  ret = pGetRawInputDeviceInfoW(devices[i].hDevice, RIDI_DEVICENAME, name, &sz);
1643  ok(ret == sz, "GetRawInputDeviceInfo gave wrong return: %d\n", err);
1644  len = lstrlenW(name);
1645  ok(len + 1 == ret, "GetRawInputDeviceInfo returned wrong length (name: %u, ret: %u)\n", len + 1, ret);
1646 
1647  /* test A variant with same size */
1648  ret = pGetRawInputDeviceInfoA(devices[i].hDevice, RIDI_DEVICENAME, nameA, &sz);
1649  ok(ret == sz, "GetRawInputDeviceInfoA gave wrong return: %d\n", err);
1650  len = strlen(nameA);
1651  ok(len + 1 == ret, "GetRawInputDeviceInfoA returned wrong length (name: %u, ret: %u)\n", len + 1, ret);
1652 
1653  /* buffer size for RIDI_DEVICEINFO is in BYTEs */
1654  memset(&info, 0, sizeof(info));
1655  info.cbSize = sizeof(info);
1656  sz = sizeof(info) - 1;
1657  ret = pGetRawInputDeviceInfoW(devices[i].hDevice, RIDI_DEVICEINFO, &info, &sz);
1658  ok(ret == -1, "GetRawInputDeviceInfo gave wrong failure: %d\n", err);
1659  ok(sz == sizeof(info), "GetRawInputDeviceInfo set wrong size\n");
1660 
1661  ret = pGetRawInputDeviceInfoW(devices[i].hDevice, RIDI_DEVICEINFO, &info, &sz);
1662  ok(ret == sizeof(info), "GetRawInputDeviceInfo gave wrong return: %d\n", err);
1663  ok(sz == sizeof(info), "GetRawInputDeviceInfo set wrong size\n");
1664  ok(info.dwType == devices[i].dwType, "GetRawInputDeviceInfo set wrong type: 0x%x\n", info.dwType);
1665 
1666  memset(&info, 0, sizeof(info));
1667  info.cbSize = sizeof(info);
1668  ret = pGetRawInputDeviceInfoA(devices[i].hDevice, RIDI_DEVICEINFO, &info, &sz);
1669  ok(ret == sizeof(info), "GetRawInputDeviceInfo gave wrong return: %d\n", err);
1670  ok(sz == sizeof(info), "GetRawInputDeviceInfo set wrong size\n");
1671  ok(info.dwType == devices[i].dwType, "GetRawInputDeviceInfo set wrong type: 0x%x\n", info.dwType);
1672 
1673  /* setupapi returns an NT device path, but CreateFile() < Vista can't
1674  * understand that; so use the \\?\ prefix instead */
1675  name[1] = '\\';
1677  todo_wine_if(info.dwType != RIM_TYPEHID)
1678  ok(file != INVALID_HANDLE_VALUE, "Failed to open %s, error %u\n", wine_dbgstr_w(name), GetLastError());
1679  CloseHandle(file);
1680  }
1681 
1682  /* check if variable changes from larger to smaller value */
1683  devcount = odevcount = ARRAY_SIZE(devices);
1684  oret = ret = pGetRawInputDeviceList(devices, &odevcount, sizeof(devices[0]));
1685  ok(ret > 0, "expected non-zero\n");
1686  ok(devcount == odevcount, "expected %d, got %d\n", devcount, odevcount);
1687  devcount = odevcount;
1688  odevcount = ARRAY_SIZE(devices);
1689  ret = pGetRawInputDeviceList(NULL, &odevcount, sizeof(devices[0]));
1690  ok(ret == 0, "expected 0, got %d\n", ret);
1691  ok(odevcount == oret, "expected %d, got %d\n", oret, odevcount);
1692 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CloseHandle
Definition: compat.h:487
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
const char * devices
Definition: diskspace.c:793
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define lstrlenW
Definition: compat.h:498
#define FILE_SHARE_READ
Definition: compat.h:136
struct _test_info info[]
Definition: SetCursorPos.c:19
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 ERROR_NOACCESS
Definition: winerror.h:578
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:523
#define todo_wine_if(is_todo)
Definition: test.h:163
__wchar_t WCHAR
Definition: xmlstorage.h:180
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define err(...)
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
unsigned int UINT
Definition: ndis.h:50
#define CreateFileW
Definition: compat.h:489
Definition: name.c:38
#define memset(x, y, z)
Definition: compat.h:39
Definition: fci.c:126
#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  BOOL foreground;
919  HWND window;
920  HHOOK hook;
921 
922  if (GetKeyboardLayout(0) != (HKL)(ULONG_PTR)0x04090409)
923  {
924  skip("Skipping Input_blackbox test on non-US keyboard\n");
925  return;
926  }
928  |WS_VISIBLE, 0, 0, 200, 60, NULL, NULL,
929  NULL, NULL);
930  ok(window != NULL, "error: %d\n", (int) GetLastError());
932  foreground = SetForegroundWindow( window );
933  if (!foreground)
934  skip("Failed to set foreground window; some tests will be skipped.\n");
935 
937  {
939  win_skip("WH_KEYBOARD_LL is not supported\n");
940  return;
941  }
942 
943  /* must process all initial messages, otherwise X11DRV_KeymapNotify unsets
944  * key state set by SendInput(). */
946 
948  ok(prevWndProc != 0 || GetLastError() == 0, "error: %d\n", (int) GetLastError());
949 
950  i.type = INPUT_KEYBOARD;
951  i.u.ki.time = 0;
952  i.u.ki.dwExtraInfo = 0;
953 
954  for (ii = 0; ii < ARRAY_SIZE(sendinput_test)-1; ii++) {
955  GetKeyboardState(ks1);
956  i.u.ki.wScan = ii+1 /* useful for debugging */;
957  i.u.ki.dwFlags = sendinput_test[ii].dwFlags;
958  i.u.ki.wVk = sendinput_test[ii].wVk;
959  SendInput(1, (INPUT*)&i, sizeof(TEST_INPUT));
961  GetKeyboardState(ks2);
962  compare_and_check(ii, ks1, ks2, &sendinput_test[ii], foreground);
963  }
964 
968 }
static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, const struct sendinput_test_s *test, BOOL foreground)
Definition: input.c:702
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define HWND_TOPMOST
Definition: winuser.h:1194
BOOL WINAPI DestroyWindow(_In_ HWND)
uint32_t ULONG_PTR
Definition: typedefs.h:65
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:864
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4290
smooth NULL
Definition: ftsmooth.c:416
#define WH_KEYBOARD_LL
Definition: winuser.h:43
_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:5320
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
UINT_PTR HKL
Definition: msctf.idl:101
static IHTMLWindow2 * window
Definition: events.c:77
unsigned char BYTE
Definition: xxhash.c:193
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[]
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
Definition: input.c:431
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WS_POPUP
Definition: pedump.c:616
#define WS_VSCROLL
Definition: pedump.c:627
#define skip(...)
Definition: atltest.h:64
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:394
#define WS_VISIBLE
Definition: pedump.c:620
#define win_skip
Definition: test.h:149
UINT WINAPI SendInput(UINT, LPINPUT, int)
Definition: ntwrapper.h:344

Referenced by START_TEST().

◆ test_input_message_source()

static void test_input_message_source ( void  )
static

Definition at line 3022 of file input.c.

3023 {
3024  WNDCLASSA cls;
3025  TEST_INPUT inputs[2];
3026  HWND hwnd;
3027  RECT rc;
3028  MSG msg;
3029 
3030  cls.style = 0;
3032  cls.cbClsExtra = 0;
3033  cls.cbWndExtra = 0;
3034  cls.hInstance = GetModuleHandleA(0);
3035  cls.hIcon = 0;
3036  cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
3037  cls.hbrBackground = 0;
3038  cls.lpszMenuName = NULL;
3039  cls.lpszClassName = "message source class";
3040  RegisterClassA(&cls);
3041  hwnd = CreateWindowA( cls.lpszClassName, "test", WS_OVERLAPPED, 0, 0, 100, 100,
3042  0, 0, 0, 0 );
3044  UpdateWindow( hwnd );
3046  SetFocus( hwnd );
3047 
3048  inputs[0].type = INPUT_KEYBOARD;
3049  inputs[0].u.ki.dwExtraInfo = 0;
3050  inputs[0].u.ki.time = 0;
3051  inputs[0].u.ki.wVk = 0;
3052  inputs[0].u.ki.wScan = 0x3c0;
3053  inputs[0].u.ki.dwFlags = KEYEVENTF_UNICODE;
3054  inputs[1] = inputs[0];
3055  inputs[1].u.ki.dwFlags |= KEYEVENTF_KEYUP;
3056 
3057  expect_src.deviceType = IMDT_UNAVAILABLE;
3058  expect_src.originId = IMO_UNAVAILABLE;
3059  SendMessageA( hwnd, WM_KEYDOWN, 0, 0 );
3060  SendMessageA( hwnd, WM_MOUSEMOVE, 0, 0 );
3061 
3062  SendInput( 2, (INPUT *)inputs, sizeof(INPUT) );
3063  while (PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ))
3064  {
3065  expect_src.deviceType = IMDT_KEYBOARD;
3066  expect_src.originId = IMO_INJECTED;
3067  TranslateMessage( &msg );
3068  DispatchMessageW( &msg );
3069  }
3070  GetWindowRect( hwnd, &rc );
3071  simulate_click( TRUE, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2 );
3072  simulate_click( FALSE, (rc.left + rc.right) / 2 + 1, (rc.top + rc.bottom) / 2 + 1 );
3073  while (PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ))
3074  {
3075  expect_src.deviceType = IMDT_MOUSE;
3076  expect_src.originId = IMO_INJECTED;
3077  TranslateMessage( &msg );
3078  DispatchMessageW( &msg );
3079  }
3080 
3081  expect_src.deviceType = IMDT_UNAVAILABLE;
3082  expect_src.originId = IMO_UNAVAILABLE;
3083  SendMessageA( hwnd, WM_KEYDOWN, 0, 0 );
3084  SendMessageA( hwnd, WM_LBUTTONDOWN, 0, 0 );
3085  PostMessageA( hwnd, WM_KEYUP, 0, 0 );
3086  PostMessageA( hwnd, WM_LBUTTONUP, 0, 0 );
3087  while (PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ))
3088  {
3089  TranslateMessage( &msg );
3090  DispatchMessageW( &msg );
3091  }
3092 
3093  expect_src.deviceType = IMDT_UNAVAILABLE;
3094  expect_src.originId = IMO_SYSTEM;
3095  SetCursorPos( (rc.left + rc.right) / 2 - 1, (rc.top + rc.bottom) / 2 - 1 );
3096  while (PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ))
3097  {
3098  TranslateMessage( &msg );
3099  DispatchMessageW( &msg );
3100  }
3101 
3102  DestroyWindow( hwnd );
3104 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
DWORD type
Definition: imm32.c:51
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
static INPUT_MESSAGE_SOURCE expect_src
Definition: input.c:2977
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
#define TRUE
Definition: types.h:120
BOOL WINAPI PostMessageA(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI UpdateWindow(_In_ HWND)
LONG top
Definition: windef.h:307
DWORD time
Definition: winable.h:50
int cbClsExtra
Definition: winuser.h:3140
LPCSTR lpszMenuName
Definition: winuser.h:3146
HWND WINAPI SetFocus(_In_opt_ HWND)
HBRUSH hbrBackground
Definition: winuser.h:3145
LONG left
Definition: windef.h:306
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LONG right
Definition: windef.h:308
BOOL WINAPI DestroyWindow(_In_ HWND)
int cbWndExtra
Definition: winuser.h:3141
#define INPUT_KEYBOARD
Definition: winable.h:10
#define FALSE
Definition: types.h:117
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4290
HCURSOR hCursor
Definition: winuser.h:3144
smooth NULL
Definition: ftsmooth.c:416
#define WM_KEYDOWN
Definition: winuser.h:1697
const char * LPCSTR
Definition: xmlstorage.h:183
DWORD dwFlags
Definition: winable.h:49
#define WS_OVERLAPPED
Definition: pedump.c:615
#define WM_KEYUP
Definition: winuser.h:1698
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2627
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
union TEST_INPUT::@1640 u
LPCSTR lpszClassName
Definition: winuser.h:3147
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2059
UINT style
Definition: winuser.h:3138
#define SW_SHOWNORMAL
Definition: winuser.h:764
WORD wScan
Definition: winable.h:48
HINSTANCE hInstance
Definition: winuser.h:3142
#define WM_LBUTTONUP
Definition: winuser.h:1759
#define WM_MOUSEMOVE
Definition: winuser.h:1757
WNDPROC lpfnWndProc
Definition: winuser.h:3139
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
BOOL WINAPI SetForegroundWindow(_In_ HWND)
LONG bottom
Definition: windef.h:309
static void simulate_click(BOOL left, int x, int y)
Definition: input.c:1997
ULONG_PTR dwExtraInfo
Definition: winable.h:51
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI UnregisterClassA(_In_ LPCSTR, HINSTANCE)
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1182
KEYBDINPUT ki
Definition: imm32.c:55
WORD wVk
Definition: winable.h:47
static LRESULT WINAPI msg_source_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
Definition: input.c:2979
ATOM WINAPI RegisterClassA(_In_ CONST WNDCLASSA *)
UINT WINAPI SendInput(UINT, LPINPUT, int)
Definition: ntwrapper.h:344
HICON hIcon
Definition: winuser.h:3143

Referenced by START_TEST().

◆ test_Input_mouse()

static void test_Input_mouse ( void  )
static

Definition at line 2105 of file input.c.

2106 {
2107  BOOL got_button_down, got_button_up;
2108  HWND hwnd, button_win, static_win;
2109  struct thread_data thread_data;
2110  HANDLE thread;
2111  DWORD thread_id;
2112  WNDCLASSA wclass;
2113  POINT pt, pt_org;
2114  int region_type;
2115  HRGN hregion;
2116  RECT region;
2117  MSG msg;
2118  BOOL ret;
2119 
2120  SetLastError(0xdeadbeef);
2121  ret = GetCursorPos(NULL);
2122  ok(!ret, "GetCursorPos succeed\n");
2123  ok(GetLastError() == 0xdeadbeef || GetLastError() == ERROR_NOACCESS, "error %u\n", GetLastError());
2124 
2125  SetLastError(0xdeadbeef);
2126  ret = GetCursorPos(&pt_org);
2127  ok(ret, "GetCursorPos failed\n");
2128  ok(GetLastError() == 0xdeadbeef, "error %u\n", GetLastError());
2129 
2130  button_win = CreateWindowA("button", "button", WS_VISIBLE | WS_POPUP,
2131  100, 100, 100, 100, 0, NULL, NULL, NULL);
2132  ok(button_win != 0, "CreateWindow failed\n");
2133 
2134  pt.x = pt.y = 150;
2135  hwnd = WindowFromPoint(pt);
2136  if (hwnd != button_win)
2137  {
2138  skip("there's another window covering test window\n");
2139  DestroyWindow(button_win);
2140  return;
2141  }
2142 
2143  /* simple button click test */
2144  simulate_click(TRUE, 150, 150);
2145  got_button_down = got_button_up = FALSE;
2146  while (wait_for_message(&msg))
2147  {
2149 
2150  if (msg.message == WM_LBUTTONDOWN)
2151  {
2152  got_button_down = TRUE;
2153  }
2154  else if (msg.message == WM_LBUTTONUP)
2155  {
2156  got_button_up = TRUE;
2157  break;
2158  }
2159  }
2160  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2161  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2162 
2163  /* click through HTTRANSPARENT child window */
2164  static_win = CreateWindowA("static", "static", WS_VISIBLE | WS_CHILD,
2165  0, 0, 100, 100, button_win, NULL, NULL, NULL);
2166  ok(static_win != 0, "CreateWindow failed\n");
2167  def_static_proc = (void*)SetWindowLongPtrA(static_win,
2169  simulate_click(FALSE, 150, 150);
2170  hittest_no = 0;
2171  got_button_down = got_button_up = FALSE;
2172  while (wait_for_message(&msg))
2173  {
2175 
2176  if (msg.message == WM_RBUTTONDOWN)
2177  {
2178  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2179  got_button_down = TRUE;
2180  }
2181  else if (msg.message == WM_RBUTTONUP)
2182  {
2183  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2184  got_button_up = TRUE;
2185  break;
2186  }
2187  }
2188  ok(hittest_no && hittest_no<50, "expected WM_NCHITTEST message\n");
2189  ok(got_button_down, "expected WM_RBUTTONDOWN message\n");
2190  ok(got_button_up, "expected WM_RBUTTONUP message\n");
2191  DestroyWindow(static_win);
2192 
2193  /* click through HTTRANSPARENT top-level window */
2194  static_win = CreateWindowA("static", "static", WS_VISIBLE | WS_POPUP,
2195  100, 100, 100, 100, 0, NULL, NULL, NULL);
2196  ok(static_win != 0, "CreateWindow failed\n");
2197  def_static_proc = (void*)SetWindowLongPtrA(static_win,
2199  simulate_click(TRUE, 150, 150);
2200  hittest_no = 0;
2201  got_button_down = got_button_up = FALSE;
2202  while (wait_for_message(&msg))
2203  {
2205 
2206  if (msg.message == WM_LBUTTONDOWN)
2207  {
2208  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2209  got_button_down = TRUE;
2210  }
2211  else if (msg.message == WM_LBUTTONUP)
2212  {
2213  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2214  got_button_up = TRUE;
2215  break;
2216  }
2217  }
2218  ok(hittest_no && hittest_no<50, "expected WM_NCHITTEST message\n");
2219  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2220  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2221  DestroyWindow(static_win);
2222 
2223  /* click on HTTRANSPARENT top-level window that belongs to other thread */
2225  ok(thread_data.start_event != NULL, "CreateEvent failed\n");
2227  ok(thread_data.end_event != NULL, "CreateEvent failed\n");
2229  ok(thread != NULL, "CreateThread failed\n");
2230  hittest_no = 0;
2231  got_button_down = got_button_up = FALSE;
2233  simulate_click(FALSE, 150, 150);
2234  while (wait_for_message(&msg))
2235  {
2237 
2238  if (msg.message == WM_RBUTTONDOWN)
2239  got_button_down = TRUE;
2240  else if (msg.message == WM_RBUTTONUP)
2241  got_button_up = TRUE;
2242  }
2246  ok(hittest_no && hittest_no<50, "expected WM_NCHITTEST message\n");
2247  ok(!got_button_down, "unexpected WM_RBUTTONDOWN message\n");
2248  ok(!got_button_up, "unexpected WM_RBUTTONUP message\n");
2249 
2250  /* click on HTTRANSPARENT top-level window that belongs to other thread,
2251  * thread input queues are attached */
2253  ok(thread != NULL, "CreateThread failed\n");
2254  hittest_no = 0;
2255  got_button_down = got_button_up = FALSE;
2258  "AttachThreadInput failed\n");
2260  SetWindowPos(thread_data.win, button_win, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
2261  simulate_click(TRUE, 150, 150);
2262  while (wait_for_message(&msg))
2263  {
2265 
2266  if (msg.message == WM_LBUTTONDOWN)
2267  got_button_down = TRUE;
2268  else if (msg.message == WM_LBUTTONUP)
2269  got_button_up = TRUE;
2270  }
2273  todo_wine ok(hittest_no > 50, "expected loop with WM_NCHITTEST messages\n");
2274  ok(!got_button_down, "unexpected WM_LBUTTONDOWN message\n");
2275  ok(!got_button_up, "unexpected WM_LBUTTONUP message\n");
2276 
2277  /* click after SetCapture call */
2278  hwnd = CreateWindowA("button", "button", WS_VISIBLE | WS_POPUP,
2279  0, 0, 100, 100, 0, NULL, NULL, NULL);
2280  ok(hwnd != 0, "CreateWindow failed\n");
2281  SetCapture(button_win);
2282  got_button_down = got_button_up = FALSE;
2283  simulate_click(FALSE, 50, 50);
2284  while (wait_for_message(&msg))
2285  {
2287 
2288  if (msg.message == WM_RBUTTONDOWN)
2289  {
2290  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2291  got_button_down = TRUE;
2292  }
2293  else if (msg.message == WM_RBUTTONUP)
2294  {
2295  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2296  got_button_up = TRUE;
2297  break;
2298  }
2299  }
2300  ok(got_button_down, "expected WM_RBUTTONDOWN message\n");
2301  ok(got_button_up, "expected WM_RBUTTONUP message\n");
2303 
2304  /* click on child window after SetCapture call */
2305  hwnd = CreateWindowA("button", "button2", WS_VISIBLE | WS_CHILD,
2306  0, 0, 100, 100, button_win, NULL, NULL, NULL);
2307  ok(hwnd != 0, "CreateWindow failed\n");
2308  got_button_down = got_button_up = FALSE;
2309  simulate_click(TRUE, 150, 150);
2310  while (wait_for_message(&msg))
2311  {
2313 
2314  if (msg.message == WM_LBUTTONDOWN)
2315  {
2316  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2317  got_button_down = TRUE;
2318  }
2319  else if (msg.message == WM_LBUTTONUP)
2320  {
2321  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2322  got_button_up = TRUE;
2323  break;
2324  }
2325  }
2326  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2327  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2329  ok(ReleaseCapture(), "ReleaseCapture failed\n");
2330 
2331  wclass.style = 0;
2332  wclass.lpfnWndProc = WndProc;
2333  wclass.cbClsExtra = 0;
2334  wclass.cbWndExtra = 0;
2335  wclass.hInstance = GetModuleHandleA(NULL);
2336  wclass.hIcon = LoadIconA(0, (LPCSTR)IDI_APPLICATION);
2337  wclass.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW);
2338  wclass.hbrBackground = CreateSolidBrush(RGB(128, 128, 128));
2339  wclass.lpszMenuName = NULL;
2340  wclass.lpszClassName = "InputLayeredTestClass";
2341  RegisterClassA( &wclass );
2342 
2343  /* click through layered window with alpha channel / color key */
2344  hwnd = CreateWindowA(wclass.lpszClassName, "InputLayeredTest",
2345  WS_VISIBLE | WS_POPUP, 100, 100, 100, 100, button_win, NULL, NULL, NULL);
2346  ok(hwnd != NULL, "CreateWindowEx failed\n");
2347 
2348  static_win = CreateWindowA("static", "Title", WS_VISIBLE | WS_CHILD,
2349  10, 10, 20, 20, hwnd, NULL, NULL, NULL);
2350  ok(static_win != NULL, "CreateWindowA failed %u\n", GetLastError());
2351 
2354  ret = SetLayeredWindowAttributes(hwnd, 0, 255, LWA_ALPHA);
2355  ok(ret, "SetLayeredWindowAttributes failed\n");
2357  Sleep(100);
2358 
2359  if (pGetWindowRgnBox)
2360  {
2361  region_type = pGetWindowRgnBox(hwnd, &region);
2362  ok(region_type == ERROR, "expected ERROR, got %d\n", region_type);
2363  }
2364 
2365  get_dc_region(&region, hwnd, DCX_PARENTCLIP);
2366  ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200,
2367  "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region));
2369  ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200,
2370  "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region));
2371  get_dc_region(&region, hwnd, DCX_USESTYLE);
2372  ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200,
2373  "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region));
2374  get_dc_region(&region, static_win, DCX_PARENTCLIP);
2375  ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200,
2376  "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region));
2377  get_dc_region(&region, static_win, DCX_WINDOW | DCX_USESTYLE);
2378  ok(region.left == 110 && region.top == 110 && region.right == 130 && region.bottom == 130,
2379  "expected region (110,110)-(130,130), got %s\n", wine_dbgstr_rect(&region));
2380  get_dc_region(&region, static_win, DCX_USESTYLE);
2381  ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200,
2382  "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region));
2383 
2384  got_button_down = got_button_up = FALSE;
2385  simulate_click(TRUE, 150, 150);
2386  while (wait_for_message(&msg))
2387  {
2389 
2390  if (msg.message == WM_LBUTTONDOWN)
2391  {
2392  ok(msg.hwnd == hwnd, "msg.hwnd = %p\n", msg.hwnd);
2393  got_button_down = TRUE;
2394  }
2395  else if (msg.message == WM_LBUTTONUP)
2396  {
2397  ok(msg.hwnd == hwnd, "msg.hwnd = %p\n", msg.hwnd);
2398  got_button_up = TRUE;
2399  break;
2400  }
2401  }
2402  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2403  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2404 
2405  ret = SetLayeredWindowAttributes(hwnd, 0, 0, LWA_ALPHA);
2406  ok(ret, "SetLayeredWindowAttributes failed\n");
2408  Sleep(100);
2409 
2410  if (pGetWindowRgnBox)
2411  {
2412  region_type = pGetWindowRgnBox(hwnd, &region);
2413  ok(region_type == ERROR, "expected ERROR, got %d\n", region_type);
2414  }
2415 
2416  got_button_down = got_button_up = FALSE;
2417  simulate_click(TRUE, 150, 150);
2418  while (wait_for_message(&msg))
2419  {
2421 
2422  if (msg.message == WM_LBUTTONDOWN)
2423  {
2424  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2425  got_button_down = TRUE;
2426  }
2427  else if (msg.message == WM_LBUTTONUP)
2428  {
2429  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2430  got_button_up = TRUE;
2431  break;
2432  }
2433  }
2434  ok(got_button_down || broken(!got_button_down), "expected WM_LBUTTONDOWN message\n");
2435  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2436 
2437  ret = SetLayeredWindowAttributes(hwnd, RGB(0, 255, 0), 255, LWA_ALPHA | LWA_COLORKEY);
2438  ok(ret, "SetLayeredWindowAttributes failed\n");
2440  Sleep(100);
2441 
2442  if (pGetWindowRgnBox)
2443  {
2444  region_type = pGetWindowRgnBox(hwnd, &region);
2445  ok(region_type == ERROR, "expected ERROR, got %d\n", region_type);
2446  }
2447 
2448  got_button_down = got_button_up = FALSE;
2449  simulate_click(TRUE, 150, 150);
2450  while (wait_for_message(&msg))
2451  {
2453 
2454  if (msg.message == WM_LBUTTONDOWN)
2455  {
2456  ok(msg.hwnd == hwnd, "msg.hwnd = %p\n", msg.hwnd);
2457  got_button_down = TRUE;
2458  }
2459  else if (msg.message == WM_LBUTTONUP)
2460  {
2461  ok(msg.hwnd == hwnd, "msg.hwnd = %p\n", msg.hwnd);
2462  got_button_up = TRUE;
2463  break;
2464  }
2465  }
2466  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2467  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2468 
2469  ret = SetLayeredWindowAttributes(hwnd, RGB(128, 128, 128), 0, LWA_COLORKEY);
2470  ok(ret, "SetLayeredWindowAttributes failed\n");
2472  Sleep(100);
2473 
2474  if (pGetWindowRgnBox)
2475  {
2476  region_type = pGetWindowRgnBox(hwnd, &region);
2477  ok(region_type == ERROR, "expected ERROR, got %d\n", region_type);
2478  }
2479 
2480  got_button_down = got_button_up = FALSE;
2481  simulate_click(TRUE, 150, 150);
2482  while (wait_for_message(&msg))
2483  {
2485 
2486  if (msg.message == WM_LBUTTONDOWN)
2487  {
2488  todo_wine
2489  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2490  got_button_down = TRUE;
2491  }
2492  else if (msg.message == WM_LBUTTONUP)
2493  {
2494  todo_wine
2495  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2496  got_button_up = TRUE;
2497  break;
2498  }
2499  }
2500  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2501  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2502 
2505  Sleep(100);
2506 
2507  if (pGetWindowRgnBox)
2508  {
2509  region_type = pGetWindowRgnBox(hwnd, &region);
2510  ok(region_type == ERROR, "expected ERROR, got %d\n", region_type);
2511  }
2512 
2513  got_button_down = got_button_up = FALSE;
2514  simulate_click(TRUE, 150, 150);
2515  while (wait_for_message(&msg))
2516  {
2518 
2519  if (msg.message == WM_LBUTTONDOWN)
2520  {
2521  ok(msg.hwnd == hwnd, "msg.hwnd = %p\n", msg.hwnd);
2522  got_button_down = TRUE;
2523  }
2524  else if (msg.message == WM_LBUTTONUP)
2525  {
2526  ok(msg.hwnd == hwnd, "msg.hwnd = %p\n", msg.hwnd);
2527  got_button_up = TRUE;
2528  break;
2529  }
2530  }
2531  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2532  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2533 
2534  hregion = CreateRectRgn(0, 0, 10, 10);
2535  ok(hregion != NULL, "CreateRectRgn failed\n");
2536  ret = SetWindowRgn(hwnd, hregion, TRUE);
2537  ok(ret, "SetWindowRgn failed\n");
2538  DeleteObject(hregion);
2540  Sleep(1000);
2541 
2542  if (pGetWindowRgnBox)
2543  {
2544  region_type = pGetWindowRgnBox(hwnd, &region);
2545  ok(region_type == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", region_type);
2546  }
2547 
2548  got_button_down = got_button_up = FALSE;
2549  simulate_click(TRUE, 150, 150);
2550  while (wait_for_message(&msg))
2551  {
2553 
2554  if (msg.message == WM_LBUTTONDOWN)
2555  {
2556  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2557  got_button_down = TRUE;
2558  }
2559  else if (msg.message == WM_LBUTTONUP)
2560  {
2561  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2562  got_button_up = TRUE;
2563  break;
2564  }
2565  }
2566  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2567  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2568 
2569  DestroyWindow(static_win);
2571  SetCursorPos(pt_org.x, pt_org.y);
2572 
2575  DestroyWindow(button_win);
2576 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define CloseHandle
Definition: compat.h:487
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
long y
Definition: polytest.cpp:48
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
BOOL WINAPI AttachThreadInput(_In_ DWORD, _In_ DWORD, _In_ BOOL)
#define RGB(r, g, b)
Definition: precomp.h:62
long x
Definition: polytest.cpp:48
#define TRUE
Definition: types.h:120
#define pt(x, y)
Definition: drawing.c:79
static WNDPROC def_static_proc
Definition: input.c:2050
#define ERROR(name)
Definition: error_private.h:53
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
HWND win
Definition: input.c:2068
LONG top
Definition: windef.h:307
#define DCX_USESTYLE
Definition: GetDCEx.c:10
int cbClsExtra
Definition: winuser.h:3140
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
LPCSTR lpszMenuName
Definition: winuser.h:3146
#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:3145
#define WS_CHILD
Definition: pedump.c:617
LONG left
Definition: windef.h:306
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
LONG right
Definition: windef.h:308
BOOL WINAPI DestroyWindow(_In_ HWND)
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2029
#define DCX_WINDOW
Definition: winuser.h:2095
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:3141
#define ERROR_NOACCESS
Definition: winerror.h:578
LONG WINAPI GetWindowLongA(_In_ HWND, _In_ int)
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4290
HCURSOR hCursor
Definition: winuser.h:3144
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:136
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:637
static LRESULT WINAPI static_hook_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
Definition: input.c:2052
const char * LPCSTR
Definition: xmlstorage.h:183
static DWORD hittest_no
Definition: input.c:2051
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:458
#define WM_RBUTTONDOWN
Definition: winuser.h:1761
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
HANDLE end_event
Definition: input.c:2067
#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:500
#define WM_RBUTTONUP
Definition: winuser.h:1762
static HANDLE thread
Definition: service.c:33
static void get_dc_region(RECT *region, HWND hwnd, DWORD flags)
Definition: input.c:2088
int ret
#define todo_wine
Definition: test.h:162
#define SetWindowLongPtrA
Definition: winuser.h:5320
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
LPCSTR lpszClassName
Definition: winuser.h:3147
static DWORD WINAPI create_static_win(void *arg)
Definition: input.c:2071
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:3138
#define SWP_NOSIZE
Definition: winuser.h:1230
#define DCX_PARENTCLIP
Definition: winuser.h:2097
HWND WINAPI SetCapture(_In_ HWND hWnd)
HINSTANCE hInstance
Definition: winuser.h:3142
static DWORD thread_id
Definition: protocol.c:159
#define ok(value,...)
Definition: atltest.h:57
#define WM_LBUTTONUP
Definition: winuser.h:1759
__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:3139
static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: input.c:342
#define skip(...)
Definition: atltest.h:64
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2889
LONG bottom
Definition: windef.h:309
static void simulate_click(BOOL left, int x, int y)
Definition: input.c:1997
#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:2016
HICON hIcon
Definition: winuser.h:3143
HANDLE start_event
Definition: input.c:2066

Referenced by START_TEST().

◆ test_Input_unicode()

static void test_Input_unicode ( void  )
static

Definition at line 1179 of file input.c.

1180 {
1181  WCHAR classNameW[] = {'I','n','p','u','t','U','n','i','c','o','d','e',
1182  'K','e','y','T','e','s','t','C','l','a','s','s',0};
1183  WCHAR windowNameW[] = {'I','n','p','u','t','U','n','i','c','o','d','e',
1184  'K','e','y','T','e','s','t',0};
1185  MSG msg;
1186  WNDCLASSW wclass;
1188  HHOOK hook;
1189  HMODULE hModuleImm32;
1190  BOOL (WINAPI *pImmDisableIME)(DWORD);
1191 
1192  wclass.lpszClassName = classNameW;
1193  wclass.style = CS_HREDRAW | CS_VREDRAW;
1194  wclass.lpfnWndProc = unicode_wnd_proc;
1195  wclass.hInstance = hInstance;
1196  wclass.hIcon = LoadIconW(0, (LPCWSTR)IDI_APPLICATION);
1197  wclass.hCursor = LoadCursorW( NULL, (LPCWSTR)IDC_ARROW);
1198  wclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
1199  wclass.lpszMenuName = 0;
1200  wclass.cbClsExtra = 0;
1201  wclass.cbWndExtra = 0;
1202  if(!RegisterClassW(&wclass)){
1203  win_skip("Unicode functions not supported\n");
1204  return;
1205  }
1206 
1207  hModuleImm32 = LoadLibraryA("imm32.dll");
1208  if (hModuleImm32) {
1209  pImmDisableIME = (void *)GetProcAddress(hModuleImm32, "ImmDisableIME");
1210  if (pImmDisableIME)
1211  pImmDisableIME(0);
1212  }
1213  pImmDisableIME = NULL;
1214  FreeLibrary(hModuleImm32);
1215 
1216  /* create the test window that will receive the keystrokes */
1217  hWndTest = CreateWindowW(wclass.lpszClassName, windowNameW,
1218  WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, 100, 100,
1219  NULL, NULL, hInstance, NULL);
1220 
1221  assert(hWndTest);
1223 
1225  if(!hook)
1226  win_skip("unable to set WH_KEYBOARD_LL hook\n");
1227 
1232 
1233  /* flush pending messages */
1234  while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageW(&msg);
1235 
1236  SetFocus(hWndTest);
1237 
1239 
1240  if(hook)
1243 }
UINT style
Definition: winuser.h:3151
LPCWSTR lpszMenuName
Definition: winuser.h:3159
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:3153
HWND WINAPI SetFocus(_In_opt_ HWND)
#define IDI_APPLICATION
Definition: winuser.h:699
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI DestroyWindow(_In_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4291
#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:3152
#define CW_USEDEFAULT
Definition: winuser.h:225
static BOOL(WINAPI *pGetCurrentInputMessageSource)(INPUT_MESSAGE_SOURCE *source)
smooth NULL
Definition: ftsmooth.c:416
static void test_unicode_keys(HWND hwnd, HHOOK hook)
Definition: input.c:987
LPCWSTR lpszClassName
Definition: winuser.h:3160
#define SW_SHOW
Definition: winuser.h:769
BOOL WINAPI IsWindowUnicode(_In_ HWND)
static HWND hWndTest
Definition: input.c:63
#define CS_VREDRAW
Definition: winuser.h:653
#define FreeLibrary(x)
Definition: compat.h:496
#define WH_KEYBOARD_LL
Definition: winuser.h:43
int cbWndExtra
Definition: winuser.h:3154
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define WINAPI
Definition: msvc.h:6
HICON hIcon
Definition: winuser.h:3156
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
static POINTER_INPUT_TYPE *static DWORD
Definition: input.c:84
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
#define SWP_NOSIZE
Definition: winuser.h:1230
HCURSOR hCursor
Definition: winuser.h:3157
HBRUSH hbrBackground
Definition: winuser.h:3158
Definition: input.c:431
HINSTANCE hInstance
Definition: winuser.h:3155
#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:838
BOOL WINAPI SetForegroundWindow(_In_ HWND)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define GetProcAddress(x, y)
Definition: compat.h:501
#define SWP_NOMOVE
Definition: winuser.h:1229
static LRESULT CALLBACK llkbd_unicode_hook(int nCode, WPARAM wParam, LPARAM lParam)
Definition: input.c:1146
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:149
static LRESULT CALLBACK unicode_wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: input.c:1120

Referenced by START_TEST().

◆ test_Input_whitebox()

static void test_Input_whitebox ( void  )
static

Definition at line 348 of file input.c.

349 {
350  MSG msg;
351  WNDCLASSA wclass;
353 
354  wclass.lpszClassName = "InputSysKeyTestClass";
355  wclass.style = CS_HREDRAW | CS_VREDRAW;
356  wclass.lpfnWndProc = WndProc;
357  wclass.hInstance = hInstance;
358  wclass.hIcon = LoadIconA( 0, (LPCSTR)IDI_APPLICATION );
359  wclass.hCursor = LoadCursorA( NULL, (LPCSTR)IDC_ARROW );
360  wclass.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 );
361  wclass.lpszMenuName = 0;
362  wclass.cbClsExtra = 0;
363  wclass.cbWndExtra = 0;
364  RegisterClassA( &wclass );
365  /* create the test window that will receive the keystrokes */
366  hWndTest = CreateWindowA( wclass.lpszClassName, "InputSysKeyTest",
367  WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, 100, 100,
368  NULL, NULL, hInstance, NULL);
369  assert( hWndTest );
374 
375  /* flush pending messages */
376  while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
377 
378  SetFocus( hWndTest );
381 }
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
static void TestSysKeys(HWND hWnd)
Definition: input.c:335
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL WINAPI UpdateWindow(_In_ HWND)
int cbClsExtra
Definition: winuser.h:3140
#define assert(x)
Definition: debug.h:53
#define CS_HREDRAW
Definition: winuser.h:648
LPCSTR lpszMenuName
Definition: winuser.h:3146
#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:3145
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:3141
HINSTANCE hInstance
Definition: charmap.c:20
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4290
HCURSOR hCursor
Definition: winuser.h:3144
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416