diff --git a/abstract_backend.h b/abstract_backend.h index 13db34134d..1d1d73a94a 100644 --- a/abstract_backend.h +++ b/abstract_backend.h @@ -79,6 +79,7 @@ public: Q_SIGNALS: void screensQueried(); + void initFailed(); void cursorChanged(); void readyChanged(bool); diff --git a/backends/wayland/wayland_backend.cpp b/backends/wayland/wayland_backend.cpp index 252dcf1094..87d72f2c63 100644 --- a/backends/wayland/wayland_backend.cpp +++ b/backends/wayland/wayland_backend.cpp @@ -368,6 +368,7 @@ WaylandBackend::WaylandBackend(const QByteArray &display, QObject *parent) , m_displayName(display) { connect(this, &WaylandBackend::outputsChanged, this, &WaylandBackend::screensQueried); + connect(this, &WaylandBackend::connectionFailed, this, &WaylandBackend::initFailed); } WaylandBackend::~WaylandBackend() diff --git a/backends/x11/x11windowed_backend.cpp b/backends/x11/x11windowed_backend.cpp index 334ba7503e..e3f853d9b7 100644 --- a/backends/x11/x11windowed_backend.cpp +++ b/backends/x11/x11windowed_backend.cpp @@ -100,6 +100,8 @@ void X11WindowedBackend::init() waylandServer()->seat()->setHasPointer(true); waylandServer()->seat()->setHasKeyboard(true); emit screensQueried(); + } else { + emit initFailed(); } } diff --git a/backends/x11/x11windowed_backend.h b/backends/x11/x11windowed_backend.h index dc47299e59..900b34b57f 100644 --- a/backends/x11/x11windowed_backend.h +++ b/backends/x11/x11windowed_backend.h @@ -57,10 +57,6 @@ public: } xcb_window_t rootWindow() const; - bool isValid() const { - return m_connection != nullptr && m_window != XCB_WINDOW_NONE; - } - QSize size() const { return m_size; } diff --git a/main_wayland.cpp b/main_wayland.cpp index 51cb0bf676..4fdbca6313 100644 --- a/main_wayland.cpp +++ b/main_wayland.cpp @@ -102,12 +102,6 @@ void ApplicationWayland::createBackend() if (m_windowed) { if (!m_waylandDisplay.isEmpty()) { Wayland::WaylandBackend *b = new Wayland::WaylandBackend(m_waylandDisplay, this); - connect(b, &Wayland::WaylandBackend::connectionFailed, this, - [] () { - fputs(i18n("kwin_wayland: could not connect to Wayland Server, ensure WAYLAND_DISPLAY is set.\n").toLocal8Bit().constData(), stderr); - ::exit(1); - } - ); backend = b; } if (!backend && !m_x11Display.isEmpty()) { @@ -129,6 +123,12 @@ void ApplicationWayland::createBackend() if (backend) { connect(backend, &AbstractBackend::screensQueried, this, &ApplicationWayland::continueStartupWithScreens); + connect(backend, &AbstractBackend::initFailed, this, + [] () { + std::cerr << "FATAL ERROR: backend failed to initialize, exiting now" << std::endl; + ::exit(1); + } + ); backend->init(); } else { std::cerr << "FATAL ERROR: could not create a backend, exiting now" << std::endl;