diff options
author | Peter Åstrand (astrand) <astrand@cendio.se> | 2018-04-02 22:15:47 +0200 |
---|---|---|
committer | Peter Åstrand (astrand) <astrand@cendio.se> | 2018-04-09 11:02:20 +0200 |
commit | ffeda0767ff1c61c72627f4aacb1526764630161 (patch) | |
tree | 925dabe37f11c5d72e10ddd35a8c6b8068548238 /unix | |
parent | ab98f7657b715a991023fc5e98ba2c58103d40d6 (diff) | |
download | tigervnc-ffeda0767ff1c61c72627f4aacb1526764630161.tar.gz tigervnc-ffeda0767ff1c61c72627f4aacb1526764630161.zip |
Remove "screen" argument from Randr glue functions
Screen is a Xvnc thing and not relevant for x0vncserver etc.
Diffstat (limited to 'unix')
-rw-r--r-- | unix/common/RandrGlue.h | 30 | ||||
-rw-r--r-- | unix/common/randr.cxx | 58 | ||||
-rw-r--r-- | unix/common/unixcommon.h | 5 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/RandrGlue.c | 43 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/XorgGlue.h | 1 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/XserverDesktop.cc | 13 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/vncExtInit.cc | 9 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/vncModule.c | 2 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/xvnc.c | 2 |
9 files changed, 94 insertions, 69 deletions
diff --git a/unix/common/RandrGlue.h b/unix/common/RandrGlue.h index 40d2d2e7..48ce3273 100644 --- a/unix/common/RandrGlue.h +++ b/unix/common/RandrGlue.h @@ -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 diff --git a/unix/common/randr.cxx b/unix/common/randr.cxx index 08bd45e6..85819916 100644 --- a/unix/common/randr.cxx +++ b/unix/common/randr.cxx @@ -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; } diff --git a/unix/common/unixcommon.h b/unix/common/unixcommon.h index 66fe84c2..5f5c8d62 100644 --- a/unix/common/unixcommon.h +++ b/unix/common/unixcommon.h @@ -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); diff --git a/unix/xserver/hw/vnc/RandrGlue.c b/unix/xserver/hw/vnc/RandrGlue.c index 54a035d5..86ec8bcc 100644 --- a/unix/xserver/hw/vnc/RandrGlue.c +++ b/unix/xserver/hw/vnc/RandrGlue.c @@ -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); +} diff --git a/unix/xserver/hw/vnc/XorgGlue.h b/unix/xserver/hw/vnc/XorgGlue.h index 8cf29350..68d66686 100644 --- a/unix/xserver/hw/vnc/XorgGlue.h +++ b/unix/xserver/hw/vnc/XorgGlue.h @@ -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 } diff --git a/unix/xserver/hw/vnc/XserverDesktop.cc b/unix/xserver/hw/vnc/XserverDesktop.cc index 19a09fc9..080943d0 100644 --- a/unix/xserver/hw/vnc/XserverDesktop.cc +++ b/unix/xserver/hw/vnc/XserverDesktop.cc @@ -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) diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc index 52e270a3..54cca953 100644 --- a/unix/xserver/hw/vnc/vncExtInit.cc +++ b/unix/xserver/hw/vnc/vncExtInit.cc @@ -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); diff --git a/unix/xserver/hw/vnc/vncModule.c b/unix/xserver/hw/vnc/vncModule.c index 5d95ef06..2a6e73c9 100644 --- a/unix/xserver/hw/vnc/vncModule.c +++ b/unix/xserver/hw/vnc/vncModule.c @@ -110,7 +110,7 @@ void vncClientGone(int fd) { } -int vncRandRCreateOutputs(int scrIdx, int extraOutputs) +int vncRandRCreateScreenOutputs(int scrIdx, int extraOutputs) { return 0; } diff --git a/unix/xserver/hw/vnc/xvnc.c b/unix/xserver/hw/vnc/xvnc.c index 0f17095d..f06e0b15 100644 --- a/unix/xserver/hw/vnc/xvnc.c +++ b/unix/xserver/hw/vnc/xvnc.c @@ -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; |