OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/base/ime/input_method_ibus.h" | 5 #include "ui/base/ime/input_method_ibus.h" |
6 | 6 |
7 #include <X11/X.h> | 7 #include <X11/X.h> |
8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
9 #include <X11/Xutil.h> | 9 #include <X11/Xutil.h> |
10 #undef FocusIn | 10 #undef FocusIn |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 return; | 260 return; |
261 } | 261 } |
262 | 262 |
263 if (previous_selection_range_ == selection_range && | 263 if (previous_selection_range_ == selection_range && |
264 previous_surrounding_text_ == surrounding_text) | 264 previous_surrounding_text_ == surrounding_text) |
265 return; | 265 return; |
266 | 266 |
267 previous_selection_range_ = selection_range; | 267 previous_selection_range_ = selection_range; |
268 previous_surrounding_text_ = surrounding_text; | 268 previous_surrounding_text_ = surrounding_text; |
269 | 269 |
270 // In the original meaning of SetSurroundingText is not just selection text, | 270 // Here SetSurroundingText accepts relative position of |surrounding_text|, so |
271 // but currently there are no way to retrieve surrounding text in | 271 // we have to convert |selection_range| from node coordinates to |
272 // TextInputClient. | 272 // |surrounding_text| coordinates. |
273 GetInputContextClient()->SetSurroundingText( | 273 GetInputContextClient()->SetSurroundingText( |
274 UTF16ToUTF8(surrounding_text), | 274 UTF16ToUTF8(surrounding_text), |
275 selection_range.start(), /* cursor position. */ | 275 selection_range.start() - text_range.start(), |
276 selection_range.end()); /* selection anchor position. */ | 276 selection_range.end() - text_range.start()); |
277 } | 277 } |
278 | 278 |
279 void InputMethodIBus::CancelComposition(const TextInputClient* client) { | 279 void InputMethodIBus::CancelComposition(const TextInputClient* client) { |
280 if (context_focused_ && IsTextInputClientFocused(client)) | 280 if (context_focused_ && IsTextInputClientFocused(client)) |
281 ResetContext(); | 281 ResetContext(); |
282 } | 282 } |
283 | 283 |
284 std::string InputMethodIBus::GetInputLocale() { | 284 std::string InputMethodIBus::GetInputLocale() { |
285 // Not supported. | 285 // Not supported. |
286 return ""; | 286 return ""; |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 } | 933 } |
934 | 934 |
935 // Use a black thin underline by default. | 935 // Use a black thin underline by default. |
936 if (out_composition->underlines.empty()) { | 936 if (out_composition->underlines.empty()) { |
937 out_composition->underlines.push_back(CompositionUnderline( | 937 out_composition->underlines.push_back(CompositionUnderline( |
938 0, length, SK_ColorBLACK, false /* thick */)); | 938 0, length, SK_ColorBLACK, false /* thick */)); |
939 } | 939 } |
940 } | 940 } |
941 | 941 |
942 } // namespace ui | 942 } // namespace ui |
OLD | NEW |