%description global-resource-devel
Development package for tizen global resource
+## libds-tizen-embedded-compositor
+%package embedded-compositor
+Summary: Library for tizen embedded compositor
+Group: Development/Libraries
+
+%description embedded-compositor
+Library for tizen embedded compositor
+
+%package embedded-compositor-devel
+Summary: Development package for tizen embedded compositor
+Group: Development/Libraries
+
+%description embedded-compositor-devel
+Development package for tizen embedded compositor
+
%prep
%setup -q
cp %{SOURCE1001} .
%{_libdir}/pkgconfig/libds-tizen-global-resource.pc
%{_libdir}/libds-tizen-global-resource.so
%{_bindir}/libds-tizen-global-resource-tests
+
+%files embedded-compositor
+%manifest %{name}.manifest
+%defattr(-,root,root,-)
+%license LICENSE
+%{_libdir}/libds-tizen-embedded-compositor.so.*
+
+%files embedded-compositor-devel
+%manifest %{name}.manifest
+%defattr(-,root,root,-)
+%license LICENSE
+%{_includedir}/libds-tizen/embedded_compositor.h
+%{_libdir}/pkgconfig/libds-tizen-embedded-compositor.pc
+%{_libdir}/libds-tizen-embedded-compositor.so
--- /dev/null
+#include <assert.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <wayland-server.h>
+#include <tizen-extension-server-protocol.h>
+#include <libds/log.h>
+
+#include "util.h"
+#include "libds-tizen/embedded_compositor.h"
+
+#define TIZEN_EMBEDDED_COMPOSITOR_VERSION 1
+
+struct ds_tizen_embedded_compositor
+{
+ struct wl_global *global;
+
+ struct wl_listener destroy;
+
+ struct {
+ struct wl_signal destroy;
+ } events;
+};
+
+struct ds_tizen_embedded_compositor_client
+{
+ struct ds_tizen_embedded_compositor *embedded_compositor;
+
+ struct wl_resource *resource;
+ struct wl_client *wl_client;
+};
+
+static void embedded_compositor_handle_display_destroy(struct wl_listener *listener,
+ void *data);
+
+static void embedded_compositor_bind(struct wl_client *wl_client, void *data,
+ uint32_t version, uint32_t id);
+
+WL_EXPORT struct ds_tizen_embedded_compositor *
+ds_tizen_embedded_compositor_create(struct wl_display *display)
+{
+ struct ds_tizen_embedded_compositor *embedded_compositor;
+
+ embedded_compositor = calloc(1, sizeof *embedded_compositor);
+ if (!embedded_compositor) {
+ ds_err("calloc() failed.");
+ return NULL;
+ }
+
+ embedded_compositor->global = wl_global_create(display, &tizen_embedded_compositor_interface,
+ TIZEN_EMBEDDED_COMPOSITOR_VERSION, embedded_compositor, embedded_compositor_bind);
+ if (!embedded_compositor->global) {
+ ds_err("wl_global_create() failed. tizen_embedded_compositor_interface");
+ free(embedded_compositor);
+ return NULL;
+ }
+
+ embedded_compositor->destroy.notify = embedded_compositor_handle_display_destroy;
+ wl_display_add_destroy_listener(display, &embedded_compositor->destroy);
+
+ wl_signal_init(&embedded_compositor->events.destroy);
+
+ ds_inf("Global created: tizen_embedded_compositor(%p)", embedded_compositor);
+
+ return embedded_compositor;
+}
+
+WL_EXPORT void
+ds_tizen_embedded_compositor_add_destroy_listener(
+ struct ds_tizen_embedded_compositor *embedded_compositor,
+ struct wl_listener *listener)
+{
+ wl_signal_add(&embedded_compositor->events.destroy, listener);
+}
+
+static void
+embedded_compositor_handle_display_destroy(struct wl_listener *listener, void *data)
+{
+ struct ds_tizen_embedded_compositor *embedded_compositor;
+
+ embedded_compositor = wl_container_of(listener, embedded_compositor, destroy);
+
+ ds_inf("Global destroy: embedded_compositor(%p)", embedded_compositor);
+
+ wl_signal_emit(&embedded_compositor->events.destroy, embedded_compositor);
+ wl_list_remove(&embedded_compositor->destroy.link);
+ wl_global_destroy(embedded_compositor->global);
+ free(embedded_compositor);
+}
+
+static void
+embedded_compositor_handle_get_socket(struct wl_client *wl_client,
+ struct wl_resource *resource)
+{
+ struct ds_tizen_embedded_compositor_client *client;
+ int sock_fd=-1;
+ pid_t pid = 0;
+
+ ds_inf("tizen_embedded_compositor: get_socket");
+
+ client = wl_resource_get_user_data(resource);
+
+ wl_client_get_credentials(client->wl_client, &pid, NULL, NULL);
+
+ sock_fd = socket(PF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0);
+ if (sock_fd < 0) {
+ ds_err("Could not create socket: %m, (client=%p, pid=%d)", client, pid);
+ return;
+ }
+
+ tizen_embedded_compositor_send_socket(resource, sock_fd);
+
+ ds_inf("tizen_embedded_compositor: (sock_fd,%d) sent! (client,%p) (pid,%d)",
+ sock_fd, client, pid);
+
+ close(sock_fd);
+}
+
+static void
+embedded_compositor_handle_destroy(struct wl_client *wl_client,
+ struct wl_resource *resource)
+{
+ wl_resource_destroy(resource);
+}
+
+static const struct tizen_embedded_compositor_interface embedded_compositor_impl =
+{
+ embedded_compositor_handle_get_socket,
+ embedded_compositor_handle_destroy,
+};
+
+static void
+_tizen_embedded_compositor_client_handle_destroy(struct wl_resource *resource)
+{
+ struct ds_tizen_embedded_compositor_client *client;
+
+ client = wl_resource_get_user_data(resource);
+
+ ds_inf("_tizen_embedded_compositor_client_handle_destroy (client:%p)", client);
+
+ free(client);
+}
+
+static void
+embedded_compositor_bind(struct wl_client *wl_client, void *data, uint32_t version,
+ uint32_t id)
+{
+ struct ds_tizen_embedded_compositor *embedded_compositor = data;
+ struct ds_tizen_embedded_compositor_client *client;
+
+ client = calloc(1, sizeof *client);
+ if (client == NULL) {
+ ds_err("calloc() failed. tizen_embedded_compositor");
+ wl_client_post_no_memory(wl_client);
+ return;
+ }
+
+ ds_inf("tizen_embedded_compositor_client binds. (client:%p)", client);
+
+ client->embedded_compositor = embedded_compositor;
+ client->wl_client = wl_client;
+
+ client->resource = wl_resource_create(wl_client,
+ &tizen_embedded_compositor_interface,
+ MIN(version, TIZEN_EMBEDDED_COMPOSITOR_VERSION), id);
+
+ if (client->resource == NULL) {
+ ds_err("tizen_embedded_compositor : wl_resource_create() failed.");
+ free(client);
+ wl_client_post_no_memory(wl_client);
+ return;
+ }
+
+ wl_resource_set_implementation(client->resource, &embedded_compositor_impl,
+ client, _tizen_embedded_compositor_client_handle_destroy);
+}
--- /dev/null
+libds_tizen_embedded_compositor_files = [
+ 'embedded_compositor.c',
+]
+
+libds_tizen_embedded_compositor_deps = [
+ deps_libds_tizen,
+ dependency('tizen-extension-server', required: true),
+]
+
+lib_libds_tizen_embedded_compositor = shared_library('ds-tizen-embedded-compositor', libds_tizen_embedded_compositor_files,
+ dependencies: libds_tizen_embedded_compositor_deps,
+ include_directories: [ common_inc, include_directories('.'), include_directories('..') ],
+ version: meson.project_version(),
+ install: true
+)
+
+deps_libds_tizen_embedded_compositor = declare_dependency(
+ link_with: lib_libds_tizen_embedded_compositor,
+ dependencies: libds_tizen_embedded_compositor_deps,
+ include_directories: [ common_inc, include_directories('.') ],
+)
+
+pkgconfig = import('pkgconfig')
+pkgconfig.generate(lib_libds_tizen_embedded_compositor,
+ version: meson.project_version(),
+ filebase: 'libds-tizen-embedded-compositor',
+ name: 'libds-tizen-embedded-compositor',
+ description: 'tizen memory flusher extension of libds-tizen for tizen platform',
+)