Chromium Code Reviews| Index: chrome/browser/ui/libgtkui/x11_input_method_context_impl_gtk.cc |
| diff --git a/chrome/browser/ui/libgtkui/x11_input_method_context_impl_gtk.cc b/chrome/browser/ui/libgtkui/x11_input_method_context_impl_gtk.cc |
| index 65bbe050e473fba18c3b4a86d3bf6cec1e8f6c1e..2a6077d893f4f2435f2000295d269b8b6f078483 100644 |
| --- a/chrome/browser/ui/libgtkui/x11_input_method_context_impl_gtk.cc |
| +++ b/chrome/browser/ui/libgtkui/x11_input_method_context_impl_gtk.cc |
| @@ -22,6 +22,7 @@ |
| #include "ui/events/event.h" |
| #include "ui/events/keycodes/keyboard_code_conversion_x.h" |
| #include "ui/gfx/x/x11_types.h" |
| +#include "ui/views/linux_ui/linux_ui.h" |
| namespace libgtkui { |
| @@ -81,9 +82,12 @@ bool X11InputMethodContextImplGtk2::DispatchKeyEvent( |
| gint x = 0; |
| gint y = 0; |
| gdk_window_get_origin(event->key.window, &x, &y); |
| - GdkRectangle rect = {last_caret_bounds_.x() - x, last_caret_bounds_.y() - y, |
| - last_caret_bounds_.width(), last_caret_bounds_.height()}; |
| - gtk_im_context_set_cursor_location(gtk_context_, &rect); |
| + |
| + GdkRectangle gdk_rect = { |
| + last_caret_bounds_.x() - x, last_caret_bounds_.y() - y, |
| + last_caret_bounds_.width(), last_caret_bounds_.height() |
| + }; |
| + gtk_im_context_set_cursor_location(gtk_context_, &gdk_rect); |
| const bool handled = |
| gtk_im_context_filter_keypress(gtk_context_, &event->key); |
| @@ -109,7 +113,12 @@ void X11InputMethodContextImplGtk2::SetCursorLocation(const gfx::Rect& rect) { |
| // client window, which is unknown at this point. So we'll call |
| // gtk_im_context_set_cursor_location() later in ProcessKeyEvent() where |
| // (and only where) we know the client window. |
| - last_caret_bounds_ = rect; |
| + if (views::LinuxUI::instance()) { |
| + last_caret_bounds_ = gfx::ScaleToEnclosingRect( |
| + rect, views::LinuxUI::instance()->GetDeviceScaleFactor()); |
|
sadrul
2016/12/22 03:25:53
Consider using gfx::ConvertRectToPixel (https://cs
Shu Chen
2017/02/20 07:55:44
Done.
|
| + } else { |
| + last_caret_bounds_ = rect; |
| + } |
| } |
| // private: |