winex11.drv: Remove the old display settings handler interface.
Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
9c99d9bceb
commit
b45c04f4c3
|
@ -45,9 +45,6 @@ struct x11drv_display_setting
|
||||||
DEVMODEW desired_mode;
|
DEVMODEW desired_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct x11drv_mode_info *dd_modes = NULL;
|
|
||||||
static unsigned int dd_mode_count = 0;
|
|
||||||
static unsigned int dd_max_modes = 0;
|
|
||||||
/* All Windows drivers seen so far either support 32 bit depths, or 24 bit depths, but never both. So if we have
|
/* All Windows drivers seen so far either support 32 bit depths, or 24 bit depths, but never both. So if we have
|
||||||
* a 32 bit framebuffer, report 32 bit bpps, otherwise 24 bit ones.
|
* a 32 bit framebuffer, report 32 bit bpps, otherwise 24 bit ones.
|
||||||
*/
|
*/
|
||||||
|
@ -55,90 +52,6 @@ static const unsigned int depths_24[] = {8, 16, 24};
|
||||||
static const unsigned int depths_32[] = {8, 16, 32};
|
static const unsigned int depths_32[] = {8, 16, 32};
|
||||||
const unsigned int *depths;
|
const unsigned int *depths;
|
||||||
|
|
||||||
/* pointers to functions that actually do the hard stuff */
|
|
||||||
static int (*pGetCurrentMode)(void);
|
|
||||||
static LONG (*pSetCurrentMode)(int mode);
|
|
||||||
static const char *handler_name;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the handlers for resolution changing functions
|
|
||||||
* and initialize the master list of modes
|
|
||||||
*/
|
|
||||||
struct x11drv_mode_info *X11DRV_Settings_SetHandlers(const char *name,
|
|
||||||
int (*pNewGCM)(void),
|
|
||||||
LONG (*pNewSCM)(int),
|
|
||||||
unsigned int nmodes,
|
|
||||||
int reserve_depths)
|
|
||||||
{
|
|
||||||
handler_name = name;
|
|
||||||
pGetCurrentMode = pNewGCM;
|
|
||||||
pSetCurrentMode = pNewSCM;
|
|
||||||
TRACE("Resolution settings now handled by: %s\n", name);
|
|
||||||
if (reserve_depths)
|
|
||||||
/* leave room for other depths */
|
|
||||||
dd_max_modes = (3+1)*(nmodes);
|
|
||||||
else
|
|
||||||
dd_max_modes = nmodes;
|
|
||||||
|
|
||||||
if (dd_modes)
|
|
||||||
{
|
|
||||||
TRACE("Destroying old display modes array\n");
|
|
||||||
HeapFree(GetProcessHeap(), 0, dd_modes);
|
|
||||||
}
|
|
||||||
dd_modes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*dd_modes) * dd_max_modes);
|
|
||||||
dd_mode_count = 0;
|
|
||||||
TRACE("Initialized new display modes array\n");
|
|
||||||
return dd_modes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add one mode to the master list */
|
|
||||||
void X11DRV_Settings_AddOneMode(unsigned int width, unsigned int height, unsigned int bpp, unsigned int freq)
|
|
||||||
{
|
|
||||||
struct x11drv_mode_info *info = &dd_modes[dd_mode_count];
|
|
||||||
DWORD dwBpp = screen_bpp;
|
|
||||||
if (dd_mode_count >= dd_max_modes)
|
|
||||||
{
|
|
||||||
ERR("Maximum modes (%d) exceeded\n", dd_max_modes);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (bpp == 0) bpp = dwBpp;
|
|
||||||
info->width = width;
|
|
||||||
info->height = height;
|
|
||||||
info->refresh_rate = freq;
|
|
||||||
info->bpp = bpp;
|
|
||||||
TRACE("initialized mode %d: %dx%dx%d @%d Hz (%s)\n",
|
|
||||||
dd_mode_count, width, height, bpp, freq, handler_name);
|
|
||||||
dd_mode_count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* copy all the current modes using the other color depths */
|
|
||||||
void X11DRV_Settings_AddDepthModes(void)
|
|
||||||
{
|
|
||||||
int i, j;
|
|
||||||
int existing_modes = dd_mode_count;
|
|
||||||
DWORD dwBpp = screen_bpp;
|
|
||||||
const DWORD *depths = screen_bpp == 32 ? depths_32 : depths_24;
|
|
||||||
|
|
||||||
for (j=0; j<3; j++)
|
|
||||||
{
|
|
||||||
if (depths[j] != dwBpp)
|
|
||||||
{
|
|
||||||
for (i=0; i < existing_modes; i++)
|
|
||||||
{
|
|
||||||
X11DRV_Settings_AddOneMode(dd_modes[i].width, dd_modes[i].height,
|
|
||||||
depths[j], dd_modes[i].refresh_rate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* return the number of modes that are initialized */
|
|
||||||
unsigned int X11DRV_Settings_GetModeCount(void)
|
|
||||||
{
|
|
||||||
return dd_mode_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO: Remove the old display settings handler interface once all backends are migrated to the new interface */
|
|
||||||
static struct x11drv_settings_handler handler;
|
static struct x11drv_settings_handler handler;
|
||||||
|
|
||||||
/* Cached display modes for a device, protected by modes_section */
|
/* Cached display modes for a device, protected by modes_section */
|
||||||
|
@ -440,10 +353,6 @@ BOOL CDECL X11DRV_EnumDisplaySettingsEx( LPCWSTR name, DWORD n, LPDEVMODEW devmo
|
||||||
UINT mode_count;
|
UINT mode_count;
|
||||||
ULONG_PTR id;
|
ULONG_PTR id;
|
||||||
|
|
||||||
/* Use the new interface if it is available */
|
|
||||||
if (!handler.name)
|
|
||||||
goto old_interface;
|
|
||||||
|
|
||||||
if (n == ENUM_REGISTRY_SETTINGS)
|
if (n == ENUM_REGISTRY_SETTINGS)
|
||||||
{
|
{
|
||||||
if (!read_registry_settings(name, devmode))
|
if (!read_registry_settings(name, devmode))
|
||||||
|
@ -503,56 +412,6 @@ done:
|
||||||
devmode->dmDriverVersion = DM_SPECVERSION;
|
devmode->dmDriverVersion = DM_SPECVERSION;
|
||||||
lstrcpyW(devmode->dmDeviceName, dev_name);
|
lstrcpyW(devmode->dmDeviceName, dev_name);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
old_interface:
|
|
||||||
devmode->dmSize = FIELD_OFFSET(DEVMODEW, dmICMMethod);
|
|
||||||
devmode->dmSpecVersion = DM_SPECVERSION;
|
|
||||||
devmode->dmDriverVersion = DM_SPECVERSION;
|
|
||||||
memcpy(devmode->dmDeviceName, dev_name, sizeof(dev_name));
|
|
||||||
devmode->dmDriverExtra = 0;
|
|
||||||
devmode->u2.dmDisplayFlags = 0;
|
|
||||||
devmode->dmDisplayFrequency = 0;
|
|
||||||
devmode->u1.s2.dmPosition.x = 0;
|
|
||||||
devmode->u1.s2.dmPosition.y = 0;
|
|
||||||
devmode->u1.s2.dmDisplayOrientation = 0;
|
|
||||||
devmode->u1.s2.dmDisplayFixedOutput = 0;
|
|
||||||
|
|
||||||
if (n == ENUM_CURRENT_SETTINGS)
|
|
||||||
{
|
|
||||||
TRACE("mode %d (current) -- getting current mode (%s)\n", n, handler_name);
|
|
||||||
n = pGetCurrentMode();
|
|
||||||
}
|
|
||||||
if (n == ENUM_REGISTRY_SETTINGS)
|
|
||||||
{
|
|
||||||
TRACE("mode %d (registry) -- getting default mode (%s)\n", n, handler_name);
|
|
||||||
return read_registry_settings(name, devmode);
|
|
||||||
}
|
|
||||||
if (n < dd_mode_count)
|
|
||||||
{
|
|
||||||
devmode->dmPelsWidth = dd_modes[n].width;
|
|
||||||
devmode->dmPelsHeight = dd_modes[n].height;
|
|
||||||
devmode->dmBitsPerPel = dd_modes[n].bpp;
|
|
||||||
devmode->dmDisplayFrequency = dd_modes[n].refresh_rate;
|
|
||||||
devmode->dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL |
|
|
||||||
DM_DISPLAYFLAGS;
|
|
||||||
if (devmode->dmDisplayFrequency)
|
|
||||||
{
|
|
||||||
devmode->dmFields |= DM_DISPLAYFREQUENCY;
|
|
||||||
TRACE("mode %d -- %dx%dx%dbpp @%d Hz (%s)\n", n,
|
|
||||||
devmode->dmPelsWidth, devmode->dmPelsHeight, devmode->dmBitsPerPel,
|
|
||||||
devmode->dmDisplayFrequency, handler_name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
TRACE("mode %d -- %dx%dx%dbpp (%s)\n", n,
|
|
||||||
devmode->dmPelsWidth, devmode->dmPelsHeight, devmode->dmBitsPerPel,
|
|
||||||
handler_name);
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
TRACE("mode %d -- not present (%s)\n", n, handler_name);
|
|
||||||
SetLastError(ERROR_NO_MORE_FILES);
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL is_detached_mode(const DEVMODEW *mode)
|
BOOL is_detached_mode(const DEVMODEW *mode)
|
||||||
|
@ -939,16 +798,8 @@ LONG CDECL X11DRV_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode,
|
||||||
HWND hwnd, DWORD flags, LPVOID lpvoid )
|
HWND hwnd, DWORD flags, LPVOID lpvoid )
|
||||||
{
|
{
|
||||||
struct x11drv_display_setting *displays;
|
struct x11drv_display_setting *displays;
|
||||||
WCHAR primary_adapter[CCHDEVICENAME];
|
|
||||||
char bpp_buffer[16], freq_buffer[18];
|
|
||||||
INT display_idx, display_count;
|
INT display_idx, display_count;
|
||||||
DEVMODEW default_mode;
|
|
||||||
LONG ret;
|
LONG ret;
|
||||||
DWORD i;
|
|
||||||
|
|
||||||
/* Use the new interface if it is available */
|
|
||||||
if (!handler.name)
|
|
||||||
goto old_interface;
|
|
||||||
|
|
||||||
ret = get_display_settings(&displays, &display_count, devname, devmode);
|
ret = get_display_settings(&displays, &display_count, devname, devmode);
|
||||||
if (ret != DISP_CHANGE_SUCCESSFUL)
|
if (ret != DISP_CHANGE_SUCCESSFUL)
|
||||||
|
@ -994,83 +845,4 @@ LONG CDECL X11DRV_ChangeDisplaySettingsEx( LPCWSTR devname, LPDEVMODEW devmode,
|
||||||
X11DRV_DisplayDevices_Update(TRUE);
|
X11DRV_DisplayDevices_Update(TRUE);
|
||||||
heap_free(displays);
|
heap_free(displays);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
old_interface:
|
|
||||||
if (!get_primary_adapter(primary_adapter))
|
|
||||||
return DISP_CHANGE_FAILED;
|
|
||||||
|
|
||||||
if (!devname && !devmode)
|
|
||||||
{
|
|
||||||
default_mode.dmSize = sizeof(default_mode);
|
|
||||||
if (!EnumDisplaySettingsExW(primary_adapter, 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_detached_mode(devmode))
|
|
||||||
{
|
|
||||||
FIXME("Detaching adapters is currently unsupported.\n");
|
|
||||||
return DISP_CHANGE_SUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < dd_mode_count; i++)
|
|
||||||
{
|
|
||||||
if (devmode->dmFields & DM_BITSPERPEL)
|
|
||||||
{
|
|
||||||
if (devmode->dmBitsPerPel != dd_modes[i].bpp)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (devmode->dmFields & DM_PELSWIDTH)
|
|
||||||
{
|
|
||||||
if (devmode->dmPelsWidth != dd_modes[i].width)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (devmode->dmFields & DM_PELSHEIGHT)
|
|
||||||
{
|
|
||||||
if (devmode->dmPelsHeight != dd_modes[i].height)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ((devmode->dmFields & DM_DISPLAYFREQUENCY) && (dd_modes[i].refresh_rate != 0) &&
|
|
||||||
devmode->dmDisplayFrequency != 0 && devmode->dmDisplayFrequency != 1)
|
|
||||||
{
|
|
||||||
if (devmode->dmDisplayFrequency != dd_modes[i].refresh_rate)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/* we have a valid mode */
|
|
||||||
TRACE("Requested display settings match mode %d (%s)\n", i, handler_name);
|
|
||||||
|
|
||||||
if (flags & CDS_UPDATEREGISTRY && !write_registry_settings(devname, devmode))
|
|
||||||
{
|
|
||||||
ERR("Failed to write %s display settings to registry.\n", wine_dbgstr_w(devname));
|
|
||||||
return DISP_CHANGE_NOTUPDATED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lstrcmpiW(primary_adapter, devname))
|
|
||||||
{
|
|
||||||
FIXME("Changing non-primary adapter %s settings is currently unsupported.\n",
|
|
||||||
wine_dbgstr_w(devname));
|
|
||||||
return DISP_CHANGE_SUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(flags & (CDS_TEST | CDS_NORESET)))
|
|
||||||
return pSetCurrentMode(i);
|
|
||||||
|
|
||||||
return DISP_CHANGE_SUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* no valid modes found, only print the fields we were trying to matching against */
|
|
||||||
bpp_buffer[0] = freq_buffer[0] = 0;
|
|
||||||
if (devmode->dmFields & DM_BITSPERPEL)
|
|
||||||
sprintf(bpp_buffer, "bpp=%u ", devmode->dmBitsPerPel);
|
|
||||||
if ((devmode->dmFields & DM_DISPLAYFREQUENCY) && (devmode->dmDisplayFrequency != 0))
|
|
||||||
sprintf(freq_buffer, "freq=%u ", devmode->dmDisplayFrequency);
|
|
||||||
ERR("No matching mode found: width=%d height=%d %s%s(%s)\n",
|
|
||||||
devmode->dmPelsWidth, devmode->dmPelsHeight, bpp_buffer, freq_buffer, handler_name);
|
|
||||||
|
|
||||||
return DISP_CHANGE_BADMODE;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -649,14 +649,6 @@ extern RECT get_host_primary_monitor_rect(void) DECLSPEC_HIDDEN;
|
||||||
extern RECT get_work_area( const RECT *monitor_rect ) DECLSPEC_HIDDEN;
|
extern RECT get_work_area( const RECT *monitor_rect ) DECLSPEC_HIDDEN;
|
||||||
extern void xinerama_init( unsigned int width, unsigned int height ) DECLSPEC_HIDDEN;
|
extern void xinerama_init( unsigned int width, unsigned int height ) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
struct x11drv_mode_info
|
|
||||||
{
|
|
||||||
unsigned int width;
|
|
||||||
unsigned int height;
|
|
||||||
unsigned int bpp;
|
|
||||||
unsigned int refresh_rate;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define DEPTH_COUNT 3
|
#define DEPTH_COUNT 3
|
||||||
extern const unsigned int *depths DECLSPEC_HIDDEN;
|
extern const unsigned int *depths DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
|
@ -714,15 +706,7 @@ extern BOOL is_desktop_fullscreen(void) DECLSPEC_HIDDEN;
|
||||||
extern BOOL is_detached_mode(const DEVMODEW *) DECLSPEC_HIDDEN;
|
extern BOOL is_detached_mode(const DEVMODEW *) DECLSPEC_HIDDEN;
|
||||||
extern BOOL create_desktop_win_data( Window win ) DECLSPEC_HIDDEN;
|
extern BOOL create_desktop_win_data( Window win ) DECLSPEC_HIDDEN;
|
||||||
extern BOOL get_primary_adapter(WCHAR *) DECLSPEC_HIDDEN;
|
extern BOOL get_primary_adapter(WCHAR *) DECLSPEC_HIDDEN;
|
||||||
extern void X11DRV_Settings_AddDepthModes(void) DECLSPEC_HIDDEN;
|
|
||||||
extern void X11DRV_Settings_AddOneMode(unsigned int width, unsigned int height, unsigned int bpp, unsigned int freq) DECLSPEC_HIDDEN;
|
|
||||||
unsigned int X11DRV_Settings_GetModeCount(void) DECLSPEC_HIDDEN;
|
|
||||||
void X11DRV_Settings_Init(void) DECLSPEC_HIDDEN;
|
void X11DRV_Settings_Init(void) DECLSPEC_HIDDEN;
|
||||||
struct x11drv_mode_info *X11DRV_Settings_SetHandlers(const char *name,
|
|
||||||
int (*pNewGCM)(void),
|
|
||||||
LONG (*pNewSCM)(int),
|
|
||||||
unsigned int nmodes,
|
|
||||||
int reserve_depths) DECLSPEC_HIDDEN;
|
|
||||||
|
|
||||||
void X11DRV_XF86VM_Init(void) DECLSPEC_HIDDEN;
|
void X11DRV_XF86VM_Init(void) DECLSPEC_HIDDEN;
|
||||||
void X11DRV_XRandR_Init(void) DECLSPEC_HIDDEN;
|
void X11DRV_XRandR_Init(void) DECLSPEC_HIDDEN;
|
||||||
|
|
Loading…
Reference in New Issue