client: compose multi-display frames and map input across the view
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Failing after 20s
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Failing after 21s
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Failing after 22s
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Failing after 20s
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Failing after 20s
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Failing after 19s
build / module (push) Failing after 17s
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Failing after 19s
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Failing after 19s
build / host-linux (push) Failing after 19s
build / host-windows-cross (push) Failing after 19s
build / obs (clang) (push) Failing after 19s
build / docs (push) Failing after 4s
build / obs (gcc) (push) Failing after 19s
build / idd (push) Canceled after 0s
build / host-windows-native (push) Canceled after 0s

Adds the EGL composition pass, the app:display selector and the input
coordinate shift needed when only part of the guest desktop is shown.
This commit is contained in:
donny committed 2026-07-28 07:13:18 +00:00
1 parent dfe8edfbc2
commit 95e55273ea
4 files changed
+113 -6

No files matched your search

+4 -1
View File
@@ -410,7 +410,10 @@ bool egl_desktopSetup(EGL_Desktop * desktop, const LG_RendererFormat format)
{
if (egl_composeSetup(desktop->compose, &desktop->format))
{
egl_composeGetSize(desktop->compose, &desktop->width, &desktop->height);
unsigned int viewWidth, viewHeight;
egl_composeGetSize(desktop->compose, &viewWidth, &viewHeight);
desktop->width = viewWidth;
desktop->height = viewHeight;
desktop->composeActive = true;
DEBUG_INFO("Composing %u displays from a %ux%u atlas into a %ux%u view",
+8
View File
@@ -96,6 +96,14 @@ static struct Option options[] =
.type = OPTION_TYPE_INT,
.value.x_int = 1000
},
{
.module = "app",
.name = "display",
.description = "Which guest display to show when the guest has several: "
"`all` for the whole desktop, or an index or output name",
.type = OPTION_TYPE_STRING,
.value.x_string = "all",
},
{
.module = "app",
.name = "allowDMA",
+90 -3
View File
@@ -46,6 +46,7 @@
#include "common/locking.h"
#include "common/event.h"
#include "common/ivshmem.h"
#include "common/option.h"
#include "common/time.h"
#include "common/version.h"
#include "common/paths.h"
@@ -557,6 +558,74 @@ int main_cursorThread(void * unused)
return 0;
}
/* Work out which part of the guest's virtual desktop to present, from the
* `app:display` option.
*
* The default, `all`, shows the whole desktop with the monitors arranged as
* the guest has them. Naming a single display instead shows just that one,
* which is how several client instances can each take one guest monitor: they
* all subscribe to the same frames and each crops its own.
*
* An unrecognised selection falls back to the whole desktop rather than
* failing, so a stale config cannot leave the user with a blank window. */
static void configureDisplayView(LG_RendererFormat * format,
const KVMFRFrame * frame)
{
format->displayCount = frame->displayCount;
memcpy(format->displays, frame->displays,
frame->displayCount * sizeof(*frame->displays));
// the whole virtual desktop, which the host reports as the screen size
format->viewX = 0;
format->viewY = 0;
format->viewWidth = frame->screenWidth;
format->viewHeight = frame->screenHeight;
if (!frame->displayCount)
return;
const char * select = option_get_string("app", "display");
if (!select || !*select || strcasecmp(select, "all") == 0)
{
DEBUG_INFO("Showing all %u guest displays (%ux%u virtual desktop)",
frame->displayCount, frame->screenWidth, frame->screenHeight);
return;
}
const KVMFRDisplay * chosen = NULL;
// an index into the display list, as reported by the host
char * end;
const long index = strtol(select, &end, 10);
if (*select && !*end && index >= 0 && index < (long)frame->displayCount)
chosen = &frame->displays[index];
else
for(unsigned i = 0; i < frame->displayCount; ++i)
if (strcasecmp(frame->displays[i].name, select) == 0)
{
chosen = &frame->displays[i];
break;
}
if (!chosen)
{
DEBUG_WARN("No guest display matches `%s`, showing the whole desktop",
select);
for(unsigned i = 0; i < frame->displayCount; ++i)
DEBUG_WARN(" available: %u or `%s`", i, frame->displays[i].name);
return;
}
format->viewX = chosen->desktopX;
format->viewY = chosen->desktopY;
format->viewWidth = chosen->desktopWidth;
format->viewHeight = chosen->desktopHeight;
DEBUG_INFO("Showing guest display `%s` (%ux%u at +%d+%d)",
chosen->name, chosen->desktopWidth, chosen->desktopHeight,
chosen->desktopX, chosen->desktopY);
}
int main_frameThread(void * unused)
{
struct DMAFrameInfo
@@ -668,6 +737,8 @@ int main_frameThread(void * unused)
lgrFormat.sdrWhiteLevel = frame->sdrWhiteLevel ?
frame->sdrWhiteLevel : KVMFR_SDR_WHITE_LEVEL_DEFAULT;
configureDisplayView(&lgrFormat, frame);
if (lgrFormat.hdrMetadata)
{
memcpy(lgrFormat.hdrDisplayPrimary, frame->hdrDisplayPrimary, sizeof(lgrFormat.hdrDisplayPrimary));
@@ -788,11 +859,27 @@ int main_frameThread(void * unused)
renderQueue_surfaceFormat(lgrFormat, rendererSupportsNativeHDR);
LG_UNLOCK(g_state.lgrLock);
g_state.srcSize.x = lgrFormat.screenWidth;
g_state.srcSize.y = lgrFormat.screenHeight;
/* With a multi-display guest what reaches the screen is the composed
* view, not the packed frame, so both the source size used for input
* mapping and the auto-resize target must come from the view. */
g_state.displayCount = lgrFormat.displayCount;
memcpy(g_state.displays, lgrFormat.displays,
lgrFormat.displayCount * sizeof(*lgrFormat.displays));
g_state.viewX = lgrFormat.viewX;
g_state.viewY = lgrFormat.viewY;
const unsigned int viewW = lgrFormat.displayCount ?
lgrFormat.viewWidth : lgrFormat.screenWidth;
const unsigned int viewH = lgrFormat.displayCount ?
lgrFormat.viewHeight : lgrFormat.screenHeight;
g_state.srcSize.x = viewW;
g_state.srcSize.y = viewH;
g_state.haveSrcSize = true;
if (g_params.autoResize)
g_state.ds->setWindowSize(lgrFormat.frameWidth, lgrFormat.frameHeight);
g_state.ds->setWindowSize(
lgrFormat.displayCount ? viewW : lgrFormat.frameWidth,
lgrFormat.displayCount ? viewH : lgrFormat.frameHeight);
core_updatePositionInfo();
}
+11 -2
View File
@@ -120,10 +120,14 @@ bool util_guestCurToLocal(struct DoublePoint *local)
if (!g_cursor.guest.valid || !g_state.posInfoValid)
return false;
/* The guest reports its cursor in virtual desktop coordinates. When only
* part of that desktop is on show, shift into the coordinates of the
* presented view. Both offsets are zero unless a single display of a
* multi-display guest has been selected. */
const struct DoublePoint point =
{
.x = g_cursor.guest.x + g_cursor.guest.hx,
.y = g_cursor.guest.y + g_cursor.guest.hy
.x = g_cursor.guest.x + g_cursor.guest.hx - g_state.viewX,
.y = g_cursor.guest.y + g_cursor.guest.hy - g_state.viewY
};
switch((g_state.rotate + g_params.winRotate) % LG_ROTATE_MAX)
@@ -190,6 +194,11 @@ void util_localCurToGuest(struct DoublePoint *guest)
default:
DEBUG_UNREACHABLE();
}
/* the guest addresses its cursor across the whole virtual desktop, so undo
* the shift applied when only part of that desktop is presented */
guest->x += g_state.viewX;
guest->y += g_state.viewY;
}
void util_rotatePoint(struct DoublePoint *point)