Screen is a Xvnc thing and not relevant for x0vncserver etc.tags/v1.8.90
@@ -30,31 +30,31 @@ | |||
extern "C" { | |||
#endif | |||
int vncGetScreenWidth(int scrIdx); | |||
int vncGetScreenHeight(int scrIdx); | |||
int vncGetScreenWidth(void); | |||
int vncGetScreenHeight(void); | |||
int vncRandRResizeScreen(int scrIdx, int width, int height); | |||
void vncRandRUpdateSetTime(int scrIdx); | |||
int vncRandRResizeScreen(int width, int height); | |||
void vncRandRUpdateSetTime(void); | |||
int vncRandRHasOutputClones(int scrIdx); | |||
int vncRandRHasOutputClones(void); | |||
int vncRandRGetOutputCount(int scrIdx); | |||
int vncRandRGetAvailableOutputs(int scrIdx); | |||
int vncRandRGetOutputCount(void); | |||
int vncRandRGetAvailableOutputs(void); | |||
char *vncRandRGetOutputName(int scrIdx, int outputIdx); | |||
char *vncRandRGetOutputName(int outputIdx); | |||
int vncRandRIsOutputEnabled(int scrIdx, int outputIdx); | |||
int vncRandRIsOutputUsable(int scrIdx, int outputIdx); | |||
int vncRandRIsOutputEnabled(int outputIdx); | |||
int vncRandRIsOutputUsable(int outputIdx); | |||
int vncRandRDisableOutput(int scrIdx, int outputIdx); | |||
int vncRandRReconfigureOutput(int scrIdx, int outputIdx, int x, int y, | |||
int vncRandRDisableOutput(int outputIdx); | |||
int vncRandRReconfigureOutput(int outputIdx, int x, int y, | |||
int width, int height); | |||
unsigned int vncRandRGetOutputId(int scrIdx, int outputIdx); | |||
void vncRandRGetOutputDimensions(int scrIdx, int outputIdx, | |||
unsigned int vncRandRGetOutputId(int outputIdx); | |||
void vncRandRGetOutputDimensions(int outputIdx, | |||
int *x, int *y, int *width, int *height); | |||
int vncRandRCreateOutputs(int scrIdx, int extraOutputs); | |||
int vncRandRCreateOutputs(int extraOutputs); | |||
void *vncRandRCreatePreferredMode(void *output, int width, int height); | |||
#ifdef __cplusplus |
@@ -30,20 +30,20 @@ | |||
#include <RandrGlue.h> | |||
static rfb::LogWriter vlog("RandR"); | |||
rfb::ScreenSet computeScreenLayout(int screenIndex, OutputIdMap *outputIdMap) | |||
rfb::ScreenSet computeScreenLayout(OutputIdMap *outputIdMap) | |||
{ | |||
rfb::ScreenSet layout; | |||
OutputIdMap newIdMap; | |||
for (int i = 0;i < vncRandRGetOutputCount(screenIndex);i++) { | |||
for (int i = 0;i < vncRandRGetOutputCount();i++) { | |||
unsigned int outputId; | |||
int x, y, width, height; | |||
/* Disabled? */ | |||
if (!vncRandRIsOutputEnabled(screenIndex, i)) | |||
if (!vncRandRIsOutputEnabled(i)) | |||
continue; | |||
outputId = vncRandRGetOutputId(screenIndex, i); | |||
outputId = vncRandRGetOutputId(i); | |||
/* Known output? */ | |||
if (outputIdMap->count(outputId) == 1) | |||
@@ -65,7 +65,7 @@ rfb::ScreenSet computeScreenLayout(int screenIndex, OutputIdMap *outputIdMap) | |||
newIdMap[outputId] = id; | |||
} | |||
vncRandRGetOutputDimensions(screenIndex, i, &x, &y, &width, &height); | |||
vncRandRGetOutputDimensions(i, &x, &y, &width, &height); | |||
layout.add_screen(rfb::Screen(newIdMap[outputId], x, y, width, height, 0)); | |||
} | |||
@@ -78,41 +78,39 @@ rfb::ScreenSet computeScreenLayout(int screenIndex, OutputIdMap *outputIdMap) | |||
* that we have no active outputs... | |||
*/ | |||
if (layout.num_screens() == 0) | |||
layout.add_screen(rfb::Screen(0, 0, 0, vncGetScreenWidth(screenIndex), | |||
vncGetScreenHeight(screenIndex), 0)); | |||
layout.add_screen(rfb::Screen(0, 0, 0, vncGetScreenWidth(), | |||
vncGetScreenHeight(), 0)); | |||
return layout; | |||
} | |||
unsigned int setScreenLayout(int screenIndex, | |||
int fb_width, int fb_height, const rfb::ScreenSet& layout, | |||
unsigned int setScreenLayout(int fb_width, int fb_height, const rfb::ScreenSet& layout, | |||
OutputIdMap *outputIdMap) | |||
{ | |||
int ret; | |||
int availableOutputs; | |||
// RandR support? | |||
if (vncRandRGetOutputCount(screenIndex) == 0) | |||
if (vncRandRGetOutputCount() == 0) | |||
return rfb::resultProhibited; | |||
/* | |||
* First check that we don't have any active clone modes. That's just | |||
* too messy to deal with. | |||
*/ | |||
if (vncRandRHasOutputClones(screenIndex)) { | |||
if (vncRandRHasOutputClones()) { | |||
vlog.error("Clone mode active. Refusing to touch screen layout."); | |||
return rfb::resultInvalid; | |||
} | |||
/* Next count how many useful outputs we have... */ | |||
availableOutputs = vncRandRGetAvailableOutputs(screenIndex); | |||
availableOutputs = vncRandRGetAvailableOutputs(); | |||
/* Try to create more outputs if needed... (only works on Xvnc) */ | |||
if (layout.num_screens() > availableOutputs) { | |||
vlog.debug("Insufficient screens. Need to create %d more.", | |||
layout.num_screens() - availableOutputs); | |||
ret = vncRandRCreateOutputs(screenIndex, | |||
layout.num_screens() - availableOutputs); | |||
ret = vncRandRCreateOutputs(layout.num_screens() - availableOutputs); | |||
if (!ret) { | |||
vlog.error("Unable to create more screens, as needed by the new client layout."); | |||
return rfb::resultInvalid; | |||
@@ -120,9 +118,9 @@ unsigned int setScreenLayout(int screenIndex, | |||
} | |||
/* First we might need to resize the screen */ | |||
if ((fb_width != vncGetScreenWidth(screenIndex)) || | |||
(fb_height != vncGetScreenHeight(screenIndex))) { | |||
ret = vncRandRResizeScreen(screenIndex, fb_width, fb_height); | |||
if ((fb_width != vncGetScreenWidth()) || | |||
(fb_height != vncGetScreenHeight())) { | |||
ret = vncRandRResizeScreen(fb_width, fb_height); | |||
if (!ret) { | |||
vlog.error("Failed to resize screen to %dx%d", fb_width, fb_height); | |||
return rfb::resultInvalid; | |||
@@ -130,12 +128,12 @@ unsigned int setScreenLayout(int screenIndex, | |||
} | |||
/* Next, reconfigure all known outputs, and turn off the other ones */ | |||
for (int i = 0;i < vncRandRGetOutputCount(screenIndex);i++) { | |||
for (int i = 0;i < vncRandRGetOutputCount();i++) { | |||
unsigned int output; | |||
rfb::ScreenSet::const_iterator iter; | |||
output = vncRandRGetOutputId(screenIndex, i); | |||
output = vncRandRGetOutputId(i); | |||
/* Known? */ | |||
if (outputIdMap->count(output) == 0) | |||
@@ -150,9 +148,9 @@ unsigned int setScreenLayout(int screenIndex, | |||
/* Missing? */ | |||
if (iter == layout.end()) { | |||
/* Disable and move on... */ | |||
ret = vncRandRDisableOutput(screenIndex, i); | |||
ret = vncRandRDisableOutput(i); | |||
if (!ret) { | |||
char *name = vncRandRGetOutputName(screenIndex, i); | |||
char *name = vncRandRGetOutputName(i); | |||
vlog.error("Failed to disable unused output '%s'", | |||
name); | |||
free(name); | |||
@@ -163,13 +161,13 @@ unsigned int setScreenLayout(int screenIndex, | |||
} | |||
/* Reconfigure new mode and position */ | |||
ret = vncRandRReconfigureOutput(screenIndex, i, | |||
ret = vncRandRReconfigureOutput(i, | |||
iter->dimensions.tl.x, | |||
iter->dimensions.tl.y, | |||
iter->dimensions.width(), | |||
iter->dimensions.height()); | |||
if (!ret) { | |||
char *name = vncRandRGetOutputName(screenIndex, i); | |||
char *name = vncRandRGetOutputName(i); | |||
vlog.error("Failed to reconfigure output '%s' to %dx%d+%d+%d", | |||
name, | |||
iter->dimensions.width(), iter->dimensions.height(), | |||
@@ -196,22 +194,22 @@ unsigned int setScreenLayout(int screenIndex, | |||
continue; | |||
/* Find an unused output */ | |||
for (i = 0;i < vncRandRGetOutputCount(screenIndex);i++) { | |||
output = vncRandRGetOutputId(screenIndex, i); | |||
for (i = 0;i < vncRandRGetOutputCount();i++) { | |||
output = vncRandRGetOutputId(i); | |||
/* In use? */ | |||
if (outputIdMap->count(output) == 1) | |||
continue; | |||
/* Can it be used? */ | |||
if (!vncRandRIsOutputUsable(screenIndex, i)) | |||
if (!vncRandRIsOutputUsable(i)) | |||
continue; | |||
break; | |||
} | |||
/* Shouldn't happen */ | |||
if (i == vncRandRGetOutputCount(screenIndex)) | |||
if (i == vncRandRGetOutputCount()) | |||
return rfb::resultInvalid; | |||
/* | |||
@@ -222,13 +220,13 @@ unsigned int setScreenLayout(int screenIndex, | |||
(*outputIdMap)[output] = iter->id; | |||
/* Reconfigure new mode and position */ | |||
ret = vncRandRReconfigureOutput(screenIndex, i, | |||
ret = vncRandRReconfigureOutput(i, | |||
iter->dimensions.tl.x, | |||
iter->dimensions.tl.y, | |||
iter->dimensions.width(), | |||
iter->dimensions.height()); | |||
if (!ret) { | |||
char *name = vncRandRGetOutputName(screenIndex, i); | |||
char *name = vncRandRGetOutputName(i); | |||
vlog.error("Failed to reconfigure output '%s' to %dx%d+%d+%d", | |||
name, | |||
iter->dimensions.width(), iter->dimensions.height(), | |||
@@ -243,7 +241,7 @@ unsigned int setScreenLayout(int screenIndex, | |||
* This is normally done in the X11 request handlers, which is | |||
* why we have to deal with it manually here. | |||
*/ | |||
vncRandRUpdateSetTime(screenIndex); | |||
vncRandRUpdateSetTime(); | |||
return rfb::resultSuccess; | |||
} |
@@ -30,10 +30,9 @@ | |||
typedef std::map<unsigned int, rdr::U32> OutputIdMap; | |||
rfb::ScreenSet computeScreenLayout(int screenIndex, OutputIdMap *outputIdMap); | |||
rfb::ScreenSet computeScreenLayout(OutputIdMap *outputIdMap); | |||
unsigned int setScreenLayout(int screenIndex, | |||
int fb_width, int fb_height, const rfb::ScreenSet& layout, | |||
unsigned int setScreenLayout(int fb_width, int fb_height, const rfb::ScreenSet& layout, | |||
OutputIdMap *outputIdMap); | |||
@@ -28,18 +28,28 @@ | |||
#include "randrstr.h" | |||
#include "RandrGlue.h" | |||
#include "XorgGlue.h" | |||
int vncGetScreenWidth(int scrIdx) | |||
static int scrIdx; | |||
void vncSetGlueContext(int screenIndex); | |||
void vncSetGlueContext(int screenIndex) | |||
{ | |||
scrIdx = screenIndex; | |||
} | |||
int vncGetScreenWidth(void) | |||
{ | |||
return screenInfo.screens[scrIdx]->width; | |||
} | |||
int vncGetScreenHeight(int scrIdx) | |||
int vncGetScreenHeight(void) | |||
{ | |||
return screenInfo.screens[scrIdx]->height; | |||
} | |||
int vncRandRResizeScreen(int scrIdx, int width, int height) | |||
int vncRandRResizeScreen(int width, int height) | |||
{ | |||
ScreenPtr pScreen = screenInfo.screens[scrIdx]; | |||
/* Try to retain DPI when we resize */ | |||
@@ -48,13 +58,13 @@ int vncRandRResizeScreen(int scrIdx, int width, int height) | |||
pScreen->mmHeight * height / pScreen->height); | |||
} | |||
void vncRandRUpdateSetTime(int scrIdx) | |||
void vncRandRUpdateSetTime(void) | |||
{ | |||
rrScrPrivPtr rp = rrGetScrPriv(screenInfo.screens[scrIdx]); | |||
rp->lastSetTime = currentTime; | |||
} | |||
int vncRandRHasOutputClones(int scrIdx) | |||
int vncRandRHasOutputClones(void) | |||
{ | |||
rrScrPrivPtr rp = rrGetScrPriv(screenInfo.screens[scrIdx]); | |||
for (int i = 0;i < rp->numCrtcs;i++) { | |||
@@ -64,13 +74,13 @@ int vncRandRHasOutputClones(int scrIdx) | |||
return 0; | |||
} | |||
int vncRandRGetOutputCount(int scrIdx) | |||
int vncRandRGetOutputCount(void) | |||
{ | |||
rrScrPrivPtr rp = rrGetScrPriv(screenInfo.screens[scrIdx]); | |||
return rp->numOutputs; | |||
} | |||
int vncRandRGetAvailableOutputs(int scrIdx) | |||
int vncRandRGetAvailableOutputs(void) | |||
{ | |||
rrScrPrivPtr rp = rrGetScrPriv(screenInfo.screens[scrIdx]); | |||
@@ -125,13 +135,13 @@ int vncRandRGetAvailableOutputs(int scrIdx) | |||
return availableOutputs; | |||
} | |||
char *vncRandRGetOutputName(int scrIdx, int outputIdx) | |||
char *vncRandRGetOutputName(int outputIdx) | |||
{ | |||
rrScrPrivPtr rp = rrGetScrPriv(screenInfo.screens[scrIdx]); | |||
return strdup(rp->outputs[outputIdx]->name); | |||
} | |||
int vncRandRIsOutputEnabled(int scrIdx, int outputIdx) | |||
int vncRandRIsOutputEnabled(int outputIdx) | |||
{ | |||
rrScrPrivPtr rp = rrGetScrPriv(screenInfo.screens[scrIdx]); | |||
@@ -143,7 +153,7 @@ int vncRandRIsOutputEnabled(int scrIdx, int outputIdx) | |||
return 1; | |||
} | |||
int vncRandRIsOutputUsable(int scrIdx, int outputIdx) | |||
int vncRandRIsOutputUsable(int outputIdx) | |||
{ | |||
rrScrPrivPtr rp = rrGetScrPriv(screenInfo.screens[scrIdx]); | |||
@@ -163,7 +173,7 @@ int vncRandRIsOutputUsable(int scrIdx, int outputIdx) | |||
return 0; | |||
} | |||
int vncRandRDisableOutput(int scrIdx, int outputIdx) | |||
int vncRandRDisableOutput(int outputIdx) | |||
{ | |||
rrScrPrivPtr rp = rrGetScrPriv(screenInfo.screens[scrIdx]); | |||
RRCrtcPtr crtc; | |||
@@ -175,13 +185,13 @@ int vncRandRDisableOutput(int scrIdx, int outputIdx) | |||
return RRCrtcSet(crtc, NULL, crtc->x, crtc->y, crtc->rotation, 0, NULL); | |||
} | |||
unsigned int vncRandRGetOutputId(int scrIdx, int outputIdx) | |||
unsigned int vncRandRGetOutputId(int outputIdx) | |||
{ | |||
rrScrPrivPtr rp = rrGetScrPriv(screenInfo.screens[scrIdx]); | |||
return rp->outputs[outputIdx]->id; | |||
} | |||
void vncRandRGetOutputDimensions(int scrIdx, int outputIdx, | |||
void vncRandRGetOutputDimensions(int outputIdx, | |||
int *x, int *y, int *width, int *height) | |||
{ | |||
rrScrPrivPtr rp = rrGetScrPriv(screenInfo.screens[scrIdx]); | |||
@@ -202,7 +212,7 @@ void vncRandRGetOutputDimensions(int scrIdx, int outputIdx, | |||
} | |||
} | |||
int vncRandRReconfigureOutput(int scrIdx, int outputIdx, int x, int y, | |||
int vncRandRReconfigureOutput(int outputIdx, int x, int y, | |||
int width, int height) | |||
{ | |||
rrScrPrivPtr rp = rrGetScrPriv(screenInfo.screens[scrIdx]); | |||
@@ -239,3 +249,8 @@ int vncRandRReconfigureOutput(int scrIdx, int outputIdx, int x, int y, | |||
/* Reconfigure new mode and position */ | |||
return RRCrtcSet(crtc, mode, x, y, crtc->rotation, 1, &output); | |||
} | |||
int vncRandRCreateOutputs(int extraOutputs) | |||
{ | |||
return vncRandRCreateScreenOutputs(scrIdx, extraOutputs); | |||
} |
@@ -48,6 +48,7 @@ int vncGetScreenY(int scrIdx); | |||
// These hide in xvnc.c or vncModule.c | |||
void vncClientGone(int fd); | |||
int vncRandRCreateScreenOutputs(int scrIdx, int extraOutputs); | |||
#ifdef __cplusplus | |||
} |
@@ -48,6 +48,10 @@ | |||
#include "XorgGlue.h" | |||
#include "Input.h" | |||
extern "C" { | |||
void vncSetGlueContext(int screenIndex); | |||
} | |||
using namespace rfb; | |||
using namespace network; | |||
@@ -185,14 +189,16 @@ void XserverDesktop::setFramebuffer(int w, int h, void* fbptr, int stride_) | |||
data = (rdr::U8*)fbptr; | |||
stride = stride_; | |||
layout = ::computeScreenLayout(screenIndex, &outputIdMap); | |||
vncSetGlueContext(screenIndex); | |||
layout = ::computeScreenLayout(&outputIdMap); | |||
server->setPixelBuffer(this, layout); | |||
} | |||
void XserverDesktop::refreshScreenLayout() | |||
{ | |||
server->setScreenLayout(::computeScreenLayout(screenIndex, &outputIdMap)); | |||
vncSetGlueContext(screenIndex); | |||
server->setScreenLayout(::computeScreenLayout(&outputIdMap)); | |||
} | |||
char* XserverDesktop::substitute(const char* varName) | |||
@@ -557,7 +563,8 @@ unsigned int XserverDesktop::setScreenLayout(int fb_width, int fb_height, | |||
layout.print(buffer, sizeof(buffer)); | |||
vlog.debug("%s", buffer); | |||
return ::setScreenLayout(screenIndex, fb_width, fb_height, layout, &outputIdMap); | |||
vncSetGlueContext(screenIndex); | |||
return ::setScreenLayout(fb_width, fb_height, layout, &outputIdMap); | |||
} | |||
void XserverDesktop::grabRegion(const rfb::Region& region) |
@@ -44,6 +44,10 @@ | |||
#include "RandrGlue.h" | |||
#include "xorg-version.h" | |||
extern "C" { | |||
void vncSetGlueContext(int screenIndex); | |||
} | |||
using namespace rfb; | |||
static rfb::LogWriter vlog("vncext"); | |||
@@ -212,13 +216,14 @@ void vncExtensionInit(void) | |||
CharArray desktopNameStr(desktopName.getData()); | |||
PixelFormat pf = vncGetPixelFormat(scr); | |||
vncSetGlueContext(scr); | |||
desktop[scr] = new XserverDesktop(scr, | |||
listeners, | |||
httpListeners, | |||
desktopNameStr.buf, | |||
pf, | |||
vncGetScreenWidth(scr), | |||
vncGetScreenHeight(scr), | |||
vncGetScreenWidth(), | |||
vncGetScreenHeight(), | |||
vncFbptr[scr], | |||
vncFbstride[scr]); | |||
vlog.info("created VNC server for screen %d", scr); |
@@ -110,7 +110,7 @@ void vncClientGone(int fd) | |||
{ | |||
} | |||
int vncRandRCreateOutputs(int scrIdx, int extraOutputs) | |||
int vncRandRCreateScreenOutputs(int scrIdx, int extraOutputs) | |||
{ | |||
return 0; | |||
} |
@@ -1377,7 +1377,7 @@ static RRCrtcPtr vncRandRCrtcCreate(ScreenPtr pScreen) | |||
} | |||
/* Used from XserverDesktop when it needs more outputs... */ | |||
int vncRandRCreateOutputs(int scrIdx, int extraOutputs) | |||
int vncRandRCreateScreenOutputs(int scrIdx, int extraOutputs) | |||
{ | |||
RRCrtcPtr crtc; | |||