Commit 31867340 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

win32u: Move NtUserEnumDisplayMonitors implementation from user32.

parent 45dcaf02
......@@ -269,11 +269,6 @@ static LONG CDECL loaderdrv_ChangeDisplaySettingsEx( LPCWSTR name, LPDEVMODEW mo
return load_driver()->pChangeDisplaySettingsEx( name, mode, hwnd, flags, lparam );
}
static BOOL CDECL loaderdrv_EnumDisplayMonitors( HDC hdc, LPRECT rect, MONITORENUMPROC proc, LPARAM lp )
{
return load_driver()->pEnumDisplayMonitors( hdc, rect, proc, lp );
}
static BOOL CDECL loaderdrv_CreateDesktopWindow( HWND hwnd )
{
return load_driver()->pCreateDesktopWindow( hwnd );
......@@ -334,7 +329,6 @@ static struct user_driver_funcs lazy_load_driver =
loaderdrv_UpdateClipboard,
/* display modes */
loaderdrv_ChangeDisplaySettingsEx,
loaderdrv_EnumDisplayMonitors,
NULL,
NULL,
/* windowing functions */
......@@ -379,13 +373,6 @@ void CDECL __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT v
driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver) );
*driver = *funcs;
#define SET_USER_FUNC(name) \
do { if (!driver->p##name) driver->p##name = nulldrv_##name; } while(0)
SET_USER_FUNC(EnumDisplayMonitors);
#undef SET_USER_FUNC
prev = InterlockedCompareExchangePointer( (void **)&USER_Driver, driver, &lazy_load_driver );
if (prev != &lazy_load_driver)
{
......
......@@ -214,11 +214,19 @@ static void dpiaware_init(void)
}
static const void *kernel_callback_table[] =
{
User32CallEnumDisplayMonitor,
};
/***********************************************************************
* USER initialisation routine
*/
static BOOL process_attach(void)
{
NtCurrentTeb()->Peb->KernelCallbackTable = kernel_callback_table;
dpiaware_init();
register_desktop_class();
......
......@@ -66,8 +66,6 @@ extern const struct user_driver_funcs *USER_Driver DECLSPEC_HIDDEN;
extern void USER_unload_driver(void) DECLSPEC_HIDDEN;
extern BOOL CDECL nulldrv_EnumDisplayMonitors( HDC hdc, RECT *rect, MONITORENUMPROC proc, LPARAM lp ) DECLSPEC_HIDDEN;
struct received_message_info;
enum user_obj_type
......@@ -219,6 +217,10 @@ extern BOOL WINPROC_call_window( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
extern const WCHAR *CLASS_GetVersionedName(const WCHAR *classname, UINT *basename_offset,
WCHAR *combined, BOOL register_class) DECLSPEC_HIDDEN;
/* kernel callbacks */
BOOL WINAPI User32CallEnumDisplayMonitor( struct enum_display_monitor_params *params, ULONG size );
/* message spy definitions */
#define SPY_DISPATCHMESSAGE 0x0100
......
......@@ -807,17 +807,11 @@ static void CDECL nulldrv_UpdateClipboard(void)
}
static LONG CDECL nulldrv_ChangeDisplaySettingsEx( LPCWSTR name, LPDEVMODEW mode, HWND hwnd,
DWORD flags, LPVOID lparam )
DWORD flags, LPVOID lparam )
{
return DISP_CHANGE_FAILED;
}
static BOOL CDECL nulldrv_EnumDisplayMonitors( HDC hdc, RECT *rect, MONITORENUMPROC proc, LPARAM lp )
{
/* FIXME: move from user32 */
return FALSE;
}
static BOOL CDECL nulldrv_EnumDisplaySettingsEx( LPCWSTR name, DWORD num, LPDEVMODEW mode, DWORD flags )
{
return FALSE;
......@@ -1099,7 +1093,6 @@ void CDECL __wine_set_display_driver( struct user_driver_funcs *driver, UINT ver
SET_USER_FUNC(ClipCursor);
SET_USER_FUNC(UpdateClipboard);
SET_USER_FUNC(ChangeDisplaySettingsEx);
SET_USER_FUNC(EnumDisplayMonitors);
SET_USER_FUNC(EnumDisplaySettingsEx);
SET_USER_FUNC(UpdateDisplayDevices);
SET_USER_FUNC(CreateDesktopWindow);
......
......@@ -1171,6 +1171,7 @@ static struct unix_funcs unix_funcs =
NtUserCallTwoParam,
NtUserCountClipboardFormats,
NtUserEnumDisplayDevices,
NtUserEnumDisplayMonitors,
NtUserEnumDisplaySettings,
NtUserGetDisplayConfigBufferSizes,
NtUserGetKeyNameText,
......
......@@ -1320,6 +1320,77 @@ BOOL WINAPI NtUserEnumDisplaySettings( UNICODE_STRING *device, DWORD mode,
return ret;
}
struct monitor_enum_info
{
HANDLE handle;
RECT rect;
};
/***********************************************************************
* NtUserEnumDisplayMonitors (win32u.@)
*/
BOOL WINAPI NtUserEnumDisplayMonitors( HDC hdc, RECT *rect, MONITORENUMPROC proc, LPARAM lparam )
{
struct monitor_enum_info enum_buf[8], *enum_info = enum_buf;
struct enum_display_monitor_params params;
struct monitor *monitor;
ULONG count = 0, i;
USEROBJECTFLAGS flags;
HWINSTA winstation;
BOOL ret = TRUE;
/* Report physical monitor information only if window station has visible display surfaces */
winstation = NtUserGetProcessWindowStation();
if (NtUserGetObjectInformation( winstation, UOI_FLAGS, &flags, sizeof(flags), NULL ) &&
(flags.dwFlags & WSF_VISIBLE))
{
if (!lock_display_devices()) return FALSE;
count = list_count( &monitors );
if (!count || (count > ARRAYSIZE(enum_buf) &&
!(enum_info = malloc( count * sizeof(*enum_info) ))))
{
unlock_display_devices();
return FALSE;
}
count = 0;
LIST_FOR_EACH_ENTRY(monitor, &monitors, struct monitor, entry)
{
if (!(monitor->dev.state_flags & DISPLAY_DEVICE_ACTIVE)) continue;
enum_info[count].handle = monitor->handle;
enum_info[count].rect = monitor->rc_monitor;
count++;
}
unlock_display_devices();
if (!count) return FALSE;
}
else
{
if (!(enum_info = malloc( sizeof(*enum_info) ))) return FALSE;
enum_info->handle = NULLDRV_DEFAULT_HMONITOR;
SetRect( &enum_info->rect, 0, 0, 1024, 768 );
count = 1;
}
params.proc = proc;
params.hdc = hdc;
params.lparam = lparam;
for (i = 0; i < count; i++)
{
params.monitor = enum_info[i].handle;
params.rect = enum_info[i].rect;
if (!user32_call( NtUserCallEnumDisplayMonitor, &params, sizeof(params) ))
{
ret = FALSE;
break;
}
}
if (enum_info != enum_buf) free( enum_info );
return ret;
}
static BOOL get_monitor_info( HMONITOR handle, MONITORINFO *info )
{
struct monitor *monitor;
......
......@@ -876,7 +876,7 @@
@ stub NtUserEndMenu
@ stub NtUserEndPaint
@ stdcall NtUserEnumDisplayDevices(ptr long ptr long)
@ stub NtUserEnumDisplayMonitors
@ stdcall NtUserEnumDisplayMonitors(long ptr ptr long)
@ stdcall NtUserEnumDisplaySettings(ptr long ptr long)
@ stub NtUserEvent
@ stub NtUserExcludeUpdateRgn
......@@ -1330,7 +1330,7 @@
@ cdecl __wine_set_visible_region(long long ptr ptr ptr)
# Graphics drivers
@ cdecl __wine_set_display_driver(long)
@ cdecl __wine_set_display_driver(ptr long)
# OpenGL
@ cdecl __wine_get_wgl_driver(long long)
......
......@@ -200,6 +200,7 @@ struct unix_funcs
INT (WINAPI *pNtUserCountClipboardFormats)(void);
BOOL (WINAPI *pNtUserEnumDisplayDevices)( UNICODE_STRING *device, DWORD index,
DISPLAY_DEVICEW *info, DWORD flags );
BOOL (WINAPI *pNtUserEnumDisplayMonitors)( HDC hdc, RECT *rect, MONITORENUMPROC proc, LPARAM lp );
BOOL (WINAPI *pNtUserEnumDisplaySettings)( UNICODE_STRING *device, DWORD mode,
DEVMODEW *dev_mode, DWORD flags );
LONG (WINAPI *pNtUserGetDisplayConfigBufferSizes)( UINT32 flags, UINT32 *num_path_info,
......@@ -266,6 +267,13 @@ static inline struct user_thread_info *get_user_thread_info(void)
extern const struct user_driver_funcs *user_driver DECLSPEC_HIDDEN;
static inline NTSTATUS user32_call( ULONG id, void *args, ULONG len )
{
/* FIXME: use KeUserModeCallback instead */
NTSTATUS (WINAPI *func)(void *, ULONG) = ((void **)NtCurrentTeb()->Peb->KernelCallbackTable)[id];
return func( args, len );
}
static inline BOOL set_ntstatus( NTSTATUS status )
{
if (status) SetLastError( RtlNtStatusToDosError( status ));
......
......@@ -617,6 +617,11 @@ BOOL WINAPI NtUserEnumDisplayDevices( UNICODE_STRING *device, DWORD index,
return unix_funcs->pNtUserEnumDisplayDevices( device, index, info, flags );
}
BOOL WINAPI NtUserEnumDisplayMonitors( HDC hdc, RECT *rect, MONITORENUMPROC proc, LPARAM lp )
{
return unix_funcs->pNtUserEnumDisplayMonitors( hdc, rect, proc, lp );
}
BOOL WINAPI NtUserEnumDisplaySettings( UNICODE_STRING *device, DWORD mode,
DEVMODEW *dev_mode, DWORD flags )
{
......
......@@ -23,6 +23,22 @@
#include <wingdi.h>
#include <winternl.h>
/* KernelCallbackTable codes, not compatible with Windows */
enum
{
NtUserCallEnumDisplayMonitor,
};
/* NtUserCallEnumDisplayMonitor params */
struct enum_display_monitor_params
{
MONITORENUMPROC proc;
HMONITOR monitor;
HDC hdc;
RECT rect;
LPARAM lparam;
};
/* NtUserCallTwoParam codes, not compatible with Windows */
enum
{
......@@ -73,6 +89,7 @@ HWINSTA WINAPI NtUserCreateWindowStation( OBJECT_ATTRIBUTES *attr, ACCESS_MASK m
ULONG arg4, ULONG arg5, ULONG arg6, ULONG arg7 );
BOOL WINAPI NtUserEnumDisplayDevices( UNICODE_STRING *device, DWORD index,
DISPLAY_DEVICEW *info, DWORD flags );
BOOL WINAPI NtUserEnumDisplayMonitors( HDC hdc, RECT *rect, MONITORENUMPROC proc, LPARAM lp );
BOOL WINAPI NtUserEnumDisplaySettings( UNICODE_STRING *device, DWORD mode,
DEVMODEW *dev_mode, DWORD flags );
INT WINAPI NtUserGetClipboardFormatName( UINT format, WCHAR *buffer, INT maxlen );
......
......@@ -167,7 +167,7 @@ struct gdi_dc_funcs
};
/* increment this when you change the DC function table */
#define WINE_GDI_DRIVER_VERSION 72
#define WINE_GDI_DRIVER_VERSION 73
#define GDI_PRIORITY_NULL_DRV 0 /* null driver */
#define GDI_PRIORITY_FONT_DRV 100 /* any font driver */
......@@ -291,7 +291,6 @@ struct user_driver_funcs
void (CDECL *pUpdateClipboard)(void);
/* display modes */
LONG (CDECL *pChangeDisplaySettingsEx)(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID);
BOOL (CDECL *pEnumDisplayMonitors)(HDC,LPRECT,MONITORENUMPROC,LPARAM);
BOOL (CDECL *pEnumDisplaySettingsEx)(LPCWSTR,DWORD,LPDEVMODEW,DWORD);
void (CDECL *pUpdateDisplayDevices)(const struct gdi_device_manager *,BOOL,void*);
/* windowing functions */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment