Skip to content

Commit

Permalink
Create a wayland input panel shell integration
Browse files Browse the repository at this point in the history
Move all the wayland input panel code there. Allows to start
QT_WAYLAND_SHELL_INTEGRATION=inputpanel-shell maliit-keyboard to get it
started as input panel instead of previous hacks.
  • Loading branch information
jpetersen committed May 24, 2017
1 parent d615a46 commit 06367f1
Show file tree
Hide file tree
Showing 8 changed files with 246 additions and 174 deletions.
19 changes: 19 additions & 0 deletions CMakeLists.txt
Expand Up @@ -46,6 +46,7 @@ if(enable-wayland)
find_package(WaylandProtocols REQUIRED PRIVATE)
find_package(QtWaylandScanner REQUIRED)
find_package(Wayland REQUIRED)
find_package(Qt5WaylandClient REQUIRED PRIVATE)
endif()

include_directories(src common)
Expand Down Expand Up @@ -291,6 +292,19 @@ if(enable-qt5-inputcontext)
target_link_libraries(maliitplatforminputcontextplugin maliit-connection Qt5::Quick)
endif()

if(enable-wayland)
set(INPUT_PANEL_SHELL_SOURCES
src/qt/plugins/shellintegration/inputpanelshellplugin.cpp
src/qt/plugins/shellintegration/qwaylandinputpanelshellintegration.cpp
src/qt/plugins/shellintegration/qwaylandinputpanelshellintegration.h src/qt/plugins/shellintegration/qwaylandinputpanelsurface.cpp src/qt/plugins/shellintegration/qwaylandinputpanelsurface.h)

ecm_add_qtwayland_client_protocol(INPUT_PANEL_SHELL_SOURCES PROTOCOL ${WAYLANDPROTOCOLS_PATH}/unstable/input-method/input-method-unstable-v1.xml BASENAME input-method-unstable-v1)

add_library(inputpanel-shell MODULE ${INPUT_PANEL_SHELL_SOURCES})
target_link_libraries(inputpanel-shell Qt5::WaylandClient)
target_include_directories(inputpanel-shell PRIVATE ${Qt5WaylandClient_PRIVATE_INCLUDE_DIRS})
endif()

add_executable(maliit-exampleapp-plainqt
examples/apps/plainqt/mainwindow.cpp
examples/apps/plainqt/mainwindow.h
Expand Down Expand Up @@ -410,6 +424,11 @@ if(enable-qt5-inputcontext)
install(TARGETS maliitplatforminputcontextplugin LIBRARY DESTINATION ${QT5_PLUGINS_INSTALL_DIR}/platforminputcontext)
endif()

if(enable-wayland)
install(TARGETS inputpanel-shell
LIBRARY DESTINATION ${QT5_PLUGINS_INSTALL_DIR}/wayland-shell-integration)
endif()

if(enable-dbus-activation)
configure_file(connection/org.maliit.server.service.in org.maliit.server.service @ONLY)

Expand Down
3 changes: 3 additions & 0 deletions src/qt/plugins/shellintegration/inputpanelshell.json
@@ -0,0 +1,3 @@
{
"Keys":[ "inputpanel-shell" ]
}
40 changes: 40 additions & 0 deletions src/qt/plugins/shellintegration/inputpanelshellplugin.cpp
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2017 Jan Arne Petersen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* and appearing in the file LICENSE.LGPL included in the packaging
* of this file.
*/

#include <QtWaylandClient/private/qwaylandshellintegrationplugin_p.h>

#include "qwaylandinputpanelshellintegration.h"

QT_BEGIN_NAMESPACE

namespace QtWaylandClient
{

class QWaylandInputPanelShellIntegrationPlugin: public QWaylandShellIntegrationPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QWaylandShellIntegrationFactoryInterface_iid FILE "inputpanelshell.json")

public:
virtual QWaylandShellIntegration *create(const QString &key, const QStringList &paramList) override;
};

QWaylandShellIntegration *QWaylandInputPanelShellIntegrationPlugin::create(const QString &key, const QStringList &paramList)
{
Q_UNUSED(key);
Q_UNUSED(paramList);
return new QWaylandInputPanelShellIntegration();
}

}

QT_END_NAMESPACE

#include "inputpanelshellplugin.moc"
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2017 Jan Arne Petersen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* and appearing in the file LICENSE.LGPL included in the packaging
* of this file.
*/

#include "qwaylandinputpanelshellintegration.h"

#include <QtWaylandClient/private/qwaylandwindow_p.h>

#include "qwaylandinputpanelsurface.h"

QT_BEGIN_NAMESPACE

namespace QtWaylandClient
{

QWaylandInputPanelShellIntegration::QWaylandInputPanelShellIntegration()
: QWaylandShellIntegration()
{
}

QWaylandInputPanelShellIntegration::~QWaylandInputPanelShellIntegration()
{
}

bool QWaylandInputPanelShellIntegration::initialize(QWaylandDisplay *display)
{
auto result = QWaylandShellIntegration::initialize(display);
const auto globals = display->globals();
for (auto global: globals) {
if (global.interface == QLatin1String("zwp_input_panel_v1")) {
m_panel.reset(new QtWayland::zwp_input_panel_v1(display->wl_registry(), global.id, 1));
break;
}
}
return result;
}

QWaylandShellSurface *
QWaylandInputPanelShellIntegration::createShellSurface(QWaylandWindow *window)
{
struct zwp_input_panel_surface_v1 *ip_surface = m_panel->get_input_panel_surface(window->object());

return new QWaylandInputPanelSurface(ip_surface, window);
}

}

QT_END_NAMESPACE
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2017 Jan Arne Petersen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* and appearing in the file LICENSE.LGPL included in the packaging
* of this file.
*/

#ifndef QWAYLANDINPUTPANELSHELLINTEGRATION_H
#define QWAYLANDINPUTPANELSHELLINTEGRATION_H

#include <QtWaylandClient/private/qwaylandshellintegration_p.h>

#include "qwayland-input-method-unstable-v1.h"

QT_BEGIN_NAMESPACE

namespace QtWaylandClient
{

class QWaylandInputPanelShellIntegration: public QWaylandShellIntegration
{
public:
QWaylandInputPanelShellIntegration();
~QWaylandInputPanelShellIntegration() override;

bool initialize(QWaylandDisplay *display) override;
QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override;

private:
QScopedPointer<QtWayland::zwp_input_panel_v1> m_panel;
};

}

QT_END_NAMESPACE

#endif //QWAYLANDINPUTPANELSHELLINTEGRATION_H
46 changes: 46 additions & 0 deletions src/qt/plugins/shellintegration/qwaylandinputpanelsurface.cpp
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2017 Jan Arne Petersen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* and appearing in the file LICENSE.LGPL included in the packaging
* of this file.
*/

#include "qwaylandinputpanelsurface.h"

#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <QtWaylandClient/private/qwaylandscreen_p.h>

QT_BEGIN_NAMESPACE

Q_LOGGING_CATEGORY(qLcQpaShellIntegration, "qt.qpa.wayland.shell")

namespace QtWaylandClient
{

QWaylandInputPanelSurface::QWaylandInputPanelSurface(struct ::zwp_input_panel_surface_v1 *object,
QWaylandWindow *window)
: QWaylandShellSurface(window)
, QtWayland::zwp_input_panel_surface_v1(object)
{
qCDebug(qLcQpaShellIntegration) << Q_FUNC_INFO;
}

QWaylandInputPanelSurface::~QWaylandInputPanelSurface()
{
qCDebug(qLcQpaShellIntegration) << Q_FUNC_INFO;
}

void QWaylandInputPanelSurface::setType(Qt::WindowType type, QWaylandWindow *transientParent)
{
Q_UNUSED(type)
Q_UNUSED(transientParent)

set_toplevel(window()->screen()->output(), position_center_bottom);
}

}

QT_END_NAMESPACE
39 changes: 39 additions & 0 deletions src/qt/plugins/shellintegration/qwaylandinputpanelsurface.h
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2017 Jan Arne Petersen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* and appearing in the file LICENSE.LGPL included in the packaging
* of this file.
*/

#ifndef QWAYLANDINPUTPANELSURFACE_H
#define QWAYLANDINPUTPANELSURFACE_H

#include "qwayland-input-method-unstable-v1.h"

#include <QtCore/QLoggingCategory>
#include <QtWaylandClient/private/qwaylandshellsurface_p.h>

QT_BEGIN_NAMESPACE

Q_DECLARE_LOGGING_CATEGORY(qLcQpaShellIntegration)

namespace QtWaylandClient
{

class QWaylandInputPanelSurface : public QWaylandShellSurface, public QtWayland::zwp_input_panel_surface_v1
{
public:
QWaylandInputPanelSurface(struct ::zwp_input_panel_surface_v1 *object, QWaylandWindow *window);
~QWaylandInputPanelSurface() override;

void setType(Qt::WindowType type, QWaylandWindow *transientParent) override;
};

}

QT_END_NAMESPACE

#endif //QWAYLANDINPUTPANELSURFACE_H

0 comments on commit 06367f1

Please sign in to comment.