2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2016-04-29 13:05:03 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
2016-04-29 13:05:03 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2018-08-29 18:02:16 +00:00
|
|
|
#ifndef KWIN_VIRTUAL_KEYBOARD_H
|
|
|
|
#define KWIN_VIRTUAL_KEYBOARD_H
|
2016-04-29 13:05:03 +00:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
#include <kwinglobals.h>
|
|
|
|
#include <kwin_export.h>
|
|
|
|
|
2021-02-26 15:16:45 +00:00
|
|
|
#include <QPointer>
|
2021-04-27 15:49:55 +00:00
|
|
|
#include <QTimer>
|
2020-10-07 04:46:46 +00:00
|
|
|
#include <KWaylandServer/textinput_v2_interface.h>
|
virtualkeyboard: resize the focused window to make room for the keyboard
Summary:
alternative approach: try to resize the winidow to make room for the keyboard.
the new input wayland protocol doesn't have anymore the overlap rectangle (and it would not be going to work with qwidget apps anyways)
in the future will probably be needed anextension to the input protocol v3 which partially gets back this, tough window resizing is needed regardless
what's missing: the resize should be "temporary" and the window should be restored to its previous geometry when the keyboard closes
Test Plan: tested with test QML code
Reviewers: #plasma, #kwin, bshah, graesslin, romangg, davidedmundson
Reviewed By: #plasma, #kwin, romangg, davidedmundson
Subscribers: nicolasfella, mart, kwin, davidedmundson, graesslin
Tags: #kwin
Maniphest Tasks: T9815
Differential Revision: https://phabricator.kde.org/D18818
2019-03-20 10:04:51 +00:00
|
|
|
|
2016-04-29 13:05:03 +00:00
|
|
|
class KStatusNotifierItem;
|
2021-04-27 15:49:55 +00:00
|
|
|
class QProcess;
|
2016-04-29 13:05:03 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2021-02-26 15:16:45 +00:00
|
|
|
class AbstractClient;
|
|
|
|
|
2020-09-29 14:46:32 +00:00
|
|
|
/**
|
|
|
|
* This class implements the zwp_input_method_unstable_v1, which is currently used to provide
|
|
|
|
* the Virtual Keyboard using supported input method client (maliit-keyboard e.g.)
|
|
|
|
**/
|
|
|
|
class KWIN_EXPORT InputMethod : public QObject
|
2016-04-29 13:05:03 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2020-09-29 14:46:32 +00:00
|
|
|
~InputMethod() override;
|
2016-04-29 13:05:03 +00:00
|
|
|
|
|
|
|
void init();
|
2021-02-26 15:16:45 +00:00
|
|
|
void setEnabled(bool enable);
|
|
|
|
bool isEnabled() const {
|
|
|
|
return m_enabled;
|
|
|
|
}
|
|
|
|
bool isActive() const {
|
|
|
|
return m_active;
|
|
|
|
}
|
|
|
|
void setActive(bool active);
|
2020-07-27 19:30:49 +00:00
|
|
|
void hide();
|
|
|
|
void show();
|
2016-04-29 13:05:03 +00:00
|
|
|
|
2021-04-27 15:49:55 +00:00
|
|
|
void setInputMethodCommand(const QString &path);
|
|
|
|
|
2017-10-06 19:22:50 +00:00
|
|
|
Q_SIGNALS:
|
2021-02-26 15:16:45 +00:00
|
|
|
void activeChanged(bool active);
|
2017-10-06 19:22:50 +00:00
|
|
|
void enabledChanged(bool enabled);
|
|
|
|
|
2020-09-18 03:17:15 +00:00
|
|
|
private Q_SLOTS:
|
|
|
|
void clientAdded(AbstractClient* client);
|
|
|
|
|
|
|
|
// textinput interface slots
|
2020-09-23 10:02:54 +00:00
|
|
|
void handleFocusedSurfaceChanged();
|
2020-09-18 03:17:15 +00:00
|
|
|
void surroundingTextChanged();
|
|
|
|
void contentTypeChanged();
|
2020-09-25 06:51:04 +00:00
|
|
|
void textInputInterfaceV2EnabledChanged();
|
|
|
|
void textInputInterfaceV3EnabledChanged();
|
2020-09-18 03:17:15 +00:00
|
|
|
void stateCommitted(uint32_t serial);
|
2020-10-07 04:46:46 +00:00
|
|
|
void textInputInterfaceV2StateUpdated(quint32 serial, KWaylandServer::TextInputV2Interface::UpdateReason reason);
|
2020-09-18 03:17:15 +00:00
|
|
|
|
2020-09-25 06:51:04 +00:00
|
|
|
// inputcontext slots
|
|
|
|
void setPreeditString(uint32_t serial, const QString &text, const QString &commit);
|
|
|
|
void setPreeditCursor(qint32 index);
|
|
|
|
|
2016-04-29 13:05:03 +00:00
|
|
|
private:
|
|
|
|
void updateSni();
|
virtualkeyboard: resize the focused window to make room for the keyboard
Summary:
alternative approach: try to resize the winidow to make room for the keyboard.
the new input wayland protocol doesn't have anymore the overlap rectangle (and it would not be going to work with qwidget apps anyways)
in the future will probably be needed anextension to the input protocol v3 which partially gets back this, tough window resizing is needed regardless
what's missing: the resize should be "temporary" and the window should be restored to its previous geometry when the keyboard closes
Test Plan: tested with test QML code
Reviewers: #plasma, #kwin, bshah, graesslin, romangg, davidedmundson
Reviewed By: #plasma, #kwin, romangg, davidedmundson
Subscribers: nicolasfella, mart, kwin, davidedmundson, graesslin
Tags: #kwin
Maniphest Tasks: T9815
Differential Revision: https://phabricator.kde.org/D18818
2019-03-20 10:04:51 +00:00
|
|
|
void updateInputPanelState();
|
2020-07-11 16:40:28 +00:00
|
|
|
void adoptInputMethodContext();
|
2021-03-10 02:12:57 +00:00
|
|
|
void commitString(qint32 serial, const QString &text);
|
|
|
|
void keysymReceived(quint32 serial, quint32 time, quint32 sym, bool pressed, Qt::KeyboardModifiers modifiers);
|
|
|
|
void deleteSurroundingText(int32_t index, uint32_t length);
|
|
|
|
void setCursorPosition(qint32 index, qint32 anchor);
|
|
|
|
void setLanguage(uint32_t serial, const QString &language);
|
|
|
|
void setTextDirection(uint32_t serial, Qt::LayoutDirection direction);
|
2021-04-27 15:49:55 +00:00
|
|
|
void startInputMethod();
|
|
|
|
void stopInputMethod();
|
2016-04-29 13:05:03 +00:00
|
|
|
|
2020-09-25 06:51:04 +00:00
|
|
|
struct {
|
|
|
|
QString text = QString();
|
|
|
|
quint32 begin = 0;
|
|
|
|
quint32 end = 0;
|
|
|
|
} preedit;
|
|
|
|
|
2016-04-29 13:05:03 +00:00
|
|
|
bool m_enabled = false;
|
2021-02-26 15:16:45 +00:00
|
|
|
bool m_active = false;
|
2016-04-29 13:05:03 +00:00
|
|
|
KStatusNotifierItem *m_sni = nullptr;
|
2020-07-11 16:40:28 +00:00
|
|
|
QPointer<AbstractClient> m_inputClient;
|
virtualkeyboard: resize the focused window to make room for the keyboard
Summary:
alternative approach: try to resize the winidow to make room for the keyboard.
the new input wayland protocol doesn't have anymore the overlap rectangle (and it would not be going to work with qwidget apps anyways)
in the future will probably be needed anextension to the input protocol v3 which partially gets back this, tough window resizing is needed regardless
what's missing: the resize should be "temporary" and the window should be restored to its previous geometry when the keyboard closes
Test Plan: tested with test QML code
Reviewers: #plasma, #kwin, bshah, graesslin, romangg, davidedmundson
Reviewed By: #plasma, #kwin, romangg, davidedmundson
Subscribers: nicolasfella, mart, kwin, davidedmundson, graesslin
Tags: #kwin
Maniphest Tasks: T9815
Differential Revision: https://phabricator.kde.org/D18818
2019-03-20 10:04:51 +00:00
|
|
|
QPointer<AbstractClient> m_trackedClient;
|
|
|
|
|
2021-04-27 15:49:55 +00:00
|
|
|
QProcess *m_inputMethodProcess = nullptr;
|
|
|
|
QTimer m_inputMethodCrashTimer;
|
|
|
|
uint m_inputMethodCrashes = 0;
|
|
|
|
QString m_inputMethodCommand;
|
|
|
|
|
2020-09-29 14:46:32 +00:00
|
|
|
KWIN_SINGLETON(InputMethod)
|
2016-04-29 13:05:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|