From: jeon Date: Tue, 25 Aug 2020 08:25:18 +0000 (+0900) Subject: DSTextInput: add APIs to update InputPanel information to TextInput X-Git-Tag: accepted/tizen/unified/20200827.105812~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4d92edc63b107922cdb12d13c2641a67753c02a1;p=platform%2Fcore%2Fuifw%2Flibds.git DSTextInput: add APIs to update InputPanel information to TextInput Change-Id: Ie667e30ea5b11762db7f71d45f649388f6c3e6f8 --- diff --git a/src/DSTextInput/DSTextInput.cpp b/src/DSTextInput/DSTextInput.cpp index ada2e08..83e4eb7 100644 --- a/src/DSTextInput/DSTextInput.cpp +++ b/src/DSTextInput/DSTextInput.cpp @@ -164,6 +164,16 @@ void DSTextInputPrivate::predictionHintData(std::string key, std::string value) __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) { diff --git a/src/DSTextInput/DSTextInputPrivate.h b/src/DSTextInput/DSTextInputPrivate.h index 6796183..ae1199a 100644 --- a/src/DSTextInput/DSTextInputPrivate.h +++ b/src/DSTextInput/DSTextInputPrivate.h @@ -81,6 +81,8 @@ public: 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); diff --git a/src/DSWaylandServer/DSWaylandInputMethod.cpp b/src/DSWaylandServer/DSWaylandInputMethod.cpp index 59a2f7f..cb279fa 100644 --- a/src/DSWaylandServer/DSWaylandInputMethod.cpp +++ b/src/DSWaylandServer/DSWaylandInputMethod.cpp @@ -286,6 +286,7 @@ void DSWaylandInputMethodContextPrivate::input_method_context_update_ise_geometr 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) @@ -910,5 +911,11 @@ void DSWaylandInputMethod::contextReshowInputPanel() /* TODO: update input panel */ } +void DSWaylandInputMethod::setGeometryUpdated(bool updated) +{ + if (!__dsTextInputPrivate) return; + + __dsTextInputPrivate->setGeometryUpdated(updated); +} } diff --git a/src/DSWaylandServer/DSWaylandInputMethod.h b/src/DSWaylandServer/DSWaylandInputMethod.h index 6b66ec2..e4f9870 100644 --- a/src/DSWaylandServer/DSWaylandInputMethod.h +++ b/src/DSWaylandServer/DSWaylandInputMethod.h @@ -91,6 +91,8 @@ public: void contextUpdateCandidateState(unsigned int state); void contextReshowInputPanel(); + void setGeometryUpdated(bool updated); + protected: private: diff --git a/src/DSWaylandServer/DSWaylandInputPanel.cpp b/src/DSWaylandServer/DSWaylandInputPanel.cpp index 512130f..51ef817 100644 --- a/src/DSWaylandServer/DSWaylandInputPanel.cpp +++ b/src/DSWaylandServer/DSWaylandInputPanel.cpp @@ -249,6 +249,13 @@ stGeometry DSWaylandInputPanel::getSurfaceGeometry(DSWaylandSurface *wlSurface) return __inputPanelSurface->getGeometry(wlSurface); } +void DSWaylandInputPanel::updateTextInputPanelState(bool state) +{ + if (!__dsTextInputPrivate) return; + + __dsTextInputPrivate->updateTextInputPanelState(state); +} + void DSWaylandInputPanel::__onEventIdleEnterer(void *data) { } @@ -325,7 +332,7 @@ void DSWaylandInputPanelSurfacePrivate::show(DSWaylandInputPanelSurfaceData *sur { pub->__inputPanel->setWaitUpdate(false); pub->__inputPanel->changeVisibility(true); - pub->__inputPanel->updateInputPanelState(true); // temporary code + pub->__inputPanel->updateTextInputPanelState(true); /* TODO: * if (getfocus(surfaceData->getWlSurface())->parent) * { diff --git a/src/DSWaylandServer/DSWaylandInputPanel.h b/src/DSWaylandServer/DSWaylandInputPanel.h index b2a81d0..4217502 100644 --- a/src/DSWaylandServer/DSWaylandInputPanel.h +++ b/src/DSWaylandServer/DSWaylandInputPanel.h @@ -62,6 +62,7 @@ public: void setFloatingPosition(int x, int y); DSWaylandInputPanelFloating *getFloatingData(); stGeometry getSurfaceGeometry(DSWaylandSurface *wlSurface); + void updateTextInputPanelState(bool state); private: DSWaylandCompositor *__compositor; diff --git a/src/DSWaylandServer/DSWaylandTextInput.cpp b/src/DSWaylandServer/DSWaylandTextInput.cpp index fdfc2dd..e062cb0 100644 --- a/src/DSWaylandServer/DSWaylandTextInput.cpp +++ b/src/DSWaylandServer/DSWaylandTextInput.cpp @@ -193,6 +193,16 @@ void DSWaylandTextInputManager::contextCommitContent(unsigned int serial, std::s __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), @@ -262,6 +272,8 @@ void DSWaylandTextInputPrivate::showInputPanel(void *resource) pub->__dsTextInputPrivate->setInputPanelState(DSTextInputPrivate::InputPanelStateWillShow); /* TODO: pub->__dsTextInputPrivate->setInputPanelTransientFor(getDSWindow(__activatedResource)); */ } + + pub->__geometryUpdated = false; } void DSWaylandTextInputPrivate::text_input_destroy(Resource *resource) @@ -839,12 +851,50 @@ void DSWaylandTextInputPrivate::sendCommitContent(unsigned int serial, std::stri 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(this, compositor)), __compositor(compositor), __textInputManager(textInputManager), - __dsTextInputPrivate(nullptr) + __dsTextInputPrivate(nullptr), + __geometryUpdated(false) { } @@ -852,7 +902,8 @@ DSWaylandTextInput::DSWaylandTextInput(DSWaylandCompositor *compositor, DSWaylan : DSObject(), _d_ptr(std::make_unique(this, compositor)), __compositor(compositor), __textInputManager(textInputManager), - __dsTextInputPrivate(dsTextInputPrivate) + __dsTextInputPrivate(dsTextInputPrivate), + __geometryUpdated(false) { } @@ -1044,5 +1095,16 @@ void DSWaylandTextInput::sendCommitContent(unsigned int serial, std::string cont 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; +} } diff --git a/src/DSWaylandServer/DSWaylandTextInput.h b/src/DSWaylandServer/DSWaylandTextInput.h index 7648814..7f56414 100644 --- a/src/DSWaylandServer/DSWaylandTextInput.h +++ b/src/DSWaylandServer/DSWaylandTextInput.h @@ -67,12 +67,16 @@ public: 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; }; } diff --git a/src/DSWaylandServer/DSWaylandTextInputManager.h b/src/DSWaylandServer/DSWaylandTextInputManager.h index da94210..8523e10 100644 --- a/src/DSWaylandServer/DSWaylandTextInputManager.h +++ b/src/DSWaylandServer/DSWaylandTextInputManager.h @@ -69,6 +69,9 @@ public: 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: diff --git a/src/DSWaylandServer/DSWaylandTextInputPrivate.h b/src/DSWaylandServer/DSWaylandTextInputPrivate.h index 2d168d6..bf9ef9d 100644 --- a/src/DSWaylandServer/DSWaylandTextInputPrivate.h +++ b/src/DSWaylandServer/DSWaylandTextInputPrivate.h @@ -33,6 +33,8 @@ namespace display_server { +class DSWaylandSurface; + class DS_DECL_EXPORT DSWaylandTextInputPrivate : public DSObjectPrivate, public DSWaylandServer::wl_text_input { DS_PIMPL_USE_PUBLIC(DSWaylandTextInput); @@ -65,6 +67,8 @@ public: 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); diff --git a/tests/DSWaylandInputMethod-test.cpp b/tests/DSWaylandInputMethod-test.cpp index f3de95b..152b953 100644 --- a/tests/DSWaylandInputMethod-test.cpp +++ b/tests/DSWaylandInputMethod-test.cpp @@ -640,3 +640,17 @@ TEST_F(DSWaylandInputMethodTest, ContextReshowInputPanel) 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(); +} + diff --git a/tests/DSWaylandInputPanel-test.cpp b/tests/DSWaylandInputPanel-test.cpp index 3e369b7..7e9b421 100644 --- a/tests/DSWaylandInputPanel-test.cpp +++ b/tests/DSWaylandInputPanel-test.cpp @@ -192,3 +192,15 @@ TEST_F(DSWaylandInputPanelTest, GetSurfaceGeometry) 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(); +} + diff --git a/tests/DSWaylandTextInput-test.cpp b/tests/DSWaylandTextInput-test.cpp index 814f46a..0befd84 100644 --- a/tests/DSWaylandTextInput-test.cpp +++ b/tests/DSWaylandTextInput-test.cpp @@ -361,3 +361,31 @@ TEST_F(DSWaylandTextInputTest, SendCommitContent) 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(); +} + diff --git a/tests/DSWaylandTextInputManager-test.cpp b/tests/DSWaylandTextInputManager-test.cpp index e6ab9c9..4f74e7f 100644 --- a/tests/DSWaylandTextInputManager-test.cpp +++ b/tests/DSWaylandTextInputManager-test.cpp @@ -314,3 +314,27 @@ TEST_F(DSWaylandTextInputManagerTest, ContextCommitContent) 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(); +} +