mirror of https://github.com/mpv-player/mpv
x11: fix ICC profiling for multiple monitors
To find the correct ICC profile X atom, the screen number was calculated directly from the xrandr order of the screens. But if a primary screen is set, it should be the first Xinerama screen, even if it is not the first xrandr screen. Calculate the the proper atom id for each screen.
This commit is contained in:
parent
ffe89415fe
commit
1591ccfff5
|
@ -395,6 +395,8 @@ static void xrandr_read(struct vo_x11_state *x11)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int primary_id = -1;
|
||||||
|
RROutput primary = XRRGetOutputPrimary(x11->display, x11->rootwin);
|
||||||
for (int o = 0; o < r->noutput; o++) {
|
for (int o = 0; o < r->noutput; o++) {
|
||||||
RROutput output = r->outputs[o];
|
RROutput output = r->outputs[o];
|
||||||
XRRCrtcInfo *crtc = NULL;
|
XRRCrtcInfo *crtc = NULL;
|
||||||
|
@ -427,6 +429,8 @@ static void xrandr_read(struct vo_x11_state *x11)
|
||||||
MP_VERBOSE(x11, "Display %d (%s): [%d, %d, %d, %d] @ %f FPS\n",
|
MP_VERBOSE(x11, "Display %d (%s): [%d, %d, %d, %d] @ %f FPS\n",
|
||||||
num, d.name, d.rc.x0, d.rc.y0, d.rc.x1, d.rc.y1, d.fps);
|
num, d.name, d.rc.x0, d.rc.y0, d.rc.x1, d.rc.y1, d.fps);
|
||||||
x11->displays[num] = d;
|
x11->displays[num] = d;
|
||||||
|
if (output == primary)
|
||||||
|
primary_id = num;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
next:
|
next:
|
||||||
|
@ -436,6 +440,20 @@ static void xrandr_read(struct vo_x11_state *x11)
|
||||||
XRRFreeOutputInfo(out);
|
XRRFreeOutputInfo(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < x11->num_displays; i++) {
|
||||||
|
struct xrandr_display *d = &(x11->displays[i]);
|
||||||
|
|
||||||
|
if (i == primary_id) {
|
||||||
|
d->atom_id = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (primary_id > 0 && i < primary_id) {
|
||||||
|
d->atom_id = i+1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
d->atom_id = i;
|
||||||
|
}
|
||||||
|
|
||||||
XRRFreeScreenResources(r);
|
XRRFreeScreenResources(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1851,10 +1869,11 @@ int vo_x11_control(struct vo *vo, int *events, int request, void *arg)
|
||||||
if (!x11->pseudo_mapped)
|
if (!x11->pseudo_mapped)
|
||||||
return VO_NOTAVAIL;
|
return VO_NOTAVAIL;
|
||||||
int screen = get_icc_screen(vo);
|
int screen = get_icc_screen(vo);
|
||||||
|
int atom_id = x11->displays[screen].atom_id;
|
||||||
char prop[80];
|
char prop[80];
|
||||||
snprintf(prop, sizeof(prop), "_ICC_PROFILE");
|
snprintf(prop, sizeof(prop), "_ICC_PROFILE");
|
||||||
if (screen > 0)
|
if (atom_id > 0)
|
||||||
mp_snprintf_cat(prop, sizeof(prop), "_%d", screen);
|
mp_snprintf_cat(prop, sizeof(prop), "_%d", atom_id);
|
||||||
x11->icc_profile_property = XAs(x11, prop);
|
x11->icc_profile_property = XAs(x11, prop);
|
||||||
int len;
|
int len;
|
||||||
MP_VERBOSE(x11, "Retrieving ICC profile for display: %d\n", screen);
|
MP_VERBOSE(x11, "Retrieving ICC profile for display: %d\n", screen);
|
||||||
|
|
|
@ -44,6 +44,7 @@ struct xrandr_display {
|
||||||
double fps;
|
double fps;
|
||||||
char *name;
|
char *name;
|
||||||
bool overlaps;
|
bool overlaps;
|
||||||
|
int atom_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vo_x11_state {
|
struct vo_x11_state {
|
||||||
|
|
Loading…
Reference in New Issue