From 473f3dcd0cf430b94298bf6dd711a18d7cc6214c Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Tue, 19 Apr 2016 15:34:45 -0700 Subject: [PATCH] X11rdp: merge multimon from Xorg driver --- xorg/X11R7.6/rdp/rdprandr.c | 170 ++++++++++++++++++++++++++++++++++-- xorg/X11R7.6/rdp/rdprandr.h | 3 + xorg/X11R7.6/rdp/rdpup.c | 31 +++++++ 3 files changed, 197 insertions(+), 7 deletions(-) diff --git a/xorg/X11R7.6/rdp/rdprandr.c b/xorg/X11R7.6/rdp/rdprandr.c index d0ee6b1c..46c4908d 100644 --- a/xorg/X11R7.6/rdp/rdprandr.c +++ b/xorg/X11R7.6/rdp/rdprandr.c @@ -38,6 +38,14 @@ extern WindowPtr g_invalidate_window; /* in rdpmain.c */ static XID g_wid = 0; +static int g_panning = 0; + +#define LOG_LEVEL 1 +#define LLOG(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0) +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + /******************************************************************************/ Bool rdpRRRegisterSize(ScreenPtr pScreen, int width, int height) @@ -68,15 +76,8 @@ rdpRRSetConfig(ScreenPtr pScreen, Rotation rotateKind, int rate, Bool rdpRRGetInfo(ScreenPtr pScreen, Rotation *pRotations) { - int width; - int height; - ErrorF("rdpRRGetInfo:\n"); *pRotations = RR_Rotate_0; - - width = g_rdpScreen.width; - height = g_rdpScreen.height; - rdpRRRegisterSize(pScreen, width, height); return TRUE; } @@ -214,6 +215,19 @@ Bool rdpRRCrtcGetGamma(ScreenPtr pScreen, RRCrtcPtr crtc) { ErrorF("rdpRRCrtcGetGamma:\n"); + crtc->gammaSize = 1; + if (crtc->gammaRed == NULL) + { + crtc->gammaRed = g_malloc(32, 1); + } + if (crtc->gammaBlue == NULL) + { + crtc->gammaBlue = g_malloc(32, 1); + } + if (crtc->gammaGreen == NULL) + { + crtc->gammaGreen = g_malloc(32, 1); + } return TRUE; } @@ -257,6 +271,11 @@ rdpRRGetPanning(ScreenPtr pScrn, RRCrtcPtr crtc, BoxPtr totalArea, { ErrorF("rdpRRGetPanning:\n"); + if (!g_panning) + { + return FALSE; + } + if (totalArea != 0) { totalArea->x1 = 0; @@ -292,3 +311,140 @@ rdpRRSetPanning(ScreenPtr pScrn, RRCrtcPtr crtc, BoxPtr totalArea, ErrorF("rdpRRSetPanning:\n"); return TRUE; } + +/******************************************************************************/ +static RROutputPtr +rdpRRAddOutput(const char *aname, int x, int y, int width, int height) +{ + RRModePtr mode; + RRCrtcPtr crtc; + RROutputPtr output; + xRRModeInfo modeInfo; + char name[64]; + + sprintf (name, "%dx%d", width, height); + memset (&modeInfo, 0, sizeof(modeInfo)); + modeInfo.width = width; + modeInfo.height = height; + modeInfo.nameLength = strlen(name); + mode = RRModeGet(&modeInfo, name); + if (mode == 0) + { + LLOGLN(0, ("rdpRRAddOutput: RRModeGet failed")); + return 0; + } + + crtc = RRCrtcCreate(g_pScreen, NULL); + if (crtc == 0) + { + LLOGLN(0, ("rdpRRAddOutput: RRCrtcCreate failed")); + RRModeDestroy(mode); + return 0; + } + output = RROutputCreate(g_pScreen, aname, strlen(aname), NULL); + if (output == 0) + { + LLOGLN(0, ("rdpRRAddOutput: RROutputCreate failed")); + RRCrtcDestroy(crtc); + RRModeDestroy(mode); + return 0; + } + if (!RROutputSetClones(output, NULL, 0)) + { + LLOGLN(0, ("rdpRRAddOutput: RROutputSetClones failed")); + } + if (!RROutputSetModes(output, &mode, 1, 0)) + { + LLOGLN(0, ("rdpRRAddOutput: RROutputSetModes failed")); + } + if (!RROutputSetCrtcs(output, &crtc, 1)) + { + LLOGLN(0, ("rdpRRAddOutput: RROutputSetCrtcs failed")); + } + if (!RROutputSetConnection(output, RR_Connected)) + { + LLOGLN(0, ("rdpRRAddOutput: RROutputSetConnection failed")); + } + RRCrtcNotify(crtc, mode, x, y, RR_Rotate_0, NULL, 1, &output); + + return output; +} + +/******************************************************************************/ +static void +RRSetPrimaryOutput(rrScrPrivPtr pScrPriv, RROutputPtr output) +{ + if (pScrPriv->primaryOutput == output) + { + return; + } + /* clear the old primary */ + if (pScrPriv->primaryOutput) + { + RROutputChanged(pScrPriv->primaryOutput, 0); + pScrPriv->primaryOutput = NULL; + } + /* set the new primary */ + if (output) + { + pScrPriv->primaryOutput = output; + RROutputChanged(output, 0); + } + pScrPriv->layoutChanged = TRUE; +} + +/******************************************************************************/ +int +rdpRRSetRdpOutputs(void) +{ + rrScrPrivPtr pRRScrPriv; + int index; + int width; + int height; + char text[256]; + RROutputPtr output; + + pRRScrPriv = rrGetScrPriv(g_pScreen); + + LLOGLN(0, ("rdpRRSetRdpOutputs: numCrtcs %d", pRRScrPriv->numCrtcs)); + while (pRRScrPriv->numCrtcs > 0) + { + RRCrtcDestroy(pRRScrPriv->crtcs[0]); + } + LLOGLN(0, ("rdpRRSetRdpOutputs: numOutputs %d", pRRScrPriv->numOutputs)); + while (pRRScrPriv->numOutputs > 0) + { + RROutputDestroy(pRRScrPriv->outputs[0]); + } + + if (g_rdpScreen.client_info.monitorCount == 0) + { + rdpRRAddOutput("rdp0", 0, 0, g_rdpScreen.width, g_rdpScreen.height); + } + else + { + for (index = 0; index < g_rdpScreen.client_info.monitorCount; index++) + { + snprintf(text, 255, "rdp%d", index); + width = g_rdpScreen.client_info.minfo[index].right - g_rdpScreen.client_info.minfo[index].left + 1; + height = g_rdpScreen.client_info.minfo[index].bottom - g_rdpScreen.client_info.minfo[index].top + 1; + output = rdpRRAddOutput(text, + g_rdpScreen.client_info.minfo[index].left, + g_rdpScreen.client_info.minfo[index].top, + width, height); + if ((output != 0) && (g_rdpScreen.client_info.minfo[index].is_primary)) + { + RRSetPrimaryOutput(pRRScrPriv, output); + } + } + } + + for (index = 0; index < pRRScrPriv->numOutputs; index++) + { + RROutputSetCrtcs(pRRScrPriv->outputs[index], pRRScrPriv->crtcs, + pRRScrPriv->numCrtcs); + } + + return 0; +} + diff --git a/xorg/X11R7.6/rdp/rdprandr.h b/xorg/X11R7.6/rdp/rdprandr.h index 3aba7e1a..1860fa96 100644 --- a/xorg/X11R7.6/rdp/rdprandr.h +++ b/xorg/X11R7.6/rdp/rdprandr.h @@ -57,4 +57,7 @@ Bool rdpRRSetPanning(ScreenPtr pScrn, RRCrtcPtr crtc, BoxPtr totalArea, BoxPtr trackingArea, INT16* border); +int +rdpRRSetRdpOutputs(void); + #endif diff --git a/xorg/X11R7.6/rdp/rdpup.c b/xorg/X11R7.6/rdp/rdpup.c index 0532d063..4bee8875 100644 --- a/xorg/X11R7.6/rdp/rdpup.c +++ b/xorg/X11R7.6/rdp/rdpup.c @@ -22,6 +22,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "rdp.h" #include "xrdp_rail.h" #include "rdpglyph.h" +#include "rdprandr.h" #include #include @@ -930,6 +931,7 @@ rdpup_process_msg(struct stream *s) int y; int cx; int cy; + int index; RegionRec reg; BoxRec box; @@ -1119,16 +1121,45 @@ rdpup_process_msg(struct stream *s) { LLOGLN(0, (" client can not do new(color) cursor")); } + if (g_rdpScreen.client_info.monitorCount > 0) { LLOGLN(0, (" client can do multimon")); LLOGLN(0, (" client monitor data, monitorCount= %d", g_rdpScreen.client_info.monitorCount)); + box.x1 = g_rdpScreen.client_info.minfo[0].left; + box.y1 = g_rdpScreen.client_info.minfo[0].top; + box.x2 = g_rdpScreen.client_info.minfo[0].right; + box.y2 = g_rdpScreen.client_info.minfo[0].bottom; g_do_multimon = 1; + /* adjust monitor info so it's not negitive */ + for (index = 1; index < g_rdpScreen.client_info.monitorCount; index++) + { + box.x1 = min(box.x1, g_rdpScreen.client_info.minfo[index].left); + box.y1 = min(box.y1, g_rdpScreen.client_info.minfo[index].top); + box.x2 = max(box.x2, g_rdpScreen.client_info.minfo[index].right); + box.y2 = max(box.y2, g_rdpScreen.client_info.minfo[index].bottom); + } + for (index = 0; index < g_rdpScreen.client_info.monitorCount; index++) + { + g_rdpScreen.client_info.minfo[index].left -= box.x1; + g_rdpScreen.client_info.minfo[index].top -= box.y1; + g_rdpScreen.client_info.minfo[index].right -= box.x1; + g_rdpScreen.client_info.minfo[index].bottom -= box.y1; + LLOGLN(0, (" left %d top %d right %d bottom %d", + g_rdpScreen.client_info.minfo[index].left, + g_rdpScreen.client_info.minfo[index].top, + g_rdpScreen.client_info.minfo[index].right, + g_rdpScreen.client_info.minfo[index].bottom)); + } + rdpRRSetRdpOutputs(); + RRTellChanged(g_pScreen); } else { LLOGLN(0, (" client can not do multimon")); g_do_multimon = 0; + rdpRRSetRdpOutputs(); + RRTellChanged(g_pScreen); } rdpLoadLayout(&(g_rdpScreen.client_info));