Close CBHM window when tapping except editfield using USB Keyboard
[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         OwnPtr<Ecore_IMF_Context> context = createIMFContext(canvas);
40         if (!context)
41             return nullptr;
42
43         return adoptPtr(new InputMethodContextEfl(viewImpl, context.release()));
44     }
45     ~InputMethodContextEfl();
46
47     void handleMouseUpEvent(const Evas_Event_Mouse_Up* upEvent);
48     void handleKeyDownEvent(const Evas_Event_Key_Down* downEvent, bool* isFiltered);
49     void updateTextInputState();
50
51 #if ENABLE(TIZEN_ISF_PORT)
52     void setUseInputMethod(bool);
53     bool isShow();
54     Ecore_IMF_Autocapital_Type autoCapitalType();
55     void onFocusIn();
56     void onFocusOut();
57     void resetIMFContext();
58     void hideIMFContext();
59     bool isIMEPostion(int, int);
60 #endif
61
62 private:
63     InputMethodContextEfl(EwkViewImpl*, PassOwnPtr<Ecore_IMF_Context>);
64
65     static PassOwnPtr<Ecore_IMF_Context> createIMFContext(Evas* canvas);
66     static void onIMFInputSequenceComplete(void* data, Ecore_IMF_Context*, void* eventInfo);
67     static void onIMFPreeditSequenceChanged(void* data, Ecore_IMF_Context*, void* eventInfo);
68
69 #if ENABLE(TIZEN_ISF_PORT)
70     void initializeIMFContext(Ecore_IMF_Context*, Ecore_IMF_Input_Panel_Layout);
71
72     static void onIMFInputPanelStateChanged(void*, Ecore_IMF_Context*, int);
73     static void onIMFInputPanelGeometryChanged(void*, Ecore_IMF_Context*, int);
74     static void onIMFCandidatePanelStateChanged(void*, Ecore_IMF_Context*, int);
75     static void onIMFCandidatePanelGeometryChanged(void*, Ecore_IMF_Context*, int);
76     static Eina_Bool onIMFRetrieveSurrounding(void*, Ecore_IMF_Context*, char**, int*);
77     static void onIMFDeleteSurrounding(void*, Ecore_IMF_Context*, void*);
78
79     void setType(const String&);
80     void revertIMFContext();
81     void destroyIMFContextList();
82     void setState(int state) { m_state = state; }
83     void setIMERect(const WebCore::IntRect& rect) { m_imeRect = rect; }
84
85 #if ENABLE(TIZEN_INPUT_TAG_EXTENSION)
86     void showInputPicker(Ewk_Input_Type, const EditorState&);
87 #endif
88 #endif
89
90     EwkViewImpl* m_viewImpl;
91     OwnPtr<Ecore_IMF_Context> m_context;
92     bool m_focused;
93
94 #if ENABLE(TIZEN_ISF_PORT)
95     HashMap<int, OwnPtr<Ecore_IMF_Context> > m_contextList;
96     bool m_useInputMethod;
97     int m_state;
98     WebCore::IntRect m_imeRect;
99 #endif
100 };
101
102 } // namespace WebKit
103
104 #endif // InputMethodContextEfl_h