From ee181ef7a59d42d6b7a6527f2a48e09f85546e73 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Fri, 9 Apr 2021 16:44:44 +0200 Subject: [PATCH] layershell: Support virtual keyboards Resize layershell-based clients to adapt to the keyboard when it appears. --- src/layershellv1client.cpp | 10 ++++++++++ src/layershellv1client.h | 1 + src/layershellv1integration.cpp | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/src/layershellv1client.cpp b/src/layershellv1client.cpp index a0ceba9753..a774d23b55 100644 --- a/src/layershellv1client.cpp +++ b/src/layershellv1client.cpp @@ -272,4 +272,14 @@ void LayerShellV1Client::handleOutputDestroyed() destroyClient(); } +void LayerShellV1Client::setVirtualKeyboardGeometry(const QRect &geo) +{ + if (m_virtualKeyboardGeometry == geo) { + return; + } + + m_virtualKeyboardGeometry = geo; + scheduleRearrange(); +} + } // namespace KWin diff --git a/src/layershellv1client.h b/src/layershellv1client.h index dfb6ce046c..119ccb5fae 100644 --- a/src/layershellv1client.h +++ b/src/layershellv1client.h @@ -43,6 +43,7 @@ public: bool hasStrut() const override; void destroyClient() override; void closeWindow() override; + void setVirtualKeyboardGeometry(const QRect &geo) override; protected: Layer belongsToLayer() const override; diff --git a/src/layershellv1integration.cpp b/src/layershellv1integration.cpp index a55f961e07..187d431067 100644 --- a/src/layershellv1integration.cpp +++ b/src/layershellv1integration.cpp @@ -148,6 +148,11 @@ static void rearrangeLayer(const QList &clients, QRect *wo geometry.translate(0, -shellSurface->bottomMargin()); } + // Move the window's bottom if its virtual keyboard is overlapping it + if (shellSurface->exclusiveZone() >= 0 && !client->virtualKeyboardGeometry().isEmpty() && geometry.bottom() > client->virtualKeyboardGeometry().top()) { + geometry.setBottom(client->virtualKeyboardGeometry().top()); + } + if (geometry.isValid()) { client->setFrameGeometry(geometry); } else {