7dd31c8ef38b3b28b6613ef6291490b43f79636c
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / efl / InputMethodContextEfl.h
1 /*
2    Copyright (C) 2011 Samsung Electronics
3    Copyright (C) 2012 Intel Corporation. All rights reserved.
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Library General Public
7     License as published by the Free Software Foundation; either
8     version 2 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13     Library General Public License for more details.
14
15     You should have received a copy of the GNU Library General Public License
16     along with this library; see the file COPYING.LIB.  If not, write to
17     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18     Boston, MA 02110-1301, USA.
19 */
20
21 #ifndef InputMethodContextEfl_h
22 #define InputMethodContextEfl_h
23
24 #include <Ecore_IMF.h>
25 #include <Evas.h>
26 #include <wtf/OwnPtr.h>
27 #include <wtf/PassOwnPtr.h>
28
29 class EwkViewImpl;
30
31 namespace WebKit {
32
33 class WebPageProxy;
34
35 class InputMethodContextEfl {
36 public:
37     static PassOwnPtr<InputMethodContextEfl> create(EwkViewImpl* viewImpl, Evas* canvas)
38     {
39 #if ENABLE(TIZEN_ISF_PORT)
40         OwnPtr<Ecore_IMF_Context> context;
41 #else
42         OwnPtr<Ecore_IMF_Context> context = createIMFContext(canvas);
43         if (!context)
44             return nullptr;
45 #endif
46
47         return adoptPtr(new InputMethodContextEfl(viewImpl, context.release()));
48     }
49     ~InputMethodContextEfl();
50
51     void handleMouseUpEvent(const Evas_Event_Mouse_Up* upEvent);
52     void handleKeyDownEvent(const Evas_Event_Key_Down* downEvent, bool* isFiltered);
53     void updateTextInputState();
54
55 #if ENABLE(TIZEN_ISF_PORT)
56     bool isShow();
57     Ecore_IMF_Autocapital_Type autoCapitalType();
58     void onFocusIn();
59     void onFocusOut();
60     void resetIMFContext();
61     void hideIMFContext();
62     bool isIMEPostion(int, int);
63     void removeIMFContext(uintptr_t);
64     int inputPickerType() { return m_inputPickerType; }
65 #endif
66
67 private:
68     InputMethodContextEfl(EwkViewImpl*, PassOwnPtr<Ecore_IMF_Context>);
69
70     static PassOwnPtr<Ecore_IMF_Context> createIMFContext(Evas* canvas);
71     static void onIMFInputSequenceComplete(void* data, Ecore_IMF_Context*, void* eventInfo);
72     static void onIMFPreeditSequenceChanged(void* data, Ecore_IMF_Context*, void* eventInfo);
73
74 #if ENABLE(TIZEN_ISF_PORT)
75     void initializeIMFContext(Ecore_IMF_Context*, Ecore_IMF_Input_Panel_Layout, int, Ecore_IMF_Input_Panel_Return_Key_Type);
76
77     static void onIMFInputPanelStateChanged(void*, Ecore_IMF_Context*, int);
78     static void onIMFInputPanelGeometryChanged(void*, Ecore_IMF_Context*, int);
79     static void onIMFCandidatePanelStateChanged(void*, Ecore_IMF_Context*, int);
80     static void onIMFCandidatePanelGeometryChanged(void*, Ecore_IMF_Context*, int);
81     static Eina_Bool onIMFRetrieveSurrounding(void*, Ecore_IMF_Context*, char**, int*);
82     static void onIMFDeleteSurrounding(void*, Ecore_IMF_Context*, void*);
83
84     PassOwnPtr<Ecore_IMF_Context> takeContext(uintptr_t);
85     void setIMFContext(const EditorState&);
86     void revertIMFContext();
87     void showIMFContext(const EditorState&);
88     void destroyIMFContextList();
89     void setState(int state) { m_state = state; }
90     void setIMERect(const WebCore::IntRect& rect) { m_imeRect = rect; }
91
92 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
93     void showInputPicker(const EditorState&);
94 #endif
95
96     void setKeyboardMode(bool);
97
98     void requestFakeKeyEvent();
99     void fakeKeyEventTimerFired(WebCore::Timer<InputMethodContextEfl>*);
100 #endif
101
102     EwkViewImpl* m_viewImpl;
103     OwnPtr<Ecore_IMF_Context> m_context;
104     bool m_focused;
105
106 #if ENABLE(TIZEN_ISF_PORT)
107     static const unsigned maxContextSize;
108
109     Vector<std::pair<uintptr_t, OwnPtr<Ecore_IMF_Context> > > m_contextList;
110     uintptr_t m_contextID;
111     int m_state;
112     WebCore::IntRect m_imeRect;
113     int m_inputPickerType;
114     bool m_doNotHandleFakeKeyEvent;
115     WebCore::Timer<InputMethodContextEfl> m_fakeKeyEventTimer;
116 #endif
117 };
118
119 } // namespace WebKit
120
121 #endif // InputMethodContextEfl_h