Try to fix xrandr monitor selection - should now properly default to the primary monitor, as well as actually use it...
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5523 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
267d9a1753
commit
06be934fa2
1 changed files with 37 additions and 28 deletions
|
@ -682,6 +682,9 @@ static struct
|
|||
XRRCrtcGamma * (*pGetCrtcGamma) (Display *dpy, RRCrtc crtc);
|
||||
void (*pFreeGamma) (XRRCrtcGamma *gamma);
|
||||
void (*pSetCrtcGamma) (Display *dpy, RRCrtc crtc, XRRCrtcGamma *gamma);
|
||||
|
||||
//v1.3 has non-0 primary monitors.
|
||||
RROutput (*pGetOutputPrimary) (Display *dpy, Window window);
|
||||
} xrandr;
|
||||
static qboolean XRandR_Init(void)
|
||||
{
|
||||
|
@ -744,6 +747,8 @@ static qboolean XRandR_Init(void)
|
|||
)
|
||||
xrandr.canmodechange12 = true;
|
||||
}
|
||||
if (xrandr.vmajor > 1 || (xrandr.vmajor == 1 && xrandr.vminor >= 3))
|
||||
xrandr.pGetOutputPrimary = Sys_GetAddressForName(xrandr.lib, "XRRGetOutputPrimary");
|
||||
|
||||
//FIXME: query monitor sizes and calculate dpi for vid.dpy_[x|y]
|
||||
return true;
|
||||
|
@ -880,7 +885,7 @@ static void XRandR_Shutdown(void)
|
|||
}
|
||||
static qboolean XRandR_FindOutput(const char *name)
|
||||
{
|
||||
XRROutputInfo *primary = NULL;
|
||||
RROutput p;
|
||||
int i;
|
||||
if (!xrandr.canmodechange12)
|
||||
return false;
|
||||
|
@ -894,6 +899,12 @@ static qboolean XRandR_FindOutput(const char *name)
|
|||
for (i = 0; i < xrandr.res->noutput; i++)
|
||||
xrandr.outputs[i] = xrandr.pGetOutputInfo(vid_dpy, xrandr.res, xrandr.res->outputs[i]);
|
||||
}
|
||||
if (xrandr.pGetOutputPrimary)
|
||||
p = xrandr.pGetOutputPrimary(vid_dpy, DefaultRootWindow(vid_dpy));
|
||||
else if (xrandr.res->noutput)
|
||||
p = xrandr.res->outputs[0];
|
||||
else
|
||||
p = 0;
|
||||
xrandr.output = NULL;
|
||||
xrandr.crtc = None;
|
||||
if (xrandr.origgamma)
|
||||
|
@ -909,19 +920,17 @@ static qboolean XRandR_FindOutput(const char *name)
|
|||
{
|
||||
if (xrandr.outputs[i]->connection != RR_Connected || !xrandr.outputs[i]->ncrtc)
|
||||
continue; //not usable...
|
||||
if (!primary || (xrandr.outputs[i]->npreferred && !primary->npreferred))
|
||||
primary = xrandr.outputs[i];
|
||||
if (!xrandr.output && xrandr.res->outputs[i] == p)
|
||||
xrandr.output = xrandr.outputs[i];
|
||||
if (*name && !strncmp(xrandr.outputs[i]->name, name, xrandr.outputs[i]->nameLen))
|
||||
{ //this is the one they asked for
|
||||
xrandr.output = xrandr.outputs[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!xrandr.output)
|
||||
xrandr.output = primary;
|
||||
if (xrandr.output)
|
||||
{
|
||||
xrandr.crtc = xrandr.output->crtcs[0];
|
||||
xrandr.crtc = xrandr.output->crtc;
|
||||
xrandr.crtcinfo = xrandr.pGetCrtcInfo(vid_dpy, xrandr.res, xrandr.crtc);
|
||||
if (xrandr.crtcinfo)
|
||||
{
|
||||
|
@ -943,7 +952,7 @@ static qboolean XRandr_PickScreen(const char *devicename, int *x, int *y, int *w
|
|||
*y = c->y;
|
||||
*width = c->width;
|
||||
*height = c->height;
|
||||
Con_Printf("Found monitor %s %ix%i +%i,%i\n", xrandr.output->name, c->width, c->height, c->x, c->y);
|
||||
Con_Printf("Found monitor %s %ix%i %i,%i\n", xrandr.output->name, c->width, c->height, c->x, c->y);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue