Skip to content

Commit fd5d957

Browse files
committed
re-implement pre-xinerama behaviour
If -rrxinerama was specified xrandr handling was broken. Adding/using a custom resolution via xrandr was not working anymore.
1 parent b421bc7 commit fd5d957

File tree

1 file changed

+105
-20
lines changed
  • nx-X11/programs/Xserver/hw/nxagent

1 file changed

+105
-20
lines changed

nx-X11/programs/Xserver/hw/nxagent/Screen.c

Lines changed: 105 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3665,11 +3665,94 @@ Bool intersect_bb(int ax1, int ay1, unsigned int aw, unsigned int ah,
36653665
}
36663666
#endif
36673667

3668+
RRModePtr nxagentRRCustomMode = NULL;
3669+
3670+
/*
3671+
This is basically the code that was used on screen resize before
3672+
xinerama was implemented. We need it as fallback if the user
3673+
disables xinerama
3674+
*/
3675+
void nxagentAdjustCustomMode(ScreenPtr pScreen)
3676+
{
3677+
int doNotify = TRUE;
3678+
rrScrPrivPtr pScrPriv = rrGetScrPriv(pScreen);
3679+
RROutputPtr output;
3680+
3681+
if (pScrPriv)
3682+
{
3683+
output = RRFirstOutput(pScreen);
3684+
3685+
if (output && output -> crtc)
3686+
{
3687+
RRCrtcPtr crtc;
3688+
char name[100];
3689+
xRRModeInfo modeInfo;
3690+
const int refresh = 60;
3691+
int width = nxagentOption(Width);
3692+
int height = nxagentOption(Height);
3693+
3694+
crtc = output -> crtc;
3695+
3696+
for (int c = 0; c < pScrPriv -> numCrtcs; c++)
3697+
{
3698+
RRCrtcSet(pScrPriv -> crtcs[c], NULL, 0, 0, RR_Rotate_0, 0, NULL);
3699+
}
3700+
3701+
memset(&modeInfo, '\0', sizeof(modeInfo));
3702+
sprintf(name, "%dx%d", width, height);
3703+
3704+
modeInfo.width = width;
3705+
modeInfo.height = height;
3706+
modeInfo.hTotal = width;
3707+
modeInfo.vTotal = height;
3708+
modeInfo.dotClock = ((CARD32) width * (CARD32) height *
3709+
(CARD32) refresh);
3710+
modeInfo.nameLength = strlen(name);
3711+
3712+
if (nxagentRRCustomMode != NULL)
3713+
{
3714+
RROutputDeleteUserMode(output, nxagentRRCustomMode);
3715+
FreeResource(nxagentRRCustomMode -> mode.id, 0);
3716+
3717+
if (crtc != NULL && crtc -> mode == nxagentRRCustomMode)
3718+
{
3719+
RRCrtcSet(crtc, NULL, 0, 0, RR_Rotate_0, 0, NULL);
3720+
}
3721+
3722+
#ifdef TEST
3723+
fprintf(stderr, "%s: Going to destroy mode %p with refcnt %d.\n",
3724+
__func__, nxagentRRCustomMode, nxagentRRCustomMode->refcnt);
3725+
#endif
3726+
3727+
RRModeDestroy(nxagentRRCustomMode);
3728+
}
3729+
3730+
nxagentRRCustomMode = RRModeGet(&modeInfo, name);
3731+
3732+
RROutputAddUserMode(output, nxagentRRCustomMode);
3733+
3734+
RRCrtcSet(crtc, nxagentRRCustomMode, 0, 0, RR_Rotate_0, 1, &output);
3735+
3736+
RROutputChanged(output, 1);
3737+
3738+
doNotify = FALSE;
3739+
}
3740+
3741+
pScrPriv -> lastSetTime = currentTime;
3742+
3743+
pScrPriv->changed = 1;
3744+
pScrPriv->configChanged = 1;
3745+
} /* if (pScrPriv) */
3746+
3747+
if (doNotify)
3748+
{
3749+
RRScreenSizeNotify(pScreen);
3750+
}
3751+
}
3752+
36683753
int nxagentChangeScreenConfig(int screen, int width, int height, int mmWidth, int mmHeight)
36693754
{
36703755
ScreenPtr pScreen;
3671-
/* FIXME: when is this needed? */
3672-
int doNotify = TRUE;
36733756
int r;
36743757

36753758
#ifdef DEBUG
@@ -3725,12 +3808,18 @@ int nxagentChangeScreenConfig(int screen, int width, int height, int mmWidth, in
37253808

37263809
if (r != 0)
37273810
{
3728-
nxagentAdjustRandRXinerama(pScreen);
3729-
}
3811+
if (nxagentOption(Xinerama))
3812+
{
3813+
nxagentAdjustRandRXinerama(pScreen);
3814+
}
3815+
else
3816+
{
3817+
#ifdef DEBUG
3818+
fprintf(stderr, "%s: Xinerama is disabled\n", __func__);
3819+
#endif
37303820

3731-
if (doNotify)
3732-
{
3733-
RRScreenSizeNotify(pScreen);
3821+
nxagentAdjustCustomMode(pScreen);
3822+
}
37343823
}
37353824

37363825
#ifdef DEBUG
@@ -3782,24 +3871,20 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
37823871

37833872
XineramaScreenInfo *screeninfo = NULL;
37843873

3785-
if (nxagentOption(Xinerama)) {
3786-
screeninfo = XineramaQueryScreens(nxagentDisplay, &number);
3874+
screeninfo = XineramaQueryScreens(nxagentDisplay, &number);
3875+
if (number)
3876+
{
37873877
#ifdef DEBUG
3788-
if (number) {
3789-
fprintf(stderr, "nxagentAdjustRandRXinerama: XineramaQueryScreens() returned [%d] screens:\n", number);
3790-
for (int i=0; i < number; i++) {
3791-
fprintf(stderr, "nxagentAdjustRandRXinerama: screen_number [%d] x_org [%d] y_org [%d] width [%d] height [%d]\n", screeninfo[i].screen_number, screeninfo[i].x_org, screeninfo[i].y_org, screeninfo[i].width, screeninfo[i].height);
3792-
}
3793-
3794-
}
3795-
else
3796-
{
3797-
fprintf(stderr, "nxagentAdjustRandRXinerama: XineramaQueryScreens() failed - continuing without Xinerama\n");
3878+
fprintf(stderr, "nxagentAdjustRandRXinerama: XineramaQueryScreens() returned [%d] screens:\n", number);
3879+
for (int i=0; i < number; i++) {
3880+
fprintf(stderr, "nxagentAdjustRandRXinerama: screen_number [%d] x_org [%d] y_org [%d] width [%d] height [%d]\n", screeninfo[i].screen_number, screeninfo[i].x_org, screeninfo[i].y_org, screeninfo[i].width, screeninfo[i].height);
37983881
}
3882+
#endif
37993883
}
38003884
else
38013885
{
3802-
fprintf(stderr, "nxagentAdjustRandRXinerama: Xinerama is disabled\n");
3886+
#ifdef DEBUG
3887+
fprintf(stderr, "nxagentAdjustRandRXinerama: XineramaQueryScreens() failed - continuing without Xinerama\n");
38033888
#endif
38043889
}
38053890

0 commit comments

Comments
 (0)