DSTextInput: add APIs to update InputPanel information to TextInput 45/242345/1
authorjeon <jhyuni.kang@samsung.com>
Tue, 25 Aug 2020 08:25:18 +0000 (17:25 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Tue, 25 Aug 2020 12:41:18 +0000 (21:41 +0900)
Change-Id: Ie667e30ea5b11762db7f71d45f649388f6c3e6f8

14 files changed:
src/DSTextInput/DSTextInput.cpp
src/DSTextInput/DSTextInputPrivate.h
src/DSWaylandServer/DSWaylandInputMethod.cpp
src/DSWaylandServer/DSWaylandInputMethod.h
src/DSWaylandServer/DSWaylandInputPanel.cpp
src/DSWaylandServer/DSWaylandInputPanel.h
src/DSWaylandServer/DSWaylandTextInput.cpp
src/DSWaylandServer/DSWaylandTextInput.h
src/DSWaylandServer/DSWaylandTextInputManager.h
src/DSWaylandServer/DSWaylandTextInputPrivate.h
tests/DSWaylandInputMethod-test.cpp
tests/DSWaylandInputPanel-test.cpp
tests/DSWaylandTextInput-test.cpp
tests/DSWaylandTextInputManager-test.cpp

index ada2e08..83e4eb7 100644 (file)
@@ -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)
 {
index 6796183..ae1199a 100644 (file)
@@ -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);
index 59a2f7f..cb279fa 100644 (file)
@@ -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);
+}
 
 }
index 6b66ec2..e4f9870 100644 (file)
@@ -91,6 +91,8 @@ public:
        void contextUpdateCandidateState(unsigned int state);
        void contextReshowInputPanel();
 
+       void setGeometryUpdated(bool updated);
+
 protected:
 
 private:
index 512130f..51ef817 100644 (file)
@@ -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)
                 * {
index b2a81d0..4217502 100644 (file)
@@ -62,6 +62,7 @@ public:
        void setFloatingPosition(int x, int y);
        DSWaylandInputPanelFloating *getFloatingData();
        stGeometry getSurfaceGeometry(DSWaylandSurface *wlSurface);
+       void updateTextInputPanelState(bool state);
 
 private:
        DSWaylandCompositor *__compositor;
index fdfc2dd..e062cb0 100644 (file)
@@ -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<DSWaylandTextInputPrivate>(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<DSWaylandTextInputPrivate>(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;
+}
 
 }
index 7648814..7f56414 100644 (file)
@@ -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;
 };
 
 }
index da94210..8523e10 100644 (file)
@@ -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:
index 2d168d6..bf9ef9d 100644 (file)
@@ -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);
index f3de95b..152b953 100644 (file)
@@ -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();
+}
+
index 3e369b7..7e9b421 100644 (file)
@@ -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();
+}
+
index 814f46a..0befd84 100644 (file)
@@ -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();
+}
+
index e6ab9c9..4f74e7f 100644 (file)
@@ -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();
+}
+