Commit 82a77607 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

win32u: Split EnumDisplaySettingsEx into CurrentDisplaySettings entry.

parent 25c57c79
......@@ -764,6 +764,11 @@ static BOOL nulldrv_EnumDisplaySettingsEx( LPCWSTR name, DWORD num, LPDEVMODEW m
return FALSE;
}
static BOOL nulldrv_GetCurrentDisplaySettings( LPCWSTR name, LPDEVMODEW mode )
{
return FALSE;
}
static BOOL nulldrv_UpdateDisplayDevices( const struct gdi_device_manager *manager, BOOL force, void *param )
{
return FALSE;
......@@ -1077,6 +1082,11 @@ static BOOL loaderdrv_EnumDisplaySettingsEx( LPCWSTR name, DWORD num, LPDEVMODEW
return load_driver()->pEnumDisplaySettingsEx( name, num, mode, flags );
}
static BOOL loaderdrv_GetCurrentDisplaySettings( LPCWSTR name, LPDEVMODEW mode )
{
return load_driver()->pGetCurrentDisplaySettings( name, mode );
}
static void loaderdrv_SetCursor( HCURSOR cursor )
{
load_driver()->pSetCursor( cursor );
......@@ -1179,6 +1189,7 @@ static const struct user_driver_funcs lazy_load_driver =
/* display modes */
loaderdrv_ChangeDisplaySettingsEx,
loaderdrv_EnumDisplaySettingsEx,
loaderdrv_GetCurrentDisplaySettings,
loaderdrv_UpdateDisplayDevices,
/* windowing functions */
loaderdrv_CreateDesktopWindow,
......@@ -1254,6 +1265,7 @@ void __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT version
SET_USER_FUNC(UpdateClipboard);
SET_USER_FUNC(ChangeDisplaySettingsEx);
SET_USER_FUNC(EnumDisplaySettingsEx);
SET_USER_FUNC(GetCurrentDisplaySettings);
SET_USER_FUNC(UpdateDisplayDevices);
SET_USER_FUNC(CreateDesktopWindow);
SET_USER_FUNC(CreateWindow);
......
......@@ -2155,7 +2155,8 @@ BOOL WINAPI NtUserEnumDisplaySettings( UNICODE_STRING *device, DWORD index, DEVM
memset( &devmode->dmDriverExtra, 0, devmode->dmSize - offsetof(DEVMODEW, dmDriverExtra) );
if (index == ENUM_REGISTRY_SETTINGS) ret = read_registry_settings( adapter_path, devmode );
else ret = user_driver->pEnumDisplaySettingsEx( device_name, index, devmode, flags );
else if (index != ENUM_CURRENT_SETTINGS) ret = user_driver->pEnumDisplaySettingsEx( device_name, index, devmode, flags );
else ret = user_driver->pGetCurrentDisplaySettings( device_name, devmode );
if (!ret) WARN( "Failed to query %s display settings.\n", debugstr_w(device_name) );
else TRACE( "position %dx%d, resolution %ux%u, frequency %u, depth %u, orientation %#x.\n",
......
......@@ -309,7 +309,7 @@ BOOL ANDROID_UpdateDisplayDevices( const struct gdi_device_manager *device_manag
*/
BOOL ANDROID_EnumDisplaySettingsEx( LPCWSTR name, DWORD n, LPDEVMODEW devmode, DWORD flags )
{
if (n > 0 && n != ENUM_CURRENT_SETTINGS)
if (n > 0)
{
TRACE( "mode %d -- not present\n", n );
SetLastError( ERROR_NO_MORE_FILES );
......@@ -333,6 +333,28 @@ BOOL ANDROID_EnumDisplaySettingsEx( LPCWSTR name, DWORD n, LPDEVMODEW devmode, D
}
/***********************************************************************
* ANDROID_GetCurrentDisplaySettings
*/
BOOL ANDROID_GetCurrentDisplaySettings( LPCWSTR name, LPDEVMODEW devmode )
{
devmode->u2.dmDisplayFlags = 0;
devmode->u1.s2.dmPosition.x = 0;
devmode->u1.s2.dmPosition.y = 0;
devmode->u1.s2.dmDisplayOrientation = 0;
devmode->u1.s2.dmDisplayFixedOutput = 0;
devmode->dmPelsWidth = screen_width;
devmode->dmPelsHeight = screen_height;
devmode->dmBitsPerPel = screen_bpp;
devmode->dmDisplayFrequency = 60;
devmode->dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFLAGS | DM_DISPLAYFREQUENCY;
TRACE( "current mode -- %dx%d %d bpp @%d Hz\n",
devmode->dmPelsWidth, devmode->dmPelsHeight,
devmode->dmBitsPerPel, devmode->dmDisplayFrequency );
return TRUE;
}
/**********************************************************************
* ANDROID_wine_get_wgl_driver
*/
......@@ -355,6 +377,7 @@ static const struct user_driver_funcs android_drv_funcs =
.pSetCursor = ANDROID_SetCursor,
.pChangeDisplaySettingsEx = ANDROID_ChangeDisplaySettingsEx,
.pEnumDisplaySettingsEx = ANDROID_EnumDisplaySettingsEx,
.pGetCurrentDisplaySettings = ANDROID_GetCurrentDisplaySettings,
.pUpdateDisplayDevices = ANDROID_UpdateDisplayDevices,
.pCreateWindow = ANDROID_CreateWindow,
.pDesktopWindowProc = ANDROID_DesktopWindowProc,
......
......@@ -996,13 +996,14 @@ static DEVMODEW *display_get_modes(CGDirectDisplayID display_id, int *modes_coun
* EnumDisplaySettingsEx (MACDRV.@)
*
*/
BOOL macdrv_EnumDisplaySettingsEx(LPCWSTR devname, DWORD mode, DEVMODEW *devmode, DWORD flags)
BOOL macdrv_EnumDisplaySettingsEx(LPCWSTR devname, DWORD mode, LPDEVMODEW devmode, DWORD flags)
{
struct macdrv_display *displays = NULL;
int num_displays;
CGDisplayModeRef display_mode;
int display_mode_bpp;
BOOL synthesized = FALSE;
DWORD count, i;
TRACE("%s, %u, %p + %hu, %08x\n", debugstr_w(devname), mode, devmode, devmode->dmSize, flags);
......@@ -1011,99 +1012,88 @@ BOOL macdrv_EnumDisplaySettingsEx(LPCWSTR devname, DWORD mode, DEVMODEW *devmode
if (macdrv_get_displays(&displays, &num_displays))
goto failed;
if (mode == ENUM_CURRENT_SETTINGS)
{
TRACE("mode %d (current) -- getting current mode\n", mode);
display_mode = CGDisplayCopyDisplayMode(displays[0].displayID);
display_mode_bpp = display_mode_bits_per_pixel(display_mode);
}
else
{
DWORD count, i;
pthread_mutex_lock(&modes_mutex);
pthread_mutex_lock(&modes_mutex);
if (mode == 0 || !modes)
{
if (modes) CFRelease(modes);
modes = copy_display_modes(displays[0].displayID, (flags & EDS_RAWMODE) != 0);
modes_has_8bpp = modes_has_16bpp = FALSE;
if (mode == 0 || !modes)
if (modes)
{
if (modes) CFRelease(modes);
modes = copy_display_modes(displays[0].displayID, (flags & EDS_RAWMODE) != 0);
modes_has_8bpp = modes_has_16bpp = FALSE;
if (modes)
count = CFArrayGetCount(modes);
for (i = 0; i < count && !(modes_has_8bpp && modes_has_16bpp); i++)
{
count = CFArrayGetCount(modes);
for (i = 0; i < count && !(modes_has_8bpp && modes_has_16bpp); i++)
{
CGDisplayModeRef mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(modes, i);
int bpp = display_mode_bits_per_pixel(mode);
if (bpp == 8)
modes_has_8bpp = TRUE;
else if (bpp == 16)
modes_has_16bpp = TRUE;
}
CGDisplayModeRef mode = (CGDisplayModeRef)CFArrayGetValueAtIndex(modes, i);
int bpp = display_mode_bits_per_pixel(mode);
if (bpp == 8)
modes_has_8bpp = TRUE;
else if (bpp == 16)
modes_has_16bpp = TRUE;
}
}
}
display_mode = NULL;
if (modes)
display_mode = NULL;
if (modes)
{
int default_bpp;
DWORD seen_modes = 0;
count = CFArrayGetCount(modes);
for (i = 0; i < count; i++)
{
int default_bpp;
DWORD seen_modes = 0;
CGDisplayModeRef candidate = (CGDisplayModeRef)CFArrayGetValueAtIndex(modes, i);
count = CFArrayGetCount(modes);
for (i = 0; i < count; i++)
seen_modes++;
if (seen_modes > mode)
{
CGDisplayModeRef candidate = (CGDisplayModeRef)CFArrayGetValueAtIndex(modes, i);
seen_modes++;
if (seen_modes > mode)
{
display_mode = (CGDisplayModeRef)CFRetain(candidate);
display_mode_bpp = display_mode_bits_per_pixel(display_mode);
break;
}
display_mode = (CGDisplayModeRef)CFRetain(candidate);
display_mode_bpp = display_mode_bits_per_pixel(display_mode);
break;
}
}
default_bpp = get_default_bpp();
default_bpp = get_default_bpp();
/* If all the real modes are exhausted, synthesize lower bpp modes. */
if (!display_mode && (!modes_has_16bpp || !modes_has_8bpp))
/* If all the real modes are exhausted, synthesize lower bpp modes. */
if (!display_mode && (!modes_has_16bpp || !modes_has_8bpp))
{
/* We want to synthesize higher depths first. */
int synth_bpps[] = { modes_has_16bpp ? 0 : 16, modes_has_8bpp ? 0 : 8 };
size_t synth_bpp_idx;
for (synth_bpp_idx = 0; synth_bpp_idx < 2; synth_bpp_idx++)
{
/* We want to synthesize higher depths first. */
int synth_bpps[] = { modes_has_16bpp ? 0 : 16, modes_has_8bpp ? 0 : 8 };
size_t synth_bpp_idx;
for (synth_bpp_idx = 0; synth_bpp_idx < 2; synth_bpp_idx++)
int synth_bpp = synth_bpps[synth_bpp_idx];
if (synth_bpp == 0)
continue;
for (i = 0; i < count; i++)
{
int synth_bpp = synth_bpps[synth_bpp_idx];
if (synth_bpp == 0)
CGDisplayModeRef candidate = (CGDisplayModeRef)CFArrayGetValueAtIndex(modes, i);
/* We only synthesize modes from those having the default bpp. */
if (display_mode_bits_per_pixel(candidate) != default_bpp)
continue;
for (i = 0; i < count; i++)
seen_modes++;
if (seen_modes > mode)
{
CGDisplayModeRef candidate = (CGDisplayModeRef)CFArrayGetValueAtIndex(modes, i);
/* We only synthesize modes from those having the default bpp. */
if (display_mode_bits_per_pixel(candidate) != default_bpp)
continue;
seen_modes++;
if (seen_modes > mode)
{
display_mode = (CGDisplayModeRef)CFRetain(candidate);
display_mode_bpp = synth_bpp;
synthesized = TRUE;
break;
}
}
if (display_mode)
display_mode = (CGDisplayModeRef)CFRetain(candidate);
display_mode_bpp = synth_bpp;
synthesized = TRUE;
break;
}
}
if (display_mode)
break;
}
}
pthread_mutex_unlock(&modes_mutex);
}
pthread_mutex_unlock(&modes_mutex);
if (!display_mode)
goto failed;
......@@ -1152,6 +1142,59 @@ failed:
return FALSE;
}
/***********************************************************************
* GetCurrentDisplaySettings (MACDRV.@)
*
*/
BOOL macdrv_GetCurrentDisplaySettings(LPCWSTR devname, LPDEVMODEW devmode)
{
struct macdrv_display *displays = NULL;
int num_displays;
CGDisplayModeRef display_mode;
TRACE("%s, %p + %hu\n", debugstr_w(devname), devmode, devmode->dmSize);
init_original_display_mode();
if (macdrv_get_displays(&displays, &num_displays))
return FALSE;
display_mode = CGDisplayCopyDisplayMode(displays[0].displayID);
/* We currently only report modes for the primary display, so it's at (0, 0). */
devmode->dmPosition.x = 0;
devmode->dmPosition.y = 0;
devmode->dmFields |= DM_POSITION;
display_mode_to_devmode(displays[0].displayID, display_mode, devmode);
if (retina_enabled)
{
struct display_mode_descriptor *desc = create_original_display_mode_descriptor(displays[0].displayID);
if (display_mode_matches_descriptor(display_mode, desc))
{
devmode->dmPelsWidth *= 2;
devmode->dmPelsHeight *= 2;
}
free_display_mode_descriptor(desc);
}
CFRelease(display_mode);
macdrv_free_displays(displays);
TRACE("current mode -- %dx%dx%dbpp @%d Hz",
devmode->dmPelsWidth, devmode->dmPelsHeight, devmode->dmBitsPerPel,
devmode->dmDisplayFrequency);
if (devmode->dmDisplayOrientation)
TRACE(" rotated %u degrees", devmode->dmDisplayOrientation * 90);
if (devmode->dmDisplayFixedOutput == DMDFO_STRETCH)
TRACE(" stretched");
if (devmode->dmDisplayFlags & DM_INTERLACED)
TRACE(" interlaced");
TRACE("\n");
return TRUE;
}
/***********************************************************************
* GetDeviceGammaRamp (MACDRV.@)
......
......@@ -276,6 +276,7 @@ static const struct user_driver_funcs macdrv_funcs =
.pDestroyCursorIcon = macdrv_DestroyCursorIcon,
.pDestroyWindow = macdrv_DestroyWindow,
.pEnumDisplaySettingsEx = macdrv_EnumDisplaySettingsEx,
.pGetCurrentDisplaySettings = macdrv_GetCurrentDisplaySettings,
.pUpdateDisplayDevices = macdrv_UpdateDisplayDevices,
.pGetCursorPos = macdrv_GetCursorPos,
.pGetKeyboardLayoutList = macdrv_GetKeyboardLayoutList,
......
......@@ -127,6 +127,7 @@ extern LONG macdrv_ChangeDisplaySettingsEx(LPCWSTR devname, LPDEVMODEW devmode,
HWND hwnd, DWORD flags, LPVOID lpvoid) DECLSPEC_HIDDEN;
extern BOOL macdrv_EnumDisplaySettingsEx(LPCWSTR devname, DWORD mode,
LPDEVMODEW devmode, DWORD flags) DECLSPEC_HIDDEN;
extern BOOL macdrv_GetCurrentDisplaySettings(LPCWSTR name, LPDEVMODEW devmode) DECLSPEC_HIDDEN;
extern LRESULT macdrv_ClipboardWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) DECLSPEC_HIDDEN;
extern BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manager,
BOOL force, void *param ) DECLSPEC_HIDDEN;
......
......@@ -326,19 +326,6 @@ BOOL X11DRV_EnumDisplaySettingsEx( LPCWSTR name, DWORD n, LPDEVMODEW devmode, DW
UINT mode_count;
ULONG_PTR id;
if (n == ENUM_CURRENT_SETTINGS)
{
if (!settings_handler.get_id( name, &id ) || !settings_handler.get_current_mode( id, &mode ))
{
ERR("Failed to get %s current display settings.\n", wine_dbgstr_w(name));
return FALSE;
}
memcpy( &devmode->dmFields, &mode.dmFields, devmode->dmSize - offsetof(DEVMODEW, dmFields) );
if (!is_detached_mode( devmode )) devmode->dmBitsPerPel = get_display_depth( id );
return TRUE;
}
pthread_mutex_lock( &settings_mutex );
if (n == 0 || wcsicmp(cached_device_name, name) || cached_flags != flags)
{
......@@ -374,6 +361,26 @@ BOOL X11DRV_EnumDisplaySettingsEx( LPCWSTR name, DWORD n, LPDEVMODEW devmode, DW
return TRUE;
}
/***********************************************************************
* GetCurrentDisplaySettings (X11DRV.@)
*
*/
BOOL X11DRV_GetCurrentDisplaySettings( LPCWSTR name, LPDEVMODEW devmode )
{
DEVMODEW mode;
ULONG_PTR id;
if (!settings_handler.get_id( name, &id ) || !settings_handler.get_current_mode( id, &mode ))
{
ERR("Failed to get %s current display settings.\n", wine_dbgstr_w(name));
return FALSE;
}
memcpy( &devmode->dmFields, &mode.dmFields, devmode->dmSize - offsetof(DEVMODEW, dmFields) );
if (!is_detached_mode( devmode )) devmode->dmBitsPerPel = get_display_depth( id );
return TRUE;
}
BOOL is_detached_mode(const DEVMODEW *mode)
{
return mode->dmFields & DM_POSITION &&
......
......@@ -405,6 +405,7 @@ static const struct user_driver_funcs x11drv_funcs =
.pClipCursor = X11DRV_ClipCursor,
.pChangeDisplaySettingsEx = X11DRV_ChangeDisplaySettingsEx,
.pEnumDisplaySettingsEx = X11DRV_EnumDisplaySettingsEx,
.pGetCurrentDisplaySettings = X11DRV_GetCurrentDisplaySettings,
.pUpdateDisplayDevices = X11DRV_UpdateDisplayDevices,
.pCreateDesktopWindow = X11DRV_CreateDesktopWindow,
.pCreateWindow = X11DRV_CreateWindow,
......
......@@ -217,6 +217,7 @@ extern LONG X11DRV_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode,
HWND hwnd, DWORD flags, LPVOID lpvoid ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_EnumDisplaySettingsEx( LPCWSTR name, DWORD n, LPDEVMODEW devmode,
DWORD flags ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_GetCurrentDisplaySettings( LPCWSTR name, LPDEVMODEW devmode ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manager,
BOOL force, void *param ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_CreateDesktopWindow( HWND hwnd ) DECLSPEC_HIDDEN;
......
......@@ -297,6 +297,7 @@ struct user_driver_funcs
/* display modes */
LONG (*pChangeDisplaySettingsEx)(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID);
BOOL (*pEnumDisplaySettingsEx)(LPCWSTR,DWORD,LPDEVMODEW,DWORD);
BOOL (*pGetCurrentDisplaySettings)(LPCWSTR,LPDEVMODEW);
BOOL (*pUpdateDisplayDevices)(const struct gdi_device_manager *,BOOL,void*);
/* windowing functions */
BOOL (*pCreateDesktopWindow)(HWND);
......
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