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

Go to the source code of this file.

Classes

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

Macros

#define _WIN32_WINNT   0x401
 
#define _WIN32_IE   0x0500
 
#define MAXKEYEVENTS   12
 
#define MAXKEYMESSAGES
 
#define 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

◆ _WIN32_IE

#define _WIN32_IE   0x0500

Definition at line 49 of file input.c.

◆ _WIN32_WINNT

#define _WIN32_WINNT   0x401

Definition at line 48 of file input.c.

◆ BUFLIM

#define BUFLIM   64

◆ ctrl

#define ctrl   2

Definition at line 1762 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:418
GLfloat GLfloat p
Definition: glext.h:8902

◆ MAXKEYEVENTS

#define MAXKEYEVENTS   12

Definition at line 95 of file input.c.

◆ MAXKEYMESSAGES

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

Definition at line 96 of file input.c.

◆ MYERROR

#define MYERROR   0xdeadbeef

◆ shift

#define shift   1

Definition at line 1761 of file input.c.

◆ STEP

#define STEP   3

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

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

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

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

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

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

2077 {
2078  struct thread_data *thread_data = arg;
2079  HWND win;
2080 
2081  win = CreateWindowA("static", "static", WS_VISIBLE | WS_POPUP,
2082  100, 100, 100, 100, 0, NULL, NULL, NULL);
2083  ok(win != 0, "CreateWindow failed\n");
2086  thread_data->win = win;
2087 
2090  return 0;
2091 }
static WNDPROC def_static_proc
Definition: input.c:2055
HWND win
Definition: input.c:2073
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:2039
#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:2057
HANDLE end_event
Definition: input.c:2072
#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:2071

Referenced by test_Input_mouse().

◆ do_test()

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

Definition at line 229 of file input.c.

230 {
231  TEST_INPUT inputs[MAXKEYEVENTS];
232  KMSG expmsg[MAXKEYEVENTS];
233  MSG msg;
234  char buf[100];
235  UINT evtctr=0, ret;
236  int kmctr, i;
237 
238  buf[0]='\0';
239  TrackSysKey=0; /* see input.c */
240  for (i = 0; i < MAXKEYEVENTS; i++)
241  {
242  inputs[evtctr].type = INPUT_KEYBOARD;
243  inputs[evtctr].u.ki.wVk = GETVKEY[td[i]];
244  inputs[evtctr].u.ki.wScan = GETSCAN[td[i]];
245  inputs[evtctr].u.ki.dwFlags = GETFLAGS[td[i]];
246  inputs[evtctr].u.ki.dwExtraInfo = 0;
247  inputs[evtctr].u.ki.time = ++timetag;
248  if (td[i]) evtctr++;
249 
250  strcat(buf, getdesc[td[i]]);
251  if(td[i])
252  expmsg[i].message = KbdMessage(td[i], &(expmsg[i].wParam), &(expmsg[i].lParam));
253  else
254  expmsg[i].message = 0;
255  }
256  for( kmctr = 0; kmctr < MAXKEYEVENTS && expmsg[kmctr].message; kmctr++)
257  ;
258  ok( evtctr <= MAXKEYEVENTS, "evtctr is above MAXKEYEVENTS\n" );
259  ret = SendInput(evtctr, (INPUT *)inputs, sizeof(INPUT));
260  ok(ret == evtctr, "SendInput failed to send some events\n");
261  i = 0;
262  if (winetest_debug > 1)
263  trace("======== key stroke sequence #%d: %s =============\n",
264  seqnr + 1, buf);
266  if (winetest_debug > 1)
267  trace("message[%d] %-15s wParam %04lx lParam %08lx time %x\n", i,
268  MSGNAME[msg.message - WM_KEYFIRST], msg.wParam, msg.lParam, msg.time);
269  if( i < kmctr ) {
270  ok( msg.message == expmsg[i].message &&
271  msg.wParam == expmsg[i].wParam &&
272  msg.lParam == expmsg[i].lParam,
273  "%u/%u: wrong message %x/%08lx/%08lx expected %s/%08lx/%08lx\n",
274  seqnr, i, msg.message, msg.wParam, msg.lParam,
275  MSGNAME[(expmsg[i]).message - WM_KEYFIRST], expmsg[i].wParam, expmsg[i].lParam );
276  }
277  i++;
278  }
279  if (winetest_debug > 1)
280  trace("%d messages retrieved\n", i);
281  if (!i && kmctr)
282  {
283  skip( "simulated keyboard input doesn't work\n" );
284  return FALSE;
285  }
286  ok( i == kmctr, "message count is wrong: got %d expected: %d\n", i, kmctr);
287  return TRUE;
288 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
DWORD type
Definition: imm32.c:51
#define TRUE
Definition: types.h:120
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static const char * getdesc[]
Definition: input.c:113
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define MAXKEYEVENTS
Definition: input.c:95
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:175
#define INPUT_KEYBOARD
Definition: winable.h:10
#define WM_KEYFIRST
Definition: winuser.h:1696
static const char * MSGNAME[]
Definition: input.c:100
static const int GETFLAGS[]
Definition: input.c:111
DWORD dwFlags
Definition: winable.h:49
#define trace
Definition: atltest.h:70
Definition: input.c:127
#define WM_KEYLAST
Definition: winuser.h:1710
int ret
UINT message
Definition: input.c:128
static LONG timetag
Definition: input.c:69
static BYTE TrackSysKey
Definition: input.c:154
union TEST_INPUT::@1616 u
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:109
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:107

Referenced by TestASet().

◆ empty_message_queue()

static void empty_message_queue ( void  )
static

Definition at line 399 of file input.c.

400 {
401  MSG msg;
402  int diff = 200;
403  int min_timeout = 50;
404  DWORD time = GetTickCount() + diff;
405 
406  while (diff > 0)
407  {
408  if (MsgWaitForMultipleObjects(0, NULL, FALSE, min_timeout, QS_ALLINPUT) == WAIT_TIMEOUT) break;
409  while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
410  {
411  if (is_keyboard_message(msg.message) || is_mouse_message(msg.message))
412  ok(msg.time != 0, "message %#x has time set to 0\n", msg.message);
413 
416  }
417  diff = time - GetTickCount();
418  }
419 }
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)
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:388
#define PM_REMOVE
Definition: winuser.h:1182
static BOOL is_mouse_message(UINT message)
Definition: input.c:393

Referenced by test_Input_blackbox().

◆ get_dc_region()

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

Definition at line 2093 of file input.c.

2094 {
2095  int region_type;
2096  HRGN hregion;
2097  HDC hdc;
2098 
2099  hdc = GetDCEx(hwnd, 0, flags);
2100  ok(hdc != NULL, "GetDCEx failed\n");
2101  hregion = CreateRectRgn(40, 40, 60, 60);
2102  ok(hregion != NULL, "CreateRectRgn failed\n");
2103  GetRandomRgn(hdc, hregion, SYSRGN);
2104  region_type = GetRgnBox(hregion, region);
2105  ok(region_type == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", region_type);
2106  DeleteObject(hregion);
2107  ReleaseDC(hwnd, hdc);
2108 }
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 2884 of file input.c.

2885 {
2886  HANDLE *semaphores = arg;
2887  DWORD result;
2888 
2889  ReleaseSemaphore(semaphores[0], 1, NULL);
2890  result = WaitForSingleObject(semaphores[1], 1000);
2891  ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
2892 
2893  result = GetKeyState('X');
2894  ok((result & 0x8000) || broken(!(result & 0x8000)), /* > Win 2003 */
2895  "expected that highest bit is set, got %x\n", result);
2896 
2897  ReleaseSemaphore(semaphores[0], 1, NULL);
2898  result = WaitForSingleObject(semaphores[1], 1000);
2899  ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
2900 
2901  result = GetKeyState('X');
2902  ok(!(result & 0x8000), "expected that highest bit is unset, got %x\n", result);
2903 
2904  return 0;
2905 }
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 888 of file input.c.

889 {
890  KBDLLHOOKSTRUCT *hook_info = (KBDLLHOOKSTRUCT *)lparam;
891 
892  if (code == HC_ACTION)
893  {
894  ok(sent_messages_cnt < MAXKEYMESSAGES, "Too many messages\n");
896  {
899  sent_messages[sent_messages_cnt].wParam = hook_info->vkCode;
900  sent_messages[sent_messages_cnt++].lParam = hook_info->flags & (LLKHF_UP|LLKHF_EXTENDED);
901  }
902 
903 if(0) /* For some reason not stable on Wine */
904 {
905  if (wparam == WM_KEYDOWN || wparam == WM_SYSKEYDOWN)
906  ok(!(GetAsyncKeyState(hook_info->vkCode) & 0x8000), "key %x should be up\n", hook_info->vkCode);
907  else if (wparam == WM_KEYUP || wparam == WM_SYSKEYUP)
908  ok(GetAsyncKeyState(hook_info->vkCode) & 0x8000, "key %x should be down\n", hook_info->vkCode);
909 }
910 
911  if (winetest_debug > 1)
912  trace("Hook: w=%lx vk:%8x sc:%8x fl:%8x %lx\n", wparam,
913  hook_info->vkCode, hook_info->scanCode, hook_info->flags, hook_info->dwExtraInfo);
914  }
915  return CallNextHookEx( 0, code, wparam, lparam );
916 }
static struct message sent_messages[MAXKEYMESSAGES]
Definition: input.c:703
int winetest_debug
#define LLKHF_UP
Definition: winuser.h:2623
#define WM_KEYDOWN
Definition: winuser.h:1697
Definition: input.c:431
#define trace
Definition: atltest.h:70
#define WM_KEYUP
Definition: winuser.h:1698
Definition: input.c:432
#define MAXKEYMESSAGES
Definition: input.c:96
#define LLKHF_EXTENDED
Definition: winuser.h:2620
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:436
static UINT sent_messages_cnt
Definition: input.c:704
#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 1267 of file input.c.

1268 {
1270  POINT pt, pt1;
1271 
1272  if (code == HC_ACTION)
1273  {
1274  /* This is our new cursor position */
1275  pt_new = hook->pt;
1276  /* Should return previous position */
1277  GetCursorPos(&pt);
1278  ok(pt.x == pt_old.x && pt.y == pt_old.y, "GetCursorPos: (%d,%d)\n", pt.x, pt.y);
1279 
1280  /* Should set new position until hook chain is finished. */
1281  pt.x = pt_old.x + STEP;
1282  pt.y = pt_old.y + STEP;
1283  SetCursorPos(pt.x, pt.y);
1284  GetCursorPos(&pt1);
1285  if (clipped)
1286  ok(pt1.x == pt_old.x && pt1.y == pt_old.y, "Wrong set pos: (%d,%d)\n", pt1.x, pt1.y);
1287  else
1288  ok(pt1.x == pt.x && pt1.y == pt.y, "Wrong set pos: (%d,%d)\n", pt1.x, pt1.y);
1289  }
1290  return CallNextHookEx( 0, code, wparam, lparam );
1291 }
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:1264
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
#define STEP
Definition: input.c:1265
Definition: input.c:431
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2627
Definition: input.c:432
static POINT pt_old
Definition: input.c:1263
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:436
static POINT pt_new
Definition: input.c:1263

Referenced by test_mouse_ll_hook().

◆ hook_proc2()

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

Definition at line 1293 of file input.c.

1294 {
1296  POINT pt;
1297 
1298  if (code == HC_ACTION)
1299  {
1300  ok(hook->pt.x == pt_new.x && hook->pt.y == pt_new.y,
1301  "Wrong hook coords: (%d %d) != (%d,%d)\n", hook->pt.x, hook->pt.y, pt_new.x, pt_new.y);
1302 
1303  /* Should match position set above */
1304  GetCursorPos(&pt);
1305  if (clipped)
1306  ok(pt.x == pt_old.x && pt.y == pt_old.y, "GetCursorPos: (%d,%d)\n", pt.x, pt.y);
1307  else
1308  ok(pt.x == pt_old.x +STEP && pt.y == pt_old.y +STEP, "GetCursorPos: (%d,%d)\n", pt.x, pt.y);
1309  }
1310  return CallNextHookEx( 0, code, wparam, lparam );
1311 }
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:1264
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
#define STEP
Definition: input.c:1265
Definition: input.c:431
Definition: input.c:432
static POINT pt_old
Definition: input.c:1263
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:436
static POINT pt_new
Definition: input.c:1263

Referenced by test_mouse_ll_hook().

◆ hook_proc3()

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

Definition at line 1313 of file input.c.

1314 {
1315  POINT pt;
1316 
1317  if (code == HC_ACTION)
1318  {
1319  /* MSLLHOOKSTRUCT does not seem to be reliable and contains different data on each run. */
1320  GetCursorPos(&pt);
1321  ok(pt.x == pt_old.x && pt.y == pt_old.y, "GetCursorPos: (%d,%d)\n", pt.x, pt.y);
1322  }
1323  return CallNextHookEx( 0, code, wparam, lparam );
1324 }
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:431
Definition: input.c:432
static POINT pt_old
Definition: input.c:1263
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 157 of file input.c.

158 {
159  HMODULE hdll = GetModuleHandleA("user32");
160 
161 #define GET_PROC(func) \
162  if (!(p ## func = (void*)GetProcAddress(hdll, #func))) \
163  trace("GetProcAddress(%s) failed\n", #func)
164 
165  GET_PROC(GetCurrentInputMessageSource);
166  GET_PROC(GetMouseMovePointsEx);
167  GET_PROC(GetPointerType);
172 #undef GET_PROC
173 }
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:821
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 388 of file input.c.

389 {
390  return (message >= WM_KEYFIRST && message <= WM_KEYLAST);
391 }
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 393 of file input.c.

394 {
395  return (message >= WM_MOUSEFIRST && message <= WM_MOUSELAST);
396 }
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 175 of file input.c.

176 {
177  UINT message;
178  int VKey = GETVKEY[kev];
179  WORD flags;
180 
181  flags = LOBYTE(GETSCAN[kev]);
183 
184  if (GETFLAGS[kev] & KEYEVENTF_KEYUP )
185  {
186  message = WM_KEYUP;
187  if( (InputKeyStateTable[VK_MENU] & 0x80) && (
188  (VKey == VK_MENU) || (VKey == VK_CONTROL) ||
189  !(InputKeyStateTable[VK_CONTROL] & 0x80))) {
190  if( TrackSysKey == VK_MENU || /* <ALT>-down/<ALT>-up sequence */
191  (VKey != VK_MENU)) /* <ALT>-down...<something else>-up */
193  TrackSysKey = 0;
194  }
195  InputKeyStateTable[VKey] &= ~0x80;
196  flags |= KF_REPEAT | KF_UP;
197  }
198  else
199  {
200  if (InputKeyStateTable[VKey] & 0x80) flags |= KF_REPEAT;
201  if (!(InputKeyStateTable[VKey] & 0x80)) InputKeyStateTable[VKey] ^= 0x01;
202  InputKeyStateTable[VKey] |= 0x80;
203  AsyncKeyStateTable[VKey] |= 0x80;
204 
206  if( (InputKeyStateTable[VK_MENU] & 0x80) &&
207  !(InputKeyStateTable[VK_CONTROL] & 0x80)) {
209  TrackSysKey = VKey;
210  }
211  }
212 
213  if (InputKeyStateTable[VK_MENU] & 0x80) flags |= KF_ALTDOWN;
214 
215  if( plParam) *plParam = MAKELPARAM( 1, flags );
216  if( pwParam) *pwParam = VKey;
217  return message;
218 }
Definition: tftpd.h:59
static BYTE AsyncKeyStateTable[256]
Definition: input.c:153
#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:152
static const int GETFLAGS[]
Definition: input.c:111
#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:154
#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:109
static const int GETVKEY[]
Definition: input.c:107

Referenced by do_test().

◆ llkbd_unicode_hook()

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

Definition at line 1151 of file input.c.

1152 {
1153  if(nCode == HC_ACTION){
1155  if(!info->vkCode){
1156  key_status.sendinput_broken = TRUE;
1157  win_skip("SendInput doesn't support unicode on this platform\n");
1158  }else{
1159  if(key_status.expect_alt){
1160  ok(info->vkCode == VK_LMENU, "vkCode should have been VK_LMENU[0x%04x], was: 0x%x\n", VK_LMENU, info->vkCode);
1161  key_status.expect_alt = FALSE;
1162  }else
1163  todo_wine_if(key_status.vk != VK_PACKET)
1164  ok(info->vkCode == key_status.vk, "Unexpected vkCode %#x, expected %#x.\n", info->vkCode, key_status.vk);
1165  }
1166  switch(wParam){
1167  case WM_KEYDOWN:
1168  key_status.last_hook_down = info->scanCode;
1169  break;
1170  case WM_KEYUP:
1171  key_status.last_hook_up = info->scanCode;
1172  break;
1173  case WM_SYSKEYDOWN:
1174  key_status.last_hook_syskey_down = info->scanCode;
1175  break;
1176  case WM_SYSKEYUP:
1177  key_status.last_hook_syskey_up = info->scanCode;
1178  break;
1179  }
1180  }
1181  return CallNextHookEx(NULL, nCode, wParam, lParam);
1182 }
#define TRUE
Definition: types.h:120
WPARAM wParam
Definition: combotst.c:138
smooth NULL
Definition: ftsmooth.c:416
#define WM_KEYDOWN
Definition: winuser.h:1697
#define todo_wine_if(is_todo)
Definition: test.h:164
struct tagKBDLLHOOKSTRUCT * LPKBDLLHOOKSTRUCT
#define WM_KEYUP
Definition: winuser.h:1698
#define VK_LMENU
Definition: winuser.h:2261
LRESULT WINAPI CallNextHookEx(_In_opt_ HHOOK, _In_ int, _In_ WPARAM, _In_ LPARAM)
static struct @1675 key_status
#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:150
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 2984 of file input.c.

2985 {
2986  INPUT_MESSAGE_SOURCE source;
2987  MSG msg;
2988 
2989  ok( pGetCurrentInputMessageSource( &source ), "GetCurrentInputMessageSource failed\n" );
2990  switch (message)
2991  {
2992  case WM_KEYDOWN:
2993  case WM_KEYUP:
2994  case WM_SYSKEYDOWN:
2995  case WM_SYSKEYUP:
2996  case WM_MOUSEMOVE:
2997  case WM_LBUTTONDOWN:
2998  case WM_LBUTTONUP:
2999  case WM_RBUTTONDOWN:
3000  case WM_RBUTTONUP:
3001  ok( source.deviceType == expect_src.deviceType || /* also accept system-generated WM_MOUSEMOVE */
3002  (message == WM_MOUSEMOVE && source.deviceType == IMDT_UNAVAILABLE),
3003  "%x: wrong deviceType %x/%x\n", message, source.deviceType, expect_src.deviceType );
3004  ok( source.originId == expect_src.originId ||
3005  (message == WM_MOUSEMOVE && source.originId == IMO_SYSTEM),
3006  "%x: wrong originId %x/%x\n", message, source.originId, expect_src.originId );
3007  SendMessageA( hwnd, WM_USER, 0, 0 );
3008  PostMessageA( hwnd, WM_USER, 0, 0 );
3010  ok( source.deviceType == expect_src.deviceType || /* also accept system-generated WM_MOUSEMOVE */
3011  (message == WM_MOUSEMOVE && source.deviceType == IMDT_UNAVAILABLE),
3012  "%x: wrong deviceType %x/%x\n", message, source.deviceType, expect_src.deviceType );
3013  ok( source.originId == expect_src.originId ||
3014  (message == WM_MOUSEMOVE && source.originId == IMO_SYSTEM),
3015  "%x: wrong originId %x/%x\n", message, source.originId, expect_src.originId );
3016  break;
3017  default:
3018  ok( source.deviceType == IMDT_UNAVAILABLE, "%x: wrong deviceType %x\n",
3019  message, source.deviceType );
3020  ok( source.originId == 0, "%x: wrong originId %x\n", message, source.originId );
3021  break;
3022  }
3023 
3024  return DefWindowProcA( hwnd, message, wp, lp );
3025 }
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:2982
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 2584 of file input.c.

2585 {
2586  if (message == WM_USER+1)
2587  {
2588  HWND hwnd = (HWND)lParam;
2589  ok(GetFocus() == hwnd, "thread expected focus %p, got %p\n", hwnd, GetFocus());
2590  ok(GetActiveWindow() == hwnd, "thread expected active %p, got %p\n", hwnd, GetActiveWindow());
2591  }
2593 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: tftpd.h:59
HANDLE HWND
Definition: compat.h:13
WPARAM wParam
Definition: combotst.c:138
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:1905
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 975 of file input.c.

976 {
977  key_status.last_key_down = -1;
978  key_status.last_key_up = -1;
979  key_status.last_syskey_down = -1;
980  key_status.last_syskey_up = -1;
981  key_status.last_char = -1;
982  key_status.last_syschar = -1;
983  key_status.last_hook_down = -1;
984  key_status.last_hook_up = -1;
985  key_status.last_hook_syskey_down = -1;
986  key_status.last_hook_syskey_up = -1;
987  key_status.vk = vk;
988  key_status.expect_alt = FALSE;
989  key_status.sendinput_broken = FALSE;
990 }
WORD vk
Definition: input.c:82
static struct @1675 key_status

Referenced by test_unicode_keys().

◆ simulate_click()

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

Definition at line 2002 of file input.c.

2003 {
2004  INPUT input[2];
2005  UINT events_no;
2006 
2007  SetCursorPos(x, y);
2008  memset(input, 0, sizeof(input));
2009  input[0].type = INPUT_MOUSE;
2010  U(input[0]).mi.dx = x;
2011  U(input[0]).mi.dy = y;
2012  U(input[0]).mi.dwFlags = left ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_RIGHTDOWN;
2013  input[1].type = INPUT_MOUSE;
2014  U(input[1]).mi.dx = x;
2015  U(input[1]).mi.dy = y;
2016  U(input[1]).mi.dwFlags = left ? MOUSEEVENTF_LEFTUP : MOUSEEVENTF_RIGHTUP;
2017  events_no = SendInput(2, input, sizeof(input[0]));
2018  ok(events_no == 2, "SendInput returned %d\n", events_no);
2019 }
#define MOUSEEVENTF_LEFTDOWN
Definition: winuser.h:1170
#define U(x)
Definition: wordpad.c:44
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define 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 3170 of file input.c.

3171 {
3172  POINT pos;
3173 
3175  GetCursorPos( &pos );
3176 
3180  test_Input_mouse();
3181  test_keynames();
3183  test_key_map();
3184  test_ToUnicode();
3185  test_ToAscii();
3188  test_key_names();
3190  test_GetKeyState();
3191  test_OemKeyScan();
3194 
3195  if(pGetMouseMovePointsEx)
3197  else
3198  win_skip("GetMouseMovePointsEx is not available\n");
3199 
3200  if(pGetRawInputDeviceList)
3202  else
3203  win_skip("GetRawInputDeviceList is not available\n");
3204 
3205  if (pGetCurrentInputMessageSource)
3207  else
3208  win_skip("GetCurrentInputMessageSource is not available\n");
3209 
3210  SetCursorPos( pos.x, pos.y );
3211 
3212  if(pGetPointerType)
3214  else
3215  win_skip("GetPointerType is not available\n");
3216 }
static void test_keynames(void)
Definition: input.c:1250
static void test_GetRawInputData(void)
Definition: input.c:1699
static void test_GetMouseMovePointsEx(void)
Definition: input.c:1460
static void test_get_async_key_state(void)
Definition: input.c:1934
static void test_GetPointerType(void)
Definition: input.c:3111
static void test_mouse_ll_hook(void)
Definition: input.c:1326
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
static void test_Input_whitebox(void)
Definition: input.c:353
static void test_GetKeyboardLayoutList(void)
Definition: input.c:3136
static void test_ToAscii(void)
Definition: input.c:1887
static void test_Input_unicode(void)
Definition: input.c:1184
static void test_key_names(void)
Definition: input.c:1962
static void test_input_message_source(void)
Definition: input.c:3027
static void test_OemKeyScan(void)
Definition: input.c:2948
static void test_key_map(void)
Definition: input.c:1709
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2627
static void test_Input_blackbox(void)
Definition: input.c:917
static void test_GetKeyState(void)
Definition: input.c:2907
static void test_ToUnicode(void)
Definition: input.c:1814
static void test_keyboard_layout_name(void)
Definition: input.c:1941
static void init_function_pointers(void)
Definition: input.c:157
static void test_GetRawInputDeviceList(void)
Definition: input.c:1596
#define win_skip
Definition: test.h:150
static void test_Input_mouse(void)
Definition: input.c:2110
static void test_attach_input(void)
Definition: input.c:2651

◆ static_hook_proc()

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

Definition at line 2057 of file input.c.

2058 {
2059  if (msg == WM_NCHITTEST)
2060  {
2061  /* break infinite hittest loop */
2062  if(hittest_no > 50) return HTCLIENT;
2063  hittest_no++;
2064  }
2065 
2066  return def_static_proc(hwnd, msg, wp, lp);
2067 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
static WNDPROC def_static_proc
Definition: input.c:2055
#define WM_NCHITTEST
Definition: winuser.h:1668
static DWORD hittest_no
Definition: input.c:2056
#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 2651 of file input.c.

2652 {
2653  HANDLE hThread;
2654  HWND ourWnd, Wnd2;
2655  DWORD ret, tid;
2656  struct wnd_event wnd_event;
2657  WNDCLASSA cls;
2658 
2659  cls.style = 0;
2660  cls.lpfnWndProc = MsgCheckProcA;
2661  cls.cbClsExtra = 0;
2662  cls.cbWndExtra = 0;
2663  cls.hInstance = GetModuleHandleA(0);
2664  cls.hIcon = 0;
2665  cls.hCursor = LoadCursorW( NULL, (LPCWSTR)IDC_ARROW);
2666  cls.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
2667  cls.lpszMenuName = NULL;
2668  cls.lpszClassName = "TestWindowClass";
2669  if(!RegisterClassA(&cls)) return;
2670 
2673  wnd_event.attach_from = 0;
2674  wnd_event.attach_to = 0;
2676  if (!wnd_event.start_event)
2677  {
2678  win_skip("skipping interthread message test under win9x\n");
2679  return;
2680  }
2681 
2683  ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
2684 
2685  ok(WaitForSingleObject(wnd_event.start_event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2687 
2688  ourWnd = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
2689  0, 0, 0, 0, 0, 0, 0, NULL);
2690  ok(ourWnd!= 0, "failed to create ourWnd window\n");
2691 
2692  Wnd2 = CreateWindowExA(0, "TestWindowClass", NULL, WS_OVERLAPPEDWINDOW,
2693  0, 0, 0, 0, 0, 0, 0, NULL);
2694  ok(Wnd2!= 0, "failed to create Wnd2 window\n");
2695 
2696  SetFocus(ourWnd);
2697  SetActiveWindow(ourWnd);
2698 
2700  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2701 
2702  ok(GetActiveWindow() == ourWnd, "expected active %p, got %p\n", ourWnd, GetActiveWindow());
2703  ok(GetFocus() == ourWnd, "expected focus %p, got %p\n", ourWnd, GetFocus());
2704 
2705  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, (LPARAM)ourWnd);
2706 
2708  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2709  ok(GetActiveWindow() == ourWnd, "expected active %p, got %p\n", ourWnd, GetActiveWindow());
2710  ok(GetFocus() == ourWnd, "expected focus %p, got %p\n", ourWnd, GetFocus());
2711 
2712  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, 0);
2713 
2715  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2716 
2717  ok(GetActiveWindow() == ourWnd, "expected active %p, got %p\n", ourWnd, GetActiveWindow());
2718  ok(GetFocus() == ourWnd, "expected focus %p, got %p\n", ourWnd, GetFocus());
2719  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, (LPARAM)ourWnd);
2720 
2721  SetActiveWindow(Wnd2);
2722  SetFocus(Wnd2);
2723  ok(GetActiveWindow() == Wnd2, "expected active %p, got %p\n", Wnd2, GetActiveWindow());
2724  ok(GetFocus() == Wnd2, "expected focus %p, got %p\n", Wnd2, GetFocus());
2725 
2726  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, (LPARAM)Wnd2);
2727 
2729  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2730  ok(GetActiveWindow() == Wnd2, "expected active %p, got %p\n", Wnd2, GetActiveWindow());
2731  ok(GetFocus() == Wnd2, "expected focus %p, got %p\n", Wnd2, GetFocus());
2732 
2733  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, 0);
2734 
2736  ok(ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
2737 
2738  ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2740 
2743  wnd_event.attach_from = 0;
2744  wnd_event.attach_to = 0;
2746 
2748  ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
2749 
2750  ok(WaitForSingleObject(wnd_event.start_event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2752 
2753  SetFocus(ourWnd);
2754  SetActiveWindow(ourWnd);
2755 
2757  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2758 
2759  ok(GetActiveWindow() == wnd_event.hwnd, "expected active %p, got %p\n", wnd_event.hwnd, GetActiveWindow());
2760  ok(GetFocus() == wnd_event.hwnd, "expected focus %p, got %p\n", wnd_event.hwnd, GetFocus());
2761 
2763 
2765  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2766 
2767  ok(GetActiveWindow() == 0, "expected active 0, got %p\n", GetActiveWindow());
2768  ok(GetFocus() == 0, "expected focus 0, got %p\n", GetFocus());
2769 
2771 
2773  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2774 
2775  ok(GetActiveWindow() == wnd_event.hwnd, "expected active %p, got %p\n", wnd_event.hwnd, GetActiveWindow());
2776  ok(GetFocus() == wnd_event.hwnd, "expected focus %p, got %p\n", wnd_event.hwnd, GetFocus());
2777 
2779 
2780  SetFocus(Wnd2);
2781  SetActiveWindow(Wnd2);
2782  ok(GetActiveWindow() == Wnd2, "expected active %p, got %p\n", Wnd2, GetActiveWindow());
2783  ok(GetFocus() == Wnd2, "expected focus %p, got %p\n", Wnd2, GetFocus());
2784 
2785  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, (LPARAM)Wnd2);
2786 
2788  ok(ret, "AttachThreadInput error %d\n", GetLastError());
2789 
2790  ok(GetActiveWindow() == Wnd2, "expected active %p, got %p\n", Wnd2, GetActiveWindow());
2791  ok(GetFocus() == Wnd2, "expected focus %p, got %p\n", Wnd2, GetFocus());
2792 
2793  SendMessageA(wnd_event.hwnd, WM_USER+1, 0, 0);
2794 
2796  ok(ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
2797 
2798  ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2800 
2803  wnd_event.attach_from = 0;
2804  wnd_event.attach_to = 0;
2806 
2808  ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
2809 
2810  SetLastError(0xdeadbeef);
2812  ok(!ret, "AttachThreadInput succeeded\n");
2813  ok(GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef) /* <= Win XP */,
2814  "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
2815 
2816  SetLastError(0xdeadbeef);
2818  ok(!ret, "AttachThreadInput succeeded\n");
2819  ok(GetLastError() == ERROR_INVALID_PARAMETER || broken(GetLastError() == 0xdeadbeef) /* <= Win XP */,
2820  "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
2821 
2823 
2824  ok(WaitForSingleObject(wnd_event.start_event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2826 
2828  ok(ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
2829 
2830  ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2832 
2836  wnd_event.attach_to = 0;
2838 
2839  SetFocus(ourWnd);
2840  SetActiveWindow(ourWnd);
2841 
2843  ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
2844 
2845  ok(WaitForSingleObject(wnd_event.start_event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2847 
2848  ok(GetActiveWindow() == ourWnd, "expected active %p, got %p\n", ourWnd, GetActiveWindow());
2849  ok(GetFocus() == ourWnd, "expected focus %p, got %p\n", ourWnd, GetFocus());
2850 
2852  ok(ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
2853 
2854  ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2856 
2859  wnd_event.attach_from = 0;
2862 
2863  SetFocus(ourWnd);
2864  SetActiveWindow(ourWnd);
2865 
2867  ok(hThread != NULL, "CreateThread failed, error %d\n", GetLastError());
2868 
2869  ok(WaitForSingleObject(wnd_event.start_event, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2871 
2872  ok(GetActiveWindow() == ourWnd, "expected active %p, got %p\n", ourWnd, GetActiveWindow());
2873  ok(GetFocus() == ourWnd, "expected focus %p, got %p\n", ourWnd, GetFocus());
2874 
2876  ok(ret, "PostMessageA(WM_QUIT) error %d\n", GetLastError());
2877 
2878  ok(WaitForSingleObject(hThread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n");
2880  DestroyWindow(ourWnd);
2881  DestroyWindow(Wnd2);
2882 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
DWORD attach_to
Definition: input.c:2601
#define CloseHandle
Definition: compat.h:406
static LRESULT WINAPI MsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: input.c:2584
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
BOOL WINAPI AttachThreadInput(_In_ DWORD, _In_ DWORD, _In_ BOOL)
DWORD attach_from
Definition: input.c:2600
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:1059
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI DestroyWindow(_In_ HWND)
#define COLOR_WINDOW
Definition: winuser.h:908
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HWND WINAPI SetActiveWindow(_In_ HWND)
static DWORD WINAPI thread_proc(void *param)
Definition: input.c:2605
HWND hwnd
Definition: input.c:2597
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:2599
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
#define SetLastError(x)
Definition: compat.h:417
HANDLE wait_event
Definition: input.c:2598
int ret
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
BOOL setWindows
Definition: input.c:2602
#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:1905
#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:150
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 1934 of file input.c.

1935 {
1936  /* input value sanity checks */
1937  ok(0 == GetAsyncKeyState(1000000), "GetAsyncKeyState did not return 0\n");
1938  ok(0 == GetAsyncKeyState(-1000000), "GetAsyncKeyState did not return 0\n");
1939 }
#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 3136 of file input.c.

3137 {
3138  int cnt, cnt2;
3139  HKL *layouts;
3140  ULONG_PTR baselayout;
3141  LANGID langid;
3142 
3143  baselayout = GetUserDefaultLCID();
3144  langid = PRIMARYLANGID(LANGIDFROMLCID(baselayout));
3146  baselayout = MAKELONG( baselayout, 0xe001 ); /* IME */
3147  else
3148  baselayout |= baselayout << 16;
3149 
3150  cnt = GetKeyboardLayoutList(0, NULL);
3151  /* Most users will not have more than a few keyboard layouts installed at a time. */
3152  ok(cnt > 0 && cnt < 10, "Layout count %d\n", cnt);
3153  if (cnt > 0)
3154  {
3155  layouts = HeapAlloc(GetProcessHeap(), 0, sizeof(*layouts) * cnt );
3156 
3157  cnt2 = GetKeyboardLayoutList(cnt, layouts);
3158  ok(cnt == cnt2, "wrong value %d!=%d\n", cnt, cnt2);
3159  for(cnt = 0; cnt < cnt2; cnt++)
3160  {
3161  if(layouts[cnt] == (HKL)baselayout)
3162  break;
3163  }
3164  ok(cnt < cnt2, "Didnt find current keyboard\n");
3165 
3166  HeapFree(GetProcessHeap(), 0, layouts);
3167  }
3168 }
WORD LANGID
Definition: typedefs.h:79
LCID WINAPI GetUserDefaultLCID(void)
Definition: lang.c:768
LANGID langid
Definition: msctf.idl:605
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define LANG_JAPANESE
Definition: nls.h:76
#define MAKELONG(a, b)
Definition: typedefs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:403
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:402
#define PRIMARYLANGID(l)
Definition: nls.h:16

Referenced by START_TEST().

◆ test_GetKeyState()

static void test_GetKeyState ( void  )
static

Definition at line 2907 of file input.c.

2908 {
2909  HANDLE semaphores[2];
2910  HANDLE thread;
2911  DWORD result;
2912  HWND hwnd;
2913 
2914  semaphores[0] = CreateSemaphoreA(NULL, 0, 1, NULL);
2915  ok(semaphores[0] != NULL, "CreateSemaphoreA failed %u\n", GetLastError());
2916  semaphores[1] = CreateSemaphoreA(NULL, 0, 1, NULL);
2917  ok(semaphores[1] != NULL, "CreateSemaphoreA failed %u\n", GetLastError());
2918 
2919  hwnd = CreateWindowA("static", "Title", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
2920  10, 10, 200, 200, NULL, NULL, NULL, NULL);
2921  ok(hwnd != NULL, "CreateWindowA failed %u\n", GetLastError());
2922 
2923  thread = CreateThread(NULL, 0, get_key_state_thread, semaphores, 0, NULL);
2924  ok(thread != NULL, "CreateThread failed %u\n", GetLastError());
2925  result = WaitForSingleObject(semaphores[0], 1000);
2926  ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
2927 
2929  SetFocus(hwnd);
2930  keybd_event('X', 0, 0, 0);
2931 
2932  ReleaseSemaphore(semaphores[1], 1, NULL);
2933  result = WaitForSingleObject(semaphores[0], 1000);
2934  ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
2935 
2936  keybd_event('X', 0, KEYEVENTF_KEYUP, 0);
2937 
2938  ReleaseSemaphore(semaphores[1], 1, NULL);
2940  ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
2942 
2944  CloseHandle(semaphores[0]);
2945  CloseHandle(semaphores[1]);
2946 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define CloseHandle
Definition: compat.h:406
#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:2884
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI DestroyWindow(_In_ HWND)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define 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 1460 of file input.c.

1461 {
1462 #define BUFLIM 64
1463 #define MYERROR 0xdeadbeef
1464  int count, retval;
1465  MOUSEMOVEPOINT in;
1466  MOUSEMOVEPOINT out[200];
1467  POINT point;
1468 
1469  /* Get a valid content for the input struct */
1470  if(!GetCursorPos(&point)) {
1471  win_skip("GetCursorPos() failed with error %u\n", GetLastError());
1472  return;
1473  }
1474  memset(&in, 0, sizeof(MOUSEMOVEPOINT));
1475  in.x = point.x;
1476  in.y = point.y;
1477 
1478  /* test first parameter
1479  * everything different than sizeof(MOUSEMOVEPOINT)
1480  * is expected to fail with ERROR_INVALID_PARAMETER
1481  */
1483  retval = pGetMouseMovePointsEx(0, &in, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1484  if (retval == ERROR_INVALID_PARAMETER)
1485  {
1486  win_skip( "GetMouseMovePointsEx broken on WinME\n" );
1487  return;
1488  }
1489  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1491  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1492 
1494  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT)-1, &in, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1495  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1497  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1498 
1500  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT)+1, &in, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1501  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1503  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1504 
1505  /* test second and third parameter
1506  */
1508  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), NULL, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1509  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1511  "expected error ERROR_NOACCESS, got %u\n", GetLastError());
1512 
1514  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, NULL, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1515  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1517  "expected error ERROR_NOACCESS, got %u\n", GetLastError());
1518 
1520  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), NULL, NULL, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1521  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1523  "expected error ERROR_NOACCESS, got %u\n", GetLastError());
1524 
1526  count = 0;
1527  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, NULL, count, GMMP_USE_DISPLAY_POINTS);
1528  if (retval == -1)
1529  ok(GetLastError() == ERROR_POINT_NOT_FOUND, "unexpected error %u\n", GetLastError());
1530  else
1531  ok(retval == count, "expected GetMouseMovePointsEx to succeed, got %d\n", retval);
1532 
1533  /* test fourth parameter
1534  * a value higher than 64 is expected to fail with ERROR_INVALID_PARAMETER
1535  */
1537  count = -1;
1538  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, out, count, GMMP_USE_DISPLAY_POINTS);
1539  ok(retval == count, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1541  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1542 
1544  count = 0;
1545  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, out, count, GMMP_USE_DISPLAY_POINTS);
1546  if (retval == -1)
1547  ok(GetLastError() == ERROR_POINT_NOT_FOUND, "unexpected error %u\n", GetLastError());
1548  else
1549  ok(retval == count, "expected GetMouseMovePointsEx to succeed, got %d\n", retval);
1550 
1552  count = BUFLIM;
1553  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, out, count, GMMP_USE_DISPLAY_POINTS);
1554  if (retval == -1)
1555  ok(GetLastError() == ERROR_POINT_NOT_FOUND, "unexpected error %u\n", GetLastError());
1556  else
1557  ok((0 <= retval) && (retval <= count), "expected GetMouseMovePointsEx to succeed, got %d\n", retval);
1558 
1560  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, out, BUFLIM+1, GMMP_USE_DISPLAY_POINTS);
1561  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1563  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1564 
1565  /* it was not possible to force an error with the fifth parameter on win2k */
1566 
1567  /* test combinations of wrong parameters to see which error wins */
1569  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT)-1, NULL, out, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1570  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1572  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1573 
1575  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT)-1, &in, NULL, BUFLIM, GMMP_USE_DISPLAY_POINTS);
1576  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1578  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1579 
1581  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), NULL, out, BUFLIM+1, GMMP_USE_DISPLAY_POINTS);
1582  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1584  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1585 
1587  retval = pGetMouseMovePointsEx(sizeof(MOUSEMOVEPOINT), &in, NULL, BUFLIM+1, GMMP_USE_DISPLAY_POINTS);
1588  ok(retval == -1, "expected GetMouseMovePointsEx to fail, got %d\n", retval);
1590  "expected error ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1591 
1592 #undef BUFLIM
1593 #undef MYERROR
1594 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
GLuint GLuint GLsizei count
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
POINTL point
Definition: edittest.c:50
LONG y
Definition: windef.h: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:417
#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:150

Referenced by START_TEST().

◆ test_GetPointerType()

static void test_GetPointerType ( void  )
static

Definition at line 3111 of file input.c.

3112 {
3113  BOOL ret;
3114  POINTER_INPUT_TYPE type = -1;
3115  UINT id = 0;
3116 
3117  SetLastError(0xdeadbeef);
3118  ret = pGetPointerType(id, NULL);
3119  ok(!ret, "GetPointerType should have failed.\n");
3121  "expected error ERROR_INVALID_PARAMETER, got %u.\n", GetLastError());
3122 
3123  SetLastError(0xdeadbeef);
3124  ret = pGetPointerType(id, &type);
3126  "expected error ERROR_INVALID_PARAMETER, got %u.\n", GetLastError());
3127  ok(!ret, "GetPointerType failed, got type %d for %u.\n", type, id );
3128  ok(type == -1, " type %d\n", type );
3129 
3130  id = 1;
3131  ret = pGetPointerType(id, &type);
3132  ok(ret, "GetPointerType failed, got type %d for %u.\n", type, id );
3133  ok(type == PT_MOUSE, " type %d\n", type );
3134 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:417
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 1699 of file input.c.

1700 {
1701  UINT size;
1702  UINT ret;
1703 
1704  /* Null raw input handle */
1705  ret = GetRawInputData(NULL, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
1706  ok(ret == ~0U, "Expect ret %u, got %u\n", ~0U, ret);
1707 }
#define U(x)
Definition: wordpad.c:44
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 1596 of file input.c.

1597 {
1598  RAWINPUTDEVICELIST devices[32];
1599  UINT ret, oret, devcount, odevcount, i;
1600  DWORD err;
1601 
1602  SetLastError(0xdeadbeef);
1603  ret = pGetRawInputDeviceList(NULL, NULL, 0);
1604  err = GetLastError();
1605  ok(ret == -1, "expected -1, got %d\n", ret);
1606  ok(err == ERROR_INVALID_PARAMETER, "expected 87, got %d\n", err);
1607 
1608  SetLastError(0xdeadbeef);
1609  ret = pGetRawInputDeviceList(NULL, NULL, sizeof(devices[0]));
1610  err = GetLastError();
1611  ok(ret == -1, "expected -1, got %d\n", ret);
1612  ok(err == ERROR_NOACCESS, "expected 998, got %d\n", err);
1613 
1614  devcount = 0;
1615  ret = pGetRawInputDeviceList(NULL, &devcount, sizeof(devices[0]));
1616  ok(ret == 0, "expected 0, got %d\n", ret);
1617  ok(devcount > 0, "expected non-zero\n");
1618 
1619  SetLastError(0xdeadbeef);
1620  devcount = 0;
1621  ret = pGetRawInputDeviceList(devices, &devcount, sizeof(devices[0]));
1622  err = GetLastError();
1623  ok(ret == -1, "expected -1, got %d\n", ret);
1624  ok(err == ERROR_INSUFFICIENT_BUFFER, "expected 122, got %d\n", err);
1625  ok(devcount > 0, "expected non-zero\n");
1626 
1627  /* devcount contains now the correct number of devices */
1628  ret = pGetRawInputDeviceList(devices, &devcount, sizeof(devices[0]));
1629  ok(ret > 0, "expected non-zero\n");
1630 
1631  for(i = 0; i < devcount; ++i)
1632  {
1633  WCHAR name[128];
1634  char nameA[128];
1635  UINT sz, len;
1636  RID_DEVICE_INFO info;
1637  HANDLE file;
1638 
1639  /* get required buffer size */
1640  name[0] = '\0';
1641  sz = 5;
1642  ret = pGetRawInputDeviceInfoW(devices[i].hDevice, RIDI_DEVICENAME, name, &sz);
1643  ok(ret == -1, "GetRawInputDeviceInfo gave wrong failure: %d\n", err);
1644  ok(sz > 5 && sz < ARRAY_SIZE(name), "Size should have been set and not too large (got: %u)\n", sz);
1645 
1646  /* buffer size for RIDI_DEVICENAME is in CHARs, not BYTEs */
1647  ret = pGetRawInputDeviceInfoW(devices[i].hDevice, RIDI_DEVICENAME, name, &sz);
1648  ok(ret == sz, "GetRawInputDeviceInfo gave wrong return: %d\n", err);
1649  len = lstrlenW(name);
1650  ok(len + 1 == ret, "GetRawInputDeviceInfo returned wrong length (name: %u, ret: %u)\n", len + 1, ret);
1651 
1652  /* test A variant with same size */
1653  ret = pGetRawInputDeviceInfoA(devices[i].hDevice, RIDI_DEVICENAME, nameA, &sz);
1654  ok(ret == sz, "GetRawInputDeviceInfoA gave wrong return: %d\n", err);
1655  len = strlen(nameA);
1656  ok(len + 1 == ret, "GetRawInputDeviceInfoA returned wrong length (name: %u, ret: %u)\n", len + 1, ret);
1657 
1658  /* buffer size for RIDI_DEVICEINFO is in BYTEs */
1659  memset(&info, 0, sizeof(info));
1660  info.cbSize = sizeof(info);
1661  sz = sizeof(info) - 1;
1662  ret = pGetRawInputDeviceInfoW(devices[i].hDevice, RIDI_DEVICEINFO, &info, &sz);
1663  ok(ret == -1, "GetRawInputDeviceInfo gave wrong failure: %d\n", err);
1664  ok(sz == sizeof(info), "GetRawInputDeviceInfo set wrong size\n");
1665 
1666  ret = pGetRawInputDeviceInfoW(devices[i].hDevice, RIDI_DEVICEINFO, &info, &sz);
1667  ok(ret == sizeof(info), "GetRawInputDeviceInfo gave wrong return: %d\n", err);
1668  ok(sz == sizeof(info), "GetRawInputDeviceInfo set wrong size\n");
1669  ok(info.dwType == devices[i].dwType, "GetRawInputDeviceInfo set wrong type: 0x%x\n", info.dwType);
1670 
1671  memset(&info, 0, sizeof(info));
1672  info.cbSize = sizeof(info);
1673  ret = pGetRawInputDeviceInfoA(devices[i].hDevice, RIDI_DEVICEINFO, &info, &sz);
1674  ok(ret == sizeof(info), "GetRawInputDeviceInfo gave wrong return: %d\n", err);
1675  ok(sz == sizeof(info), "GetRawInputDeviceInfo set wrong size\n");
1676  ok(info.dwType == devices[i].dwType, "GetRawInputDeviceInfo set wrong type: 0x%x\n", info.dwType);
1677 
1678  /* setupapi returns an NT device path, but CreateFile() < Vista can't
1679  * understand that; so use the \\?\ prefix instead */
1680  name[1] = '\\';
1682  todo_wine_if(info.dwType != RIM_TYPEHID)
1683  ok(file != INVALID_HANDLE_VALUE, "Failed to open %s, error %u\n", wine_dbgstr_w(name), GetLastError());
1684  CloseHandle(file);
1685  }
1686 
1687  /* check if variable changes from larger to smaller value */
1688  devcount = odevcount = ARRAY_SIZE(devices);
1689  oret = ret = pGetRawInputDeviceList(devices, &odevcount, sizeof(devices[0]));
1690  ok(ret > 0, "expected non-zero\n");
1691  ok(devcount == odevcount, "expected %d, got %d\n", devcount, odevcount);
1692  devcount = odevcount;
1693  odevcount = ARRAY_SIZE(devices);
1694  ret = pGetRawInputDeviceList(NULL, &odevcount, sizeof(devices[0]));
1695  ok(ret == 0, "expected 0, got %d\n", ret);
1696  ok(odevcount == oret, "expected %d, got %d\n", oret, odevcount);
1697 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define CloseHandle
Definition: compat.h:406
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:399
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define lstrlenW
Definition: compat.h:415
#define FILE_SHARE_READ
Definition: compat.h:125
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:434
#define todo_wine_if(is_todo)
Definition: test.h:164
__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:417
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:408
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 917 of file input.c.

918 {
919  TEST_INPUT i;
920  int ii;
921  BYTE ks1[256], ks2[256];
922  LONG_PTR prevWndProc;
923  BOOL foreground;
924  HWND window;
925  HHOOK hook;
926 
927  if (GetKeyboardLayout(0) != (HKL)(ULONG_PTR)0x04090409)
928  {
929  skip("Skipping Input_blackbox test on non-US keyboard\n");
930  return;
931  }
933  |WS_VISIBLE, 0, 0, 200, 60, NULL, NULL,
934  NULL, NULL);
935  ok(window != NULL, "error: %d\n", (int) GetLastError());
937  foreground = SetForegroundWindow( window );
938  if (!foreground)
939  skip("Failed to set foreground window; some tests will be skipped.\n");
940 
942  {
944  win_skip("WH_KEYBOARD_LL is not supported\n");
945  return;
946  }
947 
948  /* must process all initial messages, otherwise X11DRV_KeymapNotify unsets
949  * key state set by SendInput(). */
951 
953  ok(prevWndProc != 0 || GetLastError() == 0, "error: %d\n", (int) GetLastError());
954 
955  i.type = INPUT_KEYBOARD;
956  i.u.ki.time = 0;
957  i.u.ki.dwExtraInfo = 0;
958 
959  for (ii = 0; ii < ARRAY_SIZE(sendinput_test)-1; ii++) {
960  GetKeyboardState(ks1);
961  i.u.ki.wScan = ii+1 /* useful for debugging */;
962  i.u.ki.dwFlags = sendinput_test[ii].dwFlags;
963  i.u.ki.wVk = sendinput_test[ii].wVk;
964  SendInput(1, (INPUT*)&i, sizeof(TEST_INPUT));
966  GetKeyboardState(ks2);
967  compare_and_check(ii, ks1, ks2, &sendinput_test[ii], foreground);
968  }
969 
973 }
static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, const struct sendinput_test_s *test, BOOL foreground)
Definition: input.c:707
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define HWND_TOPMOST
Definition: winuser.h:1194
BOOL WINAPI DestroyWindow(_In_ HWND)
uint32_t ULONG_PTR
Definition: typedefs.h:63
HHOOK WINAPI SetWindowsHookExA(_In_ int, _In_ HOOKPROC, _In_opt_ HINSTANCE, _In_ DWORD)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HKL WINAPI GetKeyboardLayout(DWORD idThread)
Definition: input.c:122
#define INPUT_KEYBOARD
Definition: winable.h:10
static LRESULT CALLBACK WndProc2(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: input.c:869
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:888
#define SetWindowLongPtrA
Definition: winuser.h:5320
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
unsigned char BYTE
Definition: mem.h:68
UINT_PTR HKL
Definition: msctf.idl:101
static IHTMLWindow2 * window
Definition: events.c:77
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
#define GWLP_WNDPROC
Definition: treelist.c:66
#define SWP_NOSIZE
Definition: winuser.h:1230
static const struct sendinput_test_s sendinput_test[]
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
Definition: input.c:436
__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:399
#define WS_VISIBLE
Definition: pedump.c:620
#define win_skip
Definition: test.h:150
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 3027 of file input.c.

3028 {
3029  WNDCLASSA cls;
3030  TEST_INPUT inputs[2];
3031  HWND hwnd;
3032  RECT rc;
3033  MSG msg;
3034 
3035  cls.style = 0;
3037  cls.cbClsExtra = 0;
3038  cls.cbWndExtra = 0;
3039  cls.hInstance = GetModuleHandleA(0);
3040  cls.hIcon = 0;
3041  cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
3042  cls.hbrBackground = 0;
3043  cls.lpszMenuName = NULL;
3044  cls.lpszClassName = "message source class";
3045  RegisterClassA(&cls);
3046  hwnd = CreateWindowA( cls.lpszClassName, "test", WS_OVERLAPPED, 0, 0, 100, 100,
3047  0, 0, 0, 0 );
3049  UpdateWindow( hwnd );
3051  SetFocus( hwnd );
3052 
3053  inputs[0].type = INPUT_KEYBOARD;
3054  inputs[0].u.ki.dwExtraInfo = 0;
3055  inputs[0].u.ki.time = 0;
3056  inputs[0].u.ki.wVk = 0;
3057  inputs[0].u.ki.wScan = 0x3c0;
3058  inputs[0].u.ki.dwFlags = KEYEVENTF_UNICODE;
3059  inputs[1] = inputs[0];
3060  inputs[1].u.ki.dwFlags |= KEYEVENTF_KEYUP;
3061 
3062  expect_src.deviceType = IMDT_UNAVAILABLE;
3063  expect_src.originId = IMO_UNAVAILABLE;
3064  SendMessageA( hwnd, WM_KEYDOWN, 0, 0 );
3065  SendMessageA( hwnd, WM_MOUSEMOVE, 0, 0 );
3066 
3067  SendInput( 2, (INPUT *)inputs, sizeof(INPUT) );
3068  while (PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ))
3069  {
3070  expect_src.deviceType = IMDT_KEYBOARD;
3071  expect_src.originId = IMO_INJECTED;
3072  TranslateMessage( &msg );
3073  DispatchMessageW( &msg );
3074  }
3075  GetWindowRect( hwnd, &rc );
3076  simulate_click( TRUE, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2 );
3077  simulate_click( FALSE, (rc.left + rc.right) / 2 + 1, (rc.top + rc.bottom) / 2 + 1 );
3078  while (PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ))
3079  {
3080  expect_src.deviceType = IMDT_MOUSE;
3081  expect_src.originId = IMO_INJECTED;
3082  TranslateMessage( &msg );
3083  DispatchMessageW( &msg );
3084  }
3085 
3086  expect_src.deviceType = IMDT_UNAVAILABLE;
3087  expect_src.originId = IMO_UNAVAILABLE;
3088  SendMessageA( hwnd, WM_KEYDOWN, 0, 0 );
3089  SendMessageA( hwnd, WM_LBUTTONDOWN, 0, 0 );
3090  PostMessageA( hwnd, WM_KEYUP, 0, 0 );
3091  PostMessageA( hwnd, WM_LBUTTONUP, 0, 0 );
3092  while (PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ))
3093  {
3094  TranslateMessage( &msg );
3095  DispatchMessageW( &msg );
3096  }
3097 
3098  expect_src.deviceType = IMDT_UNAVAILABLE;
3099  expect_src.originId = IMO_SYSTEM;
3100  SetCursorPos( (rc.left + rc.right) / 2 - 1, (rc.top + rc.bottom) / 2 - 1 );
3101  while (PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE ))
3102  {
3103  TranslateMessage( &msg );
3104  DispatchMessageW( &msg );
3105  }
3106 
3107  DestroyWindow( hwnd );
3109 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
DWORD type
Definition: imm32.c:51
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define TRUE
Definition: types.h:120
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
static INPUT_MESSAGE_SOURCE expect_src
Definition: input.c:2982
#define KEYEVENTF_KEYUP
Definition: winuser.h:1092
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
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:821
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
union TEST_INPUT::@1616 u
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:2002
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:2984
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 2110 of file input.c.

2111 {
2112  BOOL got_button_down, got_button_up;
2113  HWND hwnd, button_win, static_win;
2114  struct thread_data thread_data;
2115  HANDLE thread;
2116  DWORD thread_id;
2117  WNDCLASSA wclass;
2118  POINT pt, pt_org;
2119  int region_type;
2120  HRGN hregion;
2121  RECT region;
2122  MSG msg;
2123  BOOL ret;
2124 
2125  SetLastError(0xdeadbeef);
2126  ret = GetCursorPos(NULL);
2127  ok(!ret, "GetCursorPos succeed\n");
2128  ok(GetLastError() == 0xdeadbeef || GetLastError() == ERROR_NOACCESS, "error %u\n", GetLastError());
2129 
2130  SetLastError(0xdeadbeef);
2131  ret = GetCursorPos(&pt_org);
2132  ok(ret, "GetCursorPos failed\n");
2133  ok(GetLastError() == 0xdeadbeef, "error %u\n", GetLastError());
2134 
2135  button_win = CreateWindowA("button", "button", WS_VISIBLE | WS_POPUP,
2136  100, 100, 100, 100, 0, NULL, NULL, NULL);
2137  ok(button_win != 0, "CreateWindow failed\n");
2138 
2139  pt.x = pt.y = 150;
2140  hwnd = WindowFromPoint(pt);
2141  if (hwnd != button_win)
2142  {
2143  skip("there's another window covering test window\n");
2144  DestroyWindow(button_win);
2145  return;
2146  }
2147 
2148  /* simple button click test */
2149  simulate_click(TRUE, 150, 150);
2150  got_button_down = got_button_up = FALSE;
2151  while (wait_for_message(&msg))
2152  {
2154 
2155  if (msg.message == WM_LBUTTONDOWN)
2156  {
2157  got_button_down = TRUE;
2158  }
2159  else if (msg.message == WM_LBUTTONUP)
2160  {
2161  got_button_up = TRUE;
2162  break;
2163  }
2164  }
2165  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2166  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2167 
2168  /* click through HTTRANSPARENT child window */
2169  static_win = CreateWindowA("static", "static", WS_VISIBLE | WS_CHILD,
2170  0, 0, 100, 100, button_win, NULL, NULL, NULL);
2171  ok(static_win != 0, "CreateWindow failed\n");
2172  def_static_proc = (void*)SetWindowLongPtrA(static_win,
2174  simulate_click(FALSE, 150, 150);
2175  hittest_no = 0;
2176  got_button_down = got_button_up = FALSE;
2177  while (wait_for_message(&msg))
2178  {
2180 
2181  if (msg.message == WM_RBUTTONDOWN)
2182  {
2183  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2184  got_button_down = TRUE;
2185  }
2186  else if (msg.message == WM_RBUTTONUP)
2187  {
2188  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2189  got_button_up = TRUE;
2190  break;
2191  }
2192  }
2193  ok(hittest_no && hittest_no<50, "expected WM_NCHITTEST message\n");
2194  ok(got_button_down, "expected WM_RBUTTONDOWN message\n");
2195  ok(got_button_up, "expected WM_RBUTTONUP message\n");
2196  DestroyWindow(static_win);
2197 
2198  /* click through HTTRANSPARENT top-level window */
2199  static_win = CreateWindowA("static", "static", WS_VISIBLE | WS_POPUP,
2200  100, 100, 100, 100, 0, NULL, NULL, NULL);
2201  ok(static_win != 0, "CreateWindow failed\n");
2202  def_static_proc = (void*)SetWindowLongPtrA(static_win,
2204  simulate_click(TRUE, 150, 150);
2205  hittest_no = 0;
2206  got_button_down = got_button_up = FALSE;
2207  while (wait_for_message(&msg))
2208  {
2210 
2211  if (msg.message == WM_LBUTTONDOWN)
2212  {
2213  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2214  got_button_down = TRUE;
2215  }
2216  else if (msg.message == WM_LBUTTONUP)
2217  {
2218  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2219  got_button_up = TRUE;
2220  break;
2221  }
2222  }
2223  ok(hittest_no && hittest_no<50, "expected WM_NCHITTEST message\n");
2224  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2225  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2226  DestroyWindow(static_win);
2227 
2228  /* click on HTTRANSPARENT top-level window that belongs to other thread */
2230  ok(thread_data.start_event != NULL, "CreateEvent failed\n");
2232  ok(thread_data.end_event != NULL, "CreateEvent failed\n");
2234  ok(thread != NULL, "CreateThread failed\n");
2235  hittest_no = 0;
2236  got_button_down = got_button_up = FALSE;
2238  simulate_click(FALSE, 150, 150);
2239  while (wait_for_message(&msg))
2240  {
2242 
2243  if (msg.message == WM_RBUTTONDOWN)
2244  got_button_down = TRUE;
2245  else if (msg.message == WM_RBUTTONUP)
2246  got_button_up = TRUE;
2247  }
2251  ok(hittest_no && hittest_no<50, "expected WM_NCHITTEST message\n");
2252  ok(!got_button_down, "unexpected WM_RBUTTONDOWN message\n");
2253  ok(!got_button_up, "unexpected WM_RBUTTONUP message\n");
2254 
2255  /* click on HTTRANSPARENT top-level window that belongs to other thread,
2256  * thread input queues are attached */
2258  ok(thread != NULL, "CreateThread failed\n");
2259  hittest_no = 0;
2260  got_button_down = got_button_up = FALSE;
2263  "AttachThreadInput failed\n");
2265  SetWindowPos(thread_data.win, button_win, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
2266  simulate_click(TRUE, 150, 150);
2267  while (wait_for_message(&msg))
2268  {
2270 
2271  if (msg.message == WM_LBUTTONDOWN)
2272  got_button_down = TRUE;
2273  else if (msg.message == WM_LBUTTONUP)
2274  got_button_up = TRUE;
2275  }
2278  todo_wine ok(hittest_no > 50, "expected loop with WM_NCHITTEST messages\n");
2279  ok(!got_button_down, "unexpected WM_LBUTTONDOWN message\n");
2280  ok(!got_button_up, "unexpected WM_LBUTTONUP message\n");
2281 
2282  /* click after SetCapture call */
2283  hwnd = CreateWindowA("button", "button", WS_VISIBLE | WS_POPUP,
2284  0, 0, 100, 100, 0, NULL, NULL, NULL);
2285  ok(hwnd != 0, "CreateWindow failed\n");
2286  SetCapture(button_win);
2287  got_button_down = got_button_up = FALSE;
2288  simulate_click(FALSE, 50, 50);
2289  while (wait_for_message(&msg))
2290  {
2292 
2293  if (msg.message == WM_RBUTTONDOWN)
2294  {
2295  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2296  got_button_down = TRUE;
2297  }
2298  else if (msg.message == WM_RBUTTONUP)
2299  {
2300  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2301  got_button_up = TRUE;
2302  break;
2303  }
2304  }
2305  ok(got_button_down, "expected WM_RBUTTONDOWN message\n");
2306  ok(got_button_up, "expected WM_RBUTTONUP message\n");
2308 
2309  /* click on child window after SetCapture call */
2310  hwnd = CreateWindowA("button", "button2", WS_VISIBLE | WS_CHILD,
2311  0, 0, 100, 100, button_win, NULL, NULL, NULL);
2312  ok(hwnd != 0, "CreateWindow failed\n");
2313  got_button_down = got_button_up = FALSE;
2314  simulate_click(TRUE, 150, 150);
2315  while (wait_for_message(&msg))
2316  {
2318 
2319  if (msg.message == WM_LBUTTONDOWN)
2320  {
2321  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2322  got_button_down = TRUE;
2323  }
2324  else if (msg.message == WM_LBUTTONUP)
2325  {
2326  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2327  got_button_up = TRUE;
2328  break;
2329  }
2330  }
2331  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2332  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2334  ok(ReleaseCapture(), "ReleaseCapture failed\n");
2335 
2336  wclass.style = 0;
2337  wclass.lpfnWndProc = WndProc;
2338  wclass.cbClsExtra = 0;
2339  wclass.cbWndExtra = 0;
2340  wclass.hInstance = GetModuleHandleA(NULL);
2341  wclass.hIcon = LoadIconA(0, (LPCSTR)IDI_APPLICATION);
2342  wclass.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW);
2343  wclass.hbrBackground = CreateSolidBrush(RGB(128, 128, 128));
2344  wclass.lpszMenuName = NULL;
2345  wclass.lpszClassName = "InputLayeredTestClass";
2346  RegisterClassA( &wclass );
2347 
2348  /* click through layered window with alpha channel / color key */
2349  hwnd = CreateWindowA(wclass.lpszClassName, "InputLayeredTest",
2350  WS_VISIBLE | WS_POPUP, 100, 100, 100, 100, button_win, NULL, NULL, NULL);
2351  ok(hwnd != NULL, "CreateWindowEx failed\n");
2352 
2353  static_win = CreateWindowA("static", "Title", WS_VISIBLE | WS_CHILD,
2354  10, 10, 20, 20, hwnd, NULL, NULL, NULL);
2355  ok(static_win != NULL, "CreateWindowA failed %u\n", GetLastError());
2356 
2359  ret = SetLayeredWindowAttributes(hwnd, 0, 255, LWA_ALPHA);
2360  ok(ret, "SetLayeredWindowAttributes failed\n");
2362  Sleep(100);
2363 
2364  if (pGetWindowRgnBox)
2365  {
2366  region_type = pGetWindowRgnBox(hwnd, &region);
2367  ok(region_type == ERROR, "expected ERROR, got %d\n", region_type);
2368  }
2369 
2370  get_dc_region(&region, hwnd, DCX_PARENTCLIP);
2371  ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200,
2372  "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region));
2374  ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200,
2375  "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region));
2376  get_dc_region(&region, hwnd, DCX_USESTYLE);
2377  ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200,
2378  "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region));
2379  get_dc_region(&region, static_win, DCX_PARENTCLIP);
2380  ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200,
2381  "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region));
2382  get_dc_region(&region, static_win, DCX_WINDOW | DCX_USESTYLE);
2383  ok(region.left == 110 && region.top == 110 && region.right == 130 && region.bottom == 130,
2384  "expected region (110,110)-(130,130), got %s\n", wine_dbgstr_rect(&region));
2385  get_dc_region(&region, static_win, DCX_USESTYLE);
2386  ok(region.left == 100 && region.top == 100 && region.right == 200 && region.bottom == 200,
2387  "expected region (100,100)-(200,200), got %s\n", wine_dbgstr_rect(&region));
2388 
2389  got_button_down = got_button_up = FALSE;
2390  simulate_click(TRUE, 150, 150);
2391  while (wait_for_message(&msg))
2392  {
2394 
2395  if (msg.message == WM_LBUTTONDOWN)
2396  {
2397  ok(msg.hwnd == hwnd, "msg.hwnd = %p\n", msg.hwnd);
2398  got_button_down = TRUE;
2399  }
2400  else if (msg.message == WM_LBUTTONUP)
2401  {
2402  ok(msg.hwnd == hwnd, "msg.hwnd = %p\n", msg.hwnd);
2403  got_button_up = TRUE;
2404  break;
2405  }
2406  }
2407  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2408  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2409 
2410  ret = SetLayeredWindowAttributes(hwnd, 0, 0, LWA_ALPHA);
2411  ok(ret, "SetLayeredWindowAttributes failed\n");
2413  Sleep(100);
2414 
2415  if (pGetWindowRgnBox)
2416  {
2417  region_type = pGetWindowRgnBox(hwnd, &region);
2418  ok(region_type == ERROR, "expected ERROR, got %d\n", region_type);
2419  }
2420 
2421  got_button_down = got_button_up = FALSE;
2422  simulate_click(TRUE, 150, 150);
2423  while (wait_for_message(&msg))
2424  {
2426 
2427  if (msg.message == WM_LBUTTONDOWN)
2428  {
2429  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2430  got_button_down = TRUE;
2431  }
2432  else if (msg.message == WM_LBUTTONUP)
2433  {
2434  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2435  got_button_up = TRUE;
2436  break;
2437  }
2438  }
2439  ok(got_button_down || broken(!got_button_down), "expected WM_LBUTTONDOWN message\n");
2440  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2441 
2442  ret = SetLayeredWindowAttributes(hwnd, RGB(0, 255, 0), 255, LWA_ALPHA | LWA_COLORKEY);
2443  ok(ret, "SetLayeredWindowAttributes failed\n");
2445  Sleep(100);
2446 
2447  if (pGetWindowRgnBox)
2448  {
2449  region_type = pGetWindowRgnBox(hwnd, &region);
2450  ok(region_type == ERROR, "expected ERROR, got %d\n", region_type);
2451  }
2452 
2453  got_button_down = got_button_up = FALSE;
2454  simulate_click(TRUE, 150, 150);
2455  while (wait_for_message(&msg))
2456  {
2458 
2459  if (msg.message == WM_LBUTTONDOWN)
2460  {
2461  ok(msg.hwnd == hwnd, "msg.hwnd = %p\n", msg.hwnd);
2462  got_button_down = TRUE;
2463  }
2464  else if (msg.message == WM_LBUTTONUP)
2465  {
2466  ok(msg.hwnd == hwnd, "msg.hwnd = %p\n", msg.hwnd);
2467  got_button_up = TRUE;
2468  break;
2469  }
2470  }
2471  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2472  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2473 
2474  ret = SetLayeredWindowAttributes(hwnd, RGB(128, 128, 128), 0, LWA_COLORKEY);
2475  ok(ret, "SetLayeredWindowAttributes failed\n");
2477  Sleep(100);
2478 
2479  if (pGetWindowRgnBox)
2480  {
2481  region_type = pGetWindowRgnBox(hwnd, &region);
2482  ok(region_type == ERROR, "expected ERROR, got %d\n", region_type);
2483  }
2484 
2485  got_button_down = got_button_up = FALSE;
2486  simulate_click(TRUE, 150, 150);
2487  while (wait_for_message(&msg))
2488  {
2490 
2491  if (msg.message == WM_LBUTTONDOWN)
2492  {
2493  todo_wine
2494  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2495  got_button_down = TRUE;
2496  }
2497  else if (msg.message == WM_LBUTTONUP)
2498  {
2499  todo_wine
2500  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2501  got_button_up = TRUE;
2502  break;
2503  }
2504  }
2505  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2506  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2507 
2510  Sleep(100);
2511 
2512  if (pGetWindowRgnBox)
2513  {
2514  region_type = pGetWindowRgnBox(hwnd, &region);
2515  ok(region_type == ERROR, "expected ERROR, got %d\n", region_type);
2516  }
2517 
2518  got_button_down = got_button_up = FALSE;
2519  simulate_click(TRUE, 150, 150);
2520  while (wait_for_message(&msg))
2521  {
2523 
2524  if (msg.message == WM_LBUTTONDOWN)
2525  {
2526  ok(msg.hwnd == hwnd, "msg.hwnd = %p\n", msg.hwnd);
2527  got_button_down = TRUE;
2528  }
2529  else if (msg.message == WM_LBUTTONUP)
2530  {
2531  ok(msg.hwnd == hwnd, "msg.hwnd = %p\n", msg.hwnd);
2532  got_button_up = TRUE;
2533  break;
2534  }
2535  }
2536  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2537  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2538 
2539  hregion = CreateRectRgn(0, 0, 10, 10);
2540  ok(hregion != NULL, "CreateRectRgn failed\n");
2541  ret = SetWindowRgn(hwnd, hregion, TRUE);
2542  ok(ret, "SetWindowRgn failed\n");
2543  DeleteObject(hregion);
2545  Sleep(1000);
2546 
2547  if (pGetWindowRgnBox)
2548  {
2549  region_type = pGetWindowRgnBox(hwnd, &region);
2550  ok(region_type == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", region_type);
2551  }
2552 
2553  got_button_down = got_button_up = FALSE;
2554  simulate_click(TRUE, 150, 150);
2555  while (wait_for_message(&msg))
2556  {
2558 
2559  if (msg.message == WM_LBUTTONDOWN)
2560  {
2561  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2562  got_button_down = TRUE;
2563  }
2564  else if (msg.message == WM_LBUTTONUP)
2565  {
2566  ok(msg.hwnd == button_win, "msg.hwnd = %p\n", msg.hwnd);
2567  got_button_up = TRUE;
2568  break;
2569  }
2570  }
2571  ok(got_button_down, "expected WM_LBUTTONDOWN message\n");
2572  ok(got_button_up, "expected WM_LBUTTONUP message\n");
2573 
2574  DestroyWindow(static_win);
2576  SetCursorPos(pt_org.x, pt_org.y);
2577 
2580  DestroyWindow(button_win);
2581 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
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)
long x
Definition: polytest.cpp:48
#define pt(x, y)
Definition: drawing.c:79
static WNDPROC def_static_proc
Definition: input.c:2055
#define ERROR(name)
Definition: error_private.h:53
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
HWND win
Definition: input.c:2073
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:1059
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)
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:2057
const char * LPCSTR
Definition: xmlstorage.h:183
static DWORD hittest_no
Definition: input.c:2056
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:2072
#define RGB(r, g, b)
Definition: wingdi.h:2939
#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:417
#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:2093
int ret
#define todo_wine
Definition: test.h:163
#define SetWindowLongPtrA
Definition: winuser.h:5320
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
LPCSTR lpszClassName
Definition: winuser.h:3147
static DWORD WINAPI create_static_win(void *arg)
Definition: input.c:2076
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:347
#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:2888
LONG bottom
Definition: windef.h:309
static void simulate_click(BOOL left, int x, int y)
Definition: input.c:2002
#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:2021
HICON hIcon
Definition: winuser.h:3143
HANDLE start_event
Definition: input.c:2071

Referenced by START_TEST().

◆ test_Input_unicode()

static void test_Input_unicode ( void  )
static

Definition at line 1184 of file input.c.

1185 {
1186  WCHAR classNameW[] = {'I','n','p','u','t','U','n','i','c','o','d','e',
1187  'K','e','y','T','e','s','t','C','l','a','s','s',0};
1188  WCHAR windowNameW[] = {'I','n','p','u','t','U','n','i','c','o','d','e',
1189  'K','e','y','T','e','s','t',0};
1190  MSG msg;
1191  WNDCLASSW wclass;
1193  HHOOK hook;
1194  HMODULE hModuleImm32;
1195  BOOL (WINAPI *pImmDisableIME)(DWORD);
1196 
1197  wclass.lpszClassName = classNameW;
1198  wclass.style = CS_HREDRAW | CS_VREDRAW;
1199  wclass.lpfnWndProc = unicode_wnd_proc;
1200  wclass.hInstance = hInstance;
1201  wclass.hIcon = LoadIconW(0, (LPCWSTR)IDI_APPLICATION);
1202  wclass.hCursor = LoadCursorW( NULL, (LPCWSTR)IDC_ARROW);
1203  wclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
1204  wclass.lpszMenuName = 0;
1205  wclass.cbClsExtra = 0;
1206  wclass.cbWndExtra = 0;
1207  if(!RegisterClassW(&wclass)){
1208  win_skip("Unicode functions not supported\n");
1209  return;
1210  }
1211 
1212  hModuleImm32 = LoadLibraryA("imm32.dll");
1213  if (hModuleImm32) {
1214  pImmDisableIME = (void *)GetProcAddress(hModuleImm32, "ImmDisableIME");
1215  if (pImmDisableIME)
1216  pImmDisableIME(0);
1217  }
1218  pImmDisableIME = NULL;
1219  FreeLibrary(hModuleImm32);
1220 
1221  /* create the test window that will receive the keystrokes */
1222  hWndTest = CreateWindowW(wclass.lpszClassName, windowNameW,
1223  WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, 100, 100,
1224  NULL, NULL, hInstance, NULL);
1225 
1226  assert(hWndTest);
1228 
1230  if(!hook)
1231  win_skip("unable to set WH_KEYBOARD_LL hook\n");
1232 
1237 
1238  /* flush pending messages */
1239  while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageW(&msg);
1240 
1241  SetFocus(hWndTest);
1242 
1244 
1245  if(hook)
1248 }
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:992
LPCWSTR lpszClassName
Definition: winuser.h:3160
#define SW_SHOW
Definition: winuser.h:769
BOOL WINAPI IsWindowUnicode(_In_ HWND)
static HWND hWndTest
Definition: input.c:68
#define CS_VREDRAW
Definition: winuser.h:653
#define FreeLibrary(x)
Definition: compat.h:413
#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:89
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:436
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:847
BOOL WINAPI SetForegroundWindow(_In_ HWND)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define GetProcAddress(x, y)
Definition: compat.h:418
#define SWP_NOMOVE
Definition: winuser.h:1229
static LRESULT CALLBACK llkbd_unicode_hook(int nCode, WPARAM wParam, LPARAM lParam)
Definition: input.c:1151
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:150
static LRESULT CALLBACK unicode_wnd_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: input.c:1125

Referenced by START_TEST().

◆ test_Input_whitebox()

static void test_Input_whitebox ( void  )
static

Definition at line 353 of file input.c.

354 {
355  MSG msg;
356  WNDCLASSA wclass;
358 
359  wclass.lpszClassName = "InputSysKeyTestClass";
360  wclass.style = CS_HREDRAW | CS_VREDRAW;
361  wclass.lpfnWndProc = WndProc;
362  wclass.hInstance = hInstance;
363  wclass.hIcon = LoadIconA( 0, (LPCSTR)IDI_APPLICATION );
364  wclass.hCursor = LoadCursorA( NULL, (LPCSTR)IDC_ARROW );
365  wclass.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 );
366  wclass.lpszMenuName = 0;
367  wclass.cbClsExtra = 0;
368  wclass.cbWndExtra = 0;
369  RegisterClassA( &wclass );
370  /* create the test window that will receive the keystrokes */
371  hWndTest = CreateWindowA( wclass.lpszClassName, "InputSysKeyTest",
372  WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, 100, 100,
373  NULL, NULL, hInstance, NULL);
374  assert( hWndTest );
379 
380  /* flush pending messages */
381  while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
382 
383  SetFocus( hWndTest );
386 }
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
static void TestSysKeys(HWND hWnd)
Definition: input.c:340
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