Skip to content

Commit

Permalink
Add basic skeleton for UILess mode support.
Browse files Browse the repository at this point in the history
  • Loading branch information
PCMan committed Oct 3, 2013
1 parent f2e0531 commit dec8b27
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libIME/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ add_library(libIME_static STATIC
${PROJECT_SOURCE_DIR}/DisplayAttributeInfoEnum.h
${PROJECT_SOURCE_DIR}/DisplayAttributeProvider.cpp
${PROJECT_SOURCE_DIR}/DisplayAttributeProvider.h
${PROJECT_SOURCE_DIR}/CandidateListUIElement.h
${PROJECT_SOURCE_DIR}/CandidateListUIElement.cpp
${PROJECT_SOURCE_DIR}/LangBarButton.cpp
${PROJECT_SOURCE_DIR}/LangBarButton.h
${PROJECT_SOURCE_DIR}/Utils.cpp
Expand Down
97 changes: 97 additions & 0 deletions libIME/CandidateListUIElement.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#include "CandidateListUIElement.h"
#include <assert.h>

namespace Ime {

CandidateListUIElement::CandidateListUIElement(ITfContext* context):
context_(context),
refCount_(1) {
}

CandidateListUIElement::~CandidateListUIElement(void) {
}

// COM stuff

// IUnknown
STDMETHODIMP CandidateListUIElement::QueryInterface(REFIID riid, void **ppvObj) {
if (ppvObj == NULL)
return E_INVALIDARG;

if(IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_ITfCandidateListUIElement))
*ppvObj = (ITfCandidateListUIElement*)this;
else
*ppvObj = NULL;

if(*ppvObj) {
AddRef();
return S_OK;
}
return E_NOINTERFACE;
}

STDMETHODIMP_(ULONG) CandidateListUIElement::AddRef(void) {
return ++refCount_;
}

STDMETHODIMP_(ULONG) CandidateListUIElement::Release(void) {
assert(refCount_ > 0);
--refCount_;
if(0 == refCount_)
delete this;
return refCount_;
}

// ITfUIElement
STDMETHODIMP CandidateListUIElement::GetDescription(BSTR *pbstrDescription) {
return S_OK;
}

STDMETHODIMP CandidateListUIElement::GetGUID(GUID *pguid) {
return S_OK;
}

STDMETHODIMP CandidateListUIElement::Show(BOOL bShow) {
return S_OK;
}

STDMETHODIMP CandidateListUIElement::IsShown(BOOL *pbShow) {
return S_OK;
}

// ITfCandidateListUIElement
STDMETHODIMP CandidateListUIElement::GetUpdatedFlags(DWORD *pdwFlags) {
return S_OK;
}

STDMETHODIMP CandidateListUIElement::GetDocumentMgr(ITfDocumentMgr **ppdim) {
if(!context_)
return E_FAIL;
return context_->GetDocumentMgr(ppdim);
}

STDMETHODIMP CandidateListUIElement::GetCount(UINT *puCount) {
return S_OK;
}

STDMETHODIMP CandidateListUIElement::GetSelection(UINT *puIndex) {
return S_OK;
}

STDMETHODIMP CandidateListUIElement::GetString(UINT uIndex, BSTR *pstr) {
return S_OK;
}

STDMETHODIMP CandidateListUIElement::GetPageIndex(UINT *pIndex, UINT uSize, UINT *puPageCnt) {
return S_OK;
}

STDMETHODIMP CandidateListUIElement::SetPageIndex(UINT *pIndex, UINT uPageCnt) {
return S_OK;
}

STDMETHODIMP CandidateListUIElement::GetCurrentPage(UINT *puPage) {
return S_OK;
}

}
47 changes: 47 additions & 0 deletions libIME/CandidateListUIElement.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once
#ifndef IME_CANDIDATE_LIST_UI_ELEMENT
#define IME_CANDIDATE_LIST_UI_ELEMENT

#include <msctf.h>
#include "ComPtr.h"

namespace Ime {

class CandidateListUIElement:
public ITfUIElement,
public ITfCandidateListUIElement {
public:
CandidateListUIElement(ITfContext* context);
virtual ~CandidateListUIElement(void);

// COM related stuff

// IUnknown
STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);

// ITfUIElement
STDMETHODIMP GetDescription(BSTR *pbstrDescription);
STDMETHODIMP GetGUID(GUID *pguid);
STDMETHODIMP Show(BOOL bShow);
STDMETHODIMP IsShown(BOOL *pbShow);

// ITfCandidateListUIElement
STDMETHODIMP GetUpdatedFlags(DWORD *pdwFlags);
STDMETHODIMP GetDocumentMgr(ITfDocumentMgr **ppdim);
STDMETHODIMP GetCount(UINT *puCount);
STDMETHODIMP GetSelection(UINT *puIndex);
STDMETHODIMP GetString(UINT uIndex, BSTR *pstr);
STDMETHODIMP GetPageIndex(UINT *pIndex, UINT uSize, UINT *puPageCnt);
STDMETHODIMP SetPageIndex(UINT *pIndex, UINT uPageCnt);
STDMETHODIMP GetCurrentPage(UINT *puPage);

private:
ComPtr<ITfContext> context_;
int refCount_;
};

}

#endif
15 changes: 15 additions & 0 deletions libIME/TextService.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ class TextService:
return (activateFlags_ & TF_TMF_IMMERSIVEMODE) != 0;
}

// alias of isImmersive()
bool isMetroApp() const {
return isImmersive();
}

// UI less mode is enabled (for ex: in fullscreen games)
bool isUiLess() const {
return (activateFlags_ & TF_TMF_UIELEMENTENABLEDONLY) != 0;
}

// is in console mode
bool isConsole() const {
return (activateFlags_ & TF_TMF_CONSOLE) != 0;
}

DWORD langBarStatus() const;

// language bar buttons
Expand Down

0 comments on commit dec8b27

Please sign in to comment.