Skip to content

Commit

Permalink
test for grid
Browse files Browse the repository at this point in the history
  • Loading branch information
jsorg71 committed Jun 1, 2024
1 parent 864c30f commit 0979502
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 52 deletions.
31 changes: 12 additions & 19 deletions module/rdpCapture.c
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,13 @@ rdpCaptureGfxA2(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects,
return rv;
}

typedef int (*captureProc)(rdpClientCon *clientCon, RegionPtr in_reg,
BoxPtr *out_rects, int *num_out_rects,
struct image_data *id);
static captureProc g_captures[] = { rdpCaptureSimple, rdpCaptureSufA16,
rdpCaptureGfxPro, rdpCaptureSufA2,
rdpCaptureGfxPro, rdpCaptureGfxA2 };

/**
* Copy an array of rectangles from one memory area to another
*****************************************************************************/
Expand All @@ -1474,30 +1481,16 @@ rdpCapture(rdpClientCon *clientCon, RegionPtr in_reg, BoxPtr *out_rects,
int *num_out_rects, struct image_data *id)
{
enum xrdp_capture_code mode;
int num_captures = sizeof(g_captures) / sizeof(g_captures[0]);

LLOGLN(10, ("rdpCapture:"));
mode = clientCon->client_info.capture_code;
switch (mode)
if (((unsigned int)mode) >= num_captures)
{
case CC_SIMPLE:
return rdpCaptureSimple(clientCon, in_reg, out_rects, num_out_rects, id);
case CC_SUF_A16:
return rdpCaptureSufA16(clientCon, in_reg, out_rects, num_out_rects, id);
case CC_SUF_RFX: /* surface command RFX */
/* FALLTHROUGH */
case CC_GFX_PRO: /* GFX progressive */
return rdpCaptureGfxPro(clientCon, in_reg, out_rects, num_out_rects, id);
case CC_SUF_A2: /* surface command h264 */
/* used for even align capture */
return rdpCaptureSufA2(clientCon, in_reg, out_rects, num_out_rects, id);
case CC_GFX_A2: /* GFX h264 */
/* used for even align capture */
return rdpCaptureGfxA2(clientCon, in_reg, out_rects, num_out_rects, id);
default:
LLOGLN(0, ("rdpCapture: mode %d not implemented", mode));
break;
LLOGLN(0, ("rdpCapture: mode %d not implemented", mode));
return FALSE;
}
return FALSE;
return g_captures[mode](clientCon, in_reg, out_rects, num_out_rects, id);
}

/**
Expand Down
23 changes: 6 additions & 17 deletions module/rdpClientCon.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,9 +945,14 @@ rdpClientConResizeAllMemoryAreas(rdpPtr dev, rdpClientCon *clientCon)
int mmheight = PixelToMM(height, pScrn->yDpi);
int ok;
dev->allow_screen_resize = 1;
#if defined(XORGXRDP_LRANDR)
ok = rdpLRRScreenSizeSet(dev, width, height, mmwidth, mmheight);
LLOGLN(0, ("rdpClientConResizeAllMemoryAreas: rdpLRRScreenSizeSet ok=[%d]", ok));
#else
ok = RRScreenSizeSet(dev->pScreen, width, height, mmwidth, mmheight);
dev->allow_screen_resize = 0;
LLOGLN(0, ("rdpClientConResizeAllMemoryAreas: RRScreenSizeSet ok=[%d]", ok));
#endif
dev->allow_screen_resize = 0;
}

rdpCaptureResetState(clientCon);
Expand Down Expand Up @@ -1015,22 +1020,6 @@ rdpClientConProcessMsgClientInput(rdpPtr dev, rdpClientCon *clientCon)

LLOGLN(10, ("rdpClientConProcessMsgClientInput: msg %d param1 %d param2 %d "
"param3 %d param4 %d", msg, param1, param2, param3, param4));

LLOGLN(0, ("rdpClientConProcessMsgClientInput: 1 screenInfo x %d y %d "
"width %d height %d", screenInfo.x, screenInfo.y,
screenInfo.width, screenInfo.height));
if (screenInfo.width != dev->width)
{
screenInfo.width = dev->width;
}
if (screenInfo.height != dev->height)
{
screenInfo.height = dev->height;
}
LLOGLN(0, ("rdpClientConProcessMsgClientInput: 2 screenInfo x %d y %d "
"width %d height %d", screenInfo.x, screenInfo.y,
screenInfo.width, screenInfo.height));

if (msg < 100)
{
rdpInputKeyboardEvent(dev, msg, param1, param2, param3, param4);
Expand Down
157 changes: 157 additions & 0 deletions module/rdpLRandR.c
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,65 @@ rdpLRRInit(rdpPtr dev)
return 0;
}

/*****************************************************************************/
static int
rdpLRRSetPixmapVisitWindow(WindowPtr window, void *data)
{
ScreenPtr screen;

LLOGLN(10, ("rdpLRRSetPixmapVisitWindow:"));
screen = window->drawable.pScreen;
if (screen->GetWindowPixmap(window) == data)
{
screen->SetWindowPixmap(window, screen->GetScreenPixmap(screen));
return WT_WALKCHILDREN;
}
return WT_DONTWALKCHILDREN;
}

/*
* Edit connection information block so that new clients
* see the current screen size on connect
*/
/* from rrscreen.c */
static void
LRREditConnectionInfo(ScreenPtr pScreen)
{
xConnSetup *connSetup;
char *vendor;
xPixmapFormat *formats;
xWindowRoot *root;
xDepth *depth;
xVisualType *visual;
int screen = 0;
int d;

if (ConnectionInfo == NULL)
return;

connSetup = (xConnSetup *) ConnectionInfo;
vendor = (char *) connSetup + sizeof(xConnSetup);
formats = (xPixmapFormat *) ((char *) vendor +
pad_to_int32(connSetup->nbytesVendor));
root = (xWindowRoot *) ((char *) formats +
sizeof(xPixmapFormat) *
screenInfo.numPixmapFormats);
while (screen != pScreen->myNum) {
depth = (xDepth *) ((char *) root + sizeof(xWindowRoot));
for (d = 0; d < root->nDepths; d++) {
visual = (xVisualType *) ((char *) depth + sizeof(xDepth));
depth = (xDepth *) ((char *) visual +
depth->nVisuals * sizeof(xVisualType));
}
root = (xWindowRoot *) ((char *) depth);
screen++;
}
root->pixWidth = pScreen->width;
root->pixHeight = pScreen->height;
root->mmWidth = pScreen->mmWidth;
root->mmHeight = pScreen->mmHeight;
}

/******************************************************************************/
static void
LRRSendConfigNotify(ScreenPtr pScreen)
Expand All @@ -1124,6 +1183,104 @@ LRRSendConfigNotify(ScreenPtr pScreen)
DeliverEvents(pWin, &event, 1, NullWindow);
}

/******************************************************************************/
Bool
rdpLRRScreenSizeSet(rdpPtr dev, int width, int height,
int mmWidth, int mmHeight)
{
WindowPtr root;
PixmapPtr screenPixmap;
BoxRec box;
ScreenPtr pScreen;

LLOGLN(10, ("rdpLRRScreenSizeSet: width %d height %d mmWidth %d mmHeight %d",
width, height, mmWidth, mmHeight));
pScreen = dev->pScreen;
root = rdpGetRootWindowPtr(pScreen);
if ((width < 1) || (height < 1))
{
LLOGLN(10, (" error width %d height %d", width, height));
return FALSE;
}
dev->width = width;
dev->height = height;
//dev->paddedWidthInBytes = PixmapBytePad(dev->width, dev->depth);
//dev->sizeInBytes = dev->paddedWidthInBytes * dev->height;
pScreen->width = width;
pScreen->height = height;
pScreen->mmWidth = mmWidth;
pScreen->mmHeight = mmHeight;

g_width = width;
g_height = height;
g_mmWidth = mmWidth;
g_mmHeight = mmHeight;

//screenPixmap = dev->screenSwPixmap;

pScreen->DestroyPixmap(dev->screenSwPixmap);
dev->screenSwPixmap = pScreen->CreatePixmap(pScreen,
dev->width, dev->height,
dev->depth,
CREATE_PIXMAP_USAGE_SHARED);
dev->pfbMemory = dev->screenSwPixmap->devPrivate.ptr;
dev->paddedWidthInBytes = dev->screenSwPixmap->devKind;
dev->sizeInBytes = dev->paddedWidthInBytes * dev->height;



//free(dev->pfbMemory_alloc);
//dev->pfbMemory_alloc = g_new0(uint8_t, dev->sizeInBytes + 16);
//dev->pfbMemory = (uint8_t *) RDPALIGN(dev->pfbMemory_alloc, 16);
//pScreen->ModifyPixmapHeader(screenPixmap, width, height,
// -1, -1,
// dev->paddedWidthInBytes,
// dev->pfbMemory);

if (dev->nvidia)
{
PixmapPtr old_screen_pixmap;
old_screen_pixmap = pScreen->GetScreenPixmap(pScreen);
screenPixmap = pScreen->CreatePixmap(pScreen,
pScreen->width,
pScreen->height,
pScreen->rootDepth,
0);
if (screenPixmap == NULL)
{
return FALSE;
}
pScreen->SetScreenPixmap(screenPixmap);
if ((pScreen->root != NULL) && (pScreen->SetWindowPixmap != NULL))
{
TraverseTree(pScreen->root, rdpLRRSetPixmapVisitWindow, old_screen_pixmap);
}
pScreen->DestroyPixmap(old_screen_pixmap);
}
box.x1 = 0;
box.y1 = 0;
box.x2 = width;
box.y2 = height;
rdpRegionInit(&root->winSize, &box, 1);
rdpRegionInit(&root->borderSize, &box, 1);
rdpRegionReset(&root->borderClip, &box);
rdpRegionBreak(&root->clipList);
root->drawable.width = width;
root->drawable.height = height;
ResizeChildrenWinSize(root, 0, 0, 0, 0);
LLOGLN(0, (" screen resized to %dx%d", pScreen->width, pScreen->height));
LRREditConnectionInfo(pScreen);
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1, 13, 0, 0, 0)
xf86EnableDisableFBAccess(pScreen->myNum, FALSE);
xf86EnableDisableFBAccess(pScreen->myNum, TRUE);
#else
xf86EnableDisableFBAccess(xf86Screens[pScreen->myNum], FALSE);
xf86EnableDisableFBAccess(xf86Screens[pScreen->myNum], TRUE);
#endif

return TRUE;
}

/******************************************************************************/
Bool
rdpLRRSetRdpOutputs(rdpPtr dev)
Expand Down
3 changes: 3 additions & 0 deletions module/rdpLRandR.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
int
rdpLRRInit(rdpPtr dev);
Bool
rdpLRRScreenSizeSet(rdpPtr dev, int width, int height,
int mmWidth, int mmHeight);
Bool
rdpLRRSetRdpOutputs(rdpPtr dev);

#endif
16 changes: 0 additions & 16 deletions module/rdpMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,22 +201,6 @@ xorgxrdpRRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height,
dev->pfbMemory = dev->screenSwPixmap->devPrivate.ptr;
dev->paddedWidthInBytes = dev->screenSwPixmap->devKind;
dev->sizeInBytes = dev->paddedWidthInBytes * dev->height;

LLOGLN(0, ("xorgxrdpRRScreenSetSize: 1 screenInfo x %d y %d "
"width %d height %d", screenInfo.x, screenInfo.y,
screenInfo.width, screenInfo.height));
if (screenInfo.width != width)
{
screenInfo.width = width;
}
if (screenInfo.height != height)
{
screenInfo.height = height;
}
LLOGLN(0, ("xorgxrdpRRScreenSetSize: 2 screenInfo x %d y %d "
"width %d height %d", screenInfo.x, screenInfo.y,
screenInfo.width, screenInfo.height));

return rv;
}

Expand Down

0 comments on commit 0979502

Please sign in to comment.