DSTextInput: add a API to get InputPanel's geometry 44/242344/1
authorjeon <jhyuni.kang@samsung.com>
Tue, 25 Aug 2020 07:52:37 +0000 (16:52 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Tue, 25 Aug 2020 12:41:10 +0000 (21:41 +0900)
Change-Id: If38af6096bc355d2540385ecb508ab39148eba78

src/DSTextInput/DSTextInput.cpp
src/DSTextInput/DSTextInputPrivate.h
src/DSWaylandServer/DSWaylandInputMethod.cpp
src/DSWaylandServer/DSWaylandInputPanel.cpp
src/DSWaylandServer/DSWaylandInputPanel.h
src/DSWaylandServer/DSWaylandInputPanelSurface.h
src/DSWaylandServer/DSWaylandInputPanelSurfacePrivate.h
tests/DSWaylandInputPanel-test.cpp
tests/DSWaylandInputPanelSurface-test.cpp

index 59d5c73..ada2e08 100644 (file)
@@ -290,6 +290,11 @@ void DSTextInputPrivate::changeInputPanelVisibility(bool visible)
        __wlInputPanel->changeVisibility(visible);
 }
 
+stGeometry DSTextInputPrivate::inputPanelGetGeometry(DSWaylandSurface *window)
+{
+       return __wlInputPanel->getSurfaceGeometry(window);
+}
+
 
 DSTextInput::DSTextInput()
   : DS_INIT_PRIVATE_PTR(DSTextInput)
index c187846..6796183 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <DSCore.h>
 #include <DSTextInput.h>
+#include <DSStruct.h>
 
 namespace display_server
 {
@@ -109,6 +110,7 @@ public:
        void updateInputPanelState(bool waitUpdate);
        void setInputPanelTransientFor(DSWaylandSurface *window);
        void changeInputPanelVisibility(bool visible);
+       stGeometry inputPanelGetGeometry(DSWaylandSurface *window);
 
 private:
        DSWaylandCompositor *__wlCompositor;
index fc79bf1..59a2f7f 100644 (file)
@@ -895,7 +895,11 @@ void DSWaylandInputMethod::contextUpdateCandidateState(unsigned int state)
                {
                        __dsTextInputPrivate->contextShowInputPanel();
                        int x = 0, y = 0, w = 0, h = 0;
-                       /* TODO: get gemetry from input panel */
+                       stGeometry geometry = __dsTextInputPrivate->inputPanelGetGeometry(nullptr);
+                       x = geometry.x;
+                       y = geometry.y;
+                       w = geometry.w;
+                       h = geometry.h;
                        __dsTextInputPrivate->contextUpdateIseGeometry(x, y, w, h);
                }
        }
index 82e2570..512130f 100644 (file)
@@ -244,6 +244,11 @@ DSWaylandInputPanelFloating* DSWaylandInputPanel::getFloatingData()
        return __inputPanelFloating;
 }
 
+stGeometry DSWaylandInputPanel::getSurfaceGeometry(DSWaylandSurface *wlSurface)
+{
+       return __inputPanelSurface->getGeometry(wlSurface);
+}
+
 void DSWaylandInputPanel::__onEventIdleEnterer(void *data)
 {
 }
@@ -452,6 +457,22 @@ void DSWaylandInputPanelSurfacePrivate::setFloatingPosition(int x, int y)
 #endif
 }
 
+stGeometry DSWaylandInputPanelSurfacePrivate::getGeometry(DSWaylandSurface *wlSurface)
+{
+       DSWindowManager *windowManager = DSWindowManager::getInstance();
+       stGeometry geometry = {0, };
+       for (auto it = __dataMap.begin();  it != __dataMap.end(); it++)
+       {
+               DSWaylandInputPanelSurfaceData *surfaceData = (*it).second;
+               if (!wlSurface || (wlSurface == surfaceData->getWlSurface()))
+               {
+                       return windowManager->getWindowGeometry(surfaceData->getWlSurface());
+               }
+       }
+       windowManager->releaseInstance();
+       return geometry;
+}
+
 void DSWaylandInputPanelSurfacePrivate::input_panel_surface_destroy_resource(Resource *resource)
 {
        auto it = __dataMap.find(resource);
@@ -610,6 +631,12 @@ void DSWaylandInputPanelSurface::setFloatingPosition(int x, int y)
        priv->setFloatingPosition(x, y);
 }
 
+stGeometry DSWaylandInputPanelSurface::getGeometry(DSWaylandSurface *wlSurface)
+{
+       DS_GET_PRIV(DSWaylandInputPanelSurface);
+
+       return priv->getGeometry(wlSurface);
+}
 
 }
 
index ab2f8bb..b2a81d0 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "DSCore.h"
 #include "DSObject.h"
+#include "DSStruct.h"
 #include "DSWaylandCompositor.h"
 #include "DSEventLoop.h"
 #include "DSTextInputPrivate.h"
@@ -60,6 +61,7 @@ public:
        bool isEffectRunning(DSWaylandSurface *window);
        void setFloatingPosition(int x, int y);
        DSWaylandInputPanelFloating *getFloatingData();
+       stGeometry getSurfaceGeometry(DSWaylandSurface *wlSurface);
 
 private:
        DSWaylandCompositor *__compositor;
index becea30..ca90872 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "DSCore.h"
 #include "DSObject.h"
+#include "DSStruct.h"
 #include "DSWaylandInputPanel.h"
 
 namespace display_server
@@ -49,6 +50,7 @@ public:
        bool isEffectRunning(DSWaylandSurface *window);
        void setPosition(DSWaylandSurface *window, int width, int height);
        void setFloatingPosition(int x, int y);
+       stGeometry getGeometry(DSWaylandSurface *wlSurface);
 
 protected:
 
index 03300df..6644229 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "DSCore.h"
 #include "DSObjectPrivate.h"
+#include "DSStruct.h"
 #include "DSWaylandInputPanelSurface.h"
 
 namespace display_server
@@ -51,6 +52,7 @@ public:
        void setTransientForSurface(DSWaylandSurface *parent);
        void updateSurfaceVisibility(bool visible);
        void setFloatingPosition(int x, int y);
+       stGeometry getGeometry(DSWaylandSurface *wlSurface);
 
 protected:
        void input_panel_surface_destroy_resource(Resource *resource);
index 85f9778..3e369b7 100644 (file)
@@ -180,3 +180,15 @@ TEST_F(DSWaylandInputPanelTest, GetFloatingData)
        DSWaylandCompositor::releaseInstance();
 }
 
+TEST_F(DSWaylandInputPanelTest, GetSurfaceGeometry)
+{
+       DSWaylandCompositor *comp = DSWaylandCompositor::getInstance();
+       DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp);
+       EXPECT_TRUE(inputPanel != nullptr);
+
+       inputPanel->getSurfaceGeometry(nullptr);
+
+       delete inputPanel;
+       DSWaylandCompositor::releaseInstance();
+}
+
index 763a8e1..c6ee3e1 100644 (file)
@@ -151,3 +151,17 @@ TEST_F(DSWaylandInputPanelSurfaceTest, SetFloatingPosition)
        DSWaylandCompositor::releaseInstance();
 }
 
+TEST_F(DSWaylandInputPanelSurfaceTest, GetGeometry)
+{
+       DSWaylandCompositor *comp = DSWaylandCompositor::getInstance();
+       DSWaylandInputPanel *inputPanel = new DSWaylandInputPanel(comp);
+       DSWaylandInputPanelSurface *inputPanelSurface = new DSWaylandInputPanelSurface(comp, inputPanel);
+       EXPECT_TRUE(inputPanelSurface != nullptr);
+
+       inputPanelSurface->getGeometry(nullptr);
+
+       delete inputPanelSurface;
+       delete inputPanel;
+       DSWaylandCompositor::releaseInstance();
+}
+