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

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

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

Powered by Google App Engine
This is Rietveld 408576698