Skip to content

Commit

Permalink
Add Ime::TextService::onKeyboardStatusChanged() virtual function.
Browse files Browse the repository at this point in the history
  • Loading branch information
PCMan committed Sep 25, 2013
1 parent a3b15b2 commit 34d7b48
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 23 deletions.
47 changes: 24 additions & 23 deletions ChewingTextService/ChewingTextService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,33 +544,34 @@ void TextService::onCompartmentChanged(const GUID& key) {
applyConfig(); // apply the latest config
return;
}

Ime::TextService::onCompartmentChanged(key);
if(::IsEqualIID(key, GUID_COMPARTMENT_KEYBOARD_OPENCLOSE)) {
// keyboard open/close state is changed
bool opened = isKeyboardOpened();
if(opened) { // keyboard is closed
initChewingContext();
}
else { // keyboard is opened
if(isComposing()) {
// end current composition if needed
ITfContext* context = currentContext();
if(context) {
endComposition(context);
context->Release();
}
}

// called when the keyboard is opened or closed
// virtual
void TextService::onKeyboardStatusChanged(bool opened) {
Ime::TextService::onKeyboardStatusChanged(opened);
if(opened) { // keyboard is opened
initChewingContext();
}
else { // keyboard is closed
if(isComposing()) {
// end current composition if needed
ITfContext* context = currentContext();
if(context) {
endComposition(context);
context->Release();
}
if(showingCandidates()) // disable candidate window if it's opened
hideCandidates();
hideMessage(); // hide message window, if there's any
freeChewingContext(); // IME is closed, chewingContext is not needed
}

if(imeModeIcon_)
imeModeIcon_->setEnabled(opened);
// FIXME: should we also disable other language bar buttons as well?
if(showingCandidates()) // disable candidate window if it's opened
hideCandidates();
hideMessage(); // hide message window, if there's any
freeChewingContext(); // IME is closed, chewingContext is not needed
}

if(imeModeIcon_)
imeModeIcon_->setEnabled(opened);
// FIXME: should we also disable other language bar buttons as well?
}

void TextService::initChewingContext() {
Expand Down
3 changes: 3 additions & 0 deletions ChewingTextService/ChewingTextService.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class TextService: public Ime::TextService {
// called when a compartment value is changed
virtual void onCompartmentChanged(const GUID& key);

// called when the keyboard is opened or closed
virtual void onKeyboardStatusChanged(bool opened);

ChewingContext* chewingContext() {
return chewingContext_;
}
Expand Down
6 changes: 6 additions & 0 deletions libIME/TextService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,13 +535,19 @@ void TextService::onCompartmentChanged(const GUID& key) {
// http://blogs.msdn.com/b/tsfaware/archive/2007/05/30/what-is-a-keyboard.aspx
if(::IsEqualGUID(key, GUID_COMPARTMENT_KEYBOARD_OPENCLOSE)) {
isKeyboardOpened_ = threadCompartmentValue(key) ? true : false;
onKeyboardStatusChanged(isKeyboardOpened_);
}
}

// virtual
void TextService::onLangBarStatusChanged(int newStatus) {
}

// called when the keyboard is opened or closed
// virtual
void TextService::onKeyboardStatusChanged(bool opened) {
}

// COM stuff

// IUnknown
Expand Down
3 changes: 3 additions & 0 deletions libIME/TextService.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ class TextService:

virtual void onLangBarStatusChanged(int newStatus);

// called when the keyboard is opened or closed
virtual void onKeyboardStatusChanged(bool opened);

// COM related stuff
public:
friend class DisplayAttributeInfoEnum;
Expand Down

0 comments on commit 34d7b48

Please sign in to comment.