Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(548)

Side by Side Diff: ui/base/ime/input_method_win.h

Issue 166063002: Unify InputMethodIMM32 into InputMethodWin again (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/ime/input_method_imm32.cc ('k') | ui/base/ime/input_method_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef UI_BASE_IME_INPUT_METHOD_WIN_H_ 5 #ifndef UI_BASE_IME_INPUT_METHOD_WIN_H_
6 #define UI_BASE_IME_INPUT_METHOD_WIN_H_ 6 #define UI_BASE_IME_INPUT_METHOD_WIN_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "ui/base/ime/input_method_base.h" 14 #include "ui/base/ime/input_method_base.h"
15 #include "ui/base/ime/win/imm32_manager.h" 15 #include "ui/base/ime/win/imm32_manager.h"
16 16
17 namespace ui { 17 namespace ui {
18 18
19 // A common InputMethod implementation shared between IMM32 and TSF. 19 // A common InputMethod implementation shared between IMM32 and TSF.
yukawa 2014/02/19 06:53:43 Oops, I'll update this line too.
yukawa 2014/02/19 10:02:42 Done.
20 class UI_BASE_EXPORT InputMethodWin : public InputMethodBase { 20 class UI_BASE_EXPORT InputMethodWin : public InputMethodBase {
21 public: 21 public:
22 InputMethodWin(internal::InputMethodDelegate* delegate, 22 InputMethodWin(internal::InputMethodDelegate* delegate,
23 HWND toplevel_window_handle); 23 HWND toplevel_window_handle);
24 24
25 private:
Yuki 2014/02/19 05:37:13 I think InputMethodWin is just a concrete implemen
yukawa 2014/02/19 06:53:43 Hmm, I sometimes use this style but I'll follow yo
Yuki 2014/02/19 07:13:57 Good article, but it wouldn't apply to this case.
yukawa 2014/02/19 10:02:42 Done. I left public and protected as they are. Do
25 // Overridden from InputMethod: 26 // Overridden from InputMethod:
26 virtual void Init(bool focused) OVERRIDE; 27 virtual void Init(bool focused) OVERRIDE;
28 virtual void OnFocus() OVERRIDE;
29 virtual void OnBlur() OVERRIDE;
30 virtual bool OnUntranslatedIMEMessage(const base::NativeEvent& event,
31 NativeEventResult* result) OVERRIDE;
27 virtual bool DispatchKeyEvent(const ui::KeyEvent& event) OVERRIDE; 32 virtual bool DispatchKeyEvent(const ui::KeyEvent& event) OVERRIDE;
33 virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE;
34 virtual void OnCaretBoundsChanged(const TextInputClient* client) OVERRIDE;
35 virtual void CancelComposition(const TextInputClient* client) OVERRIDE;
28 virtual void OnInputLocaleChanged() OVERRIDE; 36 virtual void OnInputLocaleChanged() OVERRIDE;
29 virtual std::string GetInputLocale() OVERRIDE; 37 virtual std::string GetInputLocale() OVERRIDE;
30 virtual bool IsActive() OVERRIDE; 38 virtual bool IsActive() OVERRIDE;
39 virtual bool IsCandidatePopupOpen() const OVERRIDE;
31 40
32 protected:
33 // Overridden from InputMethodBase: 41 // Overridden from InputMethodBase:
34 // If a derived class overrides this method, it should call parent's 42 // If a derived class overrides this method, it should call parent's
35 // implementation. 43 // implementation.
44 virtual void OnWillChangeFocusedClient(TextInputClient* focused_before,
45 TextInputClient* focused) OVERRIDE;
36 virtual void OnDidChangeFocusedClient(TextInputClient* focused_before, 46 virtual void OnDidChangeFocusedClient(TextInputClient* focused_before,
37 TextInputClient* focused) OVERRIDE; 47 TextInputClient* focused) OVERRIDE;
38 48
39 // Some IMEs rely on WM_IME_REQUEST message even when TSF is enabled. So
40 // OnImeRequest (and its actual implementations as OnDocumentFeed,
41 // OnReconvertString, and OnQueryCharPosition) are placed in this base class.
42 LRESULT OnImeRequest(UINT message,
43 WPARAM wparam,
44 LPARAM lparam,
45 BOOL* handled);
46 // For both WM_CHAR and WM_SYSCHAR 49 // For both WM_CHAR and WM_SYSCHAR
47 LRESULT OnChar(HWND window_handle, 50 LRESULT OnChar(HWND window_handle,
48 UINT message, 51 UINT message,
49 WPARAM wparam, 52 WPARAM wparam,
50 LPARAM lparam, 53 LPARAM lparam,
51 BOOL* handled); 54 BOOL* handled);
52 55
56 LRESULT OnImeSetContext(HWND window_handle,
57 UINT message,
58 WPARAM wparam,
59 LPARAM lparam,
60 BOOL* handled);
61 LRESULT OnImeStartComposition(HWND window_handle,
62 UINT message,
63 WPARAM wparam,
64 LPARAM lparam,
65 BOOL* handled);
66 LRESULT OnImeComposition(HWND window_handle,
67 UINT message,
68 WPARAM wparam,
69 LPARAM lparam,
70 BOOL* handled);
71 LRESULT OnImeEndComposition(HWND window_handle,
72 UINT message,
73 WPARAM wparam,
74 LPARAM lparam,
75 BOOL* handled);
76 LRESULT OnImeNotify(UINT message,
77 WPARAM wparam,
78 LPARAM lparam,
79 BOOL* handled);
80
81 // Some IMEs rely on WM_IME_REQUEST message even when TSF is enabled. So
82 // OnImeRequest (and its actual implementations as OnDocumentFeed,
83 // OnReconvertString, and OnQueryCharPosition) are placed in this base class.
84 LRESULT OnImeRequest(UINT message,
85 WPARAM wparam,
86 LPARAM lparam,
87 BOOL* handled);
53 LRESULT OnDocumentFeed(RECONVERTSTRING* reconv); 88 LRESULT OnDocumentFeed(RECONVERTSTRING* reconv);
54 LRESULT OnReconvertString(RECONVERTSTRING* reconv); 89 LRESULT OnReconvertString(RECONVERTSTRING* reconv);
55 LRESULT OnQueryCharPosition(IMECHARPOSITION* char_positon); 90 LRESULT OnQueryCharPosition(IMECHARPOSITION* char_positon);
56 91
57 // Returns the window handle to which |text_input_client| is bound. 92 // Returns the window handle to which |text_input_client| is bound.
58 // On Aura environment, |toplevel_window_handle_| is always returned. 93 // On Aura environment, |toplevel_window_handle_| is always returned.
59 HWND GetAttachedWindowHandle(const TextInputClient* text_input_client) const; 94 HWND GetAttachedWindowHandle(const TextInputClient* text_input_client) const;
60 95
61 // Returns true if the Win32 native window bound to |client| is considered 96 // Returns true if the Win32 native window bound to |client| is considered
62 // to be ready for receiving keyboard input. 97 // to be ready for receiving keyboard input.
63 bool IsWindowFocused(const TextInputClient* client) const; 98 bool IsWindowFocused(const TextInputClient* client) const;
64 99
65 // Indicates if the current input locale has an IME. 100 bool DispatchFabricatedKeyEvent(const ui::KeyEvent& event);
66 bool active_; 101
102 // Asks the client to confirm current composition text.
103 void ConfirmCompositionText();
104
105 // Enables or disables the IME according to the current text input type.
106 void UpdateIMEState();
67 107
68 // Windows IMM32 wrapper. 108 // Windows IMM32 wrapper.
69 // (See "ui/base/ime/win/ime_input.h" for its details.) 109 // (See "ui/base/ime/win/ime_input.h" for its details.)
70 ui::IMM32Manager imm32_manager_; 110 ui::IMM32Manager imm32_manager_;
71 111
72 private:
73 bool DispatchFabricatedKeyEvent(const ui::KeyEvent& event);
74
75 // The toplevel window handle. 112 // The toplevel window handle.
76 // On non-Aura environment, this value is not used and always NULL. 113 // On non-Aura environment, this value is not used and always NULL.
77 const HWND toplevel_window_handle_; 114 const HWND toplevel_window_handle_;
78 115
79 // Name of the current input locale. 116 // Name of the current input locale.
80 std::string locale_; 117 std::string locale_;
81 118
82 // The new text direction and layout alignment requested by the user by 119 // The new text direction and layout alignment requested by the user by
83 // pressing ctrl-shift. It'll be sent to the text input client when the key 120 // pressing ctrl-shift. It'll be sent to the text input client when the key
84 // is released. 121 // is released.
85 base::i18n::TextDirection pending_requested_direction_; 122 base::i18n::TextDirection pending_requested_direction_;
86 123
87 // Represents if WM_CHAR[wparam=='\r'] should be dispatched to the focused 124 // Represents if WM_CHAR[wparam=='\r'] should be dispatched to the focused
88 // text input client or ignored silently. This flag is introduced as a quick 125 // text input client or ignored silently. This flag is introduced as a quick
89 // workaround against crbug.com/319100 126 // workaround against crbug.com/319100
90 // TODO(yukawa, IME): Figure out long-term solution. 127 // TODO(yukawa, IME): Figure out long-term solution.
91 bool accept_carriage_return_; 128 bool accept_carriage_return_;
92 129
130 // Indicates if the current input locale has an IME.
131 bool active_;
132
133 // True when an IME should be allowed to process key events.
134 bool enabled_;
135
136 // True if we know for sure that a candidate window is open.
137 bool is_candidate_popup_open_;
138
139 // Window handle where composition is on-going. NULL when there is no
140 // composition.
141 HWND composing_window_handle_;
142
93 DISALLOW_COPY_AND_ASSIGN(InputMethodWin); 143 DISALLOW_COPY_AND_ASSIGN(InputMethodWin);
94 }; 144 };
95 145
96 } // namespace ui 146 } // namespace ui
97 147
98 #endif // UI_BASE_IME_INPUT_METHOD_WIN_H_ 148 #endif // UI_BASE_IME_INPUT_METHOD_WIN_H_
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_imm32.cc ('k') | ui/base/ime/input_method_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698