2 * Copyright © 2020 Samsung Electronics co., Ltd. All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 #ifndef __DS_WAYLAND_COMPOSITOR_H__
25 #define __DS_WAYLAND_COMPOSITOR_H__
34 namespace display_server
37 class DSWaylandClient;
39 class DSWaylandSurface;
40 class IDSWaylandShell;
41 class DSWaylandRegion;
43 class DSWaylandCompositorPrivate;
45 class DS_DECL_EXPORT DSWaylandCompositor : public DSObject
47 DS_PIMPL_USE_PRIVATE(DSWaylandCompositor);
49 static DSWaylandCompositor *getInstance();
50 static void releaseInstance();
55 void addClient(DSWaylandClient *client);
56 void removeClient(DSWaylandClient *client);
57 DSWaylandSeat *addSeat(uint32_t cap);
58 void removeSeat(DSWaylandSeat *seat);
60 std::string socketName();
61 struct ::wl_display *display();
62 uint32_t nextSerial();
63 uint32_t currentTime();
64 std::list<DSWaylandClient *> clients();
65 DSWaylandSeat *defaultSeat();
67 bool setShell(IDSWaylandShell *shell);
68 IDSWaylandShell *getShell(void);
70 DSWaylandSurface *getSurface(uint32_t id);
72 void sendSurfaceDestroy(DSWaylandSurface *dswSurface);
73 void regionDestroy(DSWaylandRegion *dswRegion);
76 void registerCallbackSurfaceCreated(DSObject *slot, std::function<void(std::shared_ptr<DSWaylandSurface>)> func);
77 void registerCallbackSurfaceDestroy(DSObject *slot, std::function<void(std::shared_ptr<DSWaylandSurface>)> func);
83 static std::mutex __mutex;
84 static DSWaylandCompositor *__comp;
85 static int __refCount;
87 DSWaylandCompositor() = delete;
88 ~DSWaylandCompositor();
89 DSWaylandCompositor(DSObject *parent);
90 DSWaylandCompositor& operator=(const DSWaylandCompositor&) = delete;
92 std::list<std::shared_ptr<DSWaylandSurface>> __surfaceList;
93 std::list<std::shared_ptr<DSWaylandRegion>> __regionList;
96 DSSignal<std::shared_ptr<DSWaylandSurface>> __surfaceCreatedSignal;
97 DSSignal<std::shared_ptr<DSWaylandSurface>> __surfaceDestroySignal;
102 #endif //__DS_WAYLAND_COMPOSITOR_H__