[platforms/wayland] Use XdgShell if available and prefer it
Summary: With this change the Wayland platform plugin uses the XdgShell to create the window if available. This allows to close the window and thus quit the nested kwin_wayland properly. Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D2201
This commit is contained in:
parent
f27dceda2c
commit
bec69b5705
2 changed files with 45 additions and 4 deletions
|
@ -45,6 +45,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <KWayland/Client/shm_pool.h>
|
||||
#include <KWayland/Client/surface.h>
|
||||
#include <KWayland/Client/touch.h>
|
||||
#include <KWayland/Client/xdgshell.h>
|
||||
#include <KWayland/Server/buffer_interface.h>
|
||||
#include <KWayland/Server/seat_interface.h>
|
||||
#include <KWayland/Server/surface_interface.h>
|
||||
|
@ -281,12 +282,18 @@ WaylandBackend::WaylandBackend(QObject *parent)
|
|||
|
||||
WaylandBackend::~WaylandBackend()
|
||||
{
|
||||
if (m_xdgShellSurface) {
|
||||
m_xdgShellSurface->release();
|
||||
}
|
||||
if (m_shellSurface) {
|
||||
m_shellSurface->release();
|
||||
}
|
||||
if (m_surface) {
|
||||
m_surface->release();
|
||||
}
|
||||
if (m_xdgShell) {
|
||||
m_xdgShell->release();
|
||||
}
|
||||
m_shell->release();
|
||||
m_compositor->release();
|
||||
m_registry->release();
|
||||
|
@ -361,6 +368,11 @@ void WaylandBackend::initConnection()
|
|||
emit systemCompositorDied();
|
||||
m_seat.reset();
|
||||
m_shm->destroy();
|
||||
if (m_xdgShellSurface) {
|
||||
m_xdgShellSurface->destroy();
|
||||
delete m_xdgShellSurface;
|
||||
m_xdgShellSurface = nullptr;
|
||||
}
|
||||
if (m_shellSurface) {
|
||||
m_shellSurface->destroy();
|
||||
delete m_shellSurface;
|
||||
|
@ -374,6 +386,9 @@ void WaylandBackend::initConnection()
|
|||
if (m_shell) {
|
||||
m_shell->destroy();
|
||||
}
|
||||
if (m_xdgShell) {
|
||||
m_xdgShell->destroy();
|
||||
}
|
||||
m_compositor->destroy();
|
||||
m_registry->destroy();
|
||||
m_eventQueue->destroy();
|
||||
|
@ -414,21 +429,41 @@ void WaylandBackend::createSurface()
|
|||
if (m_seat) {
|
||||
m_seat->setInstallCursor(true);
|
||||
}
|
||||
// check for xdg shell
|
||||
auto xdgIface = m_registry->interface(Registry::Interface::XdgShellUnstableV5);
|
||||
if (xdgIface.name != 0) {
|
||||
m_xdgShell = m_registry->createXdgShell(xdgIface.name, xdgIface.version, this);
|
||||
if (m_xdgShell && m_xdgShell->isValid()) {
|
||||
m_xdgShellSurface = m_xdgShell->createSurface(m_surface, this);
|
||||
connect(m_xdgShellSurface, &XdgShellSurface::closeRequested, qApp, &QCoreApplication::quit);
|
||||
setupSurface(m_xdgShellSurface);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (m_shell->isValid()) {
|
||||
m_shellSurface = m_shell->createSurface(m_surface, this);
|
||||
connect(m_shellSurface, &ShellSurface::sizeChanged, this, &WaylandBackend::shellSurfaceSizeChanged);
|
||||
m_shellSurface->setSize(initialWindowSize());
|
||||
setupSurface(m_shellSurface);
|
||||
m_shellSurface->setToplevel();
|
||||
setReady(true);
|
||||
emit screensQueried();
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void WaylandBackend::setupSurface(T *surface)
|
||||
{
|
||||
connect(surface, &T::sizeChanged, this, &WaylandBackend::shellSurfaceSizeChanged);
|
||||
surface->setSize(initialWindowSize());
|
||||
setReady(true);
|
||||
emit screensQueried();
|
||||
}
|
||||
|
||||
QSize WaylandBackend::shellSurfaceSize() const
|
||||
{
|
||||
if (m_shellSurface) {
|
||||
return m_shellSurface->size();
|
||||
}
|
||||
if (m_xdgShellSurface) {
|
||||
return m_xdgShellSurface->size();
|
||||
}
|
||||
return QSize();
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,8 @@ class Shell;
|
|||
class ShellSurface;
|
||||
class Surface;
|
||||
class Touch;
|
||||
class XdgShell;
|
||||
class XdgShellSurface;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,6 +134,8 @@ Q_SIGNALS:
|
|||
private:
|
||||
void initConnection();
|
||||
void createSurface();
|
||||
template <class T>
|
||||
void setupSurface(T *surface);
|
||||
wl_display *m_display;
|
||||
KWayland::Client::EventQueue *m_eventQueue;
|
||||
KWayland::Client::Registry *m_registry;
|
||||
|
@ -139,6 +143,8 @@ private:
|
|||
KWayland::Client::Shell *m_shell;
|
||||
KWayland::Client::Surface *m_surface;
|
||||
KWayland::Client::ShellSurface *m_shellSurface;
|
||||
KWayland::Client::XdgShell *m_xdgShell = nullptr;
|
||||
KWayland::Client::XdgShellSurface *m_xdgShellSurface = nullptr;
|
||||
QScopedPointer<WaylandSeat> m_seat;
|
||||
KWayland::Client::ShmPool *m_shm;
|
||||
KWayland::Client::ConnectionThread *m_connectionThreadObject;
|
||||
|
|
Loading…
Reference in a new issue