diff --git a/abstract_backend.h b/abstract_backend.h index 8f531cea20..5dfc5d8894 100644 --- a/abstract_backend.h +++ b/abstract_backend.h @@ -64,6 +64,9 @@ public: void setInitialWindowSize(const QSize &size) { m_initialWindowSize = size; } + void setDeviceIdentifier(const QByteArray &identifier) { + m_deviceIdentifier = identifier; + } void pointerMotion(const QPointF &position, quint32 time); void pointerButtonPressed(quint32 button, quint32 time); @@ -99,6 +102,9 @@ protected: QSize initialWindowSize() const { return m_initialWindowSize; } + QByteArray deviceIdentifier() const { + return m_deviceIdentifier; + } private Q_SLOTS: void installThemeCursor(quint32 id, const QPoint &hotspot); @@ -115,6 +121,7 @@ private: bool m_handlesOutputs = false; bool m_ready = false; QSize m_initialWindowSize; + QByteArray m_deviceIdentifier; }; } diff --git a/backends/fbdev/fb_backend.cpp b/backends/fbdev/fb_backend.cpp index d6426aa49c..e6f2b58676 100644 --- a/backends/fbdev/fb_backend.cpp +++ b/backends/fbdev/fb_backend.cpp @@ -81,11 +81,11 @@ void FramebufferBackend::init() void FramebufferBackend::openFrameBuffer() { VirtualTerminal::self()->init(); - int fd = LogindIntegration::self()->takeDevice(m_device.toUtf8().constData()); + int fd = LogindIntegration::self()->takeDevice(deviceIdentifier().constData()); if (fd < 0) { qCWarning(KWIN_FB) << "Failed to open frame buffer device through logind, trying without"; } - fd = open(m_device.toUtf8().constData(), O_RDWR | O_CLOEXEC); + fd = open(deviceIdentifier().constData(), O_RDWR | O_CLOEXEC); if (fd < 0) { qCWarning(KWIN_FB) << "failed to open frame buffer device"; return; diff --git a/backends/fbdev/fb_backend.h b/backends/fbdev/fb_backend.h index 81620dd81e..1a6e39c897 100644 --- a/backends/fbdev/fb_backend.h +++ b/backends/fbdev/fb_backend.h @@ -38,9 +38,6 @@ public: QPainterBackend *createQPainterBackend() override; void init() override; - void setDevice(const QString &device) { - m_device = device; - } bool isValid() const { return m_fd >= 0; @@ -72,7 +69,6 @@ public: private: void openFrameBuffer(); bool queryScreenInfo(); - QString m_device = QStringLiteral("/dev/fb0"); QSize m_resolution; QSize m_physicalSize; QByteArray m_id; diff --git a/backends/wayland/wayland_backend.cpp b/backends/wayland/wayland_backend.cpp index 87d72f2c63..264384857e 100644 --- a/backends/wayland/wayland_backend.cpp +++ b/backends/wayland/wayland_backend.cpp @@ -349,7 +349,7 @@ void WaylandCursor::setCursorImage(Qt::CursorShape shape) #endif } -WaylandBackend::WaylandBackend(const QByteArray &display, QObject *parent) +WaylandBackend::WaylandBackend(QObject *parent) : AbstractBackend(parent) , m_display(nullptr) , m_eventQueue(new EventQueue(this)) @@ -365,7 +365,6 @@ WaylandBackend::WaylandBackend(const QByteArray &display, QObject *parent) , m_fullscreenShell(new FullscreenShell(this)) , m_subCompositor(new SubCompositor(this)) , m_cursor(nullptr) - , m_displayName(display) { connect(this, &WaylandBackend::outputsChanged, this, &WaylandBackend::screensQueried); connect(this, &WaylandBackend::connectionFailed, this, &WaylandBackend::initFailed); @@ -440,7 +439,7 @@ void WaylandBackend::init() } ); connect(m_registry, &Registry::interfacesAnnounced, this, &WaylandBackend::createSurface); - m_connectionThreadObject->setSocketName(m_displayName); + m_connectionThreadObject->setSocketName(deviceIdentifier()); initConnection(); } diff --git a/backends/wayland/wayland_backend.h b/backends/wayland/wayland_backend.h index a083cb80d2..fa176d0b62 100644 --- a/backends/wayland/wayland_backend.h +++ b/backends/wayland/wayland_backend.h @@ -133,7 +133,7 @@ class KWIN_EXPORT WaylandBackend : public AbstractBackend { Q_OBJECT public: - explicit WaylandBackend(const QByteArray &display, QObject *parent = nullptr); + explicit WaylandBackend(QObject *parent = nullptr); virtual ~WaylandBackend(); void init() override; wl_display *display(); @@ -176,7 +176,6 @@ private: KWayland::Client::FullscreenShell *m_fullscreenShell; KWayland::Client::SubCompositor *m_subCompositor; WaylandCursor *m_cursor; - QByteArray m_displayName; }; inline diff --git a/backends/x11/x11windowed_backend.cpp b/backends/x11/x11windowed_backend.cpp index 029ffb511f..8690258aaa 100644 --- a/backends/x11/x11windowed_backend.cpp +++ b/backends/x11/x11windowed_backend.cpp @@ -45,9 +45,8 @@ along with this program. If not, see . namespace KWin { -X11WindowedBackend::X11WindowedBackend(const QByteArray &display, QObject *parent) +X11WindowedBackend::X11WindowedBackend(QObject *parent) : AbstractBackend(parent) - , m_displayName(display) { } @@ -70,14 +69,14 @@ void X11WindowedBackend::init() int screen = 0; xcb_connection_t *c = nullptr; #if HAVE_X11_XCB - Display *xDisplay = XOpenDisplay(m_displayName.constData()); + Display *xDisplay = XOpenDisplay(deviceIdentifier().constData()); if (xDisplay) { c = XGetXCBConnection(xDisplay); XSetEventQueueOwner(xDisplay, XCBOwnsEventQueue); screen = XDefaultScreen(xDisplay); } #else - c = xcb_connect(m_displayName.constData(), &screen); + c = xcb_connect(deviceIdentifier().constData(), &screen); #endif if (c && !xcb_connection_has_error(c)) { m_connection = c; diff --git a/backends/x11/x11windowed_backend.h b/backends/x11/x11windowed_backend.h index 87491435f0..6bb1153b4f 100644 --- a/backends/x11/x11windowed_backend.h +++ b/backends/x11/x11windowed_backend.h @@ -39,7 +39,7 @@ class KWIN_EXPORT X11WindowedBackend : public AbstractBackend Q_OBJECT Q_PROPERTY(QSize size READ size NOTIFY sizeChanged) public: - X11WindowedBackend(const QByteArray &display, QObject *parent); + X11WindowedBackend(QObject *parent); virtual ~X11WindowedBackend(); void init() override; @@ -79,7 +79,6 @@ private: void handleExpose(xcb_expose_event_t *event); void updateSize(xcb_configure_notify_event_t *event); - QByteArray m_displayName; xcb_connection_t *m_connection = nullptr; xcb_screen_t *m_screen = nullptr; int m_screenNumber = 0; diff --git a/main_wayland.cpp b/main_wayland.cpp index f03366a50a..5580e251b6 100644 --- a/main_wayland.cpp +++ b/main_wayland.cpp @@ -101,11 +101,13 @@ void ApplicationWayland::createBackend() AbstractBackend *backend = nullptr; if (m_windowed) { if (!m_waylandDisplay.isEmpty()) { - Wayland::WaylandBackend *b = new Wayland::WaylandBackend(m_waylandDisplay, this); + Wayland::WaylandBackend *b = new Wayland::WaylandBackend(this); + b->setDeviceIdentifier(m_waylandDisplay); backend = b; } if (!backend && !m_x11Display.isEmpty()) { - KWin::X11WindowedBackend *x11Backend = new KWin::X11WindowedBackend(m_x11Display, this); + KWin::X11WindowedBackend *x11Backend = new KWin::X11WindowedBackend(this); + x11Backend->setDeviceIdentifier(m_x11Display); backend = x11Backend; } } @@ -117,7 +119,7 @@ void ApplicationWayland::createBackend() #endif if (!m_framebuffer.isEmpty()) { FramebufferBackend *b = new FramebufferBackend(this); - b->setDevice(m_framebuffer); + b->setDeviceIdentifier(m_framebuffer.toUtf8()); backend = b; }