diff options
author | Kai Koehne <kai.koehne@qt.io> | 2017-06-13 14:39:24 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@qt.io> | 2017-06-27 07:20:19 +0000 |
commit | 5bc8671260bc716be9dffe61e84c214ca37ca5f6 (patch) | |
tree | 33fec3075b0b87e5ef32fcc6b0bfb90c7de07d40 /src/core | |
parent | 085c2c529473bbe9dd7c8c5698a45053520cc423 (diff) |
Fix location of IME window on Windows
SelectionRegion::caret_rect is only documented to be supported on
macOS, so use anchor, focus instead. Also make sure that the rect
always has a width > 0; Both the Windows QPA and the native API
require this.
Task-number: QTBUG-60334
Change-Id: I8436fbfaa204d243578b33cbcaa3f28871b462ee
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/render_widget_host_view_qt.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 169e8e54b..131f2a664 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -973,10 +973,17 @@ QVariant RenderWidgetHostViewQt::inputMethodQuery(Qt::InputMethodQuery query) case Qt::ImFont: // TODO: Implement this return QVariant(); - case Qt::ImCursorRectangle: - if (!text_input_manager_ || !text_input_manager_->GetActiveWidget()) - return QVariant(); - return toQt(text_input_manager_->GetSelectionRegion()->caret_rect); + case Qt::ImCursorRectangle: { + if (text_input_manager_) { + if (auto *region = text_input_manager_->GetSelectionRegion()) { + gfx::Rect caretRect = gfx::RectBetweenSelectionBounds(region->anchor, region->focus); + if (caretRect.width() == 0) + caretRect.set_width(1); // IME API on Windows expects a width > 0 + return toQt(caretRect); + } + } + return QVariant(); + } case Qt::ImCursorPosition: return m_cursorPosition; case Qt::ImAnchorPosition: |