Skip to content

Commit

Permalink
Ignore screen size changes which don't change anything
Browse files Browse the repository at this point in the history
  • Loading branch information
matt335672 committed Nov 29, 2021
1 parent d9f08ea commit eca1d70
Showing 1 changed file with 52 additions and 46 deletions.
98 changes: 52 additions & 46 deletions module/rdpClientCon.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,58 +693,64 @@ rdpClientConProcessScreenSizeMsg(rdpPtr dev, rdpClientCon *clientCon,

LLOGLN(0, ("rdpClientConProcessScreenSizeMsg: set width %d height %d "
"bpp %d", width, height, bpp));
clientCon->shmemstatus = SHM_RESIZING;
clientCon->rdp_width = width;
clientCon->rdp_height = height;
clientCon->rdp_bpp = bpp;
clientCon->cap_width = width;
clientCon->cap_height = height;

if (bpp < 15)
/* Only reallocate memory if the size is different */
if (clientCon->rdp_width != width || clientCon->rdp_height != height ||
clientCon->rdp_bpp != bpp)
{
clientCon->rdp_Bpp = 1;
clientCon->rdp_Bpp_mask = 0xff;
clientCon->rdp_format = XRDP_r3g3b2;
}
else if (bpp == 15)
{
clientCon->rdp_Bpp = 2;
clientCon->rdp_Bpp_mask = 0x7fff;
clientCon->rdp_format = XRDP_a1r5g5b5;
}
else if (bpp == 16)
{
clientCon->rdp_Bpp = 2;
clientCon->rdp_Bpp_mask = 0xffff;
clientCon->rdp_format = XRDP_r5g6b5;
}
else if (bpp > 16)
{
clientCon->rdp_Bpp = 4;
clientCon->rdp_Bpp_mask = 0xffffff;
clientCon->rdp_format = XRDP_a8r8g8b8;
}
clientCon->shmemstatus = SHM_RESIZING;
clientCon->rdp_width = width;
clientCon->rdp_height = height;
clientCon->rdp_bpp = bpp;
clientCon->cap_width = width;
clientCon->cap_height = height;

clientCon->cap_stride_bytes = clientCon->rdp_width * clientCon->rdp_Bpp;
if (bpp < 15)
{
clientCon->rdp_Bpp = 1;
clientCon->rdp_Bpp_mask = 0xff;
clientCon->rdp_format = XRDP_r3g3b2;
}
else if (bpp == 15)
{
clientCon->rdp_Bpp = 2;
clientCon->rdp_Bpp_mask = 0x7fff;
clientCon->rdp_format = XRDP_a1r5g5b5;
}
else if (bpp == 16)
{
clientCon->rdp_Bpp = 2;
clientCon->rdp_Bpp_mask = 0xffff;
clientCon->rdp_format = XRDP_r5g6b5;
}
else if (bpp > 16)
{
clientCon->rdp_Bpp = 4;
clientCon->rdp_Bpp_mask = 0xffffff;
clientCon->rdp_format = XRDP_a8r8g8b8;
}

if (clientCon->shmemptr != 0)
{
shmdt(clientCon->shmemptr);
}
bytes = clientCon->rdp_width * clientCon->rdp_height *
clientCon->rdp_Bpp;
clientCon->shmemid = shmget(IPC_PRIVATE, bytes, IPC_CREAT | 0777);
clientCon->shmemptr = shmat(clientCon->shmemid, 0, 0);
shmctl(clientCon->shmemid, IPC_RMID, NULL);
LLOGLN(0, ("rdpClientConProcessScreenSizeMsg: shmemid %d shmemptr %p",
clientCon->shmemid, clientCon->shmemptr));
clientCon->shmem_lineBytes = clientCon->rdp_Bpp * clientCon->rdp_width;
clientCon->cap_stride_bytes = clientCon->rdp_width * clientCon->rdp_Bpp;

if (clientCon->shmRegion != 0)
{
rdpRegionDestroy(clientCon->shmRegion);
if (clientCon->shmemptr != 0)
{
shmdt(clientCon->shmemptr);
}
bytes = clientCon->rdp_width * clientCon->rdp_height *
clientCon->rdp_Bpp;
clientCon->shmemid = shmget(IPC_PRIVATE, bytes, IPC_CREAT | 0777);
clientCon->shmemptr = shmat(clientCon->shmemid, 0, 0);
shmctl(clientCon->shmemid, IPC_RMID, NULL);
LLOGLN(0, ("rdpClientConProcessScreenSizeMsg: shmemid %d shmemptr %p",
clientCon->shmemid, clientCon->shmemptr));
clientCon->shmem_lineBytes = clientCon->rdp_Bpp * clientCon->rdp_width;

if (clientCon->shmRegion != 0)
{
rdpRegionDestroy(clientCon->shmRegion);
}
clientCon->shmRegion = rdpRegionCreate(NullBox, 0);
}
clientCon->shmRegion = rdpRegionCreate(NullBox, 0);

pScrn = xf86Screens[dev->pScreen->myNum];
mmwidth = PixelToMM(width, pScrn->xDpi);
Expand Down

0 comments on commit eca1d70

Please sign in to comment.