Commit 12d0792f authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

win32u: Move display placement logic out of graphics drivers.

parent 8b737af6
......@@ -753,8 +753,8 @@ static void nulldrv_UpdateClipboard(void)
{
}
static LONG nulldrv_ChangeDisplaySettingsEx( LPCWSTR name, LPDEVMODEW mode, HWND hwnd,
DWORD flags, LPVOID lparam )
static LONG nulldrv_ChangeDisplaySettings( LPDEVMODEW displays, HWND hwnd,
DWORD flags, LPVOID lparam )
{
return DISP_CHANGE_FAILED;
}
......@@ -1071,10 +1071,10 @@ static SHORT loaderdrv_VkKeyScanEx( WCHAR ch, HKL layout )
return load_driver()->pVkKeyScanEx( ch, layout );
}
static LONG loaderdrv_ChangeDisplaySettingsEx( LPCWSTR name, LPDEVMODEW mode, HWND hwnd,
DWORD flags, LPVOID lparam )
static LONG loaderdrv_ChangeDisplaySettings( LPDEVMODEW displays, HWND hwnd,
DWORD flags, LPVOID lparam )
{
return load_driver()->pChangeDisplaySettingsEx( name, mode, hwnd, flags, lparam );
return load_driver()->pChangeDisplaySettings( displays, hwnd, flags, lparam );
}
static BOOL loaderdrv_EnumDisplaySettingsEx( LPCWSTR name, DWORD num, LPDEVMODEW mode, DWORD flags )
......@@ -1187,7 +1187,7 @@ static const struct user_driver_funcs lazy_load_driver =
nulldrv_ClipboardWindowProc,
loaderdrv_UpdateClipboard,
/* display modes */
loaderdrv_ChangeDisplaySettingsEx,
loaderdrv_ChangeDisplaySettings,
loaderdrv_EnumDisplaySettingsEx,
loaderdrv_GetCurrentDisplaySettings,
loaderdrv_UpdateDisplayDevices,
......@@ -1263,7 +1263,7 @@ void __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT version
SET_USER_FUNC(ClipCursor);
SET_USER_FUNC(ClipboardWindowProc);
SET_USER_FUNC(UpdateClipboard);
SET_USER_FUNC(ChangeDisplaySettingsEx);
SET_USER_FUNC(ChangeDisplaySettings);
SET_USER_FUNC(EnumDisplaySettingsEx);
SET_USER_FUNC(GetCurrentDisplaySettings);
SET_USER_FUNC(UpdateDisplayDevices);
......
......@@ -260,12 +260,11 @@ static BOOL CDECL ANDROID_DeleteDC( PHYSDEV dev )
/***********************************************************************
* ANDROID_ChangeDisplaySettingsEx
* ANDROID_ChangeDisplaySettings
*/
LONG ANDROID_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode,
HWND hwnd, DWORD flags, LPVOID lpvoid )
LONG ANDROID_ChangeDisplaySettings( LPDEVMODEW displays, HWND hwnd, DWORD flags, LPVOID lpvoid )
{
FIXME( "(%s,%p,%p,0x%08x,%p)\n", debugstr_w( devname ), devmode, hwnd, flags, lpvoid );
FIXME( "(%p,%p,0x%08x,%p)\n", displays, hwnd, flags, lpvoid );
return DISP_CHANGE_SUCCESSFUL;
}
......@@ -377,7 +376,7 @@ static const struct user_driver_funcs android_drv_funcs =
.pMapVirtualKeyEx = ANDROID_MapVirtualKeyEx,
.pVkKeyScanEx = ANDROID_VkKeyScanEx,
.pSetCursor = ANDROID_SetCursor,
.pChangeDisplaySettingsEx = ANDROID_ChangeDisplaySettingsEx,
.pChangeDisplaySettings = ANDROID_ChangeDisplaySettings,
.pEnumDisplaySettingsEx = ANDROID_EnumDisplaySettingsEx,
.pGetCurrentDisplaySettings = ANDROID_GetCurrentDisplaySettings,
.pUpdateDisplayDevices = ANDROID_UpdateDisplayDevices,
......
......@@ -34,6 +34,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(display);
#define NEXT_DEVMODEW(mode) ((DEVMODEW *)((char *)((mode) + 1) + (mode)->dmDriverExtra))
struct display_mode_descriptor
{
......@@ -769,84 +770,73 @@ static CGDisplayModeRef find_best_display_mode(DEVMODEW *devmode, CFArrayRef dis
}
/***********************************************************************
* ChangeDisplaySettingsEx (MACDRV.@)
* ChangeDisplaySettings (MACDRV.@)
*
*/
LONG macdrv_ChangeDisplaySettingsEx(LPCWSTR devname, LPDEVMODEW devmode,
HWND hwnd, DWORD flags, LPVOID lpvoid)
LONG macdrv_ChangeDisplaySettings(LPDEVMODEW displays, HWND hwnd, DWORD flags, LPVOID lpvoid)
{
WCHAR primary_adapter[CCHDEVICENAME];
LONG ret = DISP_CHANGE_BADMODE;
DEVMODEW default_mode;
LONG ret = DISP_CHANGE_SUCCESSFUL;
DEVMODEW *mode;
int bpp;
struct macdrv_display *displays;
struct macdrv_display *macdrv_displays;
int num_displays;
CFArrayRef display_modes;
struct display_mode_descriptor *desc;
CGDisplayModeRef best_display_mode;
TRACE("%s %p %p 0x%08x %p\n", debugstr_w(devname), devmode, hwnd, flags, lpvoid);
TRACE("%p %p 0x%08x %p\n", displays, hwnd, flags, lpvoid);
init_original_display_mode();
if (!get_primary_adapter(primary_adapter))
return DISP_CHANGE_FAILED;
if (!devname && !devmode)
{
UNICODE_STRING str;
memset(&default_mode, 0, sizeof(default_mode));
default_mode.dmSize = sizeof(default_mode);
RtlInitUnicodeString(&str, primary_adapter);
if (!NtUserEnumDisplaySettings(&str, ENUM_REGISTRY_SETTINGS, &default_mode, 0))
{
ERR("Default mode not found for %s!\n", wine_dbgstr_w(primary_adapter));
return DISP_CHANGE_BADMODE;
}
devname = primary_adapter;
devmode = &default_mode;
}
else if (wcsicmp(primary_adapter, devname))
{
FIXME("Changing non-primary adapter settings is currently unsupported.\n");
return DISP_CHANGE_SUCCESSFUL;
}
if (is_detached_mode(devmode))
{
FIXME("Detaching adapters is currently unsupported.\n");
return DISP_CHANGE_SUCCESSFUL;
}
if (macdrv_get_displays(&displays, &num_displays))
if (macdrv_get_displays(&macdrv_displays, &num_displays))
return DISP_CHANGE_FAILED;
display_modes = copy_display_modes(displays[0].displayID, FALSE);
display_modes = copy_display_modes(macdrv_displays[0].displayID, FALSE);
if (!display_modes)
{
macdrv_free_displays(displays);
macdrv_free_displays(macdrv_displays);
return DISP_CHANGE_FAILED;
}
pthread_mutex_lock(&cached_modes_mutex);
bpp = get_default_bpp();
pthread_mutex_unlock(&cached_modes_mutex);
if (devmode->dmBitsPerPel != bpp)
TRACE("using default %d bpp instead of caller's request %d bpp\n", bpp, devmode->dmBitsPerPel);
TRACE("looking for %dx%dx%dbpp @%d Hz", devmode->dmPelsWidth, devmode->dmPelsHeight,
bpp, devmode->dmDisplayFrequency);
TRACE(" %sstretched", devmode->dmDisplayFixedOutput == DMDFO_STRETCH ? "" : "un");
TRACE(" %sinterlaced", devmode->dmDisplayFlags & DM_INTERLACED ? "" : "non-");
TRACE("\n");
desc = create_original_display_mode_descriptor(displays[0].displayID);
best_display_mode = find_best_display_mode(devmode, display_modes, bpp, desc);
desc = create_original_display_mode_descriptor(macdrv_displays[0].displayID);
if (best_display_mode)
for (mode = displays; mode->dmSize && !ret; mode = NEXT_DEVMODEW(mode))
{
if (macdrv_set_display_mode(&displays[0], best_display_mode))
if (wcsicmp(primary_adapter, mode->dmDeviceName))
{
FIXME("Changing non-primary adapter settings is currently unsupported.\n");
continue;
}
if (is_detached_mode(mode))
{
FIXME("Detaching adapters is currently unsupported.\n");
continue;
}
if (mode->dmBitsPerPel != bpp)
TRACE("using default %d bpp instead of caller's request %d bpp\n", bpp, mode->dmBitsPerPel);
TRACE("looking for %dx%dx%dbpp @%d Hz", mode->dmPelsWidth, mode->dmPelsHeight,
bpp, mode->dmDisplayFrequency);
TRACE(" %sstretched", mode->dmDisplayFixedOutput == DMDFO_STRETCH ? "" : "un");
TRACE(" %sinterlaced", mode->dmDisplayFlags & DM_INTERLACED ? "" : "non-");
TRACE("\n");
if (!(best_display_mode = find_best_display_mode(mode, display_modes, bpp, desc)))
{
ERR("No matching mode found %ux%ux%d @%u!\n", mode->dmPelsWidth, mode->dmPelsHeight,
bpp, mode->dmDisplayFrequency);
ret = DISP_CHANGE_BADMODE;
}
else if (macdrv_set_display_mode(&macdrv_displays[0], best_display_mode))
{
int mode_bpp = display_mode_bits_per_pixel(best_display_mode);
size_t width = CGDisplayModeGetWidth(best_display_mode);
......@@ -862,7 +852,6 @@ LONG macdrv_ChangeDisplaySettingsEx(LPCWSTR devname, LPDEVMODEW devmode,
send_message(NtUserGetDesktopWindow(), WM_MACDRV_UPDATE_DESKTOP_RECT, mode_bpp,
MAKELPARAM(width, height));
ret = DISP_CHANGE_SUCCESSFUL;
}
else
{
......@@ -870,16 +859,10 @@ LONG macdrv_ChangeDisplaySettingsEx(LPCWSTR devname, LPDEVMODEW devmode,
ret = DISP_CHANGE_FAILED;
}
}
else
{
/* no valid modes found */
ERR("No matching mode found %ux%ux%d @%u!\n", devmode->dmPelsWidth, devmode->dmPelsHeight,
bpp, devmode->dmDisplayFrequency);
}
free_display_mode_descriptor(desc);
CFRelease(display_modes);
macdrv_free_displays(displays);
macdrv_free_displays(macdrv_displays);
return ret;
}
......
......@@ -268,7 +268,7 @@ static const struct user_driver_funcs macdrv_funcs =
.pActivateKeyboardLayout = macdrv_ActivateKeyboardLayout,
.pBeep = macdrv_Beep,
.pChangeDisplaySettingsEx = macdrv_ChangeDisplaySettingsEx,
.pChangeDisplaySettings = macdrv_ChangeDisplaySettings,
.pClipCursor = macdrv_ClipCursor,
.pClipboardWindowProc = macdrv_ClipboardWindowProc,
.pCreateDesktopWindow = macdrv_CreateDesktopWindow,
......
......@@ -123,8 +123,7 @@ static inline struct macdrv_thread_data *macdrv_thread_data(void)
extern BOOL macdrv_ActivateKeyboardLayout(HKL hkl, UINT flags) DECLSPEC_HIDDEN;
extern void macdrv_Beep(void) DECLSPEC_HIDDEN;
extern LONG macdrv_ChangeDisplaySettingsEx(LPCWSTR devname, LPDEVMODEW devmode,
HWND hwnd, DWORD flags, LPVOID lpvoid) DECLSPEC_HIDDEN;
extern LONG macdrv_ChangeDisplaySettings(LPDEVMODEW displays, 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;
......
......@@ -403,7 +403,7 @@ static const struct user_driver_funcs x11drv_funcs =
.pGetCursorPos = X11DRV_GetCursorPos,
.pSetCursorPos = X11DRV_SetCursorPos,
.pClipCursor = X11DRV_ClipCursor,
.pChangeDisplaySettingsEx = X11DRV_ChangeDisplaySettingsEx,
.pChangeDisplaySettings = X11DRV_ChangeDisplaySettings,
.pEnumDisplaySettingsEx = X11DRV_EnumDisplaySettingsEx,
.pGetCurrentDisplaySettings = X11DRV_GetCurrentDisplaySettings,
.pUpdateDisplayDevices = X11DRV_UpdateDisplayDevices,
......
......@@ -213,8 +213,7 @@ extern void X11DRV_SetCursor( HCURSOR handle ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_SetCursorPos( INT x, INT y ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_GetCursorPos( LPPOINT pos ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_ClipCursor( LPCRECT clip ) DECLSPEC_HIDDEN;
extern LONG X11DRV_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode,
HWND hwnd, DWORD flags, LPVOID lpvoid ) DECLSPEC_HIDDEN;
extern LONG X11DRV_ChangeDisplaySettings( LPDEVMODEW displays, 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;
......
......@@ -295,7 +295,7 @@ struct user_driver_funcs
LRESULT (*pClipboardWindowProc)(HWND,UINT,WPARAM,LPARAM);
void (*pUpdateClipboard)(void);
/* display modes */
LONG (*pChangeDisplaySettingsEx)(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID);
LONG (*pChangeDisplaySettings)(LPDEVMODEW,HWND,DWORD,LPVOID);
BOOL (*pEnumDisplaySettingsEx)(LPCWSTR,DWORD,LPDEVMODEW,DWORD);
BOOL (*pGetCurrentDisplaySettings)(LPCWSTR,LPDEVMODEW);
BOOL (*pUpdateDisplayDevices)(const struct gdi_device_manager *,BOOL,void*);
......
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