fb_backend: use new udev function to detect framebuffer devices, if one is not set

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: rkflx, graesslin, anthonyfieroni, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D9556
This commit is contained in:
Nerdopolis Turfwalker 2018-04-22 17:51:09 +02:00 committed by Martin Flöser
parent 3c745bb571
commit 8321453fde

View file

@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "scene_qpainter_fb_backend.h" #include "scene_qpainter_fb_backend.h"
#include "screens.h" #include "screens.h"
#include "virtual_terminal.h" #include "virtual_terminal.h"
#include "udev.h"
// system // system
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
@ -81,13 +82,18 @@ void FramebufferBackend::init()
void FramebufferBackend::openFrameBuffer() void FramebufferBackend::openFrameBuffer()
{ {
VirtualTerminal::self()->init(); VirtualTerminal::self()->init();
int fd = LogindIntegration::self()->takeDevice(deviceIdentifier().constData()); QString framebufferDevice = deviceIdentifier().constData();
if (fd < 0) { if (framebufferDevice.isEmpty()) {
qCWarning(KWIN_FB) << "Failed to open frame buffer device through logind, trying without"; framebufferDevice = QString(Udev().primaryFramebuffer()->devNode());
} }
fd = open(deviceIdentifier().constData(), O_RDWR | O_CLOEXEC); int fd = LogindIntegration::self()->takeDevice(framebufferDevice.toUtf8().constData());
qCDebug(KWIN_FB) << "Using frame buffer device:" << framebufferDevice;
if (fd < 0) { if (fd < 0) {
qCWarning(KWIN_FB) << "failed to open frame buffer device"; qCWarning(KWIN_FB) << "Failed to open frame buffer device:" << framebufferDevice << "through logind, trying without";
}
fd = open(framebufferDevice.toUtf8().constData(), O_RDWR | O_CLOEXEC);
if (fd < 0) {
qCWarning(KWIN_FB) << "failed to open frame buffer device:" << framebufferDevice;
emit initFailed(); emit initFailed();
return; return;
} }