OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROME_BROWSER_RENDERER_HOST_GTK_IM_CONTEXT_WRAPPER_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_GTK_IM_CONTEXT_WRAPPER_H_ |
6 #define CHROME_BROWSER_RENDERER_HOST_GTK_IM_CONTEXT_WRAPPER_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_GTK_IM_CONTEXT_WRAPPER_H_ |
7 | 7 |
8 #include <gdk/gdk.h> | 8 #include <gdk/gdk.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 | 12 |
13 namespace gfx { | 13 namespace gfx { |
14 class Rect; | 14 class Rect; |
15 } | 15 } |
16 | 16 |
17 class RenderWidgetHostViewGtk; | 17 class RenderWidgetHostViewGtk; |
18 class NativeWebKeyboardEvent; | 18 class NativeWebKeyboardEvent; |
19 typedef struct _GtkIMContext GtkIMContext; | 19 typedef struct _GtkIMContext GtkIMContext; |
| 20 typedef struct _GtkWidget GtkWidget; |
20 | 21 |
21 // This class is a convenience wrapper for GtkIMContext. | 22 // This class is a convenience wrapper for GtkIMContext. |
22 // It creates and manages two GtkIMContext instances, one is GtkIMMulticontext, | 23 // It creates and manages two GtkIMContext instances, one is GtkIMMulticontext, |
23 // for plain text input box, another is GtkIMContextSimple, for password input | 24 // for plain text input box, another is GtkIMContextSimple, for password input |
24 // box. | 25 // box. |
25 // | 26 // |
26 // This class is in charge of dispatching key events to these two GtkIMContext | 27 // This class is in charge of dispatching key events to these two GtkIMContext |
27 // instances and handling signals emitted by them. Key events then will be | 28 // instances and handling signals emitted by them. Key events then will be |
28 // forwarded to renderer along with input method results via corresponding host | 29 // forwarded to renderer along with input method results via corresponding host |
29 // view. | 30 // view. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 62 |
62 // Real code of "preedit-start" signal handler. | 63 // Real code of "preedit-start" signal handler. |
63 void HandlePreeditStart(); | 64 void HandlePreeditStart(); |
64 | 65 |
65 // Real code of "preedit-changed" signal handler. | 66 // Real code of "preedit-changed" signal handler. |
66 void HandlePreeditChanged(const string16& text, int cursor_position); | 67 void HandlePreeditChanged(const string16& text, int cursor_position); |
67 | 68 |
68 // Real code of "preedit-end" signal handler. | 69 // Real code of "preedit-end" signal handler. |
69 void HandlePreeditEnd(); | 70 void HandlePreeditEnd(); |
70 | 71 |
| 72 // Real code of "realize" signal handler, used for setting im context's client |
| 73 // window. |
| 74 void HandleHostViewRealize(GtkWidget* widget); |
| 75 |
| 76 // Real code of "unrealize" signal handler, used for unsetting im context's |
| 77 // client window. |
| 78 void HandleHostViewUnrealize(); |
| 79 |
71 // Signal handlers of GtkIMContext object. | 80 // Signal handlers of GtkIMContext object. |
72 static void HandleCommitThunk(GtkIMContext* context, gchar* text, | 81 static void HandleCommitThunk(GtkIMContext* context, gchar* text, |
73 GtkIMContextWrapper* self); | 82 GtkIMContextWrapper* self); |
74 static void HandlePreeditStartThunk(GtkIMContext* context, | 83 static void HandlePreeditStartThunk(GtkIMContext* context, |
75 GtkIMContextWrapper* self); | 84 GtkIMContextWrapper* self); |
76 static void HandlePreeditChangedThunk(GtkIMContext* context, | 85 static void HandlePreeditChangedThunk(GtkIMContext* context, |
77 GtkIMContextWrapper* self); | 86 GtkIMContextWrapper* self); |
78 static void HandlePreeditEndThunk(GtkIMContext* context, | 87 static void HandlePreeditEndThunk(GtkIMContext* context, |
79 GtkIMContextWrapper* self); | 88 GtkIMContextWrapper* self); |
80 | 89 |
| 90 // Signal handlers connecting to |host_view_|'s native view widget. |
| 91 static void HandleHostViewRealizeThunk(GtkWidget* widget, |
| 92 GtkIMContextWrapper* self); |
| 93 static void HandleHostViewUnrealizeThunk(GtkWidget* widget, |
| 94 GtkIMContextWrapper* self); |
| 95 |
81 // The parent object. | 96 // The parent object. |
82 RenderWidgetHostViewGtk* host_view_; | 97 RenderWidgetHostViewGtk* host_view_; |
83 | 98 |
84 // The GtkIMContext object. | 99 // The GtkIMContext object. |
85 // In terms of the DOM event specification Appendix A | 100 // In terms of the DOM event specification Appendix A |
86 // <http://www.w3.org/TR/DOM-Level-3-Events/keyset.html>, | 101 // <http://www.w3.org/TR/DOM-Level-3-Events/keyset.html>, |
87 // GTK uses a GtkIMContext object for the following two purposes: | 102 // GTK uses a GtkIMContext object for the following two purposes: |
88 // 1. Composing Latin characters (A.1.2), and; | 103 // 1. Composing Latin characters (A.1.2), and; |
89 // 2. Composing CJK characters with an IME (A.1.3). | 104 // 2. Composing CJK characters with an IME (A.1.3). |
90 // Many JavaScript pages assume composed Latin characters are dispatched to | 105 // Many JavaScript pages assume composed Latin characters are dispatched to |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 164 |
150 // Stores a copy of the most recent commit text received by commit signal | 165 // Stores a copy of the most recent commit text received by commit signal |
151 // handler. | 166 // handler. |
152 string16 commit_text_; | 167 string16 commit_text_; |
153 | 168 |
154 DISALLOW_COPY_AND_ASSIGN(GtkIMContextWrapper); | 169 DISALLOW_COPY_AND_ASSIGN(GtkIMContextWrapper); |
155 }; | 170 }; |
156 | 171 |
157 | 172 |
158 #endif // CHROME_BROWSER_RENDERER_HOST_GTK_IM_CONTEXT_WRAPPER_H_ | 173 #endif // CHROME_BROWSER_RENDERER_HOST_GTK_IM_CONTEXT_WRAPPER_H_ |
OLD | NEW |