OLD | NEW |
1 // Copyright (c) 2012 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 "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 GdkWindow* gdk_window = gtk_widget_get_window(widget); | 592 if (widget->window) { |
593 if (gdk_window) { | 593 gtk_im_context_set_client_window(context_, widget->window); |
594 gtk_im_context_set_client_window(context_, gdk_window); | 594 gtk_im_context_set_client_window(context_simple_, widget->window); |
595 gtk_im_context_set_client_window(context_simple_, gdk_window); | |
596 } | 595 } |
597 } | 596 } |
598 | 597 |
599 void GtkIMContextWrapper::HandleHostViewUnrealize() { | 598 void GtkIMContextWrapper::HandleHostViewUnrealize() { |
600 gtk_im_context_set_client_window(context_, NULL); | 599 gtk_im_context_set_client_window(context_, NULL); |
601 gtk_im_context_set_client_window(context_simple_, NULL); | 600 gtk_im_context_set_client_window(context_simple_, NULL); |
602 } | 601 } |
603 | 602 |
604 void GtkIMContextWrapper::SendFakeCompositionKeyEvent( | 603 void GtkIMContextWrapper::SendFakeCompositionKeyEvent( |
605 WebKit::WebInputEvent::Type type) { | 604 WebKit::WebInputEvent::Type type) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 | 642 |
644 void GtkIMContextWrapper::HandleHostViewRealizeThunk( | 643 void GtkIMContextWrapper::HandleHostViewRealizeThunk( |
645 GtkWidget* widget, GtkIMContextWrapper* self) { | 644 GtkWidget* widget, GtkIMContextWrapper* self) { |
646 self->HandleHostViewRealize(widget); | 645 self->HandleHostViewRealize(widget); |
647 } | 646 } |
648 | 647 |
649 void GtkIMContextWrapper::HandleHostViewUnrealizeThunk( | 648 void GtkIMContextWrapper::HandleHostViewUnrealizeThunk( |
650 GtkWidget* widget, GtkIMContextWrapper* self) { | 649 GtkWidget* widget, GtkIMContextWrapper* self) { |
651 self->HandleHostViewUnrealize(); | 650 self->HandleHostViewUnrealize(); |
652 } | 651 } |
OLD | NEW |