GtkInputMethodFilter.h [plain text]
#include "GRefPtrGtk.h"
#include <gdk/gdk.h>
#include <wtf/text/WTFString.h>
typedef struct _GtkIMContext GtkIMContext;
typedef struct _GtkWidget GtkWidget;
namespace WebCore {
class GtkInputMethodFilter {
public:
GtkInputMethodFilter();
~GtkInputMethodFilter();
bool filterKeyEvent(GdkEventKey*);
void notifyMouseButtonPress();
void notifyFocusedIn();
void notifyFocusedOut();
void resetContext();
void setEnabled(bool);
void handleCommit(const char* compositionString);
void handlePreeditChanged();
void handlePreeditStart();
void handlePreeditEnd();
void confirmComposition();
void cancelContextComposition();
void updatePreedit();
GtkIMContext* context() { return m_context.get(); }
protected:
enum ResultsToSend {
Preedit = 1 << 1,
Composition = 1 << 2,
PreeditAndComposition = Preedit + Composition
};
void setWidget(GtkWidget*);
virtual bool canEdit() = 0;
virtual bool sendSimpleKeyEvent(GdkEventKey*, WTF::String eventString = String()) = 0;
virtual bool sendKeyEventWithCompositionResults(GdkEventKey*, ResultsToSend = PreeditAndComposition) = 0;
virtual void confirmCompositionText(String composition) = 0;
virtual void confirmCurrentComposition() = 0;
virtual void cancelCurrentComposition() = 0;
virtual void setPreedit(String, int cursorOffset) = 0;
WTF::String m_confirmedComposition;
WTF::String m_preedit;
int m_cursorOffset;
private:
void sendCompositionAndPreeditWithFakeKeyEvents(ResultsToSend);
GRefPtr<GtkIMContext> m_context;
GtkWidget* m_widget;
bool m_enabled;
bool m_composingTextCurrently;
bool m_filteringKeyEvent;
bool m_preeditChanged;
bool m_preventNextCommit;
bool m_justSentFakeKeyUp;
unsigned int m_lastFilteredKeyPressCodeWithNoResults;
};
}