OLD | NEW |
1 // Copyright (c) 2011 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 "content/browser/renderer_host/gtk_im_context_wrapper.h" | 5 #include "content/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 |
11 #include <algorithm> | 11 #include <algorithm> |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 gtk_im_context_set_surrounding(context, text.c_str(), text.length(), | 582 gtk_im_context_set_surrounding(context, text.c_str(), text.length(), |
583 cursor_index); | 583 cursor_index); |
584 | 584 |
585 return TRUE; | 585 return TRUE; |
586 } | 586 } |
587 | 587 |
588 void GtkIMContextWrapper::HandleHostViewRealize(GtkWidget* widget) { | 588 void GtkIMContextWrapper::HandleHostViewRealize(GtkWidget* widget) { |
589 // We should only set im context's client window once, because when setting | 589 // We should only set im context's client window once, because when setting |
590 // client window.im context may destroy and recreate its internal states and | 590 // client window.im context may destroy and recreate its internal states and |
591 // objects. | 591 // objects. |
592 if (widget->window) { | 592 GdkWindow* gdk_window = gtk_widget_get_window(widget); |
593 gtk_im_context_set_client_window(context_, widget->window); | 593 if (gdk_window) { |
594 gtk_im_context_set_client_window(context_simple_, widget->window); | 594 gtk_im_context_set_client_window(context_, gdk_window); |
| 595 gtk_im_context_set_client_window(context_simple_, gdk_window); |
595 } | 596 } |
596 } | 597 } |
597 | 598 |
598 void GtkIMContextWrapper::HandleHostViewUnrealize() { | 599 void GtkIMContextWrapper::HandleHostViewUnrealize() { |
599 gtk_im_context_set_client_window(context_, NULL); | 600 gtk_im_context_set_client_window(context_, NULL); |
600 gtk_im_context_set_client_window(context_simple_, NULL); | 601 gtk_im_context_set_client_window(context_simple_, NULL); |
601 } | 602 } |
602 | 603 |
603 void GtkIMContextWrapper::SendFakeCompositionKeyEvent( | 604 void GtkIMContextWrapper::SendFakeCompositionKeyEvent( |
604 WebKit::WebInputEvent::Type type) { | 605 WebKit::WebInputEvent::Type type) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 | 643 |
643 void GtkIMContextWrapper::HandleHostViewRealizeThunk( | 644 void GtkIMContextWrapper::HandleHostViewRealizeThunk( |
644 GtkWidget* widget, GtkIMContextWrapper* self) { | 645 GtkWidget* widget, GtkIMContextWrapper* self) { |
645 self->HandleHostViewRealize(widget); | 646 self->HandleHostViewRealize(widget); |
646 } | 647 } |
647 | 648 |
648 void GtkIMContextWrapper::HandleHostViewUnrealizeThunk( | 649 void GtkIMContextWrapper::HandleHostViewUnrealizeThunk( |
649 GtkWidget* widget, GtkIMContextWrapper* self) { | 650 GtkWidget* widget, GtkIMContextWrapper* self) { |
650 self->HandleHostViewUnrealize(); | 651 self->HandleHostViewUnrealize(); |
651 } | 652 } |
OLD | NEW |