Commit 3ac14606 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

winex11: Use the first active CRTC as primary if no primary is explicitly set.

parent 73d68c5a
...@@ -57,6 +57,7 @@ MAKE_FUNCPTR(XRRGetScreenResources) ...@@ -57,6 +57,7 @@ MAKE_FUNCPTR(XRRGetScreenResources)
MAKE_FUNCPTR(XRRSetCrtcConfig) MAKE_FUNCPTR(XRRSetCrtcConfig)
static typeof(XRRGetScreenResources) *pXRRGetScreenResourcesCurrent; static typeof(XRRGetScreenResources) *pXRRGetScreenResourcesCurrent;
static RRMode *xrandr12_modes; static RRMode *xrandr12_modes;
static int primary_crtc;
#endif #endif
#undef MAKE_FUNCPTR #undef MAKE_FUNCPTR
...@@ -273,14 +274,15 @@ static int xrandr12_get_current_mode(void) ...@@ -273,14 +274,15 @@ static int xrandr12_get_current_mode(void)
return 0; return 0;
} }
if (!resources->ncrtc || !(crtc_info = pXRRGetCrtcInfo( gdi_display, resources, resources->crtcs[0] ))) if (resources->ncrtc <= primary_crtc ||
!(crtc_info = pXRRGetCrtcInfo( gdi_display, resources, resources->crtcs[primary_crtc] )))
{ {
pXRRFreeScreenResources( resources ); pXRRFreeScreenResources( resources );
ERR("Failed to get CRTC info.\n"); ERR("Failed to get CRTC info.\n");
return 0; return 0;
} }
TRACE("CRTC 0: mode %#lx, %ux%u+%d+%d.\n", crtc_info->mode, TRACE("CRTC %d: mode %#lx, %ux%u+%d+%d.\n", primary_crtc, crtc_info->mode,
crtc_info->width, crtc_info->height, crtc_info->x, crtc_info->y); crtc_info->width, crtc_info->height, crtc_info->x, crtc_info->y);
for (i = 0; i < xrandr_mode_count; ++i) for (i = 0; i < xrandr_mode_count; ++i)
...@@ -318,18 +320,20 @@ static LONG xrandr12_set_current_mode( int mode ) ...@@ -318,18 +320,20 @@ static LONG xrandr12_set_current_mode( int mode )
return DISP_CHANGE_FAILED; return DISP_CHANGE_FAILED;
} }
if (!resources->ncrtc || !(crtc_info = pXRRGetCrtcInfo( gdi_display, resources, resources->crtcs[0] ))) if (resources->ncrtc <= primary_crtc ||
!(crtc_info = pXRRGetCrtcInfo( gdi_display, resources, resources->crtcs[primary_crtc] )))
{ {
pXRRFreeScreenResources( resources ); pXRRFreeScreenResources( resources );
ERR("Failed to get CRTC info.\n"); ERR("Failed to get CRTC info.\n");
return DISP_CHANGE_FAILED; return DISP_CHANGE_FAILED;
} }
TRACE("CRTC 0: mode %#lx, %ux%u+%d+%d.\n", crtc_info->mode, TRACE("CRTC %d: mode %#lx, %ux%u+%d+%d.\n", primary_crtc, crtc_info->mode,
crtc_info->width, crtc_info->height, crtc_info->x, crtc_info->y); crtc_info->width, crtc_info->height, crtc_info->x, crtc_info->y);
status = pXRRSetCrtcConfig( gdi_display, resources, resources->crtcs[0], CurrentTime, crtc_info->x, status = pXRRSetCrtcConfig( gdi_display, resources, resources->crtcs[primary_crtc],
crtc_info->y, xrandr12_modes[mode], crtc_info->rotation, crtc_info->outputs, crtc_info->noutput ); CurrentTime, crtc_info->x, crtc_info->y, xrandr12_modes[mode],
crtc_info->rotation, crtc_info->outputs, crtc_info->noutput );
pXRRFreeCrtcInfo( crtc_info ); pXRRFreeCrtcInfo( crtc_info );
pXRRFreeScreenResources( resources ); pXRRFreeScreenResources( resources );
...@@ -344,6 +348,27 @@ static LONG xrandr12_set_current_mode( int mode ) ...@@ -344,6 +348,27 @@ static LONG xrandr12_set_current_mode( int mode )
return DISP_CHANGE_SUCCESSFUL; return DISP_CHANGE_SUCCESSFUL;
} }
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;
}
static int xrandr12_init_modes(void) static int xrandr12_init_modes(void)
{ {
XRRScreenResources *resources; XRRScreenResources *resources;
...@@ -368,14 +393,14 @@ static int xrandr12_init_modes(void) ...@@ -368,14 +393,14 @@ static int xrandr12_init_modes(void)
} }
} }
if (!resources->ncrtc || !(crtc_info = pXRRGetCrtcInfo( gdi_display, resources, resources->crtcs[0] ))) if (!(crtc_info = xrandr12_get_primary_crtc_info( resources, &primary_crtc )))
{ {
pXRRFreeScreenResources( resources ); pXRRFreeScreenResources( resources );
ERR("Failed to get CRTC info.\n"); ERR("Failed to get primary CRTC info.\n");
return ret; return ret;
} }
TRACE("CRTC 0: mode %#lx, %ux%u+%d+%d.\n", crtc_info->mode, TRACE("CRTC %d: mode %#lx, %ux%u+%d+%d.\n", primary_crtc, crtc_info->mode,
crtc_info->width, crtc_info->height, crtc_info->x, crtc_info->y); 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] ))) if (!crtc_info->noutput || !(output_info = pXRRGetOutputInfo( gdi_display, resources, crtc_info->outputs[0] )))
......
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