Index: libinput/connection.cpp =================================================================== --- libinput/connection.cpp +++ libinput/connection.cpp @@ -137,9 +137,8 @@ s_context = nullptr; return nullptr; } - // TODO: don't hardcode seat name - if (!s_context->assignSeat("seat0")) { - qCWarning(KWIN_LIBINPUT) << "Failed to assign seat seat0"; + if (!s_context->assignSeat(LogindIntegration::self()->seat())) { + qCWarning(KWIN_LIBINPUT) << "Failed to assign seat"; delete s_context; s_context = nullptr; return nullptr; Index: main_wayland.cpp =================================================================== --- main_wayland.cpp +++ main_wayland.cpp @@ -585,7 +585,6 @@ QCommandLineOption framebufferDeviceOption(QStringLiteral("fb-device"), i18n("The framebuffer device to render to."), QStringLiteral("fbdev")); - framebufferDeviceOption.setDefaultValue(QStringLiteral("/dev/fb0")); QCommandLineOption x11DisplayOption(QStringLiteral("x11-display"), i18n("The X11 Display to use in windowed mode on platform X11."), QStringLiteral("display")); Index: plugins/platforms/fbdev/fb_backend.h =================================================================== --- plugins/platforms/fbdev/fb_backend.h +++ plugins/platforms/fbdev/fb_backend.h @@ -27,6 +27,8 @@ namespace KWin { +class Udev; + class KWIN_EXPORT FramebufferBackend : public Platform { Q_OBJECT @@ -89,6 +91,7 @@ QSize m_resolution; QSize m_physicalSize; QByteArray m_id; + QScopedPointer m_udev; struct Color { quint32 offset; quint32 length; Index: plugins/platforms/fbdev/fb_backend.cpp =================================================================== --- plugins/platforms/fbdev/fb_backend.cpp +++ plugins/platforms/fbdev/fb_backend.cpp @@ -24,6 +24,7 @@ #include "scene_qpainter_fb_backend.h" #include "screens.h" #include "virtual_terminal.h" +#include "udev.h" // system #include #include @@ -37,6 +38,7 @@ FramebufferBackend::FramebufferBackend(QObject *parent) : Platform(parent) + , m_udev(new Udev) { } @@ -80,12 +82,20 @@ void FramebufferBackend::openFrameBuffer() { - VirtualTerminal::self()->init(); - int fd = LogindIntegration::self()->takeDevice(deviceIdentifier().constData()); + if (strcmp(LogindIntegration::self()->seat(), "seat0") == 0) + { + VirtualTerminal::self()->init(); + } + char *framebufferDevice = strdup(deviceIdentifier().constData()); + UdevDevice::Ptr device = m_udev->primaryFramebuffer(); + if (strcmp(framebufferDevice,"\0") == 0) + framebufferDevice = strdup(device->devNode()); + int fd = LogindIntegration::self()->takeDevice(framebufferDevice); + qCDebug(KWIN_FB) << "Using frame buffer device:" << framebufferDevice; if (fd < 0) { qCWarning(KWIN_FB) << "Failed to open frame buffer device through logind, trying without"; } - fd = open(deviceIdentifier().constData(), O_RDWR | O_CLOEXEC); + fd = open(framebufferDevice, O_RDWR | O_CLOEXEC); if (fd < 0) { qCWarning(KWIN_FB) << "failed to open frame buffer device"; emit initFailed(); Index: udev.h =================================================================== --- udev.h +++ udev.h @@ -82,6 +82,7 @@ return m_udev != nullptr; } UdevDevice::Ptr primaryGpu(); + UdevDevice::Ptr primaryFramebuffer(); UdevDevice::Ptr virtualGpu(); UdevDevice::Ptr renderNode(); UdevDevice::Ptr deviceFromSyspath(const char *syspath); Index: udev.cpp =================================================================== --- udev.cpp +++ udev.cpp @@ -18,6 +18,7 @@ along with this program. If not, see . *********************************************************************/ #include "udev.h" +#include "logind.h" // Qt #include #include @@ -106,6 +107,7 @@ if (m_enumerate.isNull()) { return UdevDevice::Ptr(); } + const char defaultSeat[] = "seat0"; udev_list_entry *it = udev_enumerate_get_list_entry(m_enumerate.data()); UdevDevice::Ptr firstFound; while (it) { @@ -115,6 +117,13 @@ if (!device) { continue; } + const char *deviceSeat = device->property("ID_SEAT"); + if (!deviceSeat) { + deviceSeat = defaultSeat; + } + if (qstrcmp(deviceSeat, LogindIntegration::self()->seat())) { + continue; + } if (test(device)) { return device; } @@ -135,7 +144,6 @@ enumerate.addMatch(UdevEnumerate::Match::SysName, "card[0-9]*"); enumerate.scan(); return enumerate.find([](const UdevDevice::Ptr &device) { - // TODO: check seat auto pci = device->getParentWithSubsystemDevType("pci"); if (!pci) { return false; @@ -178,6 +186,28 @@ }); } +UdevDevice::Ptr Udev::primaryFramebuffer() +{ + if (!m_udev) { + return UdevDevice::Ptr(); + } + UdevEnumerate enumerate(this); + enumerate.addMatch(UdevEnumerate::Match::SubSystem, "graphics"); + enumerate.addMatch(UdevEnumerate::Match::SysName, "fb[0-9]*"); + enumerate.scan(); + return enumerate.find([](const UdevDevice::Ptr &device) { + auto pci = device->getParentWithSubsystemDevType("pci"); + if (!pci) { + return false; + } + const char *systAttrValue = udev_device_get_sysattr_value(pci, "boot_vga"); + if (systAttrValue && qstrcmp(systAttrValue, "1") == 0) { + return true; + } + return false; + }); +} + UdevDevice::Ptr Udev::deviceFromSyspath(const char *syspath) { return UdevDevice::Ptr(new UdevDevice(udev_device_new_from_syspath(m_udev, syspath)));