Corrected RandR wrapper return codes
In RandR land, there's a lot of return code confusion. Our wrappers
are using the same return codes as RRCrtcSet, RRScreenSizeSet: 1/TRUE
for success. Fixes:
* vncRandRCreateOutputs did not follow this convention
* A lot of code returned -1 upon failure
* vncRandRDisableOutput returned 0 for already disabled outputs
diff --git a/unix/common/randr.cxx b/unix/common/randr.cxx
index 44e46de..08bd45e 100644
--- a/unix/common/randr.cxx
+++ b/unix/common/randr.cxx
@@ -113,7 +113,7 @@
layout.num_screens() - availableOutputs);
ret = vncRandRCreateOutputs(screenIndex,
layout.num_screens() - availableOutputs);
- if (ret < 0) {
+ if (!ret) {
vlog.error("Unable to create more screens, as needed by the new client layout.");
return rfb::resultInvalid;
}
diff --git a/unix/xserver/hw/vnc/RandrGlue.c b/unix/xserver/hw/vnc/RandrGlue.c
index 9f770fa..8106571 100644
--- a/unix/xserver/hw/vnc/RandrGlue.c
+++ b/unix/xserver/hw/vnc/RandrGlue.c
@@ -50,7 +50,7 @@
pScreen->mmWidth * width / pScreen->width,
pScreen->mmHeight * height / pScreen->height);
#else
- return -1;
+ return 0;
#endif
}
@@ -199,11 +199,11 @@
crtc = rp->outputs[outputIdx]->crtc;
if (crtc == NULL)
- return 0;
+ return 1;
return RRCrtcSet(crtc, NULL, crtc->x, crtc->y, crtc->rotation, 0, NULL);
#else
- return -1;
+ return 0;
#endif
}
@@ -267,17 +267,17 @@
/* Couldn't find one... */
if (crtc == NULL)
- return -1;
+ return 0;
}
/* Make sure we have the mode we want */
mode = vncRandRCreatePreferredMode(output, width, height);
if (mode == NULL)
- return -1;
+ return 0;
/* Reconfigure new mode and position */
return RRCrtcSet(crtc, mode, x, y, crtc->rotation, 1, &output);
#else
- return -1;
+ return 0;
#endif
}
diff --git a/unix/xserver/hw/vnc/vncModule.c b/unix/xserver/hw/vnc/vncModule.c
index 3fb0776..704e56e 100644
--- a/unix/xserver/hw/vnc/vncModule.c
+++ b/unix/xserver/hw/vnc/vncModule.c
@@ -115,7 +115,7 @@
#ifdef RANDR
int vncRandRCreateOutputs(int scrIdx, int extraOutputs)
{
- return -1;
+ return 0;
}
void *vncRandRCreatePreferredMode(void *out, int width, int height)
diff --git a/unix/xserver/hw/vnc/xvnc.c b/unix/xserver/hw/vnc/xvnc.c
index 56a6ca5..4133689 100644
--- a/unix/xserver/hw/vnc/xvnc.c
+++ b/unix/xserver/hw/vnc/xvnc.c
@@ -1387,11 +1387,11 @@
while (extraOutputs > 0) {
crtc = vncRandRCrtcCreate(screenInfo.screens[scrIdx]);
if (crtc == NULL)
- return -1;
+ return 0;
extraOutputs--;
}
- return 0;
+ return 1;
}
/* Used to create a preferred mode from various places */