__wlInputMethod->predictionHintData(key, value);
}
+void DSTextInputPrivate::updateTextInputPanelState(bool state)
+{
+ __wlTextInputManager->updateTextInputPanelState(state);
+}
+
+void DSTextInputPrivate::setGeometryUpdated(bool updated)
+{
+ __wlTextInputManager->setGeometryUpdated(updated);
+}
+
void DSTextInputPrivate::contextCommitString(unsigned int serial, std::string text)
{
void setMimeType(std::string type);
void finalizeContent(std::string text, unsigned int cursorPosition);
void predictionHintData(std::string key, std::string value);
+ void updateTextInputPanelState(bool state);
+ void setGeometryUpdated(bool updated);
/* DSWaylandInputMethodContext request */
void contextCommitString(unsigned int serial, std::string text);
DS_GET_PUB(DSWaylandInputMethodContext);
pub->__inputMethod->contextUpdateIseGeometry(serial, x, y, width, height);
+ pub->__inputMethod->setGeometryUpdated(true);
}
void DSWaylandInputMethodContextPrivate::input_method_context_recapture_string(Resource *resource, uint32_t serial, int32_t index, uint32_t length, const std::string &preedit, const std::string &preedit_commit, const std::string &commit)
/* TODO: update input panel */
}
+void DSWaylandInputMethod::setGeometryUpdated(bool updated)
+{
+ if (!__dsTextInputPrivate) return;
+
+ __dsTextInputPrivate->setGeometryUpdated(updated);
+}
}
void contextUpdateCandidateState(unsigned int state);
void contextReshowInputPanel();
+ void setGeometryUpdated(bool updated);
+
protected:
private:
return __inputPanelSurface->getGeometry(wlSurface);
}
+void DSWaylandInputPanel::updateTextInputPanelState(bool state)
+{
+ if (!__dsTextInputPrivate) return;
+
+ __dsTextInputPrivate->updateTextInputPanelState(state);
+}
+
void DSWaylandInputPanel::__onEventIdleEnterer(void *data)
{
}
{
pub->__inputPanel->setWaitUpdate(false);
pub->__inputPanel->changeVisibility(true);
- pub->__inputPanel->updateInputPanelState(true); // temporary code
+ pub->__inputPanel->updateTextInputPanelState(true);
/* TODO:
* if (getfocus(surfaceData->getWlSurface())->parent)
* {
void setFloatingPosition(int x, int y);
DSWaylandInputPanelFloating *getFloatingData();
stGeometry getSurfaceGeometry(DSWaylandSurface *wlSurface);
+ void updateTextInputPanelState(bool state);
private:
DSWaylandCompositor *__compositor;
__textInput->sendCommitContent(serial, content, description, mimeTypes);
}
+void DSWaylandTextInputManager::updateTextInputPanelState(bool state)
+{
+ __textInput->updatePanelState(state);
+}
+
+void DSWaylandTextInputManager::setGeometryUpdated(bool updated)
+{
+ __textInput->setGeometryUpdated(updated);
+}
+
DSWaylandTextInputPrivate::DSWaylandTextInputPrivate(DSWaylandTextInput *p_ptr, DSWaylandCompositor *compositor)
: DSObjectPrivate(p_ptr),
pub->__dsTextInputPrivate->setInputPanelState(DSTextInputPrivate::InputPanelStateWillShow);
/* TODO: pub->__dsTextInputPrivate->setInputPanelTransientFor(getDSWindow(__activatedResource)); */
}
+
+ pub->__geometryUpdated = false;
}
void DSWaylandTextInputPrivate::text_input_destroy(Resource *resource)
send_commit_content(__activatedResource->handle, serial, content, description, mimeTypes);
}
+void DSWaylandTextInputPrivate::updatePanelState(bool state)
+{
+ DS_GET_PUB(DSWaylandTextInput);
+
+ if (!__activatedResource)
+ {
+ DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource");
+ return;
+ }
+
+ if (!pub->__geometryUpdated)
+ {
+ stGeometry geo = pub->__dsTextInputPrivate->inputPanelGetGeometry(nullptr);
+ if (!(geo.w <= 1 || geo.h <= 1))
+ pub->sendInputPanelGeometry(geo.x, geo.y, geo.w, geo.h);
+ pub->__geometryUpdated = true;
+ }
+
+ unsigned int inputPanelState = WL_TEXT_INPUT_INPUT_PANEL_STATE_HIDE;
+ if (state) inputPanelState = WL_TEXT_INPUT_INPUT_PANEL_STATE_SHOW;
+
+ send_input_panel_state(__activatedResource->handle, inputPanelState);
+}
+
+void DSWaylandTextInputPrivate::updatePanelGeometry(DSWaylandSurface *wlSurface)
+{
+ DS_GET_PUB(DSWaylandTextInput);
+ if ((pub->__dsTextInputPrivate->getInputPanelState() != DSTextInputPrivate::InputPanelStateWillHide) &&
+ (pub->__dsTextInputPrivate->getInputPanelState() != DSTextInputPrivate::InputPanelStateDidHide) &&
+ (pub->__geometryUpdated))
+ {
+ stGeometry geo = pub->__dsTextInputPrivate->inputPanelGetGeometry(nullptr);
+ if (!(geo.w <= 1 || geo.h <= 1))
+ pub->sendInputPanelGeometry(geo.x, geo.y, geo.w, geo.h);
+ }
+}
+
DSWaylandTextInput::DSWaylandTextInput(DSWaylandCompositor *compositor, DSWaylandTextInputManager *textInputManager)
: DSObject(), _d_ptr(std::make_unique<DSWaylandTextInputPrivate>(this, compositor)),
__compositor(compositor),
__textInputManager(textInputManager),
- __dsTextInputPrivate(nullptr)
+ __dsTextInputPrivate(nullptr),
+ __geometryUpdated(false)
{
}
: DSObject(), _d_ptr(std::make_unique<DSWaylandTextInputPrivate>(this, compositor)),
__compositor(compositor),
__textInputManager(textInputManager),
- __dsTextInputPrivate(dsTextInputPrivate)
+ __dsTextInputPrivate(dsTextInputPrivate),
+ __geometryUpdated(false)
{
}
priv->sendCommitContent(serial, content, description, mimeTypes);
}
+void DSWaylandTextInput::updatePanelState(bool state)
+{
+ DS_GET_PRIV(DSWaylandTextInput);
+
+ priv->updatePanelState(state);
+}
+
+void DSWaylandTextInput::setGeometryUpdated(bool updated)
+{
+ __geometryUpdated = updated;
+}
}
void sendInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value);
void sendCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes);
+ void updatePanelState(bool state);
+ void setGeometryUpdated(bool updated);
+
protected:
private:
DSWaylandCompositor *__compositor;
DSWaylandTextInputManager *__textInputManager;
DSTextInputPrivate *__dsTextInputPrivate;
+ bool __geometryUpdated;
};
}
void contextInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value);
void contextCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes);
+ void updateTextInputPanelState(bool state);
+ void setGeometryUpdated(bool updated);
+
protected:
private:
namespace display_server
{
+class DSWaylandSurface;
+
class DS_DECL_EXPORT DSWaylandTextInputPrivate : public DSObjectPrivate, public DSWaylandServer::wl_text_input
{
DS_PIMPL_USE_PUBLIC(DSWaylandTextInput);
void sendRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit);
void sendInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value);
void sendCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes);
+ void updatePanelState(bool state);
+ void updatePanelGeometry(DSWaylandSurface *wlSurface);
protected:
void text_input_destroy(Resource *resource);
DSWaylandCompositor::releaseInstance();
}
+TEST_F(DSWaylandInputMethodTest, SetGeometryUpdated)
+{
+ DSWaylandCompositor *comp = DSWaylandCompositor::getInstance();
+ DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp);
+ EXPECT_TRUE(inputMethod != nullptr);
+
+ inputMethod->activate(0);
+ inputMethod->setGeometryUpdated(true);
+ inputMethod->deactivate();
+
+ delete inputMethod;
+ DSWaylandCompositor::releaseInstance();
+}
+
DSWaylandCompositor::releaseInstance();
}
+TEST_F(DSWaylandInputPanelTest, UpdateTextInputPanelState)
+{
+ DSWaylandCompositor *comp = DSWaylandCompositor::getInstance();
+ DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp);
+ EXPECT_TRUE(inputPanel != nullptr);
+
+ inputPanel->updateTextInputPanelState(true);
+
+ delete inputPanel;
+ DSWaylandCompositor::releaseInstance();
+}
+
DSWaylandCompositor::releaseInstance();
}
+TEST_F(DSWaylandTextInputTest, UpdatePanelState)
+{
+ DSWaylandCompositor *comp = DSWaylandCompositor::getInstance();
+ DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp);
+ DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager);
+ EXPECT_TRUE(textInput != nullptr);
+
+ textInput->updatePanelState(true);
+
+ delete textInput;
+ delete textInputManager;
+ DSWaylandCompositor::releaseInstance();
+}
+
+TEST_F(DSWaylandTextInputTest, SetGeometryUpdated)
+{
+ DSWaylandCompositor *comp = DSWaylandCompositor::getInstance();
+ DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp);
+ DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager);
+ EXPECT_TRUE(textInput != nullptr);
+
+ textInput->setGeometryUpdated(true);
+
+ delete textInput;
+ delete textInputManager;
+ DSWaylandCompositor::releaseInstance();
+}
+
DSWaylandCompositor::releaseInstance();
}
+TEST_F(DSWaylandTextInputManagerTest, UpdateTextInputPanelState)
+{
+ DSWaylandCompositor *comp = DSWaylandCompositor::getInstance();
+ DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp);
+ EXPECT_TRUE(textInputManager != nullptr);
+
+ textInputManager->updateTextInputPanelState(true);
+
+ delete textInputManager;
+ DSWaylandCompositor::releaseInstance();
+}
+
+TEST_F(DSWaylandTextInputManagerTest, SetGeometryUpdated)
+{
+ DSWaylandCompositor *comp = DSWaylandCompositor::getInstance();
+ DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp);
+ EXPECT_TRUE(textInputManager != nullptr);
+
+ textInputManager->setGeometryUpdated(true);
+
+ delete textInputManager;
+ DSWaylandCompositor::releaseInstance();
+}
+