Bumping manifests a=b2g-bump
[gecko.git] / widget / windows / WinIMEHandler.h
blobe630bab34ed821eba4f68c787532613893311c86
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef WinIMEHandler_h_
7 #define WinIMEHandler_h_
9 #include "nscore.h"
10 #include "nsIWidget.h"
11 #include <windows.h>
12 #include <inputscope.h>
14 #define NS_WM_IMEFIRST WM_IME_SETCONTEXT
15 #define NS_WM_IMELAST WM_IME_KEYUP
17 class nsWindow;
19 namespace mozilla {
20 namespace widget {
22 struct MSGResult;
24 /**
25 * IMEHandler class is a mediator class. On Windows, there are two IME API
26 * sets: One is IMM which is legacy API set. The other is TSF which is modern
27 * API set. By using this class, non-IME handler classes don't need to worry
28 * that we're in which mode.
30 class IMEHandler MOZ_FINAL
32 public:
33 static void Initialize();
34 static void Terminate();
36 /**
37 * Returns TSF related native data.
39 static void* GetNativeData(uint32_t aDataType);
41 /**
42 * ProcessRawKeyMessage() message is called before calling TranslateMessage()
43 * and DispatchMessage(). If this returns true, the message is consumed.
44 * Then, caller must not perform TranslateMessage() nor DispatchMessage().
46 static bool ProcessRawKeyMessage(const MSG& aMsg);
48 /**
49 * When the message is not needed to handle anymore by the caller, this
50 * returns true. Otherwise, false.
52 static bool ProcessMessage(nsWindow* aWindow, UINT aMessage,
53 WPARAM& aWParam, LPARAM& aLParam,
54 MSGResult& aResult);
56 /**
57 * When there is a composition, returns true. Otherwise, false.
59 static bool IsComposing();
61 /**
62 * When there is a composition and it's in the window, returns true.
63 * Otherwise, false.
65 static bool IsComposingOn(nsWindow* aWindow);
67 /**
68 * Notifies IME of the notification (a request or an event).
70 static nsresult NotifyIME(nsWindow* aWindow,
71 const IMENotification& aIMENotification);
73 /**
74 * Returns update preferences.
76 static nsIMEUpdatePreference GetUpdatePreference();
78 /**
79 * Returns IME open state on the window.
81 static bool GetOpenState(nsWindow* aWindow);
83 /**
84 * Called when the window is destroying.
86 static void OnDestroyWindow(nsWindow* aWindow);
88 /**
89 * Called when nsIWidget::SetInputContext() is called before the window's
90 * InputContext is modified actually.
92 static void SetInputContext(nsWindow* aWindow,
93 InputContext& aInputContext,
94 const InputContextAction& aAction);
96 /**
97 * Associate or disassociate IME context to/from the aWindow.
99 static void AssociateIMEContext(nsWindow* aWindow, bool aEnable);
102 * Called when the window is created.
104 static void InitInputContext(nsWindow* aWindow, InputContext& aInputContext);
106 #ifdef DEBUG
108 * Returns true when current keyboard layout has IME. Otherwise, false.
110 static bool CurrentKeyboardLayoutHasIME();
111 #endif // #ifdef DEBUG
113 private:
114 #ifdef NS_ENABLE_TSF
115 static decltype(SetInputScopes)* sSetInputScopes;
116 static void SetInputScopeForIMM32(nsWindow* aWindow,
117 const nsAString& aHTMLInputType);
118 static bool sIsInTSFMode;
119 // If sIMMEnabled is false, any IME messages are not handled in TSF mode.
120 // Additionally, IME context is always disassociated from focused window.
121 static bool sIsIMMEnabled;
122 static bool sPluginHasFocus;
124 static bool IsTSFAvailable() { return (sIsInTSFMode && !sPluginHasFocus); }
125 #endif // #ifdef NS_ENABLE_TSF
128 } // namespace widget
129 } // namespace mozilla
131 #endif // #ifndef WinIMEHandler_h_