DSZone: add getWindowList(), findWindow() to make a relationship between a shell... 10/241710/1
authorSung-Jin Park <sj76.park@samsung.com>
Fri, 31 Jul 2020 11:43:55 +0000 (20:43 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 10:05:09 +0000 (19:05 +0900)
Change-Id: I7ca938cde5e75a6d1253a30e2830c7885390cf23
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
src/DSZone/DSZone.cpp
src/DSZone/DSZone.h

index 3633131..4b41491 100644 (file)
@@ -2,6 +2,7 @@
 #include "DSWaylandCompositor.h"
 #include "DSWaylandSurface.h"
 #include "DSWaylandZxdgShellV6.h"
+#include "DSDebugLog.h"
 
 namespace display_server
 {
@@ -81,20 +82,38 @@ void DSZone::callCallbackWindowShellCreated()
        __windowShellCreatedSignal.emit(nullptr);
 }
 
-void DSZone::__onShellSurfaceCreated(std::shared_ptr<DSWaylandZxdgSurfaceV6> shellSurface)
+std::list<std::shared_ptr<DSWindow>> DSZone::getWindowList()
+{
+       return __windowList;
+}
+
+std::shared_ptr<DSWindow> DSZone::__findWindow(DSWaylandSurface *dswlSurface)
 {
-       DSWindow *window = nullptr;
+       std::list<std::shared_ptr<DSWindow>> wList = getWindowList();
+       for (auto w : wList)
+       {
+               if (w->surface() == dswlSurface)
+               {
+                       DSLOG_INF("DSZone", "Window found (win=%p, surface=%p)", w, dswlSurface);
+                       return w;
+               }
+       }
+
+       return nullptr;
+}
 
-       struct ::wl_resource *surface;
-       surface = shellSurface->getWlSurface();
+void DSZone::__onShellSurfaceCreated(std::shared_ptr<DSWaylandZxdgSurfaceV6> shellSurface)
+{
+       struct ::wl_resource *surface = shellSurface->getWlSurface();
+       DSWaylandSurface *dswlSurface = DSWaylandSurface::fromWlResource(surface);
 
-       // TODO: we need a function to find DSWindow
-       //window = __findWindow(surface);
+       std::shared_ptr<DSWindow> window = __findWindow(dswlSurface);
 
-       std::shared_ptr<DSWindowShell> shell = std::make_shared<DSWindowShell>(window);
+       std::shared_ptr<DSWindowShell> shell = std::make_shared<DSWindowShell>(window.get());
        __windowShellList.push_front(shell);
 
        // emit a signal of the shell created
        __windowShellCreatedSignal.emit(shell);
 }
+
 } //  namespace display_server
index 5bb7550..4a39c0a 100644 (file)
@@ -34,9 +34,12 @@ public:
        void callCallbackWindowCreated();
        void callCallbackWindowShellCreated();
 
+       std::list<std::shared_ptr<DSWindow>> getWindowList();
+
 private:
        void onSurfaceCreated(std::shared_ptr<DSWaylandSurface> waylandSurface);
        void __onShellSurfaceCreated(std::shared_ptr<DSWaylandZxdgSurfaceV6> shellSurface);
+       std::shared_ptr<DSWindow> __findWindow(DSWaylandSurface *dswlSurface);
 
        stPosition __position;
        stSize __size;