summaryrefslogtreecommitdiffstats
path: root/src/core/render_widget_host_view_qt.cpp
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2017-09-12 15:48:45 +0200
committerPeter Varga <pvarga@inf.u-szeged.hu>2017-10-04 14:06:03 +0000
commit64a5f315206fac2316e0b4a5a65a5d1f66b1a219 (patch)
treebffae9cca3d595f683664d25a49c86e9a84d9dbc /src/core/render_widget_host_view_qt.cpp
parent9d9a22fc48f7de6c356a2527ab1170cd50e7dad8 (diff)
Disable IME on password input
Task-number: QTBUG-62433 Change-Id: Icdc3355ca9d1ec4fb25d512c56c19aca94ae8928 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/render_widget_host_view_qt.cpp')
-rw-r--r--src/core/render_widget_host_view_qt.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 136371a91..655871c9c 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -77,6 +77,9 @@
#include "ui/base/cursor/cursors_aura.h"
#endif
+#include <private/qguiapplication_p.h>
+#include <qpa/qplatforminputcontext.h>
+#include <qpa/qplatformintegration.h>
#include <QEvent>
#include <QFocusEvent>
#include <QGuiApplication>
@@ -292,6 +295,9 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost* widget
if (GetTextInputManager())
GetTextInputManager()->AddObserver(this);
+
+ const QPlatformInputContext *context = QGuiApplicationPrivate::platformIntegration()->inputContext();
+ m_imeHasHiddenTextCapability = context && context->hasCapability(QPlatformInputContext::HiddenTextCapability);
}
RenderWidgetHostViewQt::~RenderWidgetHostViewQt()
@@ -735,7 +741,7 @@ void RenderWidgetHostViewQt::OnUpdateTextInputStateCalled(content::TextInputMana
Q_UNUSED(did_update_state);
ui::TextInputType type = getTextInputType();
- m_delegate->inputMethodStateChanged(type != ui::TEXT_INPUT_TYPE_NONE);
+ m_delegate->inputMethodStateChanged(type != ui::TEXT_INPUT_TYPE_NONE, type == ui::TEXT_INPUT_TYPE_PASSWORD);
m_delegate->setInputMethodHints(toQtInputMethodHints(type));
const content::TextInputState *state = text_input_manager_->GetTextInputState();
@@ -973,8 +979,16 @@ bool RenderWidgetHostViewQt::forwardEvent(QEvent *event)
QVariant RenderWidgetHostViewQt::inputMethodQuery(Qt::InputMethodQuery query)
{
switch (query) {
- case Qt::ImEnabled:
- return QVariant(getTextInputType() != ui::TEXT_INPUT_TYPE_NONE);
+ case Qt::ImEnabled: {
+ ui::TextInputType type = getTextInputType();
+ bool editorVisible = type != ui::TEXT_INPUT_TYPE_NONE;
+ // IME manager should disable composition on input fields with ImhHiddenText hint if supported
+ if (m_imeHasHiddenTextCapability)
+ return QVariant(editorVisible);
+
+ bool passwordInput = type == ui::TEXT_INPUT_TYPE_PASSWORD;
+ return QVariant(editorVisible && !passwordInput);
+ }
case Qt::ImFont:
// TODO: Implement this
return QVariant();