Skip to content

Commit c5f3c20

Browse files
committed
Merge branch 'uli42-pr/pre-rrxinerama-fallback' into 3.6.x
Attributes GH PR #602: #602
2 parents 73c113c + bd1ca62 commit c5f3c20

File tree

2 files changed

+100
-21
lines changed

2 files changed

+100
-21
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ void nxagentInitRandRExtension(ScreenPtr pScreen)
136136

137137
pRandRScrPriv = rrGetScrPriv(pScreen);
138138

139-
pRandRScrPriv -> rrGetInfo = nxagentRandRGetInfo;
139+
pRandRScrPriv -> rrGetInfo = nxagentRandRGetInfo;
140140

141141
#if RANDR_15_INTERFACE
142142
/* nothing to be assigned here, so far */

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

Lines changed: 99 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3666,11 +3666,88 @@ Bool intersect_bb(int ax1, int ay1, unsigned int aw, unsigned int ah,
36663666
}
36673667
#endif
36683668

3669+
RRModePtr nxagentRRCustomMode = NULL;
3670+
3671+
/*
3672+
This is basically the code that was used on screen resize before
3673+
xinerama was implemented. We need it as fallback if the user
3674+
disables xinerama
3675+
*/
3676+
void nxagentAdjustCustomMode(ScreenPtr pScreen)
3677+
{
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+
3739+
pScrPriv -> lastSetTime = currentTime;
3740+
3741+
pScrPriv->changed = 1;
3742+
pScrPriv->configChanged = 1;
3743+
} /* if (pScrPriv) */
3744+
3745+
RRScreenSizeNotify(pScreen);
3746+
}
3747+
36693748
int nxagentChangeScreenConfig(int screen, int width, int height, int mmWidth, int mmHeight)
36703749
{
36713750
ScreenPtr pScreen;
3672-
/* FIXME: when is this needed? */
3673-
int doNotify = TRUE;
36743751
int r;
36753752

36763753
#ifdef DEBUG
@@ -3726,12 +3803,18 @@ int nxagentChangeScreenConfig(int screen, int width, int height, int mmWidth, in
37263803

37273804
if (r != 0)
37283805
{
3729-
nxagentAdjustRandRXinerama(pScreen);
3730-
}
3806+
if (nxagentOption(Xinerama))
3807+
{
3808+
nxagentAdjustRandRXinerama(pScreen);
3809+
}
3810+
else
3811+
{
3812+
#ifdef DEBUG
3813+
fprintf(stderr, "%s: Xinerama is disabled\n", __func__);
3814+
#endif
37313815

3732-
if (doNotify)
3733-
{
3734-
RRScreenSizeNotify(pScreen);
3816+
nxagentAdjustCustomMode(pScreen);
3817+
}
37353818
}
37363819

37373820
#ifdef DEBUG
@@ -3782,24 +3865,20 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen)
37823865

37833866
XineramaScreenInfo *screeninfo = NULL;
37843867

3785-
if (nxagentOption(Xinerama)) {
3786-
screeninfo = XineramaQueryScreens(nxagentDisplay, &number);
3868+
screeninfo = XineramaQueryScreens(nxagentDisplay, &number);
3869+
if (number)
3870+
{
37873871
#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");
3872+
fprintf(stderr, "nxagentAdjustRandRXinerama: XineramaQueryScreens() returned [%d] screens:\n", number);
3873+
for (int i=0; i < number; i++) {
3874+
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);
37983875
}
3876+
#endif
37993877
}
38003878
else
38013879
{
3802-
fprintf(stderr, "nxagentAdjustRandRXinerama: Xinerama is disabled\n");
3880+
#ifdef DEBUG
3881+
fprintf(stderr, "nxagentAdjustRandRXinerama: XineramaQueryScreens() failed - continuing without Xinerama\n");
38033882
#endif
38043883
}
38053884

0 commit comments

Comments
 (0)