#include "DSWaylandCompositor.h"
#include "DSWaylandCompositorPrivate.h"
+#include "DSWaylandClient.h"
#include "DSDebugLog.h"
namespace display_server
_display = wl_display_create();
DS_ASSERT(_display != nullptr);
- //TODO : add listener for client creation using wl_display_add_client_created_listener()
- //TODO : leave log (log system needed)
- //TODO
+ m_clientCreatedListener.notify = DSWaylandCompositorPrivate::client_created_callback;
+ m_clientCreatedListener.parent = this;
+ wl_display_add_client_created_listener(_display, &m_clientCreatedListener);
}
DSWaylandCompositorPrivate::~DSWaylandCompositorPrivate()
{
//TODO : destroy all allocated resources
- //TODO : remove listener link (installed for checking client creation)
+
+ wl_list_remove(&m_clientCreatedListener.link);
_clients.clear();
_seats.clear();
ecore_shutdown();
}
+void DSWaylandCompositorPrivate::client_created_callback(struct ::wl_listener *listener, void *data)
+{
+ struct ::wl_client *wlClient = (struct ::wl_client *)data;
+ DS_ASSERT(wlClient != nullptr);
+
+ DSWaylandClient *client = nullptr;
+ DSWaylandCompositorPrivate *compPriv = reinterpret_cast<ClientCreatedListener *>(listener)->parent;
+
+ if (compPriv != nullptr)
+ {
+ client = new DSWaylandClient(compPriv->_compositor, wlClient);
+ DS_ASSERT(client != nullptr);
+
+ DSLOG_INF("DSWaylandCompositorPrivate", "Client created ! (pid:%d, uid:%d, gid:%d)",
+ client->pid(), client->uid(), client->gid());
+ }
+}
+
void DSWaylandCompositorPrivate::initSocket(std::string sName, std::string sDir)
{
std::string socketPath = std::move(sDir);
#include "DSCore.h"
#include "DSObjectPrivate.h"
#include "dswayland-server-wayland.h"
+#include "DSWaylandClient.h"
+#include "DSDebugLog.h"
+#include <wayland-server-core.h>
#include <Ecore.h>
namespace display_server
inline void addSeat(DSWaylandSeat *seat);
inline void removeSeat(DSWaylandSeat *seat);
- //TODO : add listener for client created event
- //TODO
+ static void client_created_callback(struct ::wl_listener *listener, void *data);
+ struct ClientCreatedListener : ::wl_listener {
+ DSWaylandCompositorPrivate *parent;
+ };
+ ClientCreatedListener m_clientCreatedListener;
protected:
//virtual Resource *compositor_allocate();
void DSWaylandCompositorPrivate::addClient(DSWaylandClient *client)
{
DS_ASSERT(client != nullptr);
-
+
//TODO : check if the client is in clients already ?
_clients.push_back(client);
+ DSLOG_INF("DSWaylandCompositorPrivate", "Client(%p, PID:%d) has been added.", client, client->pid());
}
void DSWaylandCompositorPrivate::removeClient(DSWaylandClient *client)
{
DS_ASSERT(client != nullptr);
-
+
//TODO : check if the client is in clients already ?
_clients.remove(client);
+ DSLOG_INF("DSWaylandCompositorPrivate", "Client(%p, PID:%d) has been removed.", client, client->pid());
}
void DSWaylandCompositorPrivate::addSeat(DSWaylandSeat *seat)