diff --git a/module/rdpClientCon.c b/module/rdpClientCon.c index 166c1cb..baebe8b 100644 --- a/module/rdpClientCon.c +++ b/module/rdpClientCon.c @@ -121,6 +121,8 @@ static void rdpClientConProcessClientInfoMonitors(rdpPtr dev, rdpClientCon *clientCon); static int rdpSendMemoryAllocationComplete(rdpPtr dev, rdpClientCon *clientCon); +static int +rdpSendAccelAssistMonitors(rdpPtr dev, rdpClientCon *clientCon); #if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1, 18, 5, 0, 0) @@ -400,6 +402,7 @@ rdpShutdownAccelAssist(rdpPtr dev, rdpClientCon *clientCon) { } } clientCon->accel_assist_pid = -1; + clientCon->use_accel_assist = 0; return exit_code; } @@ -489,7 +492,7 @@ rdpClientConDisconnect(rdpPtr dev, rdpClientCon *clientCon) clientCon->shmemfd, clientCon->shmem_bytes); } - if (rdpClientConUseAccelAssist(dev, clientCon)) + if (clientCon->use_accel_assist) { rdpShutdownAccelAssist(dev, clientCon); } @@ -973,7 +976,6 @@ rdpClientConProcessMonitorUpdateMsg(rdpPtr dev, rdpClientCon *clientCon, LLOGLN(0, ("rdpClientConProcessMonitorUpdateMsg: (%dx%d) #%d", width, height, num_monitors)); - // Update the client_info we have clientCon->client_info.display_sizes.monitorCount = num_monitors; for (i = 0; i < num_monitors; ++i) @@ -991,6 +993,11 @@ rdpClientConProcessMonitorUpdateMsg(rdpPtr dev, rdpClientCon *clientCon, rdpClientConAddDirtyScreen(dev, clientCon, 0, 0, width, height); rdpSendMemoryAllocationComplete(dev, clientCon); + if (clientCon->use_accel_assist) + { + rdpSendAccelAssistMonitors(dev, clientCon); + } + return 0; } @@ -1425,18 +1432,17 @@ rdpClientConProcessMsgClientInfo(rdpPtr dev, rdpClientCon *clientCon) rdpInputKeyboardEvent(dev, 18, (long)(&(clientCon->client_info)), 0, 0, 0); + rdpSendMemoryAllocationComplete(dev, clientCon); + rdpClientConAddDirtyScreen(dev, clientCon, 0, 0, clientCon->rdp_width, + clientCon->rdp_height); + /* currently only nvenc and h264 is supported */ if (rdpClientConUseAccelAssist(dev, clientCon)) { + clientCon->use_accel_assist = 1; rdpStartAccelAssist(dev, clientCon); rdpSendAccelAssistMonitors(dev, clientCon); } - else - { - rdpSendMemoryAllocationComplete(dev, clientCon); - rdpClientConAddDirtyScreen(dev, clientCon, 0, 0, clientCon->rdp_width, - clientCon->rdp_height); - } return 0; } diff --git a/module/rdpClientCon.h b/module/rdpClientCon.h index c028603..6318699 100644 --- a/module/rdpClientCon.h +++ b/module/rdpClientCon.h @@ -131,6 +131,7 @@ struct _rdpClientCon /* true = skip drawing */ int suppress_output; + int use_accel_assist; int accel_assist_pid; struct _rdpClientCon *next; diff --git a/module/rdpPutImage.c b/module/rdpPutImage.c index dc82c81..01aa58f 100644 --- a/module/rdpPutImage.c +++ b/module/rdpPutImage.c @@ -88,7 +88,8 @@ rdpPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y, if (clientCon->conNumber == pBits32[1]) { /* free old */ - pixmap = clientCon->accelAssistPixmaps[pBits32[2] & 0xF]; + int monitor_index = pBits32[2] & 0xF; + pixmap = clientCon->accelAssistPixmaps[monitor_index]; if (pixmap != NULL) { pScreen->DestroyPixmap(pixmap); @@ -96,10 +97,33 @@ rdpPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y, /* set new */ pixmap = (PixmapPtr) pDst; LLOGLN(0, ("rdpPutImage: setting conNumber %d, monitor num %d " - "to pixmap %p", pBits32[1], pBits32[2], pixmap)); - clientCon->accelAssistPixmaps[pBits32[2] & 0xF] = pixmap; + "to pixmap %p", pBits32[1], monitor_index, pixmap)); + clientCon->accelAssistPixmaps[monitor_index] = pixmap; /* so it can not get freed early */ pixmap->refcnt++; + /* invalidate */ + if (dev->monitorCount < 1) + { + LLOGLN(0, ("rdpPutImage: monitor_index %d " + "invalidating 0 0 %d %d", + monitor_index, dev->width, dev->height)); + rdpClientConAddDirtyScreen(dev, clientCon, 0, 0, + dev->width, dev->height); + } + else if (monitor_index < dev->monitorCount) + { + int left = dev->minfo[monitor_index].left; + int top = dev->minfo[monitor_index].top; + int width = dev->minfo[monitor_index].right - + dev->minfo[monitor_index].left + 1; + int height = dev->minfo[monitor_index].bottom - + dev->minfo[monitor_index].top + 1; + LLOGLN(0, ("rdpPutImage: monitor_index %d " + "invalidating %d %d %d %d", + monitor_index, left, top, width, height)); + rdpClientConAddDirtyScreen(dev, clientCon, + left, top , width, height); + } break; } clientCon = clientCon->next;