2003-10-16 02:21:42 +02:00
|
|
|
/*
|
|
|
|
* Wine X11drv Xrandr interface
|
|
|
|
*
|
|
|
|
* Copyright 2003 Alexander James Pasadyn
|
2012-07-15 15:45:00 +02:00
|
|
|
* Copyright 2012 Henri Verbeet for CodeWeavers
|
2019-09-20 10:55:22 +02:00
|
|
|
* Copyright 2019 Zhiyi Zhang for CodeWeavers
|
2003-10-16 02:21:42 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-10-16 02:21:42 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2004-04-07 05:57:35 +02:00
|
|
|
#include "wine/port.h"
|
2012-07-08 16:06:39 +02:00
|
|
|
#include "wine/debug.h"
|
2003-10-16 02:21:42 +02:00
|
|
|
|
2012-07-08 16:06:39 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(xrandr);
|
2012-11-30 13:33:24 +01:00
|
|
|
#ifdef HAVE_XRRGETSCREENRESOURCES
|
2012-11-24 17:17:09 +01:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(winediag);
|
2012-11-30 13:33:24 +01:00
|
|
|
#endif
|
2012-07-08 16:06:39 +02:00
|
|
|
|
2007-07-04 12:45:03 +02:00
|
|
|
#ifdef SONAME_LIBXRANDR
|
2003-10-16 02:21:42 +02:00
|
|
|
|
2012-07-11 16:24:29 +02:00
|
|
|
#include <X11/Xlib.h>
|
2003-10-16 02:21:42 +02:00
|
|
|
#include <X11/extensions/Xrandr.h>
|
|
|
|
#include "x11drv.h"
|
|
|
|
|
2020-06-17 14:02:04 +02:00
|
|
|
#define VK_NO_PROTOTYPES
|
|
|
|
#define WINE_VK_HOST
|
|
|
|
|
2019-09-20 10:55:22 +02:00
|
|
|
#include "wine/heap.h"
|
|
|
|
#include "wine/unicode.h"
|
2020-06-17 14:02:04 +02:00
|
|
|
#include "wine/vulkan.h"
|
|
|
|
#include "wine/vulkan_driver.h"
|
2003-10-16 02:21:42 +02:00
|
|
|
|
2004-04-07 05:57:35 +02:00
|
|
|
static void *xrandr_handle;
|
|
|
|
|
|
|
|
#define MAKE_FUNCPTR(f) static typeof(f) * p##f;
|
|
|
|
MAKE_FUNCPTR(XRRConfigCurrentConfiguration)
|
|
|
|
MAKE_FUNCPTR(XRRConfigCurrentRate)
|
|
|
|
MAKE_FUNCPTR(XRRFreeScreenConfigInfo)
|
|
|
|
MAKE_FUNCPTR(XRRGetScreenInfo)
|
|
|
|
MAKE_FUNCPTR(XRRQueryExtension)
|
|
|
|
MAKE_FUNCPTR(XRRQueryVersion)
|
|
|
|
MAKE_FUNCPTR(XRRRates)
|
|
|
|
MAKE_FUNCPTR(XRRSetScreenConfig)
|
|
|
|
MAKE_FUNCPTR(XRRSetScreenConfigAndRate)
|
|
|
|
MAKE_FUNCPTR(XRRSizes)
|
2012-07-15 15:45:00 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_XRRGETSCREENRESOURCES
|
|
|
|
MAKE_FUNCPTR(XRRFreeCrtcInfo)
|
|
|
|
MAKE_FUNCPTR(XRRFreeOutputInfo)
|
|
|
|
MAKE_FUNCPTR(XRRFreeScreenResources)
|
|
|
|
MAKE_FUNCPTR(XRRGetCrtcInfo)
|
|
|
|
MAKE_FUNCPTR(XRRGetOutputInfo)
|
2012-08-20 08:12:07 +02:00
|
|
|
MAKE_FUNCPTR(XRRGetScreenResources)
|
2020-03-30 16:38:28 +02:00
|
|
|
MAKE_FUNCPTR(XRRGetScreenSizeRange)
|
2012-07-15 15:45:00 +02:00
|
|
|
MAKE_FUNCPTR(XRRSetCrtcConfig)
|
2019-04-11 05:30:32 +02:00
|
|
|
MAKE_FUNCPTR(XRRSetScreenSize)
|
2012-08-20 08:12:07 +02:00
|
|
|
static typeof(XRRGetScreenResources) *pXRRGetScreenResourcesCurrent;
|
2012-07-15 15:45:00 +02:00
|
|
|
static RRMode *xrandr12_modes;
|
2012-09-28 01:06:54 +02:00
|
|
|
static int primary_crtc;
|
2012-07-15 15:45:00 +02:00
|
|
|
#endif
|
|
|
|
|
2019-09-20 10:55:22 +02:00
|
|
|
#ifdef HAVE_XRRGETPROVIDERRESOURCES
|
2019-09-20 10:55:40 +02:00
|
|
|
MAKE_FUNCPTR(XRRSelectInput)
|
2019-09-20 10:55:22 +02:00
|
|
|
MAKE_FUNCPTR(XRRGetOutputPrimary)
|
|
|
|
MAKE_FUNCPTR(XRRGetProviderResources)
|
|
|
|
MAKE_FUNCPTR(XRRFreeProviderResources)
|
|
|
|
MAKE_FUNCPTR(XRRGetProviderInfo)
|
|
|
|
MAKE_FUNCPTR(XRRFreeProviderInfo)
|
|
|
|
#endif
|
|
|
|
|
2004-04-07 05:57:35 +02:00
|
|
|
#undef MAKE_FUNCPTR
|
|
|
|
|
2012-07-03 12:59:43 +02:00
|
|
|
static struct x11drv_mode_info *dd_modes;
|
2012-07-15 15:45:00 +02:00
|
|
|
static SizeID *xrandr10_modes;
|
2012-07-13 12:53:10 +02:00
|
|
|
static unsigned int xrandr_mode_count;
|
2013-05-10 17:51:21 +02:00
|
|
|
static int xrandr_current_mode = -1;
|
2003-10-16 02:21:42 +02:00
|
|
|
|
2005-07-06 17:53:04 +02:00
|
|
|
static int load_xrandr(void)
|
2004-04-07 05:57:35 +02:00
|
|
|
{
|
|
|
|
int r = 0;
|
|
|
|
|
2020-04-06 22:43:15 +02:00
|
|
|
if (dlopen(SONAME_LIBXRENDER, RTLD_NOW|RTLD_GLOBAL) &&
|
|
|
|
(xrandr_handle = dlopen(SONAME_LIBXRANDR, RTLD_NOW)))
|
2004-04-07 05:57:35 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
#define LOAD_FUNCPTR(f) \
|
2020-04-06 22:43:15 +02:00
|
|
|
if((p##f = dlsym(xrandr_handle, #f)) == NULL) goto sym_not_found
|
|
|
|
|
|
|
|
LOAD_FUNCPTR(XRRConfigCurrentConfiguration);
|
|
|
|
LOAD_FUNCPTR(XRRConfigCurrentRate);
|
|
|
|
LOAD_FUNCPTR(XRRFreeScreenConfigInfo);
|
|
|
|
LOAD_FUNCPTR(XRRGetScreenInfo);
|
|
|
|
LOAD_FUNCPTR(XRRQueryExtension);
|
|
|
|
LOAD_FUNCPTR(XRRQueryVersion);
|
|
|
|
LOAD_FUNCPTR(XRRRates);
|
|
|
|
LOAD_FUNCPTR(XRRSetScreenConfig);
|
|
|
|
LOAD_FUNCPTR(XRRSetScreenConfigAndRate);
|
|
|
|
LOAD_FUNCPTR(XRRSizes);
|
2012-07-15 15:45:00 +02:00
|
|
|
r = 1;
|
|
|
|
|
|
|
|
#ifdef HAVE_XRRGETSCREENRESOURCES
|
2020-04-06 22:43:15 +02:00
|
|
|
LOAD_FUNCPTR(XRRFreeCrtcInfo);
|
|
|
|
LOAD_FUNCPTR(XRRFreeOutputInfo);
|
|
|
|
LOAD_FUNCPTR(XRRFreeScreenResources);
|
|
|
|
LOAD_FUNCPTR(XRRGetCrtcInfo);
|
|
|
|
LOAD_FUNCPTR(XRRGetOutputInfo);
|
|
|
|
LOAD_FUNCPTR(XRRGetScreenResources);
|
|
|
|
LOAD_FUNCPTR(XRRGetScreenSizeRange);
|
|
|
|
LOAD_FUNCPTR(XRRSetCrtcConfig);
|
|
|
|
LOAD_FUNCPTR(XRRSetScreenSize);
|
2012-07-15 15:45:00 +02:00
|
|
|
r = 2;
|
|
|
|
#endif
|
2019-09-20 10:55:22 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_XRRGETPROVIDERRESOURCES
|
2020-04-06 22:43:15 +02:00
|
|
|
LOAD_FUNCPTR(XRRSelectInput);
|
|
|
|
LOAD_FUNCPTR(XRRGetOutputPrimary);
|
|
|
|
LOAD_FUNCPTR(XRRGetProviderResources);
|
|
|
|
LOAD_FUNCPTR(XRRFreeProviderResources);
|
|
|
|
LOAD_FUNCPTR(XRRGetProviderInfo);
|
|
|
|
LOAD_FUNCPTR(XRRFreeProviderInfo);
|
2019-09-20 10:55:22 +02:00
|
|
|
r = 4;
|
|
|
|
#endif
|
|
|
|
|
2004-04-07 05:57:35 +02:00
|
|
|
#undef LOAD_FUNCPTR
|
|
|
|
|
|
|
|
sym_not_found:
|
|
|
|
if (!r) TRACE("Unable to load function ptrs from XRandR library\n");
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2003-10-16 02:21:42 +02:00
|
|
|
static int XRandRErrorHandler(Display *dpy, XErrorEvent *event, void *arg)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-07-15 15:45:00 +02:00
|
|
|
static int xrandr10_get_current_mode(void)
|
2003-10-16 02:21:42 +02:00
|
|
|
{
|
|
|
|
SizeID size;
|
|
|
|
Rotation rot;
|
|
|
|
XRRScreenConfiguration *sc;
|
|
|
|
short rate;
|
2004-08-12 01:45:34 +02:00
|
|
|
unsigned int i;
|
2003-10-16 02:21:42 +02:00
|
|
|
int res = -1;
|
2012-08-16 16:46:37 +02:00
|
|
|
|
2013-05-10 17:51:21 +02:00
|
|
|
if (xrandr_current_mode != -1)
|
|
|
|
return xrandr_current_mode;
|
|
|
|
|
2012-08-16 16:46:37 +02:00
|
|
|
sc = pXRRGetScreenInfo (gdi_display, DefaultRootWindow( gdi_display ));
|
2004-04-07 05:57:35 +02:00
|
|
|
size = pXRRConfigCurrentConfiguration (sc, &rot);
|
|
|
|
rate = pXRRConfigCurrentRate (sc);
|
2007-01-11 15:47:06 +01:00
|
|
|
pXRRFreeScreenConfigInfo(sc);
|
2012-08-16 16:46:37 +02:00
|
|
|
|
2012-07-13 12:53:10 +02:00
|
|
|
for (i = 0; i < xrandr_mode_count; ++i)
|
2003-10-16 02:21:42 +02:00
|
|
|
{
|
2012-07-15 15:45:00 +02:00
|
|
|
if (xrandr10_modes[i] == size && dd_modes[i].refresh_rate == rate)
|
2012-07-13 12:53:10 +02:00
|
|
|
{
|
|
|
|
res = i;
|
|
|
|
break;
|
|
|
|
}
|
2003-10-16 02:21:42 +02:00
|
|
|
}
|
|
|
|
if (res == -1)
|
|
|
|
{
|
|
|
|
ERR("In unknown mode, returning default\n");
|
2013-05-10 17:51:21 +02:00
|
|
|
return 0;
|
2003-10-16 02:21:42 +02:00
|
|
|
}
|
2013-05-10 17:51:21 +02:00
|
|
|
|
|
|
|
xrandr_current_mode = res;
|
2003-10-16 02:21:42 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2012-07-15 15:45:00 +02:00
|
|
|
static LONG xrandr10_set_current_mode( int mode )
|
2003-10-16 02:21:42 +02:00
|
|
|
{
|
|
|
|
SizeID size;
|
|
|
|
Rotation rot;
|
|
|
|
Window root;
|
|
|
|
XRRScreenConfiguration *sc;
|
2012-07-13 12:53:10 +02:00
|
|
|
Status stat;
|
2003-10-16 02:21:42 +02:00
|
|
|
short rate;
|
2007-12-16 14:00:45 +01:00
|
|
|
|
2012-08-16 16:46:37 +02:00
|
|
|
root = DefaultRootWindow( gdi_display );
|
2004-04-07 05:57:35 +02:00
|
|
|
sc = pXRRGetScreenInfo (gdi_display, root);
|
2015-01-23 11:13:17 +01:00
|
|
|
pXRRConfigCurrentConfiguration (sc, &rot);
|
2012-07-13 12:53:10 +02:00
|
|
|
mode = mode % xrandr_mode_count;
|
2005-04-28 20:29:12 +02:00
|
|
|
|
2012-07-03 12:59:43 +02:00
|
|
|
TRACE("Changing Resolution to %dx%d @%d Hz\n",
|
|
|
|
dd_modes[mode].width,
|
|
|
|
dd_modes[mode].height,
|
|
|
|
dd_modes[mode].refresh_rate);
|
2005-04-28 20:29:12 +02:00
|
|
|
|
2012-07-15 15:45:00 +02:00
|
|
|
size = xrandr10_modes[mode];
|
2012-07-13 12:53:10 +02:00
|
|
|
rate = dd_modes[mode].refresh_rate;
|
|
|
|
|
|
|
|
if (rate)
|
|
|
|
stat = pXRRSetScreenConfigAndRate( gdi_display, sc, root, size, rot, rate, CurrentTime );
|
|
|
|
else
|
|
|
|
stat = pXRRSetScreenConfig( gdi_display, sc, root, size, rot, CurrentTime );
|
|
|
|
|
2004-04-07 05:57:35 +02:00
|
|
|
pXRRFreeScreenConfigInfo(sc);
|
2012-08-16 16:46:37 +02:00
|
|
|
|
2004-02-13 04:58:21 +01:00
|
|
|
if (stat == RRSetConfigSuccess)
|
2007-02-22 12:42:20 +01:00
|
|
|
{
|
2013-05-10 17:51:21 +02:00
|
|
|
xrandr_current_mode = mode;
|
2020-05-11 10:55:27 +02:00
|
|
|
X11DRV_DisplayDevices_Update( TRUE );
|
2007-02-22 12:42:20 +01:00
|
|
|
return DISP_CHANGE_SUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ERR("Resolution change not successful -- perhaps display has changed?\n");
|
|
|
|
return DISP_CHANGE_FAILED;
|
2003-10-16 02:21:42 +02:00
|
|
|
}
|
|
|
|
|
2012-07-15 15:45:00 +02:00
|
|
|
static void xrandr10_init_modes(void)
|
2012-07-09 23:16:41 +02:00
|
|
|
{
|
2012-07-13 12:53:10 +02:00
|
|
|
XRRScreenSize *sizes;
|
|
|
|
int sizes_count;
|
2012-07-09 23:16:41 +02:00
|
|
|
int i, j, nmodes = 0;
|
|
|
|
|
2012-07-13 12:53:10 +02:00
|
|
|
sizes = pXRRSizes( gdi_display, DefaultScreen(gdi_display), &sizes_count );
|
|
|
|
if (sizes_count <= 0) return;
|
2012-07-09 23:16:41 +02:00
|
|
|
|
2012-07-13 12:53:10 +02:00
|
|
|
TRACE("XRandR: found %d sizes.\n", sizes_count);
|
|
|
|
for (i = 0; i < sizes_count; ++i)
|
2012-07-09 23:16:41 +02:00
|
|
|
{
|
2012-07-13 12:53:10 +02:00
|
|
|
int rates_count;
|
|
|
|
short *rates;
|
|
|
|
|
|
|
|
rates = pXRRRates( gdi_display, DefaultScreen(gdi_display), i, &rates_count );
|
|
|
|
TRACE("- at %d: %dx%d (%d rates):", i, sizes[i].width, sizes[i].height, rates_count);
|
|
|
|
if (rates_count)
|
2012-07-09 23:16:41 +02:00
|
|
|
{
|
2012-07-13 12:53:10 +02:00
|
|
|
nmodes += rates_count;
|
|
|
|
for (j = 0; j < rates_count; ++j)
|
2012-07-09 23:16:41 +02:00
|
|
|
{
|
|
|
|
if (j > 0)
|
|
|
|
TRACE(",");
|
2012-07-13 12:53:10 +02:00
|
|
|
TRACE(" %d", rates[j]);
|
2012-07-09 23:16:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
++nmodes;
|
|
|
|
TRACE(" <default>");
|
|
|
|
}
|
|
|
|
TRACE(" Hz\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("XRandR modes: count=%d\n", nmodes);
|
|
|
|
|
2012-07-15 15:45:00 +02:00
|
|
|
if (!(xrandr10_modes = HeapAlloc( GetProcessHeap(), 0, sizeof(*xrandr10_modes) * nmodes )))
|
2012-07-13 12:53:10 +02:00
|
|
|
{
|
|
|
|
ERR("Failed to allocate xrandr mode info array.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-15 15:45:00 +02:00
|
|
|
dd_modes = X11DRV_Settings_SetHandlers( "XRandR 1.0",
|
|
|
|
xrandr10_get_current_mode,
|
|
|
|
xrandr10_set_current_mode,
|
2012-07-09 23:16:41 +02:00
|
|
|
nmodes, 1 );
|
|
|
|
|
2012-07-13 12:53:10 +02:00
|
|
|
xrandr_mode_count = 0;
|
|
|
|
for (i = 0; i < sizes_count; ++i)
|
2012-07-09 23:16:41 +02:00
|
|
|
{
|
2012-07-13 12:53:10 +02:00
|
|
|
int rates_count;
|
|
|
|
short *rates;
|
|
|
|
|
|
|
|
rates = pXRRRates( gdi_display, DefaultScreen(gdi_display), i, &rates_count );
|
|
|
|
|
|
|
|
if (rates_count)
|
2012-07-09 23:16:41 +02:00
|
|
|
{
|
2012-07-13 12:53:10 +02:00
|
|
|
for (j = 0; j < rates_count; ++j)
|
2012-07-09 23:16:41 +02:00
|
|
|
{
|
2012-07-13 12:53:10 +02:00
|
|
|
X11DRV_Settings_AddOneMode( sizes[i].width, sizes[i].height, 0, rates[j] );
|
2012-07-15 15:45:00 +02:00
|
|
|
xrandr10_modes[xrandr_mode_count++] = i;
|
2012-07-09 23:16:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-13 12:53:10 +02:00
|
|
|
X11DRV_Settings_AddOneMode( sizes[i].width, sizes[i].height, 0, 0 );
|
2012-07-15 15:45:00 +02:00
|
|
|
xrandr10_modes[xrandr_mode_count++] = i;
|
2012-07-09 23:16:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
X11DRV_Settings_AddDepthModes();
|
2012-07-13 12:53:10 +02:00
|
|
|
nmodes = X11DRV_Settings_GetModeCount();
|
2012-07-09 23:16:41 +02:00
|
|
|
|
2012-07-13 12:53:10 +02:00
|
|
|
TRACE("Available DD modes: count=%d\n", nmodes);
|
2012-07-09 23:16:41 +02:00
|
|
|
TRACE("Enabling XRandR\n");
|
|
|
|
}
|
|
|
|
|
2012-07-15 15:45:00 +02:00
|
|
|
#ifdef HAVE_XRRGETSCREENRESOURCES
|
|
|
|
|
2019-08-14 10:22:01 +02:00
|
|
|
static XRRScreenResources *xrandr_get_screen_resources(void)
|
|
|
|
{
|
|
|
|
XRRScreenResources *resources = pXRRGetScreenResourcesCurrent( gdi_display, root_window );
|
|
|
|
if (resources && !resources->ncrtc)
|
|
|
|
{
|
|
|
|
pXRRFreeScreenResources( resources );
|
|
|
|
resources = pXRRGetScreenResources( gdi_display, root_window );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!resources)
|
|
|
|
ERR("Failed to get screen resources.\n");
|
|
|
|
return resources;
|
|
|
|
}
|
|
|
|
|
2012-07-15 15:45:00 +02:00
|
|
|
static int xrandr12_get_current_mode(void)
|
|
|
|
{
|
|
|
|
XRRScreenResources *resources;
|
|
|
|
XRRCrtcInfo *crtc_info;
|
|
|
|
int i, ret = -1;
|
|
|
|
|
2013-05-10 18:03:42 +02:00
|
|
|
if (xrandr_current_mode != -1)
|
|
|
|
return xrandr_current_mode;
|
|
|
|
|
2012-08-20 08:12:07 +02:00
|
|
|
if (!(resources = pXRRGetScreenResourcesCurrent( gdi_display, root_window )))
|
2012-07-15 15:45:00 +02:00
|
|
|
{
|
|
|
|
ERR("Failed to get screen resources.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-28 01:06:54 +02:00
|
|
|
if (resources->ncrtc <= primary_crtc ||
|
|
|
|
!(crtc_info = pXRRGetCrtcInfo( gdi_display, resources, resources->crtcs[primary_crtc] )))
|
2012-07-15 15:45:00 +02:00
|
|
|
{
|
|
|
|
pXRRFreeScreenResources( resources );
|
|
|
|
ERR("Failed to get CRTC info.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-28 01:06:54 +02:00
|
|
|
TRACE("CRTC %d: mode %#lx, %ux%u+%d+%d.\n", primary_crtc, crtc_info->mode,
|
2012-07-15 15:45:00 +02:00
|
|
|
crtc_info->width, crtc_info->height, crtc_info->x, crtc_info->y);
|
|
|
|
|
|
|
|
for (i = 0; i < xrandr_mode_count; ++i)
|
|
|
|
{
|
|
|
|
if (xrandr12_modes[i] == crtc_info->mode)
|
|
|
|
{
|
|
|
|
ret = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pXRRFreeCrtcInfo( crtc_info );
|
|
|
|
pXRRFreeScreenResources( resources );
|
|
|
|
|
|
|
|
if (ret == -1)
|
|
|
|
{
|
|
|
|
ERR("Unknown mode, returning default.\n");
|
2013-05-10 18:03:42 +02:00
|
|
|
return 0;
|
2012-07-15 15:45:00 +02:00
|
|
|
}
|
|
|
|
|
2013-05-10 18:03:42 +02:00
|
|
|
xrandr_current_mode = ret;
|
2012-07-15 15:45:00 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-04-11 05:30:32 +02:00
|
|
|
static void get_screen_size( XRRScreenResources *resources, unsigned int *width, unsigned int *height )
|
|
|
|
{
|
2020-03-30 16:38:28 +02:00
|
|
|
int min_width = 0, min_height = 0, max_width, max_height;
|
2019-04-11 05:30:32 +02:00
|
|
|
XRRCrtcInfo *crtc_info;
|
|
|
|
int i;
|
2020-03-30 16:38:28 +02:00
|
|
|
|
|
|
|
pXRRGetScreenSizeRange( gdi_display, root_window, &min_width, &min_height, &max_width, &max_height );
|
|
|
|
*width = min_width;
|
|
|
|
*height = min_height;
|
2019-04-11 05:30:32 +02:00
|
|
|
|
|
|
|
for (i = 0; i < resources->ncrtc; ++i)
|
|
|
|
{
|
|
|
|
if (!(crtc_info = pXRRGetCrtcInfo( gdi_display, resources, resources->crtcs[i] )))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (crtc_info->mode != None)
|
|
|
|
{
|
|
|
|
*width = max(*width, crtc_info->x + crtc_info->width);
|
|
|
|
*height = max(*height, crtc_info->y + crtc_info->height);
|
|
|
|
}
|
|
|
|
|
|
|
|
pXRRFreeCrtcInfo( crtc_info );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-15 15:45:00 +02:00
|
|
|
static LONG xrandr12_set_current_mode( int mode )
|
|
|
|
{
|
2019-04-11 05:30:32 +02:00
|
|
|
unsigned int screen_width, screen_height;
|
2012-07-15 15:45:00 +02:00
|
|
|
Status status = RRSetConfigFailed;
|
|
|
|
XRRScreenResources *resources;
|
|
|
|
XRRCrtcInfo *crtc_info;
|
|
|
|
|
|
|
|
mode = mode % xrandr_mode_count;
|
|
|
|
|
2012-08-20 08:12:07 +02:00
|
|
|
if (!(resources = pXRRGetScreenResourcesCurrent( gdi_display, root_window )))
|
2012-07-15 15:45:00 +02:00
|
|
|
{
|
|
|
|
ERR("Failed to get screen resources.\n");
|
|
|
|
return DISP_CHANGE_FAILED;
|
|
|
|
}
|
|
|
|
|
2012-09-28 01:06:54 +02:00
|
|
|
if (resources->ncrtc <= primary_crtc ||
|
|
|
|
!(crtc_info = pXRRGetCrtcInfo( gdi_display, resources, resources->crtcs[primary_crtc] )))
|
2012-07-15 15:45:00 +02:00
|
|
|
{
|
|
|
|
pXRRFreeScreenResources( resources );
|
|
|
|
ERR("Failed to get CRTC info.\n");
|
|
|
|
return DISP_CHANGE_FAILED;
|
|
|
|
}
|
|
|
|
|
2012-09-28 01:06:54 +02:00
|
|
|
TRACE("CRTC %d: mode %#lx, %ux%u+%d+%d.\n", primary_crtc, crtc_info->mode,
|
2012-07-15 15:45:00 +02:00
|
|
|
crtc_info->width, crtc_info->height, crtc_info->x, crtc_info->y);
|
|
|
|
|
2019-04-11 05:30:32 +02:00
|
|
|
/* According to the RandR spec, the entire CRTC must fit inside the screen.
|
|
|
|
* Since we use the union of all enabled CRTCs to determine the necessary
|
|
|
|
* screen size, this might involve shrinking the screen, so we must disable
|
|
|
|
* the CRTC in question first. */
|
|
|
|
|
|
|
|
XGrabServer( gdi_display );
|
|
|
|
|
|
|
|
status = pXRRSetCrtcConfig( gdi_display, resources, resources->crtcs[primary_crtc],
|
|
|
|
CurrentTime, crtc_info->x, crtc_info->y, None,
|
|
|
|
crtc_info->rotation, NULL, 0 );
|
|
|
|
if (status != RRSetConfigSuccess)
|
|
|
|
{
|
|
|
|
XUngrabServer( gdi_display );
|
2019-10-25 15:39:54 +02:00
|
|
|
XFlush( gdi_display );
|
2019-04-11 05:30:32 +02:00
|
|
|
ERR("Failed to disable CRTC.\n");
|
|
|
|
pXRRFreeCrtcInfo( crtc_info );
|
|
|
|
pXRRFreeScreenResources( resources );
|
|
|
|
return DISP_CHANGE_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
get_screen_size( resources, &screen_width, &screen_height );
|
|
|
|
screen_width = max( screen_width, crtc_info->x + dd_modes[mode].width );
|
|
|
|
screen_height = max( screen_height, crtc_info->y + dd_modes[mode].height );
|
|
|
|
|
|
|
|
pXRRSetScreenSize( gdi_display, root_window, screen_width, screen_height,
|
|
|
|
screen_width * DisplayWidthMM( gdi_display, default_visual.screen )
|
|
|
|
/ DisplayWidth( gdi_display, default_visual.screen ),
|
|
|
|
screen_height * DisplayHeightMM( gdi_display, default_visual.screen )
|
|
|
|
/ DisplayHeight( gdi_display, default_visual.screen ));
|
|
|
|
|
2012-09-28 01:06:54 +02:00
|
|
|
status = pXRRSetCrtcConfig( gdi_display, resources, resources->crtcs[primary_crtc],
|
|
|
|
CurrentTime, crtc_info->x, crtc_info->y, xrandr12_modes[mode],
|
|
|
|
crtc_info->rotation, crtc_info->outputs, crtc_info->noutput );
|
2012-07-15 15:45:00 +02:00
|
|
|
|
2019-04-11 05:30:32 +02:00
|
|
|
XUngrabServer( gdi_display );
|
2019-10-25 15:39:54 +02:00
|
|
|
XFlush( gdi_display );
|
2019-04-11 05:30:32 +02:00
|
|
|
|
2012-07-15 15:45:00 +02:00
|
|
|
pXRRFreeCrtcInfo( crtc_info );
|
|
|
|
pXRRFreeScreenResources( resources );
|
|
|
|
|
|
|
|
if (status != RRSetConfigSuccess)
|
|
|
|
{
|
|
|
|
ERR("Resolution change not successful -- perhaps display has changed?\n");
|
|
|
|
return DISP_CHANGE_FAILED;
|
|
|
|
}
|
|
|
|
|
2013-05-10 18:03:42 +02:00
|
|
|
xrandr_current_mode = mode;
|
2020-05-11 10:55:27 +02:00
|
|
|
X11DRV_DisplayDevices_Update( TRUE );
|
2012-07-15 15:45:00 +02:00
|
|
|
return DISP_CHANGE_SUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
2012-09-28 01:06:54 +02:00
|
|
|
static XRRCrtcInfo *xrandr12_get_primary_crtc_info( XRRScreenResources *resources, int *crtc_idx )
|
|
|
|
{
|
|
|
|
XRRCrtcInfo *crtc_info;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < resources->ncrtc; ++i)
|
|
|
|
{
|
|
|
|
crtc_info = pXRRGetCrtcInfo( gdi_display, resources, resources->crtcs[i] );
|
|
|
|
if (!crtc_info || crtc_info->mode == None)
|
|
|
|
{
|
|
|
|
pXRRFreeCrtcInfo( crtc_info );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
*crtc_idx = i;
|
|
|
|
return crtc_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-04-20 10:42:33 +02:00
|
|
|
static unsigned int get_frequency( const XRRModeInfo *mode )
|
|
|
|
{
|
|
|
|
unsigned int dots = mode->hTotal * mode->vTotal;
|
|
|
|
|
|
|
|
if (!dots)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (mode->modeFlags & RR_DoubleScan)
|
|
|
|
dots *= 2;
|
|
|
|
if (mode->modeFlags & RR_Interlace)
|
|
|
|
dots /= 2;
|
|
|
|
|
|
|
|
return (mode->dotClock + dots / 2) / dots;
|
|
|
|
}
|
|
|
|
|
2012-08-20 08:12:06 +02:00
|
|
|
static int xrandr12_init_modes(void)
|
2012-07-15 15:45:00 +02:00
|
|
|
{
|
2014-08-09 21:15:09 +02:00
|
|
|
unsigned int only_one_resolution = 1, mode_count;
|
2012-07-15 15:45:00 +02:00
|
|
|
XRRScreenResources *resources;
|
|
|
|
XRROutputInfo *output_info;
|
|
|
|
XRRCrtcInfo *crtc_info;
|
2012-08-20 08:12:06 +02:00
|
|
|
int ret = -1;
|
2012-07-15 15:45:00 +02:00
|
|
|
int i, j;
|
|
|
|
|
2019-08-14 10:22:01 +02:00
|
|
|
if (!(resources = xrandr_get_screen_resources()))
|
2012-08-20 08:12:06 +02:00
|
|
|
return ret;
|
2012-08-20 08:12:07 +02:00
|
|
|
|
2012-09-28 01:06:54 +02:00
|
|
|
if (!(crtc_info = xrandr12_get_primary_crtc_info( resources, &primary_crtc )))
|
2012-07-15 15:45:00 +02:00
|
|
|
{
|
|
|
|
pXRRFreeScreenResources( resources );
|
2012-09-28 01:06:54 +02:00
|
|
|
ERR("Failed to get primary CRTC info.\n");
|
2012-08-20 08:12:06 +02:00
|
|
|
return ret;
|
2012-07-15 15:45:00 +02:00
|
|
|
}
|
|
|
|
|
2012-09-28 01:06:54 +02:00
|
|
|
TRACE("CRTC %d: mode %#lx, %ux%u+%d+%d.\n", primary_crtc, crtc_info->mode,
|
2012-07-15 15:45:00 +02:00
|
|
|
crtc_info->width, crtc_info->height, crtc_info->x, crtc_info->y);
|
|
|
|
|
|
|
|
if (!crtc_info->noutput || !(output_info = pXRRGetOutputInfo( gdi_display, resources, crtc_info->outputs[0] )))
|
|
|
|
{
|
|
|
|
pXRRFreeCrtcInfo( crtc_info );
|
|
|
|
pXRRFreeScreenResources( resources );
|
|
|
|
ERR("Failed to get output info.\n");
|
2012-08-20 08:12:06 +02:00
|
|
|
return ret;
|
2012-07-15 15:45:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("OUTPUT 0: name %s.\n", debugstr_a(output_info->name));
|
|
|
|
|
|
|
|
if (!output_info->nmode)
|
|
|
|
{
|
2016-04-19 18:34:08 +02:00
|
|
|
WARN("Output has no modes.\n");
|
2012-07-15 15:45:00 +02:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(xrandr12_modes = HeapAlloc( GetProcessHeap(), 0, sizeof(*xrandr12_modes) * output_info->nmode )))
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate xrandr mode info array.\n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
dd_modes = X11DRV_Settings_SetHandlers( "XRandR 1.2",
|
|
|
|
xrandr12_get_current_mode,
|
|
|
|
xrandr12_set_current_mode,
|
|
|
|
output_info->nmode, 1 );
|
|
|
|
|
|
|
|
xrandr_mode_count = 0;
|
|
|
|
for (i = 0; i < output_info->nmode; ++i)
|
|
|
|
{
|
|
|
|
for (j = 0; j < resources->nmode; ++j)
|
|
|
|
{
|
|
|
|
XRRModeInfo *mode = &resources->modes[j];
|
|
|
|
|
|
|
|
if (mode->id == output_info->modes[i])
|
|
|
|
{
|
2020-04-20 10:42:33 +02:00
|
|
|
unsigned int refresh = get_frequency( mode );
|
2012-07-15 15:45:00 +02:00
|
|
|
|
|
|
|
TRACE("Adding mode %#lx: %ux%u@%u.\n", mode->id, mode->width, mode->height, refresh);
|
|
|
|
X11DRV_Settings_AddOneMode( mode->width, mode->height, 0, refresh );
|
|
|
|
xrandr12_modes[xrandr_mode_count++] = mode->id;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-09 21:15:09 +02:00
|
|
|
mode_count = X11DRV_Settings_GetModeCount();
|
|
|
|
for (i = 1; i < mode_count; ++i)
|
|
|
|
{
|
|
|
|
if (dd_modes[i].width != dd_modes[0].width || dd_modes[i].height != dd_modes[0].height)
|
|
|
|
{
|
|
|
|
only_one_resolution = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Recent (304.64, possibly earlier) versions of the nvidia driver only
|
|
|
|
* report a DFP's native mode through RandR 1.2 / 1.3. Standard DMT modes
|
|
|
|
* are only listed through RandR 1.0 / 1.1. This is completely useless,
|
|
|
|
* but NVIDIA considers this a feature, so it's unlikely to change. The
|
|
|
|
* best we can do is to fall back to RandR 1.0 and encourage users to
|
|
|
|
* consider more cooperative driver vendors when we detect such a
|
|
|
|
* configuration. */
|
|
|
|
if (only_one_resolution && XQueryExtension( gdi_display, "NV-CONTROL", &i, &j, &ret ))
|
|
|
|
{
|
|
|
|
ERR_(winediag)("Broken NVIDIA RandR detected, falling back to RandR 1.0. "
|
|
|
|
"Please consider using the Nouveau driver instead.\n");
|
|
|
|
ret = -1;
|
|
|
|
HeapFree( GetProcessHeap(), 0, xrandr12_modes );
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2012-07-15 15:45:00 +02:00
|
|
|
X11DRV_Settings_AddDepthModes();
|
2012-08-20 08:12:06 +02:00
|
|
|
ret = 0;
|
2012-07-15 15:45:00 +02:00
|
|
|
|
|
|
|
done:
|
|
|
|
pXRRFreeOutputInfo( output_info );
|
|
|
|
pXRRFreeCrtcInfo( crtc_info );
|
|
|
|
pXRRFreeScreenResources( resources );
|
2012-08-20 08:12:06 +02:00
|
|
|
return ret;
|
2012-07-15 15:45:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HAVE_XRRGETSCREENRESOURCES */
|
|
|
|
|
2019-09-20 10:55:22 +02:00
|
|
|
#ifdef HAVE_XRRGETPROVIDERRESOURCES
|
|
|
|
|
|
|
|
static RECT get_primary_rect( XRRScreenResources *resources )
|
|
|
|
{
|
|
|
|
XRROutputInfo *output_info = NULL;
|
|
|
|
XRRCrtcInfo *crtc_info = NULL;
|
|
|
|
RROutput primary_output;
|
|
|
|
RECT primary_rect = {0};
|
|
|
|
RECT first_rect = {0};
|
|
|
|
INT i;
|
|
|
|
|
|
|
|
primary_output = pXRRGetOutputPrimary( gdi_display, root_window );
|
|
|
|
if (!primary_output)
|
|
|
|
goto fallback;
|
|
|
|
|
|
|
|
output_info = pXRRGetOutputInfo( gdi_display, resources, primary_output );
|
|
|
|
if (!output_info || output_info->connection != RR_Connected || !output_info->crtc)
|
|
|
|
goto fallback;
|
|
|
|
|
|
|
|
crtc_info = pXRRGetCrtcInfo( gdi_display, resources, output_info->crtc );
|
|
|
|
if (!crtc_info || !crtc_info->mode)
|
|
|
|
goto fallback;
|
|
|
|
|
|
|
|
SetRect( &primary_rect, crtc_info->x, crtc_info->y, crtc_info->x + crtc_info->width, crtc_info->y + crtc_info->height );
|
|
|
|
pXRRFreeCrtcInfo( crtc_info );
|
|
|
|
pXRRFreeOutputInfo( output_info );
|
|
|
|
return primary_rect;
|
|
|
|
|
|
|
|
/* Fallback when XRandR primary output is a disconnected output.
|
|
|
|
* Try to find a crtc with (x, y) being (0, 0). If it's found then get the primary rect from that crtc,
|
|
|
|
* otherwise use the first active crtc to get the primary rect */
|
|
|
|
fallback:
|
|
|
|
if (crtc_info)
|
|
|
|
pXRRFreeCrtcInfo( crtc_info );
|
|
|
|
if (output_info)
|
|
|
|
pXRRFreeOutputInfo( output_info );
|
|
|
|
|
2019-12-11 02:56:53 +01:00
|
|
|
WARN("Primary is set to a disconnected XRandR output.\n");
|
2019-09-20 10:55:22 +02:00
|
|
|
for (i = 0; i < resources->ncrtc; ++i)
|
|
|
|
{
|
|
|
|
crtc_info = pXRRGetCrtcInfo( gdi_display, resources, resources->crtcs[i] );
|
|
|
|
if (!crtc_info)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!crtc_info->mode)
|
|
|
|
{
|
|
|
|
pXRRFreeCrtcInfo( crtc_info );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!crtc_info->x && !crtc_info->y)
|
|
|
|
{
|
|
|
|
SetRect( &primary_rect, 0, 0, crtc_info->width, crtc_info->height );
|
|
|
|
pXRRFreeCrtcInfo( crtc_info );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsRectEmpty( &first_rect ))
|
|
|
|
SetRect( &first_rect, crtc_info->x, crtc_info->y,
|
|
|
|
crtc_info->x + crtc_info->width, crtc_info->y + crtc_info->height );
|
|
|
|
|
|
|
|
pXRRFreeCrtcInfo( crtc_info );
|
|
|
|
}
|
|
|
|
|
|
|
|
return IsRectEmpty( &primary_rect ) ? first_rect : primary_rect;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL is_crtc_primary( RECT primary, const XRRCrtcInfo *crtc )
|
|
|
|
{
|
|
|
|
return crtc &&
|
|
|
|
crtc->mode &&
|
|
|
|
crtc->x == primary.left &&
|
|
|
|
crtc->y == primary.top &&
|
|
|
|
crtc->x + crtc->width == primary.right &&
|
|
|
|
crtc->y + crtc->height == primary.bottom;
|
|
|
|
}
|
|
|
|
|
2020-06-17 14:02:04 +02:00
|
|
|
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDisplayKHR)
|
|
|
|
|
|
|
|
static void get_vulkan_device_uuid( GUID *uuid, const XRRProviderInfo *provider_info )
|
|
|
|
{
|
|
|
|
static const char *extensions[] =
|
|
|
|
{
|
|
|
|
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
|
|
|
|
"VK_EXT_acquire_xlib_display",
|
|
|
|
"VK_EXT_direct_mode_display",
|
|
|
|
};
|
|
|
|
const struct vulkan_funcs *vulkan_funcs = get_vulkan_driver( WINE_VULKAN_DRIVER_VERSION );
|
|
|
|
VkResult (*pvkGetRandROutputDisplayEXT)( VkPhysicalDevice, Display *, RROutput, VkDisplayKHR * );
|
|
|
|
PFN_vkGetPhysicalDeviceProperties2 pvkGetPhysicalDeviceProperties2;
|
|
|
|
PFN_vkEnumeratePhysicalDevices pvkEnumeratePhysicalDevices;
|
|
|
|
uint32_t device_count, device_idx, output_idx;
|
|
|
|
VkPhysicalDevice *vk_physical_devices = NULL;
|
|
|
|
VkPhysicalDeviceProperties2 properties2;
|
|
|
|
VkInstanceCreateInfo create_info;
|
|
|
|
VkPhysicalDeviceIDProperties id;
|
|
|
|
VkInstance vk_instance = NULL;
|
|
|
|
VkDisplayKHR vk_display;
|
|
|
|
VkResult vr;
|
|
|
|
|
|
|
|
if (!vulkan_funcs)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
memset( &create_info, 0, sizeof(create_info) );
|
|
|
|
create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
|
|
|
create_info.enabledExtensionCount = ARRAY_SIZE(extensions);
|
|
|
|
create_info.ppEnabledExtensionNames = extensions;
|
|
|
|
|
|
|
|
vr = vulkan_funcs->p_vkCreateInstance( &create_info, NULL, &vk_instance );
|
|
|
|
if (vr != VK_SUCCESS)
|
|
|
|
{
|
|
|
|
WARN("Failed to create a Vulkan instance, vr %d.\n", vr);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define LOAD_VK_FUNC(f) \
|
|
|
|
if (!(p##f = (void *)vulkan_funcs->p_vkGetInstanceProcAddr( vk_instance, #f ))) \
|
|
|
|
{ \
|
|
|
|
WARN("Failed to load " #f ".\n"); \
|
|
|
|
goto done; \
|
|
|
|
}
|
|
|
|
|
|
|
|
LOAD_VK_FUNC(vkEnumeratePhysicalDevices)
|
|
|
|
LOAD_VK_FUNC(vkGetPhysicalDeviceProperties2)
|
|
|
|
LOAD_VK_FUNC(vkGetRandROutputDisplayEXT)
|
|
|
|
#undef LOAD_VK_FUNC
|
|
|
|
|
|
|
|
vr = pvkEnumeratePhysicalDevices( vk_instance, &device_count, NULL );
|
|
|
|
if (vr != VK_SUCCESS || !device_count)
|
|
|
|
{
|
|
|
|
WARN("No Vulkan device found, vr %d, device_count %d.\n", vr, device_count);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(vk_physical_devices = heap_calloc( device_count, sizeof(*vk_physical_devices) )))
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
vr = pvkEnumeratePhysicalDevices( vk_instance, &device_count, vk_physical_devices );
|
|
|
|
if (vr != VK_SUCCESS)
|
|
|
|
{
|
|
|
|
WARN("vkEnumeratePhysicalDevices failed, vr %d.\n", vr);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (device_idx = 0; device_idx < device_count; ++device_idx)
|
|
|
|
{
|
|
|
|
for (output_idx = 0; output_idx < provider_info->noutputs; ++output_idx)
|
|
|
|
{
|
2020-06-18 16:28:50 +02:00
|
|
|
X11DRV_expect_error( gdi_display, XRandRErrorHandler, NULL );
|
2020-06-17 14:02:04 +02:00
|
|
|
vr = pvkGetRandROutputDisplayEXT( vk_physical_devices[device_idx], gdi_display,
|
|
|
|
provider_info->outputs[output_idx], &vk_display );
|
2020-06-18 16:28:50 +02:00
|
|
|
XSync( gdi_display, FALSE );
|
|
|
|
if (X11DRV_check_error() || vr != VK_SUCCESS || vk_display == VK_NULL_HANDLE)
|
2020-06-17 14:02:04 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
memset( &id, 0, sizeof(id) );
|
|
|
|
id.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES;
|
|
|
|
properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
|
|
|
|
properties2.pNext = &id;
|
|
|
|
|
|
|
|
pvkGetPhysicalDeviceProperties2( vk_physical_devices[device_idx], &properties2 );
|
|
|
|
memcpy( uuid, id.deviceUUID, sizeof(id.deviceUUID) );
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
heap_free( vk_physical_devices );
|
|
|
|
if (vk_instance)
|
|
|
|
vulkan_funcs->p_vkDestroyInstance( vk_instance, NULL );
|
|
|
|
}
|
|
|
|
|
2019-09-20 10:55:22 +02:00
|
|
|
static BOOL xrandr14_get_gpus( struct x11drv_gpu **new_gpus, int *count )
|
|
|
|
{
|
2019-09-25 09:28:15 +02:00
|
|
|
static const WCHAR wine_adapterW[] = {'W','i','n','e',' ','A','d','a','p','t','e','r',0};
|
2019-09-20 10:55:22 +02:00
|
|
|
struct x11drv_gpu *gpus = NULL;
|
|
|
|
XRRScreenResources *screen_resources = NULL;
|
|
|
|
XRRProviderResources *provider_resources = NULL;
|
|
|
|
XRRProviderInfo *provider_info = NULL;
|
|
|
|
XRRCrtcInfo *crtc_info = NULL;
|
|
|
|
INT primary_provider = -1;
|
|
|
|
RECT primary_rect;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
INT i, j;
|
|
|
|
|
|
|
|
screen_resources = xrandr_get_screen_resources();
|
|
|
|
if (!screen_resources)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
provider_resources = pXRRGetProviderResources( gdi_display, root_window );
|
|
|
|
if (!provider_resources)
|
|
|
|
goto done;
|
|
|
|
|
2019-09-25 09:28:15 +02:00
|
|
|
gpus = heap_calloc( provider_resources->nproviders ? provider_resources->nproviders : 1, sizeof(*gpus) );
|
2019-09-20 10:55:22 +02:00
|
|
|
if (!gpus)
|
|
|
|
goto done;
|
|
|
|
|
2019-09-25 09:28:15 +02:00
|
|
|
/* Some XRandR implementations don't support providers.
|
|
|
|
* In this case, report a fake one to try searching adapters in screen resources */
|
|
|
|
if (!provider_resources->nproviders)
|
|
|
|
{
|
|
|
|
WARN("XRandR implementation doesn't report any providers, faking one.\n");
|
|
|
|
lstrcpyW( gpus[0].name, wine_adapterW );
|
|
|
|
*new_gpus = gpus;
|
|
|
|
*count = 1;
|
|
|
|
ret = TRUE;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2019-09-20 10:55:22 +02:00
|
|
|
primary_rect = get_primary_rect( screen_resources );
|
|
|
|
for (i = 0; i < provider_resources->nproviders; ++i)
|
|
|
|
{
|
|
|
|
provider_info = pXRRGetProviderInfo( gdi_display, screen_resources, provider_resources->providers[i] );
|
|
|
|
if (!provider_info)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* Find primary provider */
|
|
|
|
for (j = 0; primary_provider == -1 && j < provider_info->ncrtcs; ++j)
|
|
|
|
{
|
|
|
|
crtc_info = pXRRGetCrtcInfo( gdi_display, screen_resources, provider_info->crtcs[j] );
|
|
|
|
if (!crtc_info)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (is_crtc_primary( primary_rect, crtc_info ))
|
|
|
|
{
|
|
|
|
primary_provider = i;
|
|
|
|
pXRRFreeCrtcInfo( crtc_info );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pXRRFreeCrtcInfo( crtc_info );
|
|
|
|
}
|
|
|
|
|
|
|
|
gpus[i].id = provider_resources->providers[i];
|
2020-06-17 14:02:04 +02:00
|
|
|
get_vulkan_device_uuid( &gpus[i].vulkan_uuid, provider_info );
|
2019-09-20 10:55:22 +02:00
|
|
|
MultiByteToWideChar( CP_UTF8, 0, provider_info->name, -1, gpus[i].name, ARRAY_SIZE(gpus[i].name) );
|
|
|
|
/* PCI IDs are all zero because there is currently no portable way to get it via XRandR. Some AMD drivers report
|
|
|
|
* their PCI address in the name but many others don't */
|
|
|
|
pXRRFreeProviderInfo( provider_info );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make primary GPU the first */
|
|
|
|
if (primary_provider > 0)
|
|
|
|
{
|
|
|
|
struct x11drv_gpu tmp = gpus[0];
|
|
|
|
gpus[0] = gpus[primary_provider];
|
|
|
|
gpus[primary_provider] = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
*new_gpus = gpus;
|
|
|
|
*count = provider_resources->nproviders;
|
|
|
|
ret = TRUE;
|
|
|
|
done:
|
|
|
|
if (provider_resources)
|
|
|
|
pXRRFreeProviderResources( provider_resources );
|
|
|
|
if (screen_resources)
|
|
|
|
pXRRFreeScreenResources( screen_resources );
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
heap_free( gpus );
|
|
|
|
ERR("Failed to get gpus\n");
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void xrandr14_free_gpus( struct x11drv_gpu *gpus )
|
|
|
|
{
|
|
|
|
heap_free( gpus );
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL xrandr14_get_adapters( ULONG_PTR gpu_id, struct x11drv_adapter **new_adapters, int *count )
|
|
|
|
{
|
|
|
|
struct x11drv_adapter *adapters = NULL;
|
|
|
|
XRRScreenResources *screen_resources = NULL;
|
|
|
|
XRRProviderInfo *provider_info = NULL;
|
|
|
|
XRRCrtcInfo *enum_crtc_info, *crtc_info = NULL;
|
2020-04-20 10:37:17 +02:00
|
|
|
XRROutputInfo *enum_output_info, *output_info = NULL;
|
2019-09-25 09:28:15 +02:00
|
|
|
RROutput *outputs;
|
|
|
|
INT crtc_count, output_count;
|
2019-09-20 10:55:22 +02:00
|
|
|
INT primary_adapter = 0;
|
|
|
|
INT adapter_count = 0;
|
|
|
|
BOOL mirrored, detached;
|
|
|
|
RECT primary_rect;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
INT i, j;
|
|
|
|
|
|
|
|
screen_resources = xrandr_get_screen_resources();
|
|
|
|
if (!screen_resources)
|
|
|
|
goto done;
|
|
|
|
|
2019-09-25 09:28:15 +02:00
|
|
|
if (gpu_id)
|
|
|
|
{
|
|
|
|
provider_info = pXRRGetProviderInfo( gdi_display, screen_resources, gpu_id );
|
|
|
|
if (!provider_info)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
crtc_count = provider_info->ncrtcs;
|
|
|
|
output_count = provider_info->noutputs;
|
|
|
|
outputs = provider_info->outputs;
|
|
|
|
}
|
|
|
|
/* Fake provider id, search adapters in screen resources */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
crtc_count = screen_resources->ncrtc;
|
|
|
|
output_count = screen_resources->noutput;
|
|
|
|
outputs = screen_resources->outputs;
|
|
|
|
}
|
2019-09-20 10:55:22 +02:00
|
|
|
|
|
|
|
/* Actual adapter count could be less */
|
2019-09-25 09:28:15 +02:00
|
|
|
adapters = heap_calloc( crtc_count, sizeof(*adapters) );
|
2019-09-20 10:55:22 +02:00
|
|
|
if (!adapters)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
primary_rect = get_primary_rect( screen_resources );
|
2019-09-25 09:28:15 +02:00
|
|
|
for (i = 0; i < output_count; ++i)
|
2019-09-20 10:55:22 +02:00
|
|
|
{
|
2019-09-25 09:28:15 +02:00
|
|
|
output_info = pXRRGetOutputInfo( gdi_display, screen_resources, outputs[i] );
|
2019-09-20 10:55:22 +02:00
|
|
|
if (!output_info)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* Only connected output are considered as monitors */
|
|
|
|
if (output_info->connection != RR_Connected)
|
|
|
|
{
|
|
|
|
pXRRFreeOutputInfo( output_info );
|
|
|
|
output_info = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Connected output doesn't mean the output is attached to a crtc */
|
|
|
|
detached = FALSE;
|
|
|
|
if (output_info->crtc)
|
|
|
|
{
|
|
|
|
crtc_info = pXRRGetCrtcInfo( gdi_display, screen_resources, output_info->crtc );
|
|
|
|
if (!crtc_info)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!output_info->crtc || !crtc_info->mode)
|
|
|
|
detached = TRUE;
|
|
|
|
|
2020-06-18 13:34:27 +02:00
|
|
|
/* Ignore mirroring output replicas because mirrored monitors are under the same adapter */
|
2019-09-20 10:55:22 +02:00
|
|
|
mirrored = FALSE;
|
|
|
|
if (!detached)
|
|
|
|
{
|
2020-04-20 10:37:17 +02:00
|
|
|
for (j = 0; j < screen_resources->noutput; ++j)
|
2019-09-20 10:55:22 +02:00
|
|
|
{
|
2020-04-20 10:37:17 +02:00
|
|
|
enum_output_info = pXRRGetOutputInfo( gdi_display, screen_resources, screen_resources->outputs[j] );
|
|
|
|
if (!enum_output_info)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (enum_output_info->connection != RR_Connected || !enum_output_info->crtc)
|
|
|
|
{
|
|
|
|
pXRRFreeOutputInfo( enum_output_info );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum_crtc_info = pXRRGetCrtcInfo( gdi_display, screen_resources, enum_output_info->crtc );
|
|
|
|
pXRRFreeOutputInfo( enum_output_info );
|
2019-09-20 10:55:22 +02:00
|
|
|
if (!enum_crtc_info)
|
2020-04-20 10:37:17 +02:00
|
|
|
continue;
|
2019-09-20 10:55:22 +02:00
|
|
|
|
2020-04-20 10:37:17 +02:00
|
|
|
/* Some outputs may have the same coordinates, aka mirrored. Choose the output with
|
2020-06-18 13:34:27 +02:00
|
|
|
* the lowest value as primary and the rest will then be replicas in a mirroring set */
|
2019-09-20 10:55:22 +02:00
|
|
|
if (crtc_info->x == enum_crtc_info->x &&
|
|
|
|
crtc_info->y == enum_crtc_info->y &&
|
|
|
|
crtc_info->width == enum_crtc_info->width &&
|
|
|
|
crtc_info->height == enum_crtc_info->height &&
|
2020-04-20 10:37:17 +02:00
|
|
|
outputs[i] > screen_resources->outputs[j])
|
2019-09-20 10:55:22 +02:00
|
|
|
{
|
|
|
|
mirrored = TRUE;
|
|
|
|
pXRRFreeCrtcInfo( enum_crtc_info );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pXRRFreeCrtcInfo( enum_crtc_info );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mirrored || detached)
|
|
|
|
{
|
|
|
|
/* Use RROutput as adapter id. The reason of not using RRCrtc is that we need to detect inactive but
|
|
|
|
* attached monitors */
|
2019-09-25 09:28:15 +02:00
|
|
|
adapters[adapter_count].id = outputs[i];
|
2019-09-20 10:55:22 +02:00
|
|
|
if (!detached)
|
|
|
|
adapters[adapter_count].state_flags |= DISPLAY_DEVICE_ATTACHED_TO_DESKTOP;
|
|
|
|
if (is_crtc_primary( primary_rect, crtc_info ))
|
|
|
|
{
|
|
|
|
adapters[adapter_count].state_flags |= DISPLAY_DEVICE_PRIMARY_DEVICE;
|
|
|
|
primary_adapter = adapter_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
++adapter_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
pXRRFreeOutputInfo( output_info );
|
|
|
|
output_info = NULL;
|
|
|
|
if (crtc_info)
|
|
|
|
{
|
|
|
|
pXRRFreeCrtcInfo( crtc_info );
|
|
|
|
crtc_info = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make primary adapter the first */
|
|
|
|
if (primary_adapter)
|
|
|
|
{
|
|
|
|
struct x11drv_adapter tmp = adapters[0];
|
|
|
|
adapters[0] = adapters[primary_adapter];
|
|
|
|
adapters[primary_adapter] = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
*new_adapters = adapters;
|
|
|
|
*count = adapter_count;
|
|
|
|
ret = TRUE;
|
|
|
|
done:
|
|
|
|
if (screen_resources)
|
|
|
|
pXRRFreeScreenResources( screen_resources );
|
|
|
|
if (provider_info)
|
|
|
|
pXRRFreeProviderInfo( provider_info );
|
|
|
|
if (output_info)
|
|
|
|
pXRRFreeOutputInfo( output_info );
|
|
|
|
if (crtc_info)
|
|
|
|
pXRRFreeCrtcInfo( crtc_info );
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
heap_free( adapters );
|
|
|
|
ERR("Failed to get adapters\n");
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void xrandr14_free_adapters( struct x11drv_adapter *adapters )
|
|
|
|
{
|
|
|
|
heap_free( adapters );
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL xrandr14_get_monitors( ULONG_PTR adapter_id, struct x11drv_monitor **new_monitors, int *count )
|
|
|
|
{
|
|
|
|
static const WCHAR generic_nonpnp_monitorW[] = {
|
|
|
|
'G','e','n','e','r','i','c',' ',
|
|
|
|
'N','o','n','-','P','n','P',' ','M','o','n','i','t','o','r',0};
|
|
|
|
struct x11drv_monitor *realloc_monitors, *monitors = NULL;
|
|
|
|
XRRScreenResources *screen_resources = NULL;
|
|
|
|
XRROutputInfo *output_info = NULL, *enum_output_info = NULL;
|
|
|
|
XRRCrtcInfo *crtc_info = NULL, *enum_crtc_info;
|
|
|
|
INT primary_index = 0, monitor_count = 0, capacity;
|
|
|
|
RECT work_rect, primary_rect;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
INT i;
|
|
|
|
|
|
|
|
screen_resources = xrandr_get_screen_resources();
|
|
|
|
if (!screen_resources)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* First start with a 2 monitors, should be enough for most cases */
|
|
|
|
capacity = 2;
|
|
|
|
monitors = heap_calloc( capacity, sizeof(*monitors) );
|
|
|
|
if (!monitors)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
output_info = pXRRGetOutputInfo( gdi_display, screen_resources, adapter_id );
|
|
|
|
if (!output_info)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (output_info->crtc)
|
|
|
|
{
|
|
|
|
crtc_info = pXRRGetCrtcInfo( gdi_display, screen_resources, output_info->crtc );
|
|
|
|
if (!crtc_info)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2020-06-18 13:34:27 +02:00
|
|
|
/* Inactive but attached monitor, no need to check for mirrored/replica monitors */
|
2019-09-20 10:55:22 +02:00
|
|
|
if (!output_info->crtc || !crtc_info->mode)
|
|
|
|
{
|
|
|
|
lstrcpyW( monitors[monitor_count].name, generic_nonpnp_monitorW );
|
|
|
|
monitors[monitor_count].state_flags = DISPLAY_DEVICE_ATTACHED;
|
|
|
|
monitor_count = 1;
|
|
|
|
}
|
|
|
|
/* Active monitors, need to find other monitors with the same coordinates as mirrored */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
query_work_area( &work_rect );
|
|
|
|
primary_rect = get_primary_rect( screen_resources );
|
|
|
|
|
|
|
|
for (i = 0; i < screen_resources->noutput; ++i)
|
|
|
|
{
|
|
|
|
enum_output_info = pXRRGetOutputInfo( gdi_display, screen_resources, screen_resources->outputs[i] );
|
|
|
|
if (!enum_output_info)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* Detached outputs don't count */
|
|
|
|
if (enum_output_info->connection != RR_Connected)
|
|
|
|
{
|
|
|
|
pXRRFreeOutputInfo( enum_output_info );
|
|
|
|
enum_output_info = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate more space if needed */
|
|
|
|
if (monitor_count >= capacity)
|
|
|
|
{
|
|
|
|
capacity *= 2;
|
|
|
|
realloc_monitors = heap_realloc( monitors, capacity * sizeof(*monitors) );
|
|
|
|
if (!realloc_monitors)
|
|
|
|
goto done;
|
|
|
|
monitors = realloc_monitors;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (enum_output_info->crtc)
|
|
|
|
{
|
|
|
|
enum_crtc_info = pXRRGetCrtcInfo( gdi_display, screen_resources, enum_output_info->crtc );
|
|
|
|
if (!enum_crtc_info)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (enum_crtc_info->x == crtc_info->x &&
|
|
|
|
enum_crtc_info->y == crtc_info->y &&
|
|
|
|
enum_crtc_info->width == crtc_info->width &&
|
|
|
|
enum_crtc_info->height == crtc_info->height)
|
|
|
|
{
|
|
|
|
/* FIXME: Read output EDID property and parse the data to get the correct name */
|
|
|
|
lstrcpyW( monitors[monitor_count].name, generic_nonpnp_monitorW );
|
|
|
|
|
|
|
|
SetRect( &monitors[monitor_count].rc_monitor, crtc_info->x, crtc_info->y,
|
|
|
|
crtc_info->x + crtc_info->width, crtc_info->y + crtc_info->height );
|
|
|
|
if (!IntersectRect( &monitors[monitor_count].rc_work, &work_rect, &monitors[monitor_count].rc_monitor ))
|
|
|
|
monitors[monitor_count].rc_work = monitors[monitor_count].rc_monitor;
|
|
|
|
|
|
|
|
monitors[monitor_count].state_flags = DISPLAY_DEVICE_ATTACHED;
|
|
|
|
if (!IsRectEmpty( &monitors[monitor_count].rc_monitor ))
|
|
|
|
monitors[monitor_count].state_flags |= DISPLAY_DEVICE_ACTIVE;
|
|
|
|
|
|
|
|
if (is_crtc_primary( primary_rect, crtc_info ))
|
|
|
|
primary_index = monitor_count;
|
|
|
|
monitor_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pXRRFreeCrtcInfo( enum_crtc_info );
|
|
|
|
}
|
|
|
|
|
|
|
|
pXRRFreeOutputInfo( enum_output_info );
|
|
|
|
enum_output_info = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure the first monitor is the primary */
|
|
|
|
if (primary_index)
|
|
|
|
{
|
|
|
|
struct x11drv_monitor tmp = monitors[0];
|
|
|
|
monitors[0] = monitors[primary_index];
|
|
|
|
monitors[primary_index] = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure the primary monitor origin is at (0, 0) */
|
|
|
|
for (i = 0; i < monitor_count; i++)
|
|
|
|
{
|
|
|
|
OffsetRect( &monitors[i].rc_monitor, -primary_rect.left, -primary_rect.top );
|
|
|
|
OffsetRect( &monitors[i].rc_work, -primary_rect.left, -primary_rect.top );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*new_monitors = monitors;
|
|
|
|
*count = monitor_count;
|
|
|
|
ret = TRUE;
|
|
|
|
done:
|
|
|
|
if (screen_resources)
|
|
|
|
pXRRFreeScreenResources( screen_resources );
|
|
|
|
if (output_info)
|
|
|
|
pXRRFreeOutputInfo( output_info);
|
|
|
|
if (crtc_info)
|
|
|
|
pXRRFreeCrtcInfo( crtc_info );
|
|
|
|
if (enum_output_info)
|
|
|
|
pXRRFreeOutputInfo( enum_output_info );
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
heap_free( monitors );
|
|
|
|
ERR("Failed to get monitors\n");
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void xrandr14_free_monitors( struct x11drv_monitor *monitors )
|
|
|
|
{
|
|
|
|
heap_free( monitors );
|
|
|
|
}
|
|
|
|
|
2019-11-01 14:20:21 +01:00
|
|
|
static BOOL xrandr14_device_change_handler( HWND hwnd, XEvent *event )
|
2019-09-20 10:55:40 +02:00
|
|
|
{
|
2019-11-01 14:20:21 +01:00
|
|
|
if (hwnd == GetDesktopWindow() && GetWindowThreadProcessId( hwnd, NULL ) == GetCurrentThreadId())
|
2020-05-11 10:55:27 +02:00
|
|
|
{
|
|
|
|
/* Don't send a WM_DISPLAYCHANGE message here because this event may be a result from
|
|
|
|
* ChangeDisplaySettings(). Otherwise, ChangeDisplaySettings() would send multiple
|
|
|
|
* WM_DISPLAYCHANGE messages instead of just one */
|
|
|
|
X11DRV_DisplayDevices_Update( FALSE );
|
|
|
|
}
|
2019-11-01 14:20:21 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void xrandr14_register_event_handlers(void)
|
|
|
|
{
|
|
|
|
Display *display = thread_init_display();
|
|
|
|
int event_base, error_base;
|
|
|
|
|
|
|
|
if (!pXRRQueryExtension( display, &event_base, &error_base ))
|
|
|
|
return;
|
|
|
|
|
|
|
|
pXRRSelectInput( display, root_window,
|
|
|
|
RRCrtcChangeNotifyMask | RROutputChangeNotifyMask | RRProviderChangeNotifyMask );
|
|
|
|
X11DRV_register_event_handler( event_base + RRNotify_CrtcChange, xrandr14_device_change_handler,
|
|
|
|
"XRandR CrtcChange" );
|
|
|
|
X11DRV_register_event_handler( event_base + RRNotify_OutputChange, xrandr14_device_change_handler,
|
|
|
|
"XRandR OutputChange" );
|
|
|
|
X11DRV_register_event_handler( event_base + RRNotify_ProviderChange, xrandr14_device_change_handler,
|
|
|
|
"XRandR ProviderChange" );
|
2019-09-20 10:55:40 +02:00
|
|
|
}
|
|
|
|
|
2019-09-20 10:55:22 +02:00
|
|
|
#endif
|
|
|
|
|
2003-10-16 02:21:42 +02:00
|
|
|
void X11DRV_XRandR_Init(void)
|
|
|
|
{
|
2019-09-20 10:55:22 +02:00
|
|
|
struct x11drv_display_device_handler handler;
|
2012-07-15 15:45:00 +02:00
|
|
|
int event_base, error_base, minor, ret;
|
2012-07-11 17:35:45 +02:00
|
|
|
static int major;
|
2003-10-16 02:21:42 +02:00
|
|
|
Bool ok;
|
|
|
|
|
2012-07-11 17:35:45 +02:00
|
|
|
if (major) return; /* already initialized? */
|
2003-10-16 02:21:42 +02:00
|
|
|
if (!usexrandr) return; /* disabled in config */
|
2019-11-05 14:04:07 +01:00
|
|
|
if (is_virtual_desktop()) return;
|
2012-07-15 15:45:00 +02:00
|
|
|
if (!(ret = load_xrandr())) return; /* can't load the Xrandr library */
|
2003-10-16 02:21:42 +02:00
|
|
|
|
|
|
|
/* see if Xrandr is available */
|
2012-08-16 16:46:37 +02:00
|
|
|
if (!pXRRQueryExtension( gdi_display, &event_base, &error_base )) return;
|
2012-07-11 17:35:44 +02:00
|
|
|
X11DRV_expect_error( gdi_display, XRandRErrorHandler, NULL );
|
2012-07-11 17:35:45 +02:00
|
|
|
ok = pXRRQueryVersion( gdi_display, &major, &minor );
|
2012-08-16 16:46:37 +02:00
|
|
|
if (X11DRV_check_error() || !ok) return;
|
2012-07-11 17:35:44 +02:00
|
|
|
|
2012-07-11 17:35:45 +02:00
|
|
|
TRACE("Found XRandR %d.%d.\n", major, minor);
|
2012-07-15 15:45:00 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_XRRGETSCREENRESOURCES
|
|
|
|
if (ret >= 2 && (major > 1 || (major == 1 && minor >= 2)))
|
2012-07-15 15:45:01 +02:00
|
|
|
{
|
|
|
|
if (major > 1 || (major == 1 && minor >= 3))
|
2020-04-06 22:43:15 +02:00
|
|
|
pXRRGetScreenResourcesCurrent = dlsym( xrandr_handle, "XRRGetScreenResourcesCurrent" );
|
2012-08-20 08:12:07 +02:00
|
|
|
if (!pXRRGetScreenResourcesCurrent)
|
|
|
|
pXRRGetScreenResourcesCurrent = pXRRGetScreenResources;
|
2012-07-15 15:45:01 +02:00
|
|
|
}
|
|
|
|
|
2012-08-20 08:12:07 +02:00
|
|
|
if (!pXRRGetScreenResourcesCurrent || xrandr12_init_modes() < 0)
|
2012-07-15 15:45:00 +02:00
|
|
|
#endif
|
|
|
|
xrandr10_init_modes();
|
2019-09-20 10:55:22 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_XRRGETPROVIDERRESOURCES
|
|
|
|
if (ret >= 4 && (major > 1 || (major == 1 && minor >= 4)))
|
|
|
|
{
|
|
|
|
handler.name = "XRandR 1.4";
|
|
|
|
handler.priority = 200;
|
2019-10-25 15:40:09 +02:00
|
|
|
handler.get_gpus = xrandr14_get_gpus;
|
|
|
|
handler.get_adapters = xrandr14_get_adapters;
|
|
|
|
handler.get_monitors = xrandr14_get_monitors;
|
|
|
|
handler.free_gpus = xrandr14_free_gpus;
|
|
|
|
handler.free_adapters = xrandr14_free_adapters;
|
|
|
|
handler.free_monitors = xrandr14_free_monitors;
|
2019-11-01 14:20:21 +01:00
|
|
|
handler.register_event_handlers = xrandr14_register_event_handlers;
|
2019-09-20 10:55:22 +02:00
|
|
|
X11DRV_DisplayDevices_SetHandler( &handler );
|
|
|
|
}
|
|
|
|
#endif
|
2003-10-16 02:21:42 +02:00
|
|
|
}
|
|
|
|
|
2012-07-08 16:06:39 +02:00
|
|
|
#else /* SONAME_LIBXRANDR */
|
|
|
|
|
|
|
|
void X11DRV_XRandR_Init(void)
|
|
|
|
{
|
|
|
|
TRACE("XRandR support not compiled in.\n");
|
|
|
|
}
|
|
|
|
|
2007-07-04 12:45:03 +02:00
|
|
|
#endif /* SONAME_LIBXRANDR */
|