Skip to content

Commit

Permalink
remove needless preedit rect
Browse files Browse the repository at this point in the history
  • Loading branch information
Windmill-City committed Dec 27, 2023
1 parent a191687 commit ab0b32d
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 94 deletions.
2 changes: 1 addition & 1 deletion IngameIME-Common
13 changes: 0 additions & 13 deletions include/common/InputContextImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,5 @@

namespace IngameIME
{
struct InternalRect : public PreEditRect
{
InternalRect() = default;
InternalRect(const PreEditRect& rect);

/**
* @brief Implicit convert to RECT
*
* @return RECT
*/
operator RECT() noexcept;
};

std::string ToUTF8(std::wstring utf16);
} // namespace IngameIME
17 changes: 4 additions & 13 deletions include/imm/ImmInputContextImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ class InputContextImpl : public InputContext
{
protected:
static std::list<InputContextImpl*> ActiveContexts;
static LRESULT WndProc(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lparam);
static LRESULT WndProc(HWND hWnd, UINT msg, WPARAM wparam, LPARAM lparam);

protected:
HWND hWnd;
WNDPROC prevProc;

HIMC ctx;

bool activated{false};
PreEditRect rect;

public:
InputContextImpl(const HWND hWnd);
Expand All @@ -37,20 +34,14 @@ class InputContextImpl : public InputContext
* @brief Retrive Commit text for current Composition
*/
void procCommit();
/**
* @brief Set CandidateList window's position for current Composition
*/
void setPreEditRect(InternalRect& rect);
/**
* @brief Retrive CandidateList infomation for application to draw
*/
void procCand();

public:
virtual InputMode getInputMode() override;
virtual void setPreEditRect(const PreEditRect& rect) override;
virtual PreEditRect getPreEditRect() override;
virtual void setActivated(const bool activated) override;
virtual bool getActivated() const override;
virtual InputMode getInputMode() override;
virtual void setActivated(const bool activated) override;
virtual bool getActivated() const override;
};
} // namespace IngameIME::imm
10 changes: 3 additions & 7 deletions include/tf/TfInputContextImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,15 @@ class InputContextImpl : public InputContext
ComPtr<CompositionHandler> h_comp;
ComPtr<InputModeHandler> h_mode;

PreEditRect rect;

bool activated{false};

public:
InputContextImpl(const HWND hWnd);
~InputContextImpl();

public:
virtual InputMode getInputMode() override;
virtual void setPreEditRect(const PreEditRect& rect) override;
virtual PreEditRect getPreEditRect() override;
virtual void setActivated(const bool activated) override;
virtual bool getActivated() const override;
virtual InputMode getInputMode() override;
virtual void setActivated(const bool activated) override;
virtual bool getActivated() const override;
};
} // namespace IngameIME::tf
25 changes: 0 additions & 25 deletions src/ImmInputContextImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,31 +160,6 @@ InputMode InputContextImpl::getInputMode()
return InputMode::AlphaNumeric;
}

void InputContextImpl::setPreEditRect(const PreEditRect& _rect)
{
this->rect = _rect;
InternalRect rect = _rect;
CANDIDATEFORM cand;
cand.dwIndex = 0;
cand.dwStyle = CFS_EXCLUDE;
cand.ptCurrentPos.x = rect.x;
cand.ptCurrentPos.y = rect.y;
cand.rcArea = rect;
ImmSetCandidateWindow(ctx, &cand);

COMPOSITIONFORM comp;
comp.dwStyle = CFS_RECT;
comp.ptCurrentPos.x = rect.x;
comp.ptCurrentPos.y = rect.y;
comp.rcArea = rect;
ImmSetCompositionWindow(ctx, &comp);
}

PreEditRect InputContextImpl::getPreEditRect()
{
return this->rect;
}

void InputContextImpl::setActivated(const bool activated)
{
if (activated == this->activated) return;
Expand Down
20 changes: 0 additions & 20 deletions src/InputContextImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,6 @@

namespace IngameIME
{
InternalRect::operator RECT() noexcept
{
RECT rect;
rect.left = this->x;
rect.top = this->y;
rect.right = this->x + this->width;
rect.bottom = this->y + this->height;

return rect;
}

InternalRect::InternalRect(const PreEditRect& rect)
{
this->x = rect.x;
this->y = rect.y;
this->width = rect.width;
this->height = rect.height;
}

std::string ToUTF8(std::wstring utf16)
{
if (utf16.empty())
Expand All @@ -32,5 +13,4 @@ std::string ToUTF8(std::wstring utf16)
WideCharToMultiByte(CP_UTF8, 0, &utf16[0], (int)utf16.size(), &strTo[0], size_needed, NULL, NULL);
return strTo;
}

} // namespace IngameIME
6 changes: 1 addition & 5 deletions src/TfContextOwner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ HRESULT STDMETHODCALLTYPE ContextOwner::GetACPFromPoint(const POINT* ptScreen, D

HRESULT STDMETHODCALLTYPE ContextOwner::GetTextExt(LONG acpStart, LONG acpEnd, RECT* prc, BOOL* pfClipped)
{
InternalRect rect = inputCtx->getPreEditRect();
*prc = rect;
// Map window coordinate to screen coordinate
MapWindowPoints(inputCtx->hWnd, NULL, (LPPOINT)prc, 2);
return S_OK;
return TS_E_NOLAYOUT;
}

HRESULT STDMETHODCALLTYPE ContextOwner::GetScreenExt(RECT* prc)
Expand Down
10 changes: 0 additions & 10 deletions src/TfInputContextImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,6 @@ InputMode InputContextImpl::getInputMode()
return h_mode->inputMode;
}

void InputContextImpl::setPreEditRect(const PreEditRect& rect)
{
this->rect = rect;
}

PreEditRect InputContextImpl::getPreEditRect()
{
return rect;
}

void InputContextImpl::setActivated(const bool activated)
{
COM_HR_BEGIN(S_OK);
Expand Down

0 comments on commit ab0b32d

Please sign in to comment.