DSWaylandRegion: add skeleton codes for create wl_region 11/241911/1 accepted/tizen/unified/20200826.133051 submit/tizen/20200821.011208
authorjeon <jhyuni.kang@samsung.com>
Thu, 20 Aug 2020 09:35:17 +0000 (18:35 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 23:58:56 +0000 (08:58 +0900)
Change-Id: I7d1c55392df451612ea667f6b44ed80d234f0e73

src/DSWaylandServer/DSWaylandCompositor.cpp
src/DSWaylandServer/DSWaylandCompositor.h
src/DSWaylandServer/DSWaylandRegion.cpp [new file with mode: 0644]
src/DSWaylandServer/DSWaylandRegion.h [new file with mode: 0644]
src/DSWaylandServer/DSWaylandRegionPrivate.h [new file with mode: 0644]
src/meson.build

index 233b8c5..9f823ee 100644 (file)
@@ -27,6 +27,7 @@
 #include "DSWaylandClient.h"
 #include "DSWaylandSeat.h"
 #include "DSWaylandSurface.h"
+#include "DSWaylandRegion.h"
 #include "DSDebugLog.h"
 
 namespace display_server
@@ -275,7 +276,12 @@ void DSWaylandCompositorPrivate::compositor_create_surface(wl_compositor::Resour
 
 void DSWaylandCompositorPrivate::compositor_create_region(wl_compositor::Resource *resource, uint32_t id)
 {
-       //TODO
+       DS_GET_PUB(DSWaylandCompositor);
+
+       DSWaylandClient *waylandClient = DSWaylandClient::fromWlClient(resource->client());
+       auto waylandRegion = std::make_shared<DSWaylandRegion>(waylandClient, id);
+
+       pub->__regionList.push_front(waylandRegion);
 }
 
 /* Begin Public Class Implementation */
@@ -508,6 +514,18 @@ void DSWaylandCompositor::sendSurfaceDestroy(DSWaylandSurface *dswSurface)
        }
 }
 
+void DSWaylandCompositor::regionDestroy(DSWaylandRegion *dswRegion)
+{
+       for (auto s : __regionList)
+       {
+               if (s.get() == dswRegion)
+               {
+                       __regionList.remove(s);
+                       break;
+               }
+       }
+}
+
 void DSWaylandCompositor::registerCallbackSurfaceCreated(DSObject *slot, std::function<void(std::shared_ptr<DSWaylandSurface>)> func)
 {
        this->__surfaceCreatedSignal.connect(slot, func);
index 4de11dc..c8ae82f 100644 (file)
@@ -38,6 +38,7 @@ class DSWaylandClient;
 class DSWaylandSeat;
 class DSWaylandSurface;
 class IDSWaylandShell;
+class DSWaylandRegion;
 
 class DSWaylandCompositorPrivate;
 
@@ -67,6 +68,7 @@ public:
        IDSWaylandShell *getShell(void);
 
        void sendSurfaceDestroy(DSWaylandSurface *dswSurface);
+       void regionDestroy(DSWaylandRegion *dswRegion);
 
        // Callback methods
        void registerCallbackSurfaceCreated(DSObject *slot, std::function<void(std::shared_ptr<DSWaylandSurface>)> func);
@@ -86,6 +88,7 @@ private:
        DSWaylandCompositor& operator=(const DSWaylandCompositor&) = delete;
 
        std::list<std::shared_ptr<DSWaylandSurface>> __surfaceList;
+       std::list<std::shared_ptr<DSWaylandRegion>> __regionList;
 
        // signals
        DSSignal<std::shared_ptr<DSWaylandSurface>> __surfaceCreatedSignal;
diff --git a/src/DSWaylandServer/DSWaylandRegion.cpp b/src/DSWaylandServer/DSWaylandRegion.cpp
new file mode 100644 (file)
index 0000000..19d3231
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#include "DSWaylandRegion.h"
+#include "DSWaylandRegionPrivate.h"
+#include "DSWaylandCompositor.h"
+
+namespace display_server
+{
+
+/* DSWaylandRegionPrivate */
+DSWaylandRegionPrivate::DSWaylandRegionPrivate(DSWaylandRegion *p_ptr)
+       : DSObjectPrivate(p_ptr),
+         __p_ptr(p_ptr)
+{}
+
+DSWaylandRegionPrivate::DSWaylandRegionPrivate(DSWaylandRegion *p_ptr, DSWaylandClient *waylandClient, uint32_t id)
+       : DSObjectPrivate(p_ptr),
+         __p_ptr(p_ptr)
+{
+       if (id > 0)
+       {
+               init(waylandClient->wlClient(), (int)id, 1);
+       }
+}
+
+DSWaylandRegionPrivate::~DSWaylandRegionPrivate()
+{}
+
+void DSWaylandRegionPrivate::region_bind_resource(Resource *resource)
+{
+}
+
+void DSWaylandRegionPrivate::region_destroy_resource(Resource *resource)
+{
+       DS_GET_PUB(DSWaylandRegion);
+
+       DSWaylandCompositor *dswCompositor = DSWaylandCompositor::getInstance();
+       if (dswCompositor)
+       {
+               dswCompositor->regionDestroy(pub);
+       }
+       DSWaylandCompositor::releaseInstance();
+}
+
+void DSWaylandRegionPrivate::region_destroy(Resource *resource)
+{
+}
+
+void DSWaylandRegionPrivate::region_add(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
+{
+}
+
+void DSWaylandRegionPrivate::region_subtract(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height)
+{
+}
+
+DS_WAYLAND_IMPL_FROM_RESOURCE(DSWaylandRegion);
+
+
+DSWaylandRegion::DSWaylandRegion()
+    : DS_INIT_PRIVATE_PTR(DSWaylandRegion)
+{}
+
+DSWaylandRegion::DSWaylandRegion(DSWaylandClient *waylandClient, uint32_t id)
+    : _d_ptr(std::make_unique<DSWaylandRegionPrivate>(this, waylandClient, id))
+{}
+
+DSWaylandRegion::~DSWaylandRegion()
+{}
+
+struct ::wl_resource *DSWaylandRegion::getWlResource()
+{
+       DS_GET_PRIV(DSWaylandRegion);
+
+       return priv->resource()->handle;
+}
+
+bool DSWaylandRegion::hasResource()
+{
+       DS_GET_PRIV(DSWaylandRegion);
+
+       if (priv->resource())
+               return true;
+       return false;
+}
+
+} /* namespace display_server */
diff --git a/src/DSWaylandServer/DSWaylandRegion.h b/src/DSWaylandServer/DSWaylandRegion.h
new file mode 100644 (file)
index 0000000..996b583
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __DS_WAYLAND_REGION_H__
+#define __DS_WAYLAND_REGION_H__
+
+#include "DSCore.h"
+#include "DSObject.h"
+#include "DSStruct.h"
+#include "DSWaylandClient.h"
+
+struct wl_resource;
+
+namespace display_server
+{
+
+class DSWaylandRegionPrivate;
+
+class DSWaylandRegion : public DSObject
+{
+       DS_PIMPL_USE_PRIVATE(DSWaylandRegion);
+       DS_WAYLAND_DEFINE_FROM_RESOURCE(DSWaylandRegion);
+public:
+       DSWaylandRegion();
+       DSWaylandRegion(DSWaylandClient *waylandClient, uint32_t id);
+       virtual ~DSWaylandRegion();
+
+       struct ::wl_resource *getWlResource();
+       bool hasResource();
+
+private:
+
+};
+
+} /* namespace display_server */
+
+#endif /* _DS_WAYLAND_REGION_H_ */
diff --git a/src/DSWaylandServer/DSWaylandRegionPrivate.h b/src/DSWaylandServer/DSWaylandRegionPrivate.h
new file mode 100644 (file)
index 0000000..d2d6338
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+* Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and associated documentation files (the "Software"),
+* to deal in the Software without restriction, including without limitation
+* the rights to use, copy, modify, merge, publish, distribute, sublicense,
+* and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice (including the next
+* paragraph) shall be included in all copies or substantial portions of the
+* Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+* DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __DS_WAYLAND_REGION_PRIVATE_H__
+#define __DS_WAYLAND_REGION_PRIVATE_H__
+
+#include "dswayland-server-wayland.h"
+#include "DSWaylandRegion.h"
+
+namespace display_server
+{
+
+class DSWaylandRegion;
+
+class DSWaylandRegionPrivate : public DSObjectPrivate, public DSWaylandServer::wl_region
+{
+DS_PIMPL_USE_PUBLIC(DSWaylandRegion);
+public:
+       DSWaylandRegionPrivate() = delete;
+       DSWaylandRegionPrivate(DSWaylandRegion *p_ptr);
+       DSWaylandRegionPrivate(DSWaylandRegion *p_ptr, DSWaylandClient *waylandClient, uint32_t id);
+       ~DSWaylandRegionPrivate() override;
+
+protected:
+       void region_bind_resource(Resource *resource);
+       void region_destroy_resource(Resource *resource);
+
+       void region_destroy(Resource *resource);
+       void region_add(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height);
+       void region_subtract(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height);
+
+private:
+};
+
+} /*namespace display_server */
+
+#endif /* _DS_WAYLAND_REGION_PRIVATE_H_ */
index 53a0f9e..61eaa73 100644 (file)
@@ -104,6 +104,9 @@ libds_wayland_srcs = [
        'DSWaylandServer/DSWaylandSurface.cpp',
        'DSWaylandServer/DSWaylandSurface.h',
        'DSWaylandServer/DSWaylandSurfacePrivate.h',
+       'DSWaylandServer/DSWaylandRegion.cpp',
+       'DSWaylandServer/DSWaylandRegion.h',
+       'DSWaylandServer/DSWaylandRegionPrivate.h',
        'DSWaylandServer/DSWaylandTizenInputDevice.h',
        'DSWaylandServer/DSWaylandTizenInputDevicePrivate.h',
        'DSWaylandServer/DSWaylandTizenInputDeviceManager.cpp',