From 294bdab77f8fb6c2b29917f5318ffe4ec2bc2ab6 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Tue, 12 Jul 2016 21:27:23 +0200 Subject: [PATCH] fix(x11grab): try and use the current display Don't hard-code ":0" as the display and try and use the DISPLAY environment variable instead. This fixes screen grabbing under X11 when the user is not on screen 0. Fix #3500. --- src/video/cameradevice.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/video/cameradevice.cpp b/src/video/cameradevice.cpp index 6a9c2c92c..6a97d3fe9 100644 --- a/src/video/cameradevice.cpp +++ b/src/video/cameradevice.cpp @@ -317,7 +317,17 @@ QVector> CameraDevice::getDeviceList() if (idesktopFormat) { if (idesktopFormat->name == QString("x11grab")) - devices.push_back(QPair{"x11grab#:0", QObject::tr("Desktop", "Desktop as a camera input for screen sharing")}); + { + QString dev = "x11grab#"; + QByteArray display = qgetenv("DISPLAY"); + + if (display.isNull()) + dev += ":0"; + else + dev += display.constData(); + + devices.push_back(QPair{dev, QObject::tr("Desktop", "Desktop as a camera input for screen sharing")}); + } if (idesktopFormat->name == QString("gdigrab")) devices.push_back(QPair{"gdigrab#desktop", QObject::tr("Desktop", "Desktop as a camera input for screen sharing")}); }