| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/renderer_host/gtk_im_context_wrapper.h" | 5 #include "chrome/browser/renderer_host/gtk_im_context_wrapper.h" |
| 6 | 6 |
| 7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
| 8 #include <gdk/gdkkeysyms.h> | 8 #include <gdk/gdkkeysyms.h> |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 | 10 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 218 |
| 219 if (!suppress) | 219 if (!suppress) |
| 220 host_view_->ForwardKeyboardEvent(wke); | 220 host_view_->ForwardKeyboardEvent(wke); |
| 221 } | 221 } |
| 222 | 222 |
| 223 last_key_code_ = key_code; | 223 last_key_code_ = key_code; |
| 224 last_key_was_up_ = (event->type == GDK_KEY_RELEASE); | 224 last_key_was_up_ = (event->type == GDK_KEY_RELEASE); |
| 225 last_key_filtered_no_result_ = (filtered && !has_result); | 225 last_key_filtered_no_result_ = (filtered && !has_result); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void GtkIMContextWrapper::UpdateInputMethodState(WebKit::WebTextInputType type, | 228 void GtkIMContextWrapper::UpdateInputMethodState( |
| 229 const gfx::Rect& caret_rect) { | 229 ui::TextInputType type, |
| 230 ui::TextInputPreeditType preedit_type, |
| 231 const gfx::Rect& caret_rect) { |
| 230 suppress_next_commit_ = false; | 232 suppress_next_commit_ = false; |
| 231 | 233 |
| 232 // The renderer has updated its IME status. | 234 // The renderer has updated its IME status. |
| 233 // Control the GtkIMContext object according to this status. | 235 // Control the GtkIMContext object according to this status. |
| 234 if (!context_ || !is_focused_) | 236 if (!context_ || !is_focused_) |
| 235 return; | 237 return; |
| 236 | 238 |
| 237 DCHECK(!is_in_key_event_handler_); | 239 DCHECK(!is_in_key_event_handler_); |
| 238 | 240 |
| 239 bool is_enabled = (type == WebKit::WebTextInputTypeText); | 241 bool is_enabled = (type == ui::TEXT_INPUT_TYPE_TEXT); |
| 240 if (is_enabled_ != is_enabled) { | 242 if (is_enabled_ != is_enabled) { |
| 241 is_enabled_ = is_enabled; | 243 is_enabled_ = is_enabled; |
| 242 if (is_enabled) | 244 if (is_enabled) |
| 243 gtk_im_context_focus_in(context_); | 245 gtk_im_context_focus_in(context_); |
| 244 else | 246 else |
| 245 gtk_im_context_focus_out(context_); | 247 gtk_im_context_focus_out(context_); |
| 246 } | 248 } |
| 247 | 249 |
| 248 if (is_enabled) { | 250 if (is_enabled) { |
| 251 // If the focused element requests normal IME, turns on to the mode |
| 252 // receiving preedit messages. Otherwise, do not receive the messages |
| 253 // and candidate window should take care of preedits. |
| 254 bool context_use_preedit = preedit_type == ui::TEXT_INPUT_PREEDIT_INLINE; |
| 255 gtk_im_context_set_use_preedit(context_, context_use_preedit); |
| 249 // Updates the position of the IME candidate window. | 256 // Updates the position of the IME candidate window. |
| 250 // The position sent from the renderer is a relative one, so we need to | 257 // The position sent from the renderer is a relative one, so we need to |
| 251 // attach the GtkIMContext object to this window before changing the | 258 // attach the GtkIMContext object to this window before changing the |
| 252 // position. | 259 // position. |
| 253 GdkRectangle cursor_rect(caret_rect.ToGdkRectangle()); | 260 GdkRectangle cursor_rect(caret_rect.ToGdkRectangle()); |
| 254 gtk_im_context_set_cursor_location(context_, &cursor_rect); | 261 gtk_im_context_set_cursor_location(context_, &cursor_rect); |
| 255 } | 262 } |
| 256 } | 263 } |
| 257 | 264 |
| 258 void GtkIMContextWrapper::OnFocusIn() { | 265 void GtkIMContextWrapper::OnFocusIn() { |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 | 633 |
| 627 void GtkIMContextWrapper::HandleHostViewRealizeThunk( | 634 void GtkIMContextWrapper::HandleHostViewRealizeThunk( |
| 628 GtkWidget* widget, GtkIMContextWrapper* self) { | 635 GtkWidget* widget, GtkIMContextWrapper* self) { |
| 629 self->HandleHostViewRealize(widget); | 636 self->HandleHostViewRealize(widget); |
| 630 } | 637 } |
| 631 | 638 |
| 632 void GtkIMContextWrapper::HandleHostViewUnrealizeThunk( | 639 void GtkIMContextWrapper::HandleHostViewUnrealizeThunk( |
| 633 GtkWidget* widget, GtkIMContextWrapper* self) { | 640 GtkWidget* widget, GtkIMContextWrapper* self) { |
| 634 self->HandleHostViewUnrealize(); | 641 self->HandleHostViewUnrealize(); |
| 635 } | 642 } |
| OLD | NEW |