From 384e110513f7afa199a9bddd0d2ad5fc1703c215 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Wed, 23 Mar 2022 13:14:43 +0100 Subject: [PATCH] Support using LayerShellQt for the input panel inputpanel-shell is rather limited and doesn't support things like proper placement and sizing. Fortunately, layer-shell can be used instead to get support for these. This adds support for using layer-shell, prefering it over inputpanel-shell. We only need to set some properties from the Maliit side, most of the actual magic is taken care of by the compositor. Most importantly, this makes it possible for the compositor to ensure Maliit does not overlap panels while at the same time ensuring nothing ends up out of the screen. --- CMakeLists.txt | 4 ++++ src/keyboard/keyboard.cpp | 4 ++-- src/plugin/inputmethod_p.h | 10 ++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 869458b1..34846f3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,8 @@ find_package(Qt5Multimedia) find_package(Qt5Feedback) find_package(Intl REQUIRED) +find_package(LayerShellQt REQUIRED) + find_package(AnthyUnicode) find_package(Anthy) find_package(Pinyin) @@ -180,6 +182,8 @@ endif() target_compile_definitions(maliit-keyboard-common PRIVATE ${maliit-keyboard-definitions}) target_compile_features(maliit-keyboard-common PRIVATE cxx_std_17) +target_link_libraries(maliit-keyboard-common LayerShellQt::Interface) + set(MALIIT_KEYBOARD_PLUGIN_SOURCES src/plugin/plugin.cpp src/plugin/plugin.h diff --git a/src/keyboard/keyboard.cpp b/src/keyboard/keyboard.cpp index ffd1dcb7..e12779d0 100644 --- a/src/keyboard/keyboard.cpp +++ b/src/keyboard/keyboard.cpp @@ -30,7 +30,7 @@ int main(int argc, char **argv) { setenv("QT_IM_MODULE", "none", true); - setenv("QT_WAYLAND_SHELL_INTEGRATION", "inputpanel-shell", true); + setenv("QT_WAYLAND_SHELL_INTEGRATION", "layer-shell;inputpanel-shell", true); QGuiApplication app(argc, argv); @@ -38,4 +38,4 @@ int main(int argc, char **argv) { Maliit::StandaloneInputMethod inputMethod(&plugin); return app.exec(); -} \ No newline at end of file +} diff --git a/src/plugin/inputmethod_p.h b/src/plugin/inputmethod_p.h index bee9e979..78374d34 100644 --- a/src/plugin/inputmethod_p.h +++ b/src/plugin/inputmethod_p.h @@ -14,6 +14,8 @@ * along with this program. If not, see . */ +#pragma once + #include "inputmethod.h" #include "coreutils.h" @@ -34,6 +36,8 @@ #include #include +#include + #include #include #include @@ -58,6 +62,12 @@ QQuickView *createWindow(MAbstractInputMethodHost *host) { QScopedPointer view(new QQuickView); + LayerShellQt::Window *layerShell = LayerShellQt::Window::get(view.get()); + layerShell->setLayer(LayerShellQt::Window::LayerTop); + layerShell->setAnchors(LayerShellQt::Window::AnchorBottom); + layerShell->setKeyboardInteractivity(LayerShellQt::Window::KeyboardInteractivityOnDemand); + layerShell->setScope(QStringLiteral("input-panel")); + QSurfaceFormat format; format.setAlphaBufferSize(8); view->setFormat(format);