[wayland] Introduce a deviceIdentifier in AbstractBackend
To be used by the concrete backends for e.g. framebuffer device name, DISPLAY or WAYLAND_DISPLAY variable.
This commit is contained in:
parent
d45cf6ee8d
commit
33fb763e37
8 changed files with 21 additions and 20 deletions
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -45,9 +45,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue