ReactOS  0.4.13-dev-563-g0561610
monitor.c File Reference
#include "wine/test.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
Include dependency graph for monitor.c:

Go to the source code of this file.

Classes

struct  vid_mode
 

Macros

#define GET_PROC(func)
 
#define vid_modes_cnt   (sizeof(vid_modes_test) / sizeof(vid_modes_test[0]))
 

Functions

static LONG (WINAPI *pChangeDisplaySettingsExA)(LPCSTR
 
static BOOL (WINAPI *pEnumDisplayDevicesA)(LPCSTR
 
static HMONITOR (WINAPI *pMonitorFromPoint)(POINT
 
static UINT32 UINT32 *static void init_function_pointers (void)
 
static BOOL CALLBACK monitor_enum_proc (HMONITOR hmon, HDC hdc, LPRECT lprc, LPARAM lparam)
 
static void test_enumdisplaydevices (void)
 
static void test_ChangeDisplaySettingsEx (void)
 
static void test_monitors (void)
 
static BOOL CALLBACK find_primary_mon (HMONITOR hmon, HDC hdc, LPRECT rc, LPARAM lp)
 
static void test_work_area (void)
 
static void test_display_config (void)
 
 START_TEST (monitor)
 

Variables

static HMODULE hdll
 
static LPDEVMODEA
 
static HWND
 
static DWORD
 
static LPVOID
 
static LPDEVMODEW
 
static LPDISPLAY_DEVICEA
 
static LPRECT
 
static MONITORENUMPROC
 
static LPARAM
 
static LPMONITORINFO
 
static const struct vid_mode vid_modes_test []
 

Macro Definition Documentation

◆ GET_PROC

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

◆ vid_modes_cnt

#define vid_modes_cnt   (sizeof(vid_modes_test) / sizeof(vid_modes_test[0]))

Definition at line 163 of file monitor.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pEnumDisplayDevicesA)
static

◆ find_primary_mon()

static BOOL CALLBACK find_primary_mon ( HMONITOR  hmon,
HDC  hdc,
LPRECT  rc,
LPARAM  lp 
)
static

Definition at line 471 of file monitor.c.

472 {
473  MONITORINFO mi;
474  BOOL ret;
475 
476  mi.cbSize = sizeof(mi);
477  ret = pGetMonitorInfoA(hmon, &mi);
478  ok(ret, "GetMonitorInfo failed\n");
479  if (mi.dwFlags & MONITORINFOF_PRIMARY)
480  {
481  *(HMONITOR *)lp = hmon;
482  return FALSE;
483  }
484  return TRUE;
485 }
#define TRUE
Definition: types.h:120
static MONITORINFO mi
Definition: win.c:7331
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
int ret
DWORD cbSize
Definition: winuser.h:3726
DWORD dwFlags
Definition: winuser.h:3729

Referenced by test_work_area().

◆ HMONITOR()

static HMONITOR ( WINAPI pMonitorFromPoint)
static

◆ init_function_pointers()

static UINT32 UINT32* static void init_function_pointers ( void  )
static

Definition at line 39 of file monitor.c.

40 {
41  hdll = GetModuleHandleA("user32.dll");
42 
43 #define GET_PROC(func) \
44  p ## func = (void*)GetProcAddress(hdll, #func); \
45  if(!p ## func) \
46  trace("GetProcAddress(%s) failed\n", #func);
47 
52  GET_PROC(GetDisplayConfigBufferSizes)
58 
59 #undef GET_PROC
60 }
LONG WINAPI ChangeDisplaySettingsExA(LPCSTR lpszDeviceName, LPDEVMODEA lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam)
Definition: display.c:521
HMONITOR WINAPI MonitorFromPoint(POINT, DWORD)
BOOL WINAPI EnumDisplayMonitors(_In_opt_ HDC, _In_opt_ LPCRECT, _In_ MONITORENUMPROC, _In_ LPARAM)
LONG WINAPI ChangeDisplaySettingsExW(LPCWSTR lpszDeviceName, LPDEVMODEW lpDevMode, HWND hwnd, DWORD dwflags, LPVOID lParam)
Definition: display.c:585
BOOL WINAPI EnumDisplayDevicesA(LPCSTR lpDevice, DWORD iDevNum, PDISPLAY_DEVICEA lpDisplayDevice, DWORD dwFlags)
Definition: display.c:23
BOOL WINAPI GetMonitorInfoW(_In_ HMONITOR, _Inout_ LPMONITORINFO)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
BOOL WINAPI GetMonitorInfoA(_In_ HMONITOR, _Inout_ LPMONITORINFO)
HMONITOR WINAPI MonitorFromWindow(HWND, DWORD)
HMONITOR WINAPI MonitorFromRect(LPCRECT, DWORD)
static HMODULE hdll
Definition: monitor.c:27
#define GET_PROC(func)

Referenced by START_TEST().

◆ LONG()

static LONG ( WINAPI pChangeDisplaySettingsExA)
static

◆ monitor_enum_proc()

static BOOL CALLBACK monitor_enum_proc ( HMONITOR  hmon,
HDC  hdc,
LPRECT  lprc,
LPARAM  lparam 
)
static

Definition at line 62 of file monitor.c.

64 {
66  char *primary = (char *)lparam;
67 
68  mi.cbSize = sizeof(mi);
69 
70  ok(pGetMonitorInfoA(hmon, (MONITORINFO*)&mi), "GetMonitorInfo failed\n");
71  if (mi.dwFlags & MONITORINFOF_PRIMARY)
72  strcpy(primary, mi.szDevice);
73 
74  return TRUE;
75 }
#define TRUE
Definition: types.h:120
static MONITORINFO mi
Definition: win.c:7331
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
#define ok(value,...)
DWORD cbSize
Definition: winuser.h:3726
DWORD dwFlags
Definition: winuser.h:3729
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Referenced by test_enumdisplaydevices().

◆ START_TEST()

START_TEST ( monitor  )

Definition at line 602 of file monitor.c.

603 {
607  test_monitors();
608  test_work_area();
610 }
static void test_work_area(void)
Definition: monitor.c:487
static void test_ChangeDisplaySettingsEx(void)
Definition: monitor.c:165
static UINT32 UINT32 *static void init_function_pointers(void)
Definition: monitor.c:39
static void test_monitors(void)
Definition: monitor.c:307
static void test_enumdisplaydevices(void)
Definition: monitor.c:77
static void test_display_config(void)
Definition: monitor.c:550

◆ test_ChangeDisplaySettingsEx()

static void test_ChangeDisplaySettingsEx ( void  )
static

Definition at line 165 of file monitor.c.

166 {
167  DEVMODEA dm;
168  DEVMODEW dmW;
169  DWORD width;
170  LONG res;
171  int i;
172 
173  if (!pChangeDisplaySettingsExA)
174  {
175  win_skip("ChangeDisplaySettingsExA is not available\n");
176  return;
177  }
178 
179  SetLastError(0xdeadbeef);
181  ok(res, "EnumDisplaySettings error %u\n", GetLastError());
182 
183  width = dm.dmPelsWidth;
184 
185  dm.dmDriverExtra = 1;
188  "ChangeDisplaySettingsA returned %d, expected DISP_CHANGE_SUCCESSFUL\n", res);
189  ok(dm.dmDriverExtra == 0 || broken(dm.dmDriverExtra == 1) /* win9x */,
190  "ChangeDisplaySettingsA didn't reset dmDriverExtra to 0\n");
191 
192  /* crashes under XP SP3 for large dmDriverExtra values */
193  dm.dmDriverExtra = 1;
194  res = pChangeDisplaySettingsExA(NULL, &dm, NULL, CDS_TEST, NULL);
196  "ChangeDisplaySettingsExW returned %d, expected DISP_CHANGE_SUCCESSFUL\n", res);
197  ok(dm.dmDriverExtra == 1, "ChangeDisplaySettingsExA shouldn't reset dmDriverExtra to 0\n");
198 
199  memset(&dmW, 0, sizeof(dmW));
200  dmW.dmSize = sizeof(dmW);
202  dmW.dmPelsWidth = dm.dmPelsWidth;
203  dmW.dmPelsHeight = dm.dmPelsHeight;
204  dmW.dmDriverExtra = 1;
205  SetLastError(0xdeadbeef);
208  {
210  "ChangeDisplaySettingsW returned %d, expected DISP_CHANGE_SUCCESSFUL\n", res);
211  ok(dmW.dmDriverExtra == 0, "ChangeDisplaySettingsW didn't reset dmDriverExtra to 0\n");
212  }
213 
214  /* Apparently XP treats dmDriverExtra being != 0 as an error */
215  dmW.dmDriverExtra = 1;
216  res = pChangeDisplaySettingsExW(NULL, &dmW, NULL, CDS_TEST, NULL);
218  {
220  "ChangeDisplaySettingsExW returned %d, expected DISP_CHANGE_SUCCESSFUL\n", res);
221  ok(dmW.dmDriverExtra == 1, "ChangeDisplaySettingsExW shouldn't reset dmDriverExtra to 0\n");
222  }
223 
224  /* the following 2 tests show that dm.dmSize being 0 is invalid, but
225  * ChangeDisplaySettingsExA still reports success.
226  */
227  memset(&dm, 0, sizeof(dm));
229  dm.dmPelsWidth = width;
230  res = pChangeDisplaySettingsExA(NULL, &dm, NULL, CDS_TEST, NULL);
232  res == DISP_CHANGE_BADMODE || /* Win98, WinMe */
233  res == DISP_CHANGE_FAILED, /* NT4 */
234  "ChangeDisplaySettingsExA returned unexpected %d\n", res);
235 
236  memset(&dmW, 0, sizeof(dmW));
238  dmW.dmPelsWidth = width;
239  SetLastError(0xdeadbeef);
240  res = pChangeDisplaySettingsExW(NULL, &dmW, NULL, CDS_TEST, NULL);
243  res == DISP_CHANGE_BADPARAM || /* NT4 */
244  res == DISP_CHANGE_BADMODE /* XP SP3 */,
245  "ChangeDisplaySettingsExW returned %d\n", res);
246 
247  memset(&dm, 0, sizeof(dm));
248  dm.dmSize = sizeof(dm);
249 
250  for (i = 0; i < vid_modes_cnt; i++)
251  {
252  dm.dmPelsWidth = vid_modes_test[i].w;
253  dm.dmPelsHeight = vid_modes_test[i].h;
254  dm.dmBitsPerPel = vid_modes_test[i].bpp;
256  dm.dmFields = vid_modes_test[i].fields;
257  res = pChangeDisplaySettingsExA(NULL, &dm, NULL, CDS_TEST, NULL);
258  ok(vid_modes_test[i].must_succeed ?
262  "Unexpected ChangeDisplaySettingsEx() return code for resolution[%d]: %d\n", i, res);
263 
265  {
266  RECT r, r1, virt;
267 
269  if (IsRectEmpty(&virt)) /* NT4 doesn't have SM_CX/YVIRTUALSCREEN */
272 
273  /* Resolution change resets clip rect */
274  ok(GetClipCursor(&r), "GetClipCursor() failed\n");
275  ok(EqualRect(&r, &virt), "Invalid clip rect: %s\n", wine_dbgstr_rect(&r));
276 
277  if (!ClipCursor(NULL)) continue;
278  ok(GetClipCursor(&r), "GetClipCursor() failed\n");
279  ok(EqualRect(&r, &virt), "Invalid clip rect: %s\n", wine_dbgstr_rect(&r));
280 
281  /* This should always work. Primary monitor is at (0,0) */
282  SetRect(&r1, 10, 10, 20, 20);
283  ok(ClipCursor(&r1), "ClipCursor() failed\n");
284  ok(GetClipCursor(&r), "GetClipCursor() failed\n");
285  ok(EqualRect(&r, &r1), "Invalid clip rect: %s\n", wine_dbgstr_rect(&r));
286  SetRect(&r1, 10, 10, 10, 10);
287  ok(ClipCursor(&r1), "ClipCursor() failed\n");
288  ok(GetClipCursor(&r), "GetClipCursor() failed\n");
289  ok(EqualRect(&r, &r1), "Invalid clip rect: %s\n", wine_dbgstr_rect(&r));
290  SetRect(&r1, 10, 10, 10, 9);
291  ok(!ClipCursor(&r1), "ClipCursor() succeeded\n");
292  /* Windows bug: further clipping fails once an empty rect is set, so we have to reset it */
293  ClipCursor(NULL);
294 
295  SetRect(&r1, virt.left - 10, virt.top - 10, virt.right + 20, virt.bottom + 20);
296  ok(ClipCursor(&r1), "ClipCursor() failed\n");
297  ok(GetClipCursor(&r), "GetClipCursor() failed\n");
298  ok(EqualRect(&r, &virt) || broken(EqualRect(&r, &r1)) /* win9x */,
299  "Invalid clip rect: %s\n", wine_dbgstr_rect(&r));
300  ClipCursor(&virt);
301  }
302  }
303  res = pChangeDisplaySettingsExA(NULL, NULL, NULL, CDS_RESET, NULL);
304  ok(res == DISP_CHANGE_SUCCESSFUL, "Failed to reset default resolution: %d\n", res);
305 }
LONG WINAPI ChangeDisplaySettingsW(LPDEVMODEW lpDevMode, DWORD dwflags)
Definition: display.c:612
GLint GLint GLsizei width
Definition: gl.h:1546
#define SM_XVIRTUALSCREEN
Definition: winuser.h:1026
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define DISP_CHANGE_RESTART
Definition: winuser.h:191
DWORD dmFields
Definition: wingdi.h:1600
BOOL WINAPI ClipCursor(_In_opt_ LPCRECT)
WORD dmSize
Definition: wingdi.h:1546
#define SM_CXVIRTUALSCREEN
Definition: winuser.h:1028
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
DWORD dmDisplayFrequency
Definition: wingdi.h:1580
WORD dmDriverExtra
Definition: wingdi.h:1547
static DNS_RECORDW r1
Definition: record.c:37
#define DISP_CHANGE_BADMODE
Definition: winuser.h:195
LONG top
Definition: windef.h:292
WORD dmDriverExtra
Definition: wingdi.h:1599
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
#define ENUM_CURRENT_SETTINGS
Definition: winuser.h:179
#define CDS_RESET
Definition: winuser.h:187
static const struct vid_mode vid_modes_test[]
Definition: monitor.c:143
#define DM_PELSWIDTH
Definition: wingdi.h:1251
BOOL WINAPI GetClipCursor(_Out_ LPRECT)
#define SM_CXSCREEN
Definition: winuser.h:949
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
long LONG
Definition: pedump.c:60
#define ok(value,...)
#define DISP_CHANGE_BADPARAM
Definition: winuser.h:193
#define DISP_CHANGE_FAILED
Definition: winuser.h:194
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
smooth NULL
Definition: ftsmooth.c:416
#define SM_CYVIRTUALSCREEN
Definition: winuser.h:1029
#define SM_CYSCREEN
Definition: winuser.h:950
#define vid_modes_cnt
Definition: monitor.c:163
BOOL WINAPI EnumDisplaySettingsA(LPCSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEA lpDevMode)
Definition: display.c:312
WORD dmSize
Definition: wingdi.h:1598
#define DISP_CHANGE_SUCCESSFUL
Definition: winuser.h:190
const char * wine_dbgstr_rect(const RECT *rect)
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
DWORD dmPelsHeight
Definition: wingdi.h:1575
DWORD dmPelsWidth
Definition: wingdi.h:1626
DWORD dmFields
Definition: wingdi.h:1548
#define broken(x)
Definition: _sntprintf.h:21
#define SM_YVIRTUALSCREEN
Definition: winuser.h:1027
DWORD dmBitsPerPel
Definition: wingdi.h:1573
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
#define DM_PELSHEIGHT
Definition: wingdi.h:1252
DWORD dmPelsHeight
Definition: wingdi.h:1627
GLuint res
Definition: glext.h:9613
LONG WINAPI ChangeDisplaySettingsA(LPDEVMODEA lpDevMode, DWORD dwflags)
Definition: display.c:570
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
LONG bottom
Definition: windef.h:294
#define CDS_TEST
Definition: winuser.h:182
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:141
DWORD dmPelsWidth
Definition: wingdi.h:1574

Referenced by START_TEST().

◆ test_display_config()

static void test_display_config ( void  )
static

Definition at line 550 of file monitor.c.

551 {
552  UINT32 paths, modes;
553  LONG ret;
554 
555  if (!pGetDisplayConfigBufferSizes)
556  {
557  win_skip("GetDisplayConfigBufferSizes is not supported\n");
558  return;
559  }
560 
561  ret = pGetDisplayConfigBufferSizes(QDC_ALL_PATHS, NULL, NULL);
562  ok(ret == ERROR_INVALID_PARAMETER, "got %d\n", ret);
563 
564  paths = 100;
565  ret = pGetDisplayConfigBufferSizes(QDC_ALL_PATHS, &paths, NULL);
566  ok(ret == ERROR_INVALID_PARAMETER, "got %d\n", ret);
567  ok(paths == 100, "got %u\n", paths);
568 
569  modes = 100;
570  ret = pGetDisplayConfigBufferSizes(QDC_ALL_PATHS, NULL, &modes);
571  ok(ret == ERROR_INVALID_PARAMETER, "got %d\n", ret);
572  ok(modes == 100, "got %u\n", modes);
573 
574  paths = modes = 0;
575  ret = pGetDisplayConfigBufferSizes(QDC_ALL_PATHS, &paths, &modes);
576  if (!ret)
577  ok(paths > 0 && modes > 0, "got %u, %u\n", paths, modes);
578  else
579  ok(ret == ERROR_NOT_SUPPORTED, "got %d\n", ret);
580 
581  /* Invalid flags, non-zero invalid flags validation is version (or driver?) dependent,
582  it's unreliable to use in tests. */
583  ret = pGetDisplayConfigBufferSizes(0, NULL, NULL);
584  ok(ret == ERROR_INVALID_PARAMETER, "got %d\n", ret);
585 
586  paths = 100;
587  ret = pGetDisplayConfigBufferSizes(0, &paths, NULL);
588  ok(ret == ERROR_INVALID_PARAMETER, "got %d\n", ret);
589  ok(paths == 100, "got %u\n", paths);
590 
591  modes = 100;
592  ret = pGetDisplayConfigBufferSizes(0, NULL, &modes);
593  ok(ret == ERROR_INVALID_PARAMETER, "got %d\n", ret);
594  ok(modes == 100, "got %u\n", modes);
595 
596  paths = modes = 100;
597  ret = pGetDisplayConfigBufferSizes(0, &paths, &modes);
598  ok(ret == ERROR_INVALID_PARAMETER || ret == ERROR_NOT_SUPPORTED, "got %d\n", ret);
599  ok(modes == 0 && paths == 0, "got %u, %u\n", modes, paths);
600 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define QDC_ALL_PATHS
Definition: wingdi.h:1265
unsigned int UINT32
long LONG
Definition: pedump.c:60
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
int ret
GLsizei const GLuint * paths
Definition: glext.h:11717
#define ERROR_NOT_SUPPORTED
Definition: compat.h:90
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_enumdisplaydevices()

static void test_enumdisplaydevices ( void  )
static

Definition at line 77 of file monitor.c.

78 {
79  DISPLAY_DEVICEA dd;
80  char primary_device_name[32];
81  char primary_monitor_device_name[32];
82  DWORD primary_num = -1, num = 0;
83  BOOL ret;
84 
85  if (!pEnumDisplayDevicesA)
86  {
87  win_skip("EnumDisplayDevicesA is not available\n");
88  return;
89  }
90 
91  dd.cb = sizeof(dd);
92  for (num = 0;; num++)
93  {
94  HDC dc;
95  ret = pEnumDisplayDevicesA(NULL, num, &dd, 0);
96  if(!ret) break;
97 
99  {
100  strcpy(primary_device_name, dd.DeviceName);
101  primary_num = num;
102  }
104  {
105  /* test creating DC */
106  dc = CreateDCA(dd.DeviceName, NULL, NULL, NULL);
107  ok(dc != NULL, "Failed to CreateDC(\"%s\") err=%d\n", dd.DeviceName, GetLastError());
108  DeleteDC(dc);
109  }
110  }
111 
112  if (primary_num == -1 || !pEnumDisplayMonitors || !pGetMonitorInfoA)
113  {
114  win_skip("EnumDisplayMonitors or GetMonitorInfoA are not available\n");
115  return;
116  }
117 
118  primary_monitor_device_name[0] = 0;
119  ret = pEnumDisplayMonitors(NULL, NULL, monitor_enum_proc, (LPARAM)primary_monitor_device_name);
120  ok(ret, "EnumDisplayMonitors failed\n");
121  ok(!strcmp(primary_monitor_device_name, primary_device_name),
122  "monitor device name %s, device name %s\n", primary_monitor_device_name,
123  primary_device_name);
124 
125  dd.cb = sizeof(dd);
126  for (num = 0;; num++)
127  {
128  ret = pEnumDisplayDevicesA(primary_device_name, num, &dd, 0);
129  if (!ret) break;
130 
131  dd.DeviceID[63] = 0;
132  ok(!strcasecmp(dd.DeviceID, "Monitor\\Default_Monitor\\{4D36E96E-E325-11CE-BFC1-08002BE10318}\\"),
133  "DeviceID \"%s\" does not start with \"Monitor\\Default_Monitor\\...\" prefix\n", dd.DeviceID);
134  }
135 }
#define strcasecmp
Definition: fake.h:9
static HDC
Definition: imagelist.c:92
static BOOL CALLBACK monitor_enum_proc(HMONITOR hmon, HDC hdc, LPRECT lprc, LPARAM lparam)
Definition: monitor.c:62
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
CHAR DeviceName[32]
Definition: wingdi.h:2788
HDC dc
Definition: cylfrac.c:34
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define DISPLAY_DEVICE_PRIMARY_DEVICE
Definition: wingdi.h:1380
#define DISPLAY_DEVICE_ATTACHED_TO_DESKTOP
Definition: wingdi.h:1378
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint num
Definition: glext.h:9618
int ret
DWORD StateFlags
Definition: wingdi.h:2790
BOOL WINAPI DeleteDC(_In_ HDC)
CHAR DeviceID[128]
Definition: wingdi.h:2791
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
HDC WINAPI CreateDCA(_In_opt_ LPCSTR pszDriver, _In_opt_ LPCSTR pszDevice, _In_opt_ LPCSTR pszOutput, _In_opt_ const DEVMODEA *pdmInit)
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_monitors()

static void test_monitors ( void  )
static

Definition at line 307 of file monitor.c.

308 {
309  HMONITOR monitor, primary, nearest;
310  POINT pt;
311  RECT rc;
312  MONITORINFO mi;
313  MONITORINFOEXA miexa;
314  MONITORINFOEXW miexw;
315  BOOL ret;
316  DWORD i;
317 
318  static const struct
319  {
320  DWORD cbSize;
321  BOOL ret;
322  } testdatami[] = {
323  {0, FALSE},
324  {sizeof(MONITORINFO)+1, FALSE},
325  {sizeof(MONITORINFO)-1, FALSE},
326  {sizeof(MONITORINFO), TRUE},
327  {-1, FALSE},
328  {0xdeadbeef, FALSE},
329  },
330  testdatamiexa[] = {
331  {0, FALSE},
332  {sizeof(MONITORINFOEXA)+1, FALSE},
333  {sizeof(MONITORINFOEXA)-1, FALSE},
334  {sizeof(MONITORINFOEXA), TRUE},
335  {-1, FALSE},
336  {0xdeadbeef, FALSE},
337  },
338  testdatamiexw[] = {
339  {0, FALSE},
340  {sizeof(MONITORINFOEXW)+1, FALSE},
341  {sizeof(MONITORINFOEXW)-1, FALSE},
342  {sizeof(MONITORINFOEXW), TRUE},
343  {-1, FALSE},
344  {0xdeadbeef, FALSE},
345  };
346 
347  if (!pMonitorFromPoint || !pMonitorFromWindow || !pMonitorFromRect)
348  {
349  win_skip("MonitorFromPoint, MonitorFromWindow, or MonitorFromRect is not available\n");
350  return;
351  }
352 
353  pt.x = pt.y = 0;
354  primary = pMonitorFromPoint( pt, MONITOR_DEFAULTTOPRIMARY );
355  ok( primary != 0, "couldn't get primary monitor\n" );
356 
357  monitor = pMonitorFromWindow( 0, MONITOR_DEFAULTTONULL );
358  ok( !monitor, "got %p, should not get a monitor for an invalid window\n", monitor );
359  monitor = pMonitorFromWindow( 0, MONITOR_DEFAULTTOPRIMARY );
360  ok( monitor == primary, "got %p, should get primary %p for MONITOR_DEFAULTTOPRIMARY\n", monitor, primary );
361  monitor = pMonitorFromWindow( 0, MONITOR_DEFAULTTONEAREST );
362  ok( monitor == primary, "got %p, should get primary %p for MONITOR_DEFAULTTONEAREST\n", monitor, primary );
363 
364  SetRect( &rc, 0, 0, 1, 1 );
365  monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
366  ok( monitor == primary, "got %p, should get primary %p\n", monitor, primary );
367 
368  monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTOPRIMARY );
369  ok( monitor == primary, "got %p, should get primary %p\n", monitor, primary );
370 
371  monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONEAREST );
372  ok( monitor == primary, "got %p, should get primary %p\n", monitor, primary );
373 
374  /* Empty rect at 0,0 is considered inside the primary monitor */
375  SetRect( &rc, 0, 0, -1, -1 );
376  monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
377  ok( monitor == primary, "got %p, should get primary %p\n", monitor, primary );
378 
379  /* Even if there is a monitor left of the primary, the primary will have the most overlapping area */
380  SetRect( &rc, -1, 0, 2, 1 );
381  monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
382  ok( monitor == primary, "got %p, should get primary %p\n", monitor, primary );
383 
384  /* But the width of the rect doesn't matter if it's empty. */
385  SetRect( &rc, -1, 0, 2, -1 );
386  monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
387  ok( monitor != primary, "got primary %p\n", monitor );
388 
389  if (!pGetMonitorInfoA)
390  {
391  win_skip("GetMonitorInfoA is not available\n");
392  return;
393  }
394 
395  /* Search for a monitor that has no others equally near to (left, top-1) */
396  SetRect( &rc, -1, -2, 2, 0 );
397  monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
398  nearest = primary;
399  while (monitor != NULL)
400  {
401  ok( monitor != primary, "got primary %p\n", monitor );
402  nearest = monitor;
403  mi.cbSize = sizeof(mi);
404  ret = pGetMonitorInfoA( monitor, &mi );
405  ok( ret, "GetMonitorInfo failed\n" );
407  monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
408  }
409 
410  /* tests for cbSize in MONITORINFO */
411  monitor = pMonitorFromWindow( 0, MONITOR_DEFAULTTOPRIMARY );
412  for (i = 0; i < (sizeof(testdatami) / sizeof(testdatami[0])); i++)
413  {
414  memset( &mi, 0, sizeof(mi) );
415  mi.cbSize = testdatami[i].cbSize;
416  ret = pGetMonitorInfoA( monitor, &mi );
417  ok( ret == testdatami[i].ret, "GetMonitorInfo returned wrong value\n" );
418  if (ret)
419  ok( (mi.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag isn't set\n" );
420  else
421  ok( !(mi.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag is set\n" );
422 
423  memset( &miexw, 0, sizeof(miexw) );
424  miexw.cbSize = testdatamiexw[i].cbSize;
425  ret = pGetMonitorInfoW( monitor, (LPMONITORINFO)&miexw );
426  ok( ret == testdatamiexw[i].ret, "GetMonitorInfo returned wrong value\n" );
427  if (ret)
428  ok( (miexw.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag isn't set\n" );
429  else
430  ok( !(miexw.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag is set\n" );
431  }
432 
433  /* tests for cbSize in MONITORINFOEXA */
434  for (i = 0; i < (sizeof(testdatamiexa) / sizeof(testdatamiexa[0])); i++)
435  {
436  memset( &miexa, 0, sizeof(miexa) );
437  miexa.cbSize = testdatamiexa[i].cbSize;
438  ret = pGetMonitorInfoA( monitor, (LPMONITORINFO)&miexa );
439  ok( ret == testdatamiexa[i].ret, "GetMonitorInfo returned wrong value\n" );
440  if (ret)
441  ok( (miexa.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag isn't set\n" );
442  else
443  ok( !(miexa.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag is set\n" );
444  }
445 
446  /* tests for cbSize in MONITORINFOEXW */
447  for (i = 0; i < (sizeof(testdatamiexw) / sizeof(testdatamiexw[0])); i++)
448  {
449  memset( &miexw, 0, sizeof(miexw) );
450  miexw.cbSize = testdatamiexw[i].cbSize;
451  ret = pGetMonitorInfoW( monitor, (LPMONITORINFO)&miexw );
452  ok( ret == testdatamiexw[i].ret, "GetMonitorInfo returned wrong value\n" );
453  if (ret)
454  ok( (miexw.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag isn't set\n" );
455  else
456  ok( !(miexw.dwFlags & MONITORINFOF_PRIMARY), "MONITORINFOF_PRIMARY flag is set\n" );
457  }
458 
459  SetRect( &rc, rc.left+1, rc.top+1, rc.left+2, rc.top+2 );
460 
461  monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL );
462  ok( monitor == NULL, "got %p\n", monitor );
463 
464  monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTOPRIMARY );
465  ok( monitor == primary, "got %p, should get primary %p\n", monitor, primary );
466 
467  monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONEAREST );
468  ok( monitor == nearest, "got %p, should get nearest %p\n", monitor, nearest );
469 }
#define TRUE
Definition: types.h:120
#define pt(x, y)
Definition: drawing.c:79
LONG top
Definition: windef.h:292
static MONITORINFO mi
Definition: win.c:7331
LONG left
Definition: windef.h:291
RECT rcMonitor
Definition: winuser.h:3727
struct tagMONITORINFOEXA MONITORINFOEXA
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
struct tagMONITORINFOEXW MONITORINFOEXW
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
struct tagMONITORINFO MONITORINFO
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
DWORD cbSize
Definition: winuser.h:3726
DWORD dwFlags
Definition: winuser.h:3729
#define memset(x, y, z)
Definition: compat.h:39
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

◆ test_work_area()

static void test_work_area ( void  )
static

Definition at line 487 of file monitor.c.

488 {
489  HMONITOR hmon;
490  MONITORINFO mi;
491  RECT rc_work, rc_normal;
492  HWND hwnd;
493  WINDOWPLACEMENT wp;
494  BOOL ret;
495 
496  if (!pEnumDisplayMonitors || !pGetMonitorInfoA)
497  {
498  win_skip("EnumDisplayMonitors or GetMonitorInfoA are not available\n");
499  return;
500  }
501 
502  hmon = 0;
503  ret = pEnumDisplayMonitors(NULL, NULL, find_primary_mon, (LPARAM)&hmon);
504  ok(!ret && hmon != 0, "Failed to find primary monitor\n");
505 
506  mi.cbSize = sizeof(mi);
507  SetLastError(0xdeadbeef);
508  ret = pGetMonitorInfoA(hmon, &mi);
509  ok(ret, "GetMonitorInfo error %u\n", GetLastError());
510  ok(mi.dwFlags & MONITORINFOF_PRIMARY, "not a primary monitor\n");
511  trace("primary monitor %s\n", wine_dbgstr_rect(&mi.rcMonitor));
512 
513  SetLastError(0xdeadbeef);
514  ret = SystemParametersInfoA(SPI_GETWORKAREA, 0, &rc_work, 0);
515  ok(ret, "SystemParametersInfo error %u\n", GetLastError());
516  trace("work area %s\n", wine_dbgstr_rect(&rc_work));
517  ok(EqualRect(&rc_work, &mi.rcWork), "work area is different\n");
518 
519  hwnd = CreateWindowExA(0, "static", NULL, WS_OVERLAPPEDWINDOW|WS_VISIBLE,100,100,10,10,0,0,0,NULL);
520  ok(hwnd != 0, "CreateWindowEx failed\n");
521 
522  ret = GetWindowRect(hwnd, &rc_normal);
523  ok(ret, "GetWindowRect failed\n");
524  trace("normal %s\n", wine_dbgstr_rect(&rc_normal));
525 
526  wp.length = sizeof(wp);
527  ret = GetWindowPlacement(hwnd, &wp);
528  ok(ret, "GetWindowPlacement failed\n");
529  trace("min: %d,%d max %d,%d normal %s\n", wp.ptMinPosition.x, wp.ptMinPosition.y,
531  OffsetRect(&wp.rcNormalPosition, rc_work.left, rc_work.top);
533  mi.rcMonitor.top != mi.rcWork.top) /* FIXME: remove once Wine is fixed */
534  {
535  ok(EqualRect(&rc_normal, &wp.rcNormalPosition), "normal pos is different\n");
536  }
537 
539 
540  wp.length = sizeof(wp);
541  ret = GetWindowPlacement(hwnd, &wp);
542  ok(ret, "GetWindowPlacement failed\n");
543  trace("min: %d,%d max %d,%d normal %s\n", wp.ptMinPosition.x, wp.ptMinPosition.y,
545  ok(EqualRect(&rc_normal, &wp.rcNormalPosition), "normal pos is different\n");
546 
548 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define trace(...)
Definition: kmt_test.h:217
long y
Definition: polytest.cpp:48
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
long x
Definition: polytest.cpp:48
LONG top
Definition: windef.h:292
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define GWL_EXSTYLE
Definition: winuser.h:845
static MONITORINFO mi
Definition: win.c:7331
LONG left
Definition: windef.h:291
RECT rcMonitor
Definition: winuser.h:3727
BOOL WINAPI DestroyWindow(_In_ HWND)
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
BOOL WINAPI SystemParametersInfoA(_In_ UINT, _In_ UINT, _Inout_opt_ PVOID, _In_ UINT)
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI GetWindowPlacement(_In_ HWND, _Inout_ WINDOWPLACEMENT *)
#define todo_wine_if(is_todo)
Definition: test.h:155
const char * wine_dbgstr_rect(const RECT *rect)
#define SetLastError(x)
Definition: compat.h:409
static BOOL CALLBACK find_primary_mon(HMONITOR hmon, HDC hdc, LPRECT rc, LPARAM lp)
Definition: monitor.c:471
int ret
POINT ptMinPosition
Definition: winuser.h:3235
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
POINT ptMaxPosition
Definition: winuser.h:3236
DWORD cbSize
Definition: winuser.h:3726
LONG WINAPI SetWindowLongA(_In_ HWND, _In_ int, _In_ LONG)
DWORD dwFlags
Definition: winuser.h:3729
RECT rcNormalPosition
Definition: winuser.h:3237
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
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define WS_VISIBLE
Definition: pedump.c:620
#define win_skip
Definition: test.h:141

Referenced by START_TEST().

Variable Documentation

◆ DWORD

Definition at line 28 of file monitor.c.

◆ hdll

HMODULE hdll
static

Definition at line 27 of file monitor.c.

Referenced by init_function_pointers().

◆ HWND

Definition at line 28 of file monitor.c.

◆ LPARAM

Definition at line 31 of file monitor.c.

◆ LPDEVMODEA

Definition at line 28 of file monitor.c.

◆ LPDEVMODEW

Definition at line 29 of file monitor.c.

◆ LPDISPLAY_DEVICEA

Definition at line 30 of file monitor.c.

◆ LPMONITORINFO

Definition at line 32 of file monitor.c.

◆ LPRECT

Definition at line 31 of file monitor.c.

◆ LPVOID

Definition at line 28 of file monitor.c.

◆ MONITORENUMPROC

MONITORENUMPROC

Definition at line 31 of file monitor.c.

◆ vid_modes_test

const struct vid_mode vid_modes_test[]
static
Initial value:
= {
{640, 480, 0, 0, DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL , 0},
{640, 480, 0, 0, DM_PELSWIDTH | DM_PELSHEIGHT , 1},
{640, 480, 0, 0, DM_BITSPERPEL , 0},
{640, 480, 0, 0, DM_DISPLAYFREQUENCY, 0},
{0, 0, 0, 0, DM_PELSWIDTH, 0},
{0, 0, 0, 0, DM_PELSHEIGHT, 0},
{640, 480, 0, 0, DM_PELSWIDTH, 0},
{640, 480, 0, 0, DM_PELSHEIGHT, 0},
{ 0, 480, 0, 0, DM_PELSWIDTH | DM_PELSHEIGHT, 0},
{640, 0, 0, 0, DM_PELSWIDTH | DM_PELSHEIGHT, 0},
}
#define DM_PELSWIDTH
Definition: wingdi.h:1251
#define DM_DISPLAYFREQUENCY
Definition: wingdi.h:1254
#define DM_PELSHEIGHT
Definition: wingdi.h:1252
#define DM_BITSPERPEL
Definition: wingdi.h:1250

Definition at line 143 of file monitor.c.

Referenced by test_ChangeDisplaySettingsEx().