From 17e22931b61836f3d4e6f829d0eb92346de638a8 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Wed, 26 Oct 2022 16:04:21 +0900 Subject: [PATCH 01/16] implement ds_tizen_remote_surface This is the server implementation for tizen_remote_surface protocol. Change-Id: I96bfae99814b9ac9331f510c5f378ed2a5c56c7e --- include/libds-tizen/remote_surface.h | 317 ++++++++ packaging/libds-tizen.spec | 32 + src/meson.build | 1 + src/remote_surface/meson.build | 30 + src/remote_surface/remote_surface.c | 1309 ++++++++++++++++++++++++++++++++++ tests/meson.build | 19 + tests/mockclient.cpp | 5 + tests/mockclient.h | 1 + tests/tc_remote_surface.cpp | 815 +++++++++++++++++++++ 9 files changed, 2529 insertions(+) create mode 100644 include/libds-tizen/remote_surface.h create mode 100644 src/remote_surface/meson.build create mode 100644 src/remote_surface/remote_surface.c create mode 100644 tests/tc_remote_surface.cpp diff --git a/include/libds-tizen/remote_surface.h b/include/libds-tizen/remote_surface.h new file mode 100644 index 0000000..7e8cf2c --- /dev/null +++ b/include/libds-tizen/remote_surface.h @@ -0,0 +1,317 @@ +#ifndef LIBDS_TIZEN_REMOTE_SURFACE_H +#define LIBDS_TIZEN_REMOTE_SURFACE_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +enum ds_tizen_remote_surface_visibility_type { + DS_TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_INVISIBLE = 0, + DS_TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_VISIBLE = 1, +}; + +enum ds_tizen_remote_surface_input_event_type { + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_TYPE_NONE = 0, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_TYPE_MOUSE_DOWN = 1, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_TYPE_MOUSE_UP = 2, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_TYPE_MOUSE_MOVE = 3, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_TYPE_TOUCH_DOWN = 4, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_TYPE_TOUCH_UP = 5, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_TYPE_TOUCH_MOVE = 6, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_TYPE_KEY_DOWN = 7, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_TYPE_KEY_UP = 8, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_TYPE_MOUSE_IN = 9, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_TYPE_MOUSE_OUT = 10, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_TYPE_KEY_CANCEL = 11, +}; + +enum ds_tizen_remote_surface_input_event_filter { + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_MOUSE_NONE = 0x00000001, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_MOUSE_UP_DOWN = 0x00000002, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_MOUSE_MOVE_X = 0x00000003, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_MOUSE_MOVE_Y = 0x00000004, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_MOUSE_MOVE_X_Y = 0x00000005, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_MOUSE_UP_DOWN_MOVE_X = 0x00000006, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_MOUSE_UP_DOWN_MOVE_Y = 0x00000007, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_MOUSE_UP_DOWN_MOVE_X_Y = 0x00000008, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_MOUSE_ALL = 0x0000000e, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_MOUSE_FLAG = 0x0000000f, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_MOUSE_WHEEL_NONE = 0x00000010, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_MOUSE_WHEEL_ALL = 0x000000e0, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_MOUSE_WHEEL_FLAG = 0x000000f0, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_TOUCH_NONE = 0x00000100, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_TOUCH_UP_DOWN = 0x00000200, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_TOUCH_MOVE_X = 0x00000300, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_TOUCH_MOVE_Y = 0x00000400, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_TOUCH_MOVE_X_Y = 0x00000500, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_TOUCH_UP_DOWN_MOVE_X = 0x00000600, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_TOUCH_UP_DOWN_MOVE_Y = 0x00000700, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_TOUCH_UP_DOWN_MOVE_X_Y = 0x00000800, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_TOUCH_ALL = 0x00000e00, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_TOUCH_FLAG = 0x00000f00, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_TOUCH_CANCEL_NONE = 0x00001000, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_TOUCH_CANCEL_ALL = 0x0000e000, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_TOUCH_CANCEL_FLAG = 0x0000f000, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_KEY_NONE = 0x00010000, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_KEY_ALL = 0x000e0000, + DS_TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILITER_KEY_FLAG = 0x000f0000, +}; + +enum ds_tizen_remote_surface_buffer_type { + DS_TIZEN_REMOTE_SURFACE_BUFFER_TYPE_TBM = 0, + DS_TIZEN_REMOTE_SURFACE_BUFFER_TYPE_IMAGE_FILE = 1, +}; + +enum ds_tizen_remote_surface_changed_buffer_event_filter { + DS_TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_EVENT_FILTER_NONE = 0x00000000, + DS_TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_EVENT_FILTER_TBM = 0x00000001, + DS_TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_EVENT_FILTER_IMAGE_FILE = 0x00000002, +}; + +struct ds_tizen_remote_surface_manager_bind_surface_event { + struct ds_tizen_remote_surface *remote_surface; + struct ds_surface *surface; +}; + +struct ds_tizen_remote_surface_transfer_mouse_event { + struct ds_tizen_remote_surface *remote_surface; + enum ds_tizen_remote_surface_input_event_type event_type; + int32_t device; + int32_t button; + int32_t x; + int32_t y; + wl_fixed_t radius_x; + wl_fixed_t radius_y; + wl_fixed_t pressure; + wl_fixed_t angle; + uint32_t clas; + uint32_t subclas; + const char *identifier; + uint32_t time; +}; + +struct ds_tizen_remote_surface_transfer_mouse_wheel_event { + struct ds_tizen_remote_surface *remote_surface; + uint32_t direction; + int32_t z; + uint32_t clas; + uint32_t subclas; + const char *identifier; + uint32_t time; +}; + +struct ds_tizen_remote_surface_transfer_touch_event { + struct ds_tizen_remote_surface *remote_surface; + enum ds_tizen_remote_surface_input_event_type event_type; + int32_t device; + int32_t button; + int32_t x; + int32_t y; + wl_fixed_t radius_x; + wl_fixed_t radius_y; + wl_fixed_t pressure; + wl_fixed_t angle; + uint32_t clas; + uint32_t subclas; + const char *identifier; + uint32_t time; +}; + +struct ds_tizen_remote_surface_transfer_touch_cancel_event { + struct ds_tizen_remote_surface *remote_surface; +}; + +struct ds_tizen_remote_surface_transfer_key_event { + struct ds_tizen_remote_surface *remote_surface; + enum ds_tizen_remote_surface_input_event_type event_type; + int32_t keycode; + uint32_t clas; + uint32_t subclas; + const char *identifier; + uint32_t time; +}; + +struct ds_tizen_remote_surface_transfer_visibility_event { + struct ds_tizen_remote_surface *remote_surface; + enum ds_tizen_remote_surface_visibility_type visibility; +}; + +struct ds_tizen_remote_surface_buffer_release_event { + struct ds_tizen_remote_surface *remote_surface; + struct ds_buffer *buffer; +}; + +struct ds_tizen_remote_surface_current_buffer_event { + struct ds_tizen_remote_surface *remote_surface; + enum ds_tizen_remote_surface_buffer_type buffer_type; + uint32_t request_serial; +}; + +struct ds_tizen_remote_surface_manager; + +struct ds_tizen_remote_surface_provider; + +struct ds_tizen_remote_surface; + +struct ds_tizen_remote_surface_region; + +struct ds_tizen_remote_surface_manager * +ds_tizen_remote_surface_manager_create(struct wl_display *display); + +void +ds_tizen_remote_surface_manager_add_destroy_listener( + struct ds_tizen_remote_surface_manager *remote_manager, + struct wl_listener *listener); + +void +ds_tizen_remote_surface_manager_add_new_provider_listener( + struct ds_tizen_remote_surface_manager *remote_manager, + struct wl_listener *listener); + +void +ds_tizen_remote_surface_manager_add_new_surface_listener( + struct ds_tizen_remote_surface_manager *remote_manager, + struct wl_listener *listener); + +void +ds_tizen_remote_surface_manager_add_bind_surface_listener( + struct ds_tizen_remote_surface_manager *remote_manager, + struct wl_listener *listener); + +void +ds_tizen_remote_surface_provider_add_destroy_listener( + struct ds_tizen_remote_surface_provider *remote_provider, + struct wl_listener *listener); + +void +ds_tizen_remote_surface_provider_add_set_offscreen_listener( + struct ds_tizen_remote_surface_provider *remote_provider, + struct wl_listener *listener); + +void +ds_tizen_remote_surface_provider_add_set_input_event_filter_listener( + struct ds_tizen_remote_surface_provider *remote_provider, + struct wl_listener *listener); + +bool +ds_tizen_remote_surface_provider_get_offscreen( + struct ds_tizen_remote_surface_provider *remote_provider); + +uint32_t +ds_tizen_remote_surface_provider_get_input_event_filter( + struct ds_tizen_remote_surface_provider *remote_provider); + +void +ds_tizen_remote_surface_provider_send_visibility( + struct ds_tizen_remote_surface_provider *remote_provider, + enum ds_tizen_remote_surface_visibility_type visibility); + +void +ds_tizen_remote_surface_add_destroy_listener( + struct ds_tizen_remote_surface *remote_surface, + struct wl_listener *listener); + +struct wl_resource * +ds_tizen_remote_surface_get_wl_tbm_resource( + struct ds_tizen_remote_surface *remote_surface); + +void +ds_tizen_remote_surface_add_set_redirect_listener( + struct ds_tizen_remote_surface *remote_surface, + struct wl_listener *listener); + +bool +ds_tizen_remote_surface_get_redirect( + struct ds_tizen_remote_surface *remote_surface); + +void +ds_tizen_remote_surface_add_set_owner_listener( + struct ds_tizen_remote_surface *remote_surface, + struct wl_listener *listener); + +struct ds_surface * +ds_tizen_remote_surface_get_owner( + struct ds_tizen_remote_surface *remote_surface); + +void +ds_tizen_remote_surface_add_buffer_release_listener( + struct ds_tizen_remote_surface *remote_surface, + struct wl_listener *listener); + +void +ds_tizen_remote_surface_add_set_remote_render_listener( + struct ds_tizen_remote_surface *remote_surface, + struct wl_listener *listener); + +bool +ds_tizen_remote_surface_get_remote_render( + struct ds_tizen_remote_surface *remote_surface); + +void +ds_tizen_remote_surface_add_set_changed_buffer_event_filter_listener( + struct ds_tizen_remote_surface *remote_surface, + struct wl_listener *listener); + +uint32_t +ds_tizen_remote_surface_get_changed_buffer_event_filter( + struct ds_tizen_remote_surface *remote_surface, + struct wl_listener *listener); + +void +ds_tizen_remote_surface_add_get_current_buffer_listener( + struct ds_tizen_remote_surface *remote_surface, + struct wl_listener *listener); + +void +ds_tizen_remote_surface_send_changed_buffer( + struct ds_tizen_remote_surface *remote_surface, + struct ds_buffer *buffer, + uint32_t time, + struct wl_array *options); + +void +ds_tizen_remote_surface_send_changed_buffer_image_file( + struct ds_tizen_remote_surface *remote_surface, + int image_file_fd, + int image_file_size, + uint32_t time, + struct wl_array *options); + +void +ds_tizen_remote_surface_send_missing( + struct ds_tizen_remote_surface *remote_surface); + +void +ds_tizen_remote_surface_send_input_event_filter( + struct ds_tizen_remote_surface *remote_surface, + uint32_t input_event_filter); + +void +ds_tizen_remote_surface_add_new_region_listener( + struct ds_tizen_remote_surface *remote_surface, + struct wl_listener *listener); + +void +ds_tizen_remote_surface_region_add_destroy_listener( + struct ds_tizen_remote_surface_region *remote_region, + struct wl_listener *listener); + +void +ds_tizen_remote_surface_region_add_set_geometry_listener( + struct ds_tizen_remote_surface_region *remote_region, + struct wl_listener *listener); + +void +ds_tizen_remote_surface_region_get_geometry( + struct ds_tizen_remote_surface_region *remote_region, + int32_t *x,int32_t *y, int32_t *w, int32_t *h); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/packaging/libds-tizen.spec b/packaging/libds-tizen.spec index 838a569..c4bfb93 100644 --- a/packaging/libds-tizen.spec +++ b/packaging/libds-tizen.spec @@ -34,6 +34,8 @@ BuildRequires: pkgconfig(tizen-surface-server) BuildRequires: pkgconfig(tizen-surface-client) BuildRequires: pkgconfig(tizen-hwc-server) BuildRequires: pkgconfig(tizen-hwc-client) +BuildRequires: pkgconfig(tizen-remote-surface-server) +BuildRequires: pkgconfig(tizen-remote-surface-client) BuildRequires: pkgconfig(cynara-client) BuildRequires: pkgconfig(cynara-session) BuildRequires: pkgconfig(libsmack) @@ -391,6 +393,21 @@ Group: Development/Libraries %description eom-devel Development package for tizen eom +## libds-tizen-remote-surface +%package remote-surface +Summary: Library for tizen remote-surface +Group: Development/Libraries + +%description remote-surface +Library for tizen remote-surface + +%package remote-surface-devel +Summary: Development package for tizen remote surface +Group: Development/Libraries + +%description remote-surface-devel +Development package for tizen remote surface + %prep %setup -q cp %{SOURCE1001} . @@ -754,3 +771,18 @@ ninja -C builddir install %{_includedir}/libds-tizen/eom.h %{_libdir}/pkgconfig/libds-tizen-eom.pc %{_libdir}/libds-tizen-eom.so + +%files remote-surface +%manifest %{name}.manifest +%defattr(-,root,root,-) +%license LICENSE +%{_libdir}/libds-tizen-remote-surface.so* + +%files remote-surface-devel +%manifest %{name}.manifest +%defattr(-,root,root,-) +%license LICENSE +%{_includedir}/libds-tizen/remote_surface.h +%{_libdir}/pkgconfig/libds-tizen-remote-surface.pc +%{_libdir}/libds-tizen-remote-surface.so* +%{_bindir}/libds-tizen-remote-surface-tests diff --git a/src/meson.build b/src/meson.build index 4ec2cd6..d0c0e13 100644 --- a/src/meson.build +++ b/src/meson.build @@ -55,3 +55,4 @@ subdir('screenshooter') subdir('scaler') subdir('video') subdir('eom') +subdir('remote_surface') diff --git a/src/remote_surface/meson.build b/src/remote_surface/meson.build new file mode 100644 index 0000000..f087a2e --- /dev/null +++ b/src/remote_surface/meson.build @@ -0,0 +1,30 @@ +libds_tizen_remote_surface_files = [ + 'remote_surface.c', +] + +libds_tizen_remote_surface_deps = [ + deps_libds_tizen, + deps_libds_tizen_tbm_server, + dependency('tizen-remote-surface-server', required: true), +] + +lib_libds_tizen_remote_surface = shared_library('ds-tizen-remote-surface', libds_tizen_remote_surface_files, + dependencies: libds_tizen_remote_surface_deps, + include_directories: [ common_inc, include_directories('.'), include_directories('..') ], + version: meson.project_version(), + install: true +) + +deps_libds_tizen_remote_surface = declare_dependency( + link_with: lib_libds_tizen_remote_surface, + dependencies: libds_tizen_remote_surface_deps, + include_directories: [ common_inc, include_directories('.') ], +) + +pkgconfig = import('pkgconfig') +pkgconfig.generate(lib_libds_tizen_remote_surface, + version: meson.project_version(), + filebase: 'libds-tizen-remote-surface', + name: 'libds-tizen-remote-surface', + description: 'tizen remote surface extension of libds-tizen for tizen platform', +) diff --git a/src/remote_surface/remote_surface.c b/src/remote_surface/remote_surface.c new file mode 100644 index 0000000..a16e34c --- /dev/null +++ b/src/remote_surface/remote_surface.c @@ -0,0 +1,1309 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "util.h" +#include "libds-tizen/remote_surface.h" +#include + +#define TIZEN_REMOTE_SURFACE_VERSION 6 + +static uint32_t resource_id = 1; + +struct ds_tizen_remote_surface_manager +{ + struct wl_global *global; + + struct wl_listener destroy; + + struct wl_list remote_providers; + struct wl_list remote_surfaces; + + struct { + struct wl_signal destroy; + struct wl_signal new_provider; + struct wl_signal new_surface; + struct wl_signal bind_surface; + } events; +}; + +struct ds_tizen_remote_surface_client +{ + struct ds_tizen_remote_surface_manager *remote_manager; + + struct wl_resource *resource; + struct wl_client *wl_client; + + struct { + struct wl_listener surface_destroy; + } listener; + + struct { + struct wl_signal destroy; + } events; +}; + +struct ds_tizen_remote_surface_provider +{ + struct wl_list link; + + struct wl_resource *resource; + + struct ds_surface *surface; + + uint32_t input_event_filter; + uint32_t offscreen; + + unsigned int resource_id; + + struct { + struct wl_listener surface_destroy; + } listener; + + struct { + struct wl_signal destroy; + struct wl_signal set_offscreen; + struct wl_signal set_input_event_filter; + } events; +}; + +struct ds_tizen_remote_surface +{ + struct wl_list link; + + struct wl_resource *resource; + + struct ds_surface *surface; + + struct wl_resource *wl_tbm_resource; + + bool redirect; + struct ds_surface *owner_surface; + bool remote_render; + uint32_t changed_buffer_event_filter; + + struct { + struct wl_listener surface_destroy; + struct wl_listener owner_surface_destroy; + struct wl_listener wl_tbm_resource_destroy; + } listener; + + struct { + struct wl_signal destroy; + struct wl_signal set_redirect; + struct wl_signal transfer_mouse_event; + struct wl_signal transfer_mouse_wheel_event; + struct wl_signal transfer_touch_event; + struct wl_signal transfer_touch_cancel_event; + struct wl_signal transfer_key_event; + struct wl_signal transfer_visibility_event; + struct wl_signal set_owner; + struct wl_signal new_region; + struct wl_signal buffer_release; + struct wl_signal set_remote_render; + struct wl_signal set_changed_buffer_event_filter; + struct wl_signal get_current_buffer; + } events; +}; + +struct ds_tizen_remote_surface_region +{ + struct wl_resource *resource; + + int32_t x; + int32_t y; + int32_t w; + int32_t h; + + struct { + struct wl_signal destroy; + struct wl_signal set_geometry; + } events; +}; + +static int +remote_surface_dummy_fd_get(void) +{ + static const char template[] = "/libds_rsm_dummy_fdXXXXXX"; + const char *path; + char *name; + size_t name_size; + long flags; + static int fd = -1; + + if (fd >= 0) + return fd; + + path = getenv("XDG_RUNTIME_DIR"); + if (!path) { + ds_err("fail to get XDG_RUNTIME_DIR"); + return -1; + } + + name_size = strlen(path) + sizeof(template); + name = malloc(name_size); + if (!name) { + ds_err("malloc() failed"); + return -1; + } + + snprintf(name, name_size, "%s%s", path, template); + fd = mkstemp(name); + if (fd < 0) { + ds_err("mkstemp() failed"); + free(name); + return -1; + } + + flags = fcntl(fd, F_GETFD); + if (flags == -1) { + ds_err("fcntl(F_GETFD) failed"); + unlink(name); + free(name); + return -1; + } + + if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1) { + ds_err("fcntl(F_SETFD, FD_CLOEXEC) failed"); + unlink(name); + free(name); + return -1; + } + + unlink(name); + free(name); + + return fd; +} + +static void +remote_surface_provider_handle_destroy(struct wl_client *wl_client, + struct wl_resource *resource) +{ + wl_resource_destroy(resource); +} + +static void +remote_surface_provider_handle_set_offscreen(struct wl_client *wl_client, + struct wl_resource *provider_resource, uint32_t offscreen) +{ + struct ds_tizen_remote_surface_provider *remote_provider; + + remote_provider = wl_resource_get_user_data(provider_resource); + + if (remote_provider->offscreen == offscreen) + return; + + remote_provider->offscreen = offscreen; + + wl_signal_emit(&remote_provider->events.set_offscreen, remote_provider); +} + +static void +remote_surface_provider_handle_set_input_event_filter(struct wl_client *wl_client, + struct wl_resource *provider_resource, uint32_t event_filter) +{ + struct ds_tizen_remote_surface_provider *remote_provider; + + remote_provider = wl_resource_get_user_data(provider_resource); + + if (remote_provider->input_event_filter == event_filter) + return; + + remote_provider->input_event_filter = event_filter; + + wl_signal_emit(&remote_provider->events.set_input_event_filter, remote_provider); +} + +static const struct tizen_remote_surface_provider_interface remote_surface_provider_impl = +{ + .destroy = remote_surface_provider_handle_destroy, + .offscreen_set = remote_surface_provider_handle_set_offscreen, + .set_input_event_filter = remote_surface_provider_handle_set_input_event_filter, +}; + +static void +remote_surface_provider_handle_surface_destroy(struct wl_listener *listener, void *data) +{ + struct ds_tizen_remote_surface_provider *remote_provider; + + remote_provider = wl_container_of(listener, remote_provider, listener.surface_destroy); + + if (remote_provider->listener.surface_destroy.notify) { + wl_list_remove(&remote_provider->listener.surface_destroy.link); + remote_provider->listener.surface_destroy.notify = NULL; + } + + remote_provider->surface = NULL; +} + +static void +remote_surface_provider_handle_resource_destroy(struct wl_resource *remote_provider_resource) +{ + struct ds_tizen_remote_surface_provider *remote_provider; + + remote_provider = wl_resource_get_user_data(remote_provider_resource); + + ds_inf("remote_surface_provider:%p destroy", remote_provider); + + if (remote_provider->listener.surface_destroy.notify) { + wl_list_remove(&remote_provider->listener.surface_destroy.link); + remote_provider->listener.surface_destroy.notify = NULL; + } + + wl_list_remove(&remote_provider->link); + + wl_signal_emit(&remote_provider->events.destroy, remote_provider); + + free(remote_provider); +} + +static void +remote_surface_manager_handle_create_provider(struct wl_client *wl_client, + struct wl_resource *remote_surface_client_resource, + uint32_t id, + struct wl_resource *surface_resource) +{ + struct ds_tizen_remote_surface_client *remote_client; + struct ds_tizen_remote_surface_provider *remote_provider; + struct ds_surface *surface; + + remote_client = wl_resource_get_user_data(remote_surface_client_resource); + surface = ds_surface_from_resource(surface_resource); + + remote_provider = calloc(1, sizeof *remote_provider); + if (!remote_provider) { + wl_client_post_no_memory(wl_client); + return; + } + + remote_provider->resource = wl_resource_create(wl_client, &tizen_remote_surface_provider_interface, + wl_resource_get_version(remote_client->resource), id); + if (!remote_provider->resource) { + wl_client_post_no_memory(wl_client); + free(remote_provider); + return; + } + + remote_provider->listener.surface_destroy.notify = remote_surface_provider_handle_surface_destroy; + ds_surface_add_destroy_listener(surface, &remote_provider->listener.surface_destroy); + remote_provider->surface = surface; + + wl_resource_set_implementation(remote_provider->resource, &remote_surface_provider_impl, + remote_provider, remote_surface_provider_handle_resource_destroy); + + ds_inf("remote_surface_provider:%p create", remote_provider); + + wl_signal_init(&remote_provider->events.destroy); + wl_signal_init(&remote_provider->events.set_offscreen); + wl_signal_init(&remote_provider->events.set_input_event_filter); + + wl_signal_emit(&remote_client->remote_manager->events.new_provider, remote_provider); + + remote_provider->resource_id = resource_id++; + + tizen_remote_surface_provider_send_resource_id(remote_provider->resource, remote_provider->resource_id); + + wl_list_insert(&remote_client->remote_manager->remote_providers, &remote_provider->link); +} + +static void +remote_surface_handle_destroy(struct wl_client *wl_client, + struct wl_resource *resource) +{ + wl_resource_destroy(resource); +} + +static void +remote_surface_handle_redirect(struct wl_client *wl_client, + struct wl_resource *remote_surface_resource) +{ + struct ds_tizen_remote_surface *remote_surface; + + remote_surface = wl_resource_get_user_data(remote_surface_resource); + + remote_surface->redirect = true; + + wl_signal_emit(&remote_surface->events.set_redirect, remote_surface); +} + +static void +remote_surface_handle_unredirect(struct wl_client *wl_client, + struct wl_resource *remote_surface_resource) +{ + struct ds_tizen_remote_surface *remote_surface; + + remote_surface = wl_resource_get_user_data(remote_surface_resource); + + remote_surface->redirect = false; + + wl_signal_emit(&remote_surface->events.set_redirect, remote_surface); +} + +static void +remote_surface_handle_transfer_mouse_event(struct wl_client *wl_client, + struct wl_resource *remote_surface_resource, + uint32_t event_type, int32_t device, int32_t button, + int32_t x, int32_t y, wl_fixed_t radius_x, wl_fixed_t radius_y, + wl_fixed_t pressure, wl_fixed_t angle, uint32_t clas, uint32_t subclas, + const char *identifier, uint32_t time) +{ + struct ds_tizen_remote_surface *remote_surface; + struct ds_tizen_remote_surface_transfer_mouse_event event; + + remote_surface = wl_resource_get_user_data(remote_surface_resource); + + event.remote_surface = remote_surface; + event.event_type = event_type; + event.device = device; + event.button = button; + event.x = x; + event.y = y; + event.radius_x = radius_x; + event.radius_y = radius_y; + event.pressure = pressure; + event.angle = angle; + event.clas = clas; + event.subclas = subclas; + event.identifier = identifier; + event.time = time; + + wl_signal_emit(&remote_surface->events.transfer_mouse_event, &event); +} + +static void +remote_surface_handle_transfer_mouse_wheel(struct wl_client *wl_client, + struct wl_resource *remote_surface_resource, + uint32_t direction, int32_t z, uint32_t clas, uint32_t subclas, + const char *identifier, uint32_t time) +{ + struct ds_tizen_remote_surface *remote_surface; + struct ds_tizen_remote_surface_transfer_mouse_wheel_event event; + + remote_surface = wl_resource_get_user_data(remote_surface_resource); + + event.remote_surface = remote_surface; + event.direction = direction; + event.z = z; + event.clas = clas; + event.subclas = subclas; + event.identifier = identifier; + event.time = time; + + wl_signal_emit(&remote_surface->events.transfer_mouse_wheel_event, &event); +} + +static void +remote_surface_handle_transfer_touch_event(struct wl_client *wl_client, + struct wl_resource *remote_surface_resource, + uint32_t event_type, int32_t device, int32_t button, int32_t x, int32_t y, + wl_fixed_t radius_x, wl_fixed_t radius_y, wl_fixed_t pressure, wl_fixed_t angle, + uint32_t clas, uint32_t subclas, const char *identifier, uint32_t time) +{ + struct ds_tizen_remote_surface *remote_surface; + struct ds_tizen_remote_surface_transfer_touch_event event; + + remote_surface = wl_resource_get_user_data(remote_surface_resource); + + event.remote_surface = remote_surface; + event.event_type = event_type; + event.device = device; + event.button = button; + event.x = x; + event.y = y; + event.radius_x = radius_x; + event.radius_y = radius_y; + event.pressure = pressure; + event.angle = angle; + event.clas = clas; + event.subclas = subclas; + event.identifier = identifier; + event.time = time; + + wl_signal_emit(&remote_surface->events.transfer_touch_event, &event); +} + +static void +remote_surface_handle_transfer_touch_cancel(struct wl_client *wl_client, + struct wl_resource *remote_surface_resource) +{ + struct ds_tizen_remote_surface *remote_surface; + struct ds_tizen_remote_surface_transfer_touch_cancel_event event; + + remote_surface = wl_resource_get_user_data(remote_surface_resource); + + event.remote_surface = remote_surface; + + wl_signal_emit(&remote_surface->events.transfer_touch_cancel_event, &event); +} + +static void +remote_surface_handle_transfer_key_event(struct wl_client *wl_client, + struct wl_resource *remote_surface_resource, + uint32_t event_type, int32_t keycode, uint32_t clas, uint32_t subclas, + const char *identifier, uint32_t time) +{ + struct ds_tizen_remote_surface *remote_surface; + struct ds_tizen_remote_surface_transfer_key_event event; + + remote_surface = wl_resource_get_user_data(remote_surface_resource); + + event.remote_surface = remote_surface; + event.event_type = event_type; + event.keycode = keycode; + event.clas = clas; + event.subclas = subclas; + event.identifier = identifier; + event.time = time; + + wl_signal_emit(&remote_surface->events.transfer_key_event, &event); +} + +static void +remote_surface_handle_transfer_visibility(struct wl_client *wl_client, + struct wl_resource *remote_surface_resource, + uint32_t visibility_type) +{ + struct ds_tizen_remote_surface *remote_surface; + struct ds_tizen_remote_surface_transfer_visibility_event event; + + remote_surface = wl_resource_get_user_data(remote_surface_resource); + + event.remote_surface = remote_surface; + event.visibility = visibility_type; + + wl_signal_emit(&remote_surface->events.transfer_visibility_event, &event); +} + +static void +remote_surface_handle_owner_surface_destroy(struct wl_listener *listener, void *data) +{ + struct ds_tizen_remote_surface *remote_surface; + + remote_surface = wl_container_of(listener, remote_surface, listener.surface_destroy); + + if (remote_surface->listener.owner_surface_destroy.notify) { + wl_list_remove(&remote_surface->listener.owner_surface_destroy.link); + remote_surface->listener.owner_surface_destroy.notify = NULL; + } + + remote_surface->owner_surface = NULL; +} + +static void +remote_surface_handle_set_owner(struct wl_client *wl_client, + struct wl_resource *remote_surface_resource, + struct wl_resource *surface_resource) +{ + struct ds_tizen_remote_surface *remote_surface; + struct ds_surface *surface; + + remote_surface = wl_resource_get_user_data(remote_surface_resource); + surface = ds_surface_from_resource(surface_resource); + + remote_surface->listener.owner_surface_destroy.notify = remote_surface_handle_owner_surface_destroy; + ds_surface_add_destroy_listener(surface, &remote_surface->listener.owner_surface_destroy); + remote_surface->owner_surface = surface; + + wl_signal_emit(&remote_surface->events.set_owner, remote_surface); +} + +static void +remote_region_handle_destroy(struct wl_client *wl_client, + struct wl_resource *resource) +{ + wl_resource_destroy(resource); +} + +static void +remote_region_handle_set_geometry(struct wl_client *wl_client, + struct wl_resource *remote_region_resource, + int32_t x, int32_t y, int32_t w, int32_t h) +{ + struct ds_tizen_remote_surface_region *remote_region; + + remote_region = wl_resource_get_user_data(remote_region_resource); + + remote_region->x = x; + remote_region->y = y; + remote_region->w = w; + remote_region->h = h; + + wl_signal_emit(&remote_region->events.set_geometry, remote_region); +} + +static const struct tizen_remote_surface_region_interface remote_surface_region_impl = +{ + .destroy = remote_region_handle_destroy, + .set_geometry = remote_region_handle_set_geometry, +}; + +static void +remote_surface_region_handle_resource_destroy(struct wl_resource *remote_region_resource) +{ + struct ds_tizen_remote_surface_region *remote_region; + + remote_region = wl_resource_get_user_data(remote_region_resource); + + ds_inf("remote_region:%p destroy", remote_region); + + wl_signal_emit(&remote_region->events.destroy, remote_region); + + free(remote_region); +} + +static void +remote_surface_handle_create_region(struct wl_client *wl_client, + struct wl_resource *remote_surface_resource, + uint32_t id) +{ + struct ds_tizen_remote_surface *remote_surface; + struct ds_tizen_remote_surface_region *remote_region; + + remote_surface = wl_resource_get_user_data(remote_surface_resource); + + remote_region = calloc(1, sizeof *remote_region); + if (!remote_region) { + wl_client_post_no_memory(wl_client); + return; + } + + remote_region->resource = wl_resource_create(wl_client, &tizen_remote_surface_region_interface, + 1, id); + if (!remote_region->resource) { + wl_client_post_no_memory(wl_client); + free(remote_region); + return; + } + + wl_resource_set_implementation(remote_region->resource, &remote_surface_region_impl, + remote_region, remote_surface_region_handle_resource_destroy); + + ds_inf("remote_surface_region:%p create", remote_region); + + wl_signal_init(&remote_region->events.destroy); + wl_signal_init(&remote_region->events.set_geometry); + + wl_signal_emit(&remote_surface->events.new_region, remote_region); +} + +static void +remote_surface_handle_release(struct wl_client *wl_client, + struct wl_resource *remote_surface_resource, + struct wl_resource *remote_buffer_resource) +{ + struct ds_tizen_remote_surface *remote_surface; + struct ds_buffer *buffer; + struct ds_tizen_remote_surface_buffer_release_event event; + + remote_surface = wl_resource_get_user_data(remote_surface_resource); + buffer = ds_buffer_from_resource(remote_buffer_resource); + + event.remote_surface = remote_surface; + event.buffer = buffer; + + wl_signal_emit(&remote_surface->events.buffer_release, &event); +} + +static void +remote_surface_handle_set_remote_render(struct wl_client *wl_client, + struct wl_resource *remote_surface_resource, + uint32_t set) +{ + struct ds_tizen_remote_surface *remote_surface; + + remote_surface = wl_resource_get_user_data(remote_surface_resource); + + if (set > 0) + remote_surface->remote_render = true; + else + remote_surface->remote_render = false; + + wl_signal_emit(&remote_surface->events.set_remote_render, remote_surface); +} + +static void +remote_surface_handle_set_changed_buffer_event_filter(struct wl_client *wl_client, + struct wl_resource *remote_surface_resource, + enum tizen_remote_surface_changed_buffer_event_filter filter) +{ + struct ds_tizen_remote_surface *remote_surface; + + remote_surface = wl_resource_get_user_data(remote_surface_resource); + + remote_surface->changed_buffer_event_filter = filter; + + wl_signal_emit(&remote_surface->events.set_changed_buffer_event_filter, remote_surface); +} + +static void +remote_surface_handle_get_current_buffer(struct wl_client *wl_client, + struct wl_resource *remote_surface_resource, + enum tizen_remote_surface_buffer_type buff_type, + uint32_t req_serial) +{ + struct ds_tizen_remote_surface *remote_surface; + struct ds_tizen_remote_surface_current_buffer_event event; + + remote_surface = wl_resource_get_user_data(remote_surface_resource); + + event.remote_surface = remote_surface; + event.buffer_type = buff_type; + event.request_serial = req_serial; + + wl_signal_emit(&remote_surface->events.get_current_buffer, &event); +} + +static const struct tizen_remote_surface_interface remote_surface_impl = +{ + .destroy = remote_surface_handle_destroy, + .redirect = remote_surface_handle_redirect, + .unredirect = remote_surface_handle_unredirect, + .transfer_mouse_event = remote_surface_handle_transfer_mouse_event, + .transfer_mouse_wheel = remote_surface_handle_transfer_mouse_wheel, + .transfer_touch_event = remote_surface_handle_transfer_touch_event, + .transfer_touch_cancel = remote_surface_handle_transfer_touch_cancel, + .transfer_key_event = remote_surface_handle_transfer_key_event, + .transfer_visibility = remote_surface_handle_transfer_visibility, + .set_owner = remote_surface_handle_set_owner, + .create_region = remote_surface_handle_create_region, + .release = remote_surface_handle_release, + .set_remote_render = remote_surface_handle_set_remote_render, + .set_changed_buffer_event_filter = remote_surface_handle_set_changed_buffer_event_filter, + .get_current_buffer = remote_surface_handle_get_current_buffer, +}; + +static void +remote_surface_handle_surface_destroy(struct wl_listener *listener, void *data) +{ + struct ds_tizen_remote_surface *remote_surface; + + remote_surface = wl_container_of(listener, remote_surface, listener.surface_destroy); + + if (remote_surface->listener.surface_destroy.notify) { + wl_list_remove(&remote_surface->listener.surface_destroy.link); + remote_surface->listener.surface_destroy.notify = NULL; + } + + remote_surface->surface = NULL; +} + +static void +remote_surface_handle_wl_tbm_resource_destroy(struct wl_listener *listener, void *data) +{ + struct ds_tizen_remote_surface *remote_surface; + + remote_surface = wl_container_of(listener, remote_surface, listener.wl_tbm_resource_destroy); + + if (remote_surface->listener.wl_tbm_resource_destroy.notify) { + wl_list_remove(&remote_surface->listener.wl_tbm_resource_destroy.link); + remote_surface->listener.wl_tbm_resource_destroy.notify = NULL; + } + + remote_surface->wl_tbm_resource = NULL; +} + +static void +remote_surface_handle_resource_destroy(struct wl_resource *remote_surface_resource) +{ + struct ds_tizen_remote_surface *remote_surface; + + remote_surface = wl_resource_get_user_data(remote_surface_resource); + + ds_inf("remote_surface:%p destroy", remote_surface); + + if (remote_surface->listener.surface_destroy.notify) { + wl_list_remove(&remote_surface->listener.surface_destroy.link); + remote_surface->listener.surface_destroy.notify = NULL; + } + + if (remote_surface->listener.owner_surface_destroy.notify) { + wl_list_remove(&remote_surface->listener.owner_surface_destroy.link); + remote_surface->listener.owner_surface_destroy.notify = NULL; + } + + wl_list_remove(&remote_surface->link); + + wl_signal_emit(&remote_surface->events.destroy, remote_surface); + + free(remote_surface); +} + +static void +remote_surface_manager_handle_create_surface(struct wl_client *wl_client, + struct wl_resource *remote_surface_client_resource, + uint32_t id, + uint32_t resource_id, + struct wl_resource *wl_tbm_resource) +{ + struct ds_tizen_remote_surface_client *remote_client; + struct ds_tizen_remote_surface *remote_surface; + struct ds_surface *surface = NULL; + struct ds_tizen_remote_surface_provider *remote_provider; + + remote_client = wl_resource_get_user_data(remote_surface_client_resource); + + wl_list_for_each(remote_provider, &remote_client->remote_manager->remote_providers, link) { + if (remote_provider->resource_id == resource_id) { + surface = remote_provider->surface; + break; + } + } + + if (!surface) { + ds_err("fail to find ds_surface from resource_id:%d", resource_id); + return; + } + + remote_surface = calloc(1, sizeof *remote_surface); + if (!remote_surface) { + wl_client_post_no_memory(wl_client); + return; + } + + remote_surface->resource = wl_resource_create(wl_client, &tizen_remote_surface_interface, + wl_resource_get_version(remote_client->resource), id); + if (!remote_surface->resource) { + wl_client_post_no_memory(wl_client); + free(remote_surface); + return; + } + + remote_surface->listener.surface_destroy.notify = remote_surface_handle_surface_destroy; + ds_surface_add_destroy_listener(surface, &remote_surface->listener.surface_destroy); + remote_surface->surface = surface; + + remote_surface->listener.wl_tbm_resource_destroy.notify = remote_surface_handle_wl_tbm_resource_destroy; + wl_resource_add_destroy_listener(wl_tbm_resource, &remote_surface->listener.wl_tbm_resource_destroy); + remote_surface->wl_tbm_resource = wl_tbm_resource; + + wl_resource_set_implementation(remote_surface->resource, &remote_surface_impl, + remote_surface, remote_surface_handle_resource_destroy); + + ds_inf("remote_surface:%p create", remote_surface); + + wl_signal_init(&remote_surface->events.destroy); + wl_signal_init(&remote_surface->events.set_redirect); + wl_signal_init(&remote_surface->events.transfer_mouse_event); + wl_signal_init(&remote_surface->events.transfer_mouse_wheel_event); + wl_signal_init(&remote_surface->events.transfer_touch_event); + wl_signal_init(&remote_surface->events.transfer_touch_cancel_event); + wl_signal_init(&remote_surface->events.transfer_key_event); + wl_signal_init(&remote_surface->events.transfer_visibility_event); + wl_signal_init(&remote_surface->events.set_owner); + wl_signal_init(&remote_surface->events.new_region); + wl_signal_init(&remote_surface->events.buffer_release); + wl_signal_init(&remote_surface->events.set_remote_render); + wl_signal_init(&remote_surface->events.set_changed_buffer_event_filter); + wl_signal_init(&remote_surface->events.get_current_buffer); + + wl_list_insert(&remote_client->remote_manager->remote_surfaces, &remote_surface->link); + + wl_signal_emit(&remote_client->remote_manager->events.new_surface, remote_surface); +} + +static void +remote_surface_manager_handle_bind_surface(struct wl_client *wl_client, + struct wl_resource *remote_surface_client_resource, + struct wl_resource *surface_resource, + struct wl_resource *remote_surface_resource) +{ + struct ds_tizen_remote_surface_manager_bind_surface_event event; + struct ds_tizen_remote_surface_client *remote_client; + struct ds_tizen_remote_surface *remote_surface; + struct ds_surface *surface; + + remote_client = wl_resource_get_user_data(remote_surface_client_resource); + surface = ds_surface_from_resource(surface_resource); + remote_surface = wl_resource_get_user_data(surface_resource); + + event.remote_surface = remote_surface; + event.surface = surface; + + wl_signal_emit(&remote_client->remote_manager->events.bind_surface, &event); +} + +static void +remote_surface_manager_handle_destroy(struct wl_client *wl_client, + struct wl_resource *resource) +{ + wl_resource_destroy(resource); +} + +static void +remote_surface_manager_handle_create_surface_with_wl_surface(struct wl_client *wl_client, + struct wl_resource *remote_client_resource, + uint32_t id, + uint32_t resource_id, + struct wl_resource *wl_tbm_resource, + struct wl_resource *surface_resource) +{ + struct ds_tizen_remote_surface_client *remote_client; + struct ds_tizen_remote_surface *remote_surface; + struct ds_surface *surface = NULL, *owner_surface; + struct ds_tizen_remote_surface_provider *remote_provider; + + remote_client = wl_resource_get_user_data(remote_client_resource); + owner_surface = ds_surface_from_resource(surface_resource); + + wl_list_for_each(remote_provider, &remote_client->remote_manager->remote_providers, link) { + if (remote_provider->resource_id == resource_id) { + surface = remote_provider->surface; + break; + } + } + + if (!surface) { + ds_err("fail to find ds_surface from resource_id:%d", resource_id); + return; + } + + remote_surface = calloc(1, sizeof *remote_surface); + if (!remote_surface) { + wl_client_post_no_memory(wl_client); + return; + } + + remote_surface->resource = wl_resource_create(wl_client, &tizen_remote_surface_interface, + wl_resource_get_version(remote_client->resource), id); + if (!remote_surface->resource) { + wl_client_post_no_memory(wl_client); + free(remote_surface); + return; + } + + remote_surface->listener.owner_surface_destroy.notify = remote_surface_handle_owner_surface_destroy; + ds_surface_add_destroy_listener(owner_surface, &remote_surface->listener.owner_surface_destroy); + remote_surface->owner_surface = owner_surface; + + remote_surface->listener.surface_destroy.notify = remote_surface_handle_surface_destroy; + ds_surface_add_destroy_listener(surface, &remote_surface->listener.surface_destroy); + remote_surface->surface = surface; + + remote_surface->listener.wl_tbm_resource_destroy.notify = remote_surface_handle_wl_tbm_resource_destroy; + wl_resource_add_destroy_listener(wl_tbm_resource, &remote_surface->listener.wl_tbm_resource_destroy); + remote_surface->wl_tbm_resource = wl_tbm_resource; + + wl_resource_set_implementation(remote_surface->resource, &remote_surface_impl, + remote_surface, remote_surface_handle_resource_destroy); + + ds_inf("remote_surface:%p create", remote_surface); + + wl_signal_init(&remote_surface->events.destroy); + wl_signal_init(&remote_surface->events.set_redirect); + wl_signal_init(&remote_surface->events.transfer_mouse_event); + wl_signal_init(&remote_surface->events.transfer_mouse_wheel_event); + wl_signal_init(&remote_surface->events.transfer_touch_event); + wl_signal_init(&remote_surface->events.transfer_touch_cancel_event); + wl_signal_init(&remote_surface->events.transfer_key_event); + wl_signal_init(&remote_surface->events.transfer_visibility_event); + wl_signal_init(&remote_surface->events.set_owner); + wl_signal_init(&remote_surface->events.new_region); + wl_signal_init(&remote_surface->events.buffer_release); + wl_signal_init(&remote_surface->events.set_remote_render); + wl_signal_init(&remote_surface->events.set_changed_buffer_event_filter); + wl_signal_init(&remote_surface->events.get_current_buffer); + + wl_list_insert(&remote_client->remote_manager->remote_surfaces, &remote_surface->link); + + wl_signal_emit(&remote_client->remote_manager->events.new_surface, remote_surface); + wl_signal_emit(&remote_surface->events.set_owner, remote_surface); +} + +static const struct tizen_remote_surface_manager_interface remote_surface_manager_impl = +{ + .create_provider = remote_surface_manager_handle_create_provider, + .create_surface = remote_surface_manager_handle_create_surface, + .bind_surface = remote_surface_manager_handle_bind_surface, + .destroy = remote_surface_manager_handle_destroy, + .create_surface_with_wl_surface = remote_surface_manager_handle_create_surface_with_wl_surface, +}; + +static void +tizen_remote_surface_client_handle_resource_destroy(struct wl_resource *resource) +{ + struct ds_tizen_remote_surface_client *remote_client; + + remote_client = wl_resource_get_user_data(resource); + + ds_inf("_tizen_remote_surface_client_handle_destroy (client:%p)", remote_client); + + free(remote_client); +} + +static void +remote_surface_manager_bind(struct wl_client *wl_client, void *data, uint32_t version, + uint32_t id) +{ + struct ds_tizen_remote_surface_manager *remote_manager = data; + struct ds_tizen_remote_surface_client *remote_client; + + remote_client = calloc(1, sizeof *remote_client); + if (!remote_client) { + ds_err("calloc() failed. tizen_remote_surface_client"); + wl_client_post_no_memory(wl_client); + return; + } + + ds_inf("tizen_remote_surface_client binds. (client:%p)", remote_client); + + remote_client->remote_manager = remote_manager; + remote_client->wl_client = wl_client; + + remote_client->resource = wl_resource_create(wl_client, &tizen_remote_surface_manager_interface, + MIN(version, TIZEN_REMOTE_SURFACE_VERSION), id); + if (!remote_client->resource) { + ds_err("tizen_remote_surface : wl_resource_create() failed."); + free(remote_client); + wl_client_post_no_memory(wl_client); + return; + } + + wl_resource_set_implementation(remote_client->resource, &remote_surface_manager_impl, + remote_client, tizen_remote_surface_client_handle_resource_destroy); + + wl_signal_init(&remote_client->events.destroy); +} + +static void +remote_surface_manager_handle_display_destroy(struct wl_listener *listener, void *data) +{ + struct ds_tizen_remote_surface_manager *remote_manager; + + remote_manager = wl_container_of(listener, remote_manager, destroy); + + ds_inf("Global destroy: remote_surface_manager(%p)", remote_manager); + + wl_signal_emit(&remote_manager->events.destroy, remote_manager); + wl_list_remove(&remote_manager->destroy.link); + wl_global_destroy(remote_manager->global); + free(remote_manager); +} + +WL_EXPORT struct ds_tizen_remote_surface_manager * +ds_tizen_remote_surface_manager_create(struct wl_display *display) +{ + struct ds_tizen_remote_surface_manager *remote_manager; + + remote_manager = calloc(1, sizeof *remote_manager); + if (!remote_manager) { + ds_err("calloc() failed."); + return NULL; + } + + remote_manager->global = wl_global_create(display, &tizen_remote_surface_manager_interface, + TIZEN_REMOTE_SURFACE_VERSION, remote_manager, remote_surface_manager_bind); + if (!remote_manager->global) { + ds_err("wl_global_create() failed. tizen_remote_surface_interface"); + free(remote_manager); + return NULL; + } + + remote_manager->destroy.notify = remote_surface_manager_handle_display_destroy; + wl_display_add_destroy_listener(display, &remote_manager->destroy); + + wl_list_init(&remote_manager->remote_providers); + wl_list_init(&remote_manager->remote_surfaces); + + wl_signal_init(&remote_manager->events.destroy); + wl_signal_init(&remote_manager->events.new_provider); + wl_signal_init(&remote_manager->events.new_surface); + wl_signal_init(&remote_manager->events.bind_surface); + + ds_inf("Global created: tizen_remote_surface_manager(%p)", remote_manager); + + return remote_manager; +} + +WL_EXPORT void +ds_tizen_remote_surface_manager_add_destroy_listener( + struct ds_tizen_remote_surface_manager *remote_manager, + struct wl_listener *listener) +{ + wl_signal_add(&remote_manager->events.destroy, listener); +} + +WL_EXPORT void +ds_tizen_remote_surface_manager_add_new_provider_listener( + struct ds_tizen_remote_surface_manager *remote_manager, + struct wl_listener *listener) +{ + wl_signal_add(&remote_manager->events.new_provider, listener); +} + +WL_EXPORT void +ds_tizen_remote_surface_manager_add_new_surface_listener( + struct ds_tizen_remote_surface_manager *remote_manager, + struct wl_listener *listener) +{ + wl_signal_add(&remote_manager->events.new_surface, listener); +} + +WL_EXPORT void +ds_tizen_remote_surface_manager_add_bind_surface_listener( + struct ds_tizen_remote_surface_manager *remote_manager, + struct wl_listener *listener) +{ + wl_signal_add(&remote_manager->events.bind_surface, listener); +} + +WL_EXPORT void +ds_tizen_remote_surface_provider_add_destroy_listener( + struct ds_tizen_remote_surface_provider *remote_provider, + struct wl_listener *listener) +{ + wl_signal_add(&remote_provider->events.destroy, listener); +} + +WL_EXPORT void +ds_tizen_remote_surface_provider_add_set_offscreen_listener( + struct ds_tizen_remote_surface_provider *remote_provider, + struct wl_listener *listener) +{ + wl_signal_add(&remote_provider->events.set_offscreen, listener); +} + +WL_EXPORT void +ds_tizen_remote_surface_provider_add_set_input_event_filter_listener( + struct ds_tizen_remote_surface_provider *remote_provider, + struct wl_listener *listener) +{ + wl_signal_add(&remote_provider->events.set_input_event_filter, listener); +} + +WL_EXPORT bool +ds_tizen_remote_surface_provider_get_offscreen( + struct ds_tizen_remote_surface_provider *remote_provider) +{ + return remote_provider->offscreen; +} + +WL_EXPORT uint32_t +ds_tizen_remote_surface_provider_get_input_event_filter( + struct ds_tizen_remote_surface_provider *remote_provider) +{ + return remote_provider->input_event_filter; +} + +WL_EXPORT void +ds_tizen_remote_surface_provider_send_visibility( + struct ds_tizen_remote_surface_provider *remote_provider, + enum ds_tizen_remote_surface_visibility_type visibility) +{ + tizen_remote_surface_provider_send_visibility(remote_provider->resource, + visibility); +} + +WL_EXPORT void +ds_tizen_remote_surface_add_destroy_listener( + struct ds_tizen_remote_surface *remote_surface, + struct wl_listener *listener) +{ + wl_signal_add(&remote_surface->events.destroy, listener); +} + +struct wl_resource * +ds_tizen_remote_surface_get_wl_tbm_resource( + struct ds_tizen_remote_surface *remote_surface) +{ + return remote_surface->wl_tbm_resource; +} + +WL_EXPORT void +ds_tizen_remote_surface_add_set_redirect_listener( + struct ds_tizen_remote_surface *remote_surface, + struct wl_listener *listener) +{ + wl_signal_add(&remote_surface->events.set_redirect, listener); +} + +WL_EXPORT bool +ds_tizen_remote_surface_get_redirect( + struct ds_tizen_remote_surface *remote_surface) +{ + return remote_surface->redirect; +} + +WL_EXPORT void +ds_tizen_remote_surface_add_set_owner_listener( + struct ds_tizen_remote_surface *remote_surface, + struct wl_listener *listener) +{ + wl_signal_add(&remote_surface->events.set_owner, listener); +} + +WL_EXPORT struct ds_surface * +ds_tizen_remote_surface_get_owner( + struct ds_tizen_remote_surface *remote_surface) +{ + return remote_surface->owner_surface; +} + +WL_EXPORT void +ds_tizen_remote_surface_add_buffer_release_listener( + struct ds_tizen_remote_surface *remote_surface, + struct wl_listener *listener) +{ + wl_signal_add(&remote_surface->events.buffer_release, listener); +} + +WL_EXPORT void +ds_tizen_remote_surface_add_set_remote_render_listener( + struct ds_tizen_remote_surface *remote_surface, + struct wl_listener *listener) +{ + wl_signal_add(&remote_surface->events.set_remote_render, listener); +} + +WL_EXPORT bool +ds_tizen_remote_surface_get_remote_render( + struct ds_tizen_remote_surface *remote_surface) +{ + return remote_surface->remote_render; +} + +WL_EXPORT void +ds_tizen_remote_surface_add_set_changed_buffer_event_filter_listener( + struct ds_tizen_remote_surface *remote_surface, + struct wl_listener *listener) +{ + wl_signal_add(&remote_surface->events.set_changed_buffer_event_filter, listener); +} + +WL_EXPORT uint32_t +ds_tizen_remote_surface_get_changed_buffer_event_filter( + struct ds_tizen_remote_surface *remote_surface, + struct wl_listener *listener) +{ + return remote_surface->changed_buffer_event_filter; +} + +WL_EXPORT void +ds_tizen_remote_surface_add_get_current_buffer_listener( + struct ds_tizen_remote_surface *remote_surface, + struct wl_listener *listener) +{ + wl_signal_add(&remote_surface->events.get_current_buffer, listener); +} + +WL_EXPORT void +ds_tizen_remote_surface_send_changed_buffer( + struct ds_tizen_remote_surface *remote_surface, + struct ds_buffer *buffer, + uint32_t time, + struct wl_array *options) +{ + int version; + struct ds_tbm_client_buffer *tbm_client_buffer; + struct wl_resource *buffer_resource; + + version = wl_resource_get_version(remote_surface->resource); + + tbm_client_buffer = ds_tbm_client_buffer_from_buffer(buffer); + if (!tbm_client_buffer) { + ds_err("not support buffer"); + return; + } + + buffer_resource = ds_buffer_get_resource(buffer); + if (!buffer_resource) { + ds_err("buffer resource is null"); + return; + } + + if (version >= TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_SINCE_VERSION) { + tizen_remote_surface_send_changed_buffer(remote_surface->resource, + TIZEN_REMOTE_SURFACE_BUFFER_TYPE_TBM, + buffer_resource, + remote_surface_dummy_fd_get(), + 0, + time, + options); + } else { + tizen_remote_surface_send_update_buffer(remote_surface->resource, + buffer_resource, + time); + } +} + +WL_EXPORT void +ds_tizen_remote_surface_send_changed_buffer_image_file( + struct ds_tizen_remote_surface *remote_surface, + int image_file_fd, + int image_file_size, + uint32_t time, + struct wl_array *options) +{ + int version; + + version = wl_resource_get_version(remote_surface->resource); + + if (version < TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_SINCE_VERSION) { + ds_err("not support remote_surface:%p version:%d", remote_surface, version); + return; + } + + tizen_remote_surface_send_changed_buffer(remote_surface->resource, + TIZEN_REMOTE_SURFACE_BUFFER_TYPE_IMAGE_FILE, + NULL, + image_file_fd, + image_file_size, + time, + options); +} + +WL_EXPORT void +ds_tizen_remote_surface_send_missing( + struct ds_tizen_remote_surface *remote_surface) +{ + tizen_remote_surface_send_missing(remote_surface->resource); +} + +WL_EXPORT void +ds_tizen_remote_surface_send_input_event_filter( + struct ds_tizen_remote_surface *remote_surface, + uint32_t input_event_filter) +{ + tizen_remote_surface_send_input_event_filter(remote_surface->resource, + input_event_filter); +} + +WL_EXPORT void +ds_tizen_remote_surface_add_new_region_listener( + struct ds_tizen_remote_surface *remote_surface, + struct wl_listener *listener) +{ + wl_signal_add(&remote_surface->events.new_region, listener); +} + +WL_EXPORT void +ds_tizen_remote_surface_region_add_destroy_listener( + struct ds_tizen_remote_surface_region *remote_region, + struct wl_listener *listener) +{ + wl_signal_add(&remote_region->events.destroy, listener); +} + +WL_EXPORT void +ds_tizen_remote_surface_region_add_set_geometry_listener( + struct ds_tizen_remote_surface_region *remote_region, + struct wl_listener *listener) +{ + wl_signal_add(&remote_region->events.set_geometry, listener); +} + +WL_EXPORT void +ds_tizen_remote_surface_region_get_geometry( + struct ds_tizen_remote_surface_region *remote_region, + int32_t *x,int32_t *y, int32_t *w, int32_t *h) +{ + if (x) *x = remote_region->x; + if (y) *y = remote_region->y; + if (w) *w = remote_region->w; + if (h) *h = remote_region->h; +} diff --git a/tests/meson.build b/tests/meson.build index bf9a9d8..59201d4 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -383,3 +383,22 @@ executable('libds-tizen-video-tests', install_dir: libds_tizen_bindir, install : true ) + +tc_remote_surface_files = [ + 'tc_main.cpp', + 'tc_remote_surface.cpp', +] + +executable('libds-tizen-remote-surface-tests', + [ + tc_mock_files, + tc_remote_surface_files + ], + dependencies: [ + deps_test_common, + deps_libds_tizen_remote_surface, + dependency('tizen-remote-surface-client', required: true), + ], + install_dir: libds_tizen_bindir, + install : true +) diff --git a/tests/mockclient.cpp b/tests/mockclient.cpp index 135c51c..3c12d65 100644 --- a/tests/mockclient.cpp +++ b/tests/mockclient.cpp @@ -112,3 +112,8 @@ void MockClient::ExpectProtocolError(const struct wl_interface *intf, << "Should get interface '" << intf->name << "' but got '" << interface->name << "'"; } + +struct wl_display * MockClient::GetWlDisplay() +{ + return display; +} diff --git a/tests/mockclient.h b/tests/mockclient.h index d3f4bf6..3fdd2eb 100644 --- a/tests/mockclient.h +++ b/tests/mockclient.h @@ -41,6 +41,7 @@ public: void RoundTrip(); void ExpectNoError(); void ExpectProtocolError(const struct wl_interface *intf, uint32_t code); + struct wl_display * GetWlDisplay(); private: struct wl_display *display; diff --git a/tests/tc_remote_surface.cpp b/tests/tc_remote_surface.cpp new file mode 100644 index 0000000..3cbfd6d --- /dev/null +++ b/tests/tc_remote_surface.cpp @@ -0,0 +1,815 @@ +#include "tc_main.h" +#include "mockclient.h" +#include "mockcompositor.h" + +#include +#include +#include +#include +#include +#include + +TEST(RemoteSurfaceSimpleTest, CreateRemoteSurfaceManager) +{ + struct wl_display *display = wl_display_create(); + + struct ds_tizen_remote_surface_manager *remote_surface_manager = + ds_tizen_remote_surface_manager_create(display); + ASSERT_NE(remote_surface_manager, nullptr); + + wl_display_destroy(display); +} + +class RemoteSurfaceCompositor : public MockCompositor, public ::testing::Test +{ +public: + RemoteSurfaceCompositor() : + MockCompositor(&RemoteSurfaceCompositor::SetUpComp, this) + { + } + + static void SetUpComp(void *data) + { + RemoteSurfaceCompositor *comp = static_cast(data); + + struct ds_tizen_remote_surface_manager *remote_surface_manager = + ds_tizen_remote_surface_manager_create(comp->GetWlDisplay()); + ASSERT_NE(remote_surface_manager, nullptr); + + struct wayland_tbm_server *tbm_server = + wayland_tbm_server_init(comp->GetWlDisplay(), NULL, -1, 0);; + ASSERT_NE(tbm_server, nullptr); + } +}; + +static void handle_global(void *data, struct wl_registry *registry, + uint32_t name, const char *interface, uint32_t version); +static void handle_global_remove(void *data, struct wl_registry *registry, + uint32_t name); + +static const struct wl_registry_listener registry_listener = { + .global = handle_global, + .global_remove = handle_global_remove, +}; + +class MockRemoteSurfaceClient : public MockClient +{ +public: + MockRemoteSurfaceClient() : MockClient(®istry_listener, this), + resource_id(0), + provider_visibility(0), + input_event_filter(0) + { + EXPECT_NE(this->compositor, nullptr); + EXPECT_NE(this->remote_surface_manager, nullptr); + + surface = wl_compositor_create_surface(this->compositor); + EXPECT_NE(this->surface, nullptr); + + surface2 = wl_compositor_create_surface(this->compositor); + EXPECT_NE(this->surface, nullptr); + + wl_tbm_client = wayland_tbm_client_init(GetWlDisplay()); + EXPECT_NE(wl_tbm_client, nullptr); + + wl_tbm = wayland_tbm_client_get_wl_tbm(wl_tbm_client); + } + + ~MockRemoteSurfaceClient() + { + wl_surface_destroy(this->surface); + tizen_remote_surface_manager_destroy(this->remote_surface_manager); + wl_compositor_destroy(this->compositor); + } + + struct wl_compositor *compositor; + struct tizen_remote_surface_manager *remote_surface_manager; + struct wl_surface *surface, *surface2; + uint32_t resource_id; + uint32_t provider_visibility; + uint32_t input_event_filter; + struct wayland_tbm_client *wl_tbm_client; + struct wl_tbm *wl_tbm; +}; + +static void +handle_global(void *data, struct wl_registry *registry, + uint32_t name, const char *interface, uint32_t version) +{ + MockRemoteSurfaceClient *client = static_cast(data); + + if (strcmp(interface, "wl_compositor") == 0) { + client->compositor = static_cast( + wl_registry_bind(registry, name, &wl_compositor_interface, 4)); + } else if (strcmp(interface, "tizen_remote_surface_manager") == 0) { + client->remote_surface_manager = static_cast( + wl_registry_bind(registry, name, &tizen_remote_surface_manager_interface, 6)); + } +} + +static void +handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) +{ +} + +static void +handle_provider_resource_id(void *data, + struct tizen_remote_surface_provider *provider, + uint32_t resource_id) +{ + MockRemoteSurfaceClient *client = static_cast(data); + + client->resource_id = resource_id; +} + +static void +handle_provider_visibility(void *data, + struct tizen_remote_surface_provider *provider, + uint32_t visibility) +{ + MockRemoteSurfaceClient *client = static_cast(data); + + client->provider_visibility = visibility; +} + +static const struct tizen_remote_surface_provider_listener provider_listener = +{ + handle_provider_resource_id, + handle_provider_visibility, +}; + +static void +handle_remote_surface_update_buffer(void *data, + struct tizen_remote_surface *remote_surface, + struct wl_buffer *buffer, + uint32_t time) +{ + wl_buffer_destroy(buffer); +} + +static void +handle_remote_surface_missing(void *data, + struct tizen_remote_surface *remote_surface) +{ +} + +static void +handle_remote_surface_changed_buffer(void *data, + struct tizen_remote_surface *remote_surface, + uint32_t type, + struct wl_buffer *tbm, + int32_t fd, + uint32_t size, + uint32_t time, + struct wl_array *keys) +{ + tbm_surface_h tbm_surface; + + if (type == TIZEN_REMOTE_SURFACE_BUFFER_TYPE_TBM) { + tbm_surface = static_cast(wl_buffer_get_user_data(tbm)); + ASSERT_EQ(tbm_surface, nullptr); + + wl_buffer_destroy(tbm); + } + + close(fd); +} + +static void +handle_remote_surface_input_ev_filter(void *data, + struct tizen_remote_surface *tizen_remote_surface, + uint32_t input_event_filter) +{ + MockRemoteSurfaceClient *client = static_cast(data); + + client->input_event_filter = input_event_filter; +} + +static const struct tizen_remote_surface_listener remote_surface_listener = +{ + handle_remote_surface_update_buffer, /* deprecated */ + handle_remote_surface_missing, + handle_remote_surface_changed_buffer, + handle_remote_surface_input_ev_filter, +}; + +TEST_F(RemoteSurfaceCompositor, CreateProvider) +{ + MockRemoteSurfaceClient *client = new MockRemoteSurfaceClient(); + + struct tizen_remote_surface_provider *remote_surface_provider; + + remote_surface_provider = + tizen_remote_surface_manager_create_provider(client->remote_surface_manager, + client->surface); + EXPECT_TRUE(remote_surface_provider); + + tizen_remote_surface_provider_add_listener(remote_surface_provider, + &provider_listener, + client); + + client->ExpectNoError(); + + tizen_remote_surface_provider_destroy(remote_surface_provider); + delete client; +} + +TEST_F(RemoteSurfaceCompositor, ProviderOffscreenSet) +{ + MockRemoteSurfaceClient *client = new MockRemoteSurfaceClient(); + + struct tizen_remote_surface_provider *remote_surface_provider; + + remote_surface_provider = + tizen_remote_surface_manager_create_provider(client->remote_surface_manager, + client->surface); + EXPECT_TRUE(remote_surface_provider); + + tizen_remote_surface_provider_add_listener(remote_surface_provider, + &provider_listener, + client); + client->ExpectNoError(); + + tizen_remote_surface_provider_offscreen_set(remote_surface_provider, 1); + client->ExpectNoError(); + + tizen_remote_surface_provider_destroy(remote_surface_provider); + delete client; +} + +TEST_F(RemoteSurfaceCompositor, ProviderSetInputEventFilter) +{ + MockRemoteSurfaceClient *client = new MockRemoteSurfaceClient(); + + struct tizen_remote_surface_provider *remote_surface_provider; + + remote_surface_provider = + tizen_remote_surface_manager_create_provider(client->remote_surface_manager, + client->surface); + EXPECT_TRUE(remote_surface_provider); + + tizen_remote_surface_provider_add_listener(remote_surface_provider, + &provider_listener, + client); + client->ExpectNoError(); + + tizen_remote_surface_provider_set_input_event_filter(remote_surface_provider, + TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_MOUSE_ALL| + TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_MOUSE_WHEEL_ALL | + TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_TOUCH_ALL | + TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_TOUCH_CANCEL_ALL | + TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_KEY_ALL); + client->ExpectNoError(); + + tizen_remote_surface_provider_destroy(remote_surface_provider); + delete client; +} + +TEST_F(RemoteSurfaceCompositor, CreateSurface) +{ + MockRemoteSurfaceClient *client = new MockRemoteSurfaceClient(); + + struct tizen_remote_surface_provider *remote_surface_provider; + struct tizen_remote_surface *remote_surface; + + remote_surface_provider = + tizen_remote_surface_manager_create_provider(client->remote_surface_manager, + client->surface); + EXPECT_TRUE(remote_surface_provider); + + tizen_remote_surface_provider_add_listener(remote_surface_provider, + &provider_listener, + client); + client->ExpectNoError(); + + remote_surface = tizen_remote_surface_manager_create_surface( + client->remote_surface_manager, client->resource_id, client->wl_tbm); + EXPECT_TRUE(remote_surface); + + tizen_remote_surface_add_listener(remote_surface, &remote_surface_listener, NULL); + client->ExpectNoError(); + + tizen_remote_surface_provider_destroy(remote_surface_provider); + tizen_remote_surface_destroy(remote_surface); + delete client; +} + +TEST_F(RemoteSurfaceCompositor, CreateSurfaceWithWlSurface) +{ + MockRemoteSurfaceClient *client = new MockRemoteSurfaceClient(); + + struct tizen_remote_surface_provider *remote_surface_provider; + struct tizen_remote_surface *remote_surface; + + remote_surface_provider = + tizen_remote_surface_manager_create_provider(client->remote_surface_manager, + client->surface); + EXPECT_TRUE(remote_surface_provider); + + tizen_remote_surface_provider_add_listener(remote_surface_provider, + &provider_listener, + client); + client->ExpectNoError(); + + remote_surface = tizen_remote_surface_manager_create_surface_with_wl_surface( + client->remote_surface_manager, client->resource_id, client->wl_tbm, client->surface2); + EXPECT_TRUE(remote_surface); + + tizen_remote_surface_add_listener(remote_surface, &remote_surface_listener, NULL); + client->ExpectNoError(); + + tizen_remote_surface_provider_destroy(remote_surface_provider); + tizen_remote_surface_destroy(remote_surface); + delete client; +} + +TEST_F(RemoteSurfaceCompositor, SurfaceRedirect) +{ + MockRemoteSurfaceClient *client = new MockRemoteSurfaceClient(); + + struct tizen_remote_surface_provider *remote_surface_provider; + struct tizen_remote_surface *remote_surface; + + remote_surface_provider = + tizen_remote_surface_manager_create_provider(client->remote_surface_manager, + client->surface); + EXPECT_TRUE(remote_surface_provider); + + tizen_remote_surface_provider_add_listener(remote_surface_provider, + &provider_listener, + client); + client->ExpectNoError(); + + remote_surface = tizen_remote_surface_manager_create_surface_with_wl_surface( + client->remote_surface_manager, client->resource_id, client->wl_tbm, client->surface2); + EXPECT_TRUE(remote_surface); + + tizen_remote_surface_add_listener(remote_surface, &remote_surface_listener, NULL); + client->ExpectNoError(); + + tizen_remote_surface_redirect(remote_surface); + client->ExpectNoError(); + + tizen_remote_surface_provider_destroy(remote_surface_provider); + tizen_remote_surface_destroy(remote_surface); + delete client; +} + +TEST_F(RemoteSurfaceCompositor, SurfaceUnredirect) +{ + MockRemoteSurfaceClient *client = new MockRemoteSurfaceClient(); + + struct tizen_remote_surface_provider *remote_surface_provider; + struct tizen_remote_surface *remote_surface; + + remote_surface_provider = + tizen_remote_surface_manager_create_provider(client->remote_surface_manager, + client->surface); + EXPECT_TRUE(remote_surface_provider); + + tizen_remote_surface_provider_add_listener(remote_surface_provider, + &provider_listener, + client); + client->ExpectNoError(); + + remote_surface = tizen_remote_surface_manager_create_surface_with_wl_surface( + client->remote_surface_manager, client->resource_id, client->wl_tbm, client->surface2); + EXPECT_TRUE(remote_surface); + + tizen_remote_surface_add_listener(remote_surface, &remote_surface_listener, NULL); + client->ExpectNoError(); + + tizen_remote_surface_unredirect(remote_surface); + client->ExpectNoError(); + + tizen_remote_surface_provider_destroy(remote_surface_provider); + tizen_remote_surface_destroy(remote_surface); + delete client; +} + +TEST_F(RemoteSurfaceCompositor, SurfaceTransferMouseEvent) +{ + MockRemoteSurfaceClient *client = new MockRemoteSurfaceClient(); + + struct tizen_remote_surface_provider *remote_surface_provider; + struct tizen_remote_surface *remote_surface; + uint32_t event_type = 0; + int32_t device = 0; + int32_t button = 0; + int32_t x = 0, y = 0; + wl_fixed_t radius_x = 0, radius_y = 0; + wl_fixed_t pressure = 0; + wl_fixed_t angle = 0; + uint32_t clas = 0, subclas = 0; + const char *identifier = "test_identifier"; + uint32_t time = 0; + + remote_surface_provider = + tizen_remote_surface_manager_create_provider(client->remote_surface_manager, + client->surface); + EXPECT_TRUE(remote_surface_provider); + + tizen_remote_surface_provider_add_listener(remote_surface_provider, + &provider_listener, + client); + client->ExpectNoError(); + + remote_surface = tizen_remote_surface_manager_create_surface_with_wl_surface( + client->remote_surface_manager, client->resource_id, client->wl_tbm, client->surface2); + EXPECT_TRUE(remote_surface); + + tizen_remote_surface_add_listener(remote_surface, &remote_surface_listener, NULL); + client->ExpectNoError(); + + tizen_remote_surface_transfer_mouse_event(remote_surface, + event_type, + device, + button, + x, + y, + radius_x, + radius_y, + pressure, + angle, + clas, + subclas, + identifier, + time); + client->ExpectNoError(); + + tizen_remote_surface_provider_destroy(remote_surface_provider); + tizen_remote_surface_destroy(remote_surface); + delete client; +} + +TEST_F(RemoteSurfaceCompositor, SurfaceTransferMouseWheel) +{ + MockRemoteSurfaceClient *client = new MockRemoteSurfaceClient(); + + struct tizen_remote_surface_provider *remote_surface_provider; + struct tizen_remote_surface *remote_surface; + uint32_t direction = 0; + int32_t z = 0; + uint32_t clas = 0, subclas = 0; + const char *identifier = "test_identifier"; + uint32_t time = 0; + + remote_surface_provider = + tizen_remote_surface_manager_create_provider(client->remote_surface_manager, + client->surface); + EXPECT_TRUE(remote_surface_provider); + + tizen_remote_surface_provider_add_listener(remote_surface_provider, + &provider_listener, + client); + client->ExpectNoError(); + + remote_surface = tizen_remote_surface_manager_create_surface_with_wl_surface( + client->remote_surface_manager, client->resource_id, client->wl_tbm, client->surface2); + EXPECT_TRUE(remote_surface); + + tizen_remote_surface_add_listener(remote_surface, &remote_surface_listener, NULL); + client->ExpectNoError(); + + tizen_remote_surface_transfer_mouse_wheel(remote_surface, + direction, + z, + clas, + subclas, + identifier, + time); + client->ExpectNoError(); + + tizen_remote_surface_provider_destroy(remote_surface_provider); + tizen_remote_surface_destroy(remote_surface); + delete client; +} + +TEST_F(RemoteSurfaceCompositor, SurfaceTransferTouchEvent) +{ + MockRemoteSurfaceClient *client = new MockRemoteSurfaceClient(); + + struct tizen_remote_surface_provider *remote_surface_provider; + struct tizen_remote_surface *remote_surface; + uint32_t event_type = 0; + int32_t device = 0; + int32_t button = 0; + int32_t x = 0, y = 0; + wl_fixed_t radius_x = 0, radius_y = 0; + wl_fixed_t pressure = 0; + wl_fixed_t angle = 0; + uint32_t clas = 0, subclas = 0; + const char *identifier = "test_identifier"; + uint32_t time = 0; + + remote_surface_provider = + tizen_remote_surface_manager_create_provider(client->remote_surface_manager, + client->surface); + EXPECT_TRUE(remote_surface_provider); + + tizen_remote_surface_provider_add_listener(remote_surface_provider, + &provider_listener, + client); + client->ExpectNoError(); + + remote_surface = tizen_remote_surface_manager_create_surface_with_wl_surface( + client->remote_surface_manager, client->resource_id, client->wl_tbm, client->surface2); + EXPECT_TRUE(remote_surface); + + tizen_remote_surface_add_listener(remote_surface, &remote_surface_listener, NULL); + client->ExpectNoError(); + + tizen_remote_surface_transfer_touch_event(remote_surface, + event_type, + device, + button, + x, + y, + radius_x, + radius_y, + pressure, + angle, + clas, + subclas, + identifier, + time); + client->ExpectNoError(); + + tizen_remote_surface_provider_destroy(remote_surface_provider); + tizen_remote_surface_destroy(remote_surface); + delete client; +} + +TEST_F(RemoteSurfaceCompositor, SurfaceTransferTouchCancel) +{ + MockRemoteSurfaceClient *client = new MockRemoteSurfaceClient(); + + struct tizen_remote_surface_provider *remote_surface_provider; + struct tizen_remote_surface *remote_surface; + + remote_surface_provider = + tizen_remote_surface_manager_create_provider(client->remote_surface_manager, + client->surface); + EXPECT_TRUE(remote_surface_provider); + + tizen_remote_surface_provider_add_listener(remote_surface_provider, + &provider_listener, + client); + client->ExpectNoError(); + + remote_surface = tizen_remote_surface_manager_create_surface_with_wl_surface( + client->remote_surface_manager, client->resource_id, client->wl_tbm, client->surface2); + EXPECT_TRUE(remote_surface); + + tizen_remote_surface_add_listener(remote_surface, &remote_surface_listener, NULL); + client->ExpectNoError(); + + tizen_remote_surface_transfer_touch_cancel(remote_surface); + client->ExpectNoError(); + + tizen_remote_surface_provider_destroy(remote_surface_provider); + tizen_remote_surface_destroy(remote_surface); + delete client; +} + +TEST_F(RemoteSurfaceCompositor, SurfaceTransferKeyEvent) +{ + MockRemoteSurfaceClient *client = new MockRemoteSurfaceClient(); + + struct tizen_remote_surface_provider *remote_surface_provider; + struct tizen_remote_surface *remote_surface; + uint32_t event_type = 0; + int32_t keycode = 0; + uint32_t clas = 0, subclas = 0; + const char *identifier = "test_identifier"; + uint32_t time = 0; + + remote_surface_provider = + tizen_remote_surface_manager_create_provider(client->remote_surface_manager, + client->surface); + EXPECT_TRUE(remote_surface_provider); + + tizen_remote_surface_provider_add_listener(remote_surface_provider, + &provider_listener, + client); + client->ExpectNoError(); + + remote_surface = tizen_remote_surface_manager_create_surface_with_wl_surface( + client->remote_surface_manager, client->resource_id, client->wl_tbm, client->surface2); + EXPECT_TRUE(remote_surface); + + tizen_remote_surface_add_listener(remote_surface, &remote_surface_listener, NULL); + client->ExpectNoError(); + + tizen_remote_surface_transfer_key_event(remote_surface, + event_type, + keycode, + clas, + subclas, + identifier, + time); + client->ExpectNoError(); + + tizen_remote_surface_provider_destroy(remote_surface_provider); + tizen_remote_surface_destroy(remote_surface); + delete client; +} + +TEST_F(RemoteSurfaceCompositor, SurfaceTransferVisibility) +{ + MockRemoteSurfaceClient *client = new MockRemoteSurfaceClient(); + + struct tizen_remote_surface_provider *remote_surface_provider; + struct tizen_remote_surface *remote_surface; + + remote_surface_provider = + tizen_remote_surface_manager_create_provider(client->remote_surface_manager, + client->surface); + EXPECT_TRUE(remote_surface_provider); + + tizen_remote_surface_provider_add_listener(remote_surface_provider, + &provider_listener, + client); + client->ExpectNoError(); + + remote_surface = tizen_remote_surface_manager_create_surface_with_wl_surface( + client->remote_surface_manager, client->resource_id, client->wl_tbm, client->surface2); + EXPECT_TRUE(remote_surface); + + tizen_remote_surface_add_listener(remote_surface, &remote_surface_listener, NULL); + client->ExpectNoError(); + + tizen_remote_surface_transfer_visibility(remote_surface, + TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_VISIBLE); + client->ExpectNoError(); + + tizen_remote_surface_provider_destroy(remote_surface_provider); + tizen_remote_surface_destroy(remote_surface); + delete client; +} + +TEST_F(RemoteSurfaceCompositor, SurfaceSetOwner) +{ + MockRemoteSurfaceClient *client = new MockRemoteSurfaceClient(); + + struct tizen_remote_surface_provider *remote_surface_provider; + struct tizen_remote_surface *remote_surface; + + remote_surface_provider = + tizen_remote_surface_manager_create_provider(client->remote_surface_manager, + client->surface); + EXPECT_TRUE(remote_surface_provider); + + tizen_remote_surface_provider_add_listener(remote_surface_provider, + &provider_listener, + client); + client->ExpectNoError(); + + remote_surface = tizen_remote_surface_manager_create_surface( + client->remote_surface_manager, client->resource_id, client->wl_tbm); + EXPECT_TRUE(remote_surface); + + tizen_remote_surface_add_listener(remote_surface, &remote_surface_listener, NULL); + client->ExpectNoError(); + + tizen_remote_surface_set_owner(remote_surface, client->surface2); + client->ExpectNoError(); + + tizen_remote_surface_provider_destroy(remote_surface_provider); + tizen_remote_surface_destroy(remote_surface); + delete client; +} + +TEST_F(RemoteSurfaceCompositor, SurfaceSetRemoteRender) +{ + MockRemoteSurfaceClient *client = new MockRemoteSurfaceClient(); + + struct tizen_remote_surface_provider *remote_surface_provider; + struct tizen_remote_surface *remote_surface; + + remote_surface_provider = + tizen_remote_surface_manager_create_provider(client->remote_surface_manager, + client->surface); + EXPECT_TRUE(remote_surface_provider); + + tizen_remote_surface_provider_add_listener(remote_surface_provider, + &provider_listener, + client); + client->ExpectNoError(); + + remote_surface = tizen_remote_surface_manager_create_surface_with_wl_surface( + client->remote_surface_manager, client->resource_id, client->wl_tbm, client->surface2); + EXPECT_TRUE(remote_surface); + + tizen_remote_surface_add_listener(remote_surface, &remote_surface_listener, NULL); + client->ExpectNoError(); + + tizen_remote_surface_set_remote_render(remote_surface, 1); + client->ExpectNoError(); + + tizen_remote_surface_provider_destroy(remote_surface_provider); + tizen_remote_surface_destroy(remote_surface); + delete client; +} + +TEST_F(RemoteSurfaceCompositor, SurfaceSetChangedBufferEventFilter) +{ + MockRemoteSurfaceClient *client = new MockRemoteSurfaceClient(); + + struct tizen_remote_surface_provider *remote_surface_provider; + struct tizen_remote_surface *remote_surface; + + remote_surface_provider = + tizen_remote_surface_manager_create_provider(client->remote_surface_manager, + client->surface); + EXPECT_TRUE(remote_surface_provider); + + tizen_remote_surface_provider_add_listener(remote_surface_provider, + &provider_listener, + client); + client->ExpectNoError(); + + remote_surface = tizen_remote_surface_manager_create_surface_with_wl_surface( + client->remote_surface_manager, client->resource_id, client->wl_tbm, client->surface2); + EXPECT_TRUE(remote_surface); + + tizen_remote_surface_add_listener(remote_surface, &remote_surface_listener, NULL); + client->ExpectNoError(); + + tizen_remote_surface_set_changed_buffer_event_filter(remote_surface, + TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_EVENT_FILTER_TBM | + TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_EVENT_FILTER_IMAGE_FILE); + client->ExpectNoError(); + + tizen_remote_surface_provider_destroy(remote_surface_provider); + tizen_remote_surface_destroy(remote_surface); + delete client; +} + +TEST_F(RemoteSurfaceCompositor, SurfaceGetCurrentBuffer) +{ + MockRemoteSurfaceClient *client = new MockRemoteSurfaceClient(); + + struct tizen_remote_surface_provider *remote_surface_provider; + struct tizen_remote_surface *remote_surface; + + remote_surface_provider = + tizen_remote_surface_manager_create_provider(client->remote_surface_manager, + client->surface); + EXPECT_TRUE(remote_surface_provider); + + tizen_remote_surface_provider_add_listener(remote_surface_provider, + &provider_listener, + client); + client->ExpectNoError(); + + remote_surface = tizen_remote_surface_manager_create_surface_with_wl_surface( + client->remote_surface_manager, client->resource_id, client->wl_tbm, client->surface2); + EXPECT_TRUE(remote_surface); + + tizen_remote_surface_add_listener(remote_surface, &remote_surface_listener, NULL); + client->ExpectNoError(); + + tizen_remote_surface_get_current_buffer(remote_surface, TIZEN_REMOTE_SURFACE_BUFFER_TYPE_TBM, 1); + client->ExpectNoError(); + + tizen_remote_surface_provider_destroy(remote_surface_provider); + tizen_remote_surface_destroy(remote_surface); + delete client; +} + +TEST_F(RemoteSurfaceCompositor, RegionSetGeometry) +{ + MockRemoteSurfaceClient *client = new MockRemoteSurfaceClient(); + + struct tizen_remote_surface_provider *remote_surface_provider; + struct tizen_remote_surface *remote_surface; + struct tizen_remote_surface_region *region; + + remote_surface_provider = + tizen_remote_surface_manager_create_provider(client->remote_surface_manager, + client->surface); + EXPECT_TRUE(remote_surface_provider); + + tizen_remote_surface_provider_add_listener(remote_surface_provider, + &provider_listener, + client); + client->ExpectNoError(); + + remote_surface = tizen_remote_surface_manager_create_surface_with_wl_surface( + client->remote_surface_manager, client->resource_id, client->wl_tbm, client->surface2); + EXPECT_TRUE(remote_surface); + + tizen_remote_surface_add_listener(remote_surface, &remote_surface_listener, NULL); + client->ExpectNoError(); + + region = tizen_remote_surface_create_region(remote_surface); + EXPECT_TRUE(region); + + tizen_remote_surface_region_set_geometry(region, 0, 0, 100, 100); + client->ExpectNoError(); + + tizen_remote_surface_provider_destroy(remote_surface_provider); + tizen_remote_surface_destroy(remote_surface); + delete client; +} -- 2.7.4 From 92b877b490e9bbe232e826c8b3cd80a92d150355 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 25 Oct 2022 17:53:24 +0900 Subject: [PATCH 02/16] examples: make tinyds-policy files move the implementation of ds_tizen_policy at tinyds-tdm.c to tinyds-policy file. Change-Id: I690b48bf49485f24ab1dc74c56434e3667695b57 --- examples/meson.build | 1 + examples/tinyds-policy.c | 1019 ++++++++++++++++++++++++++++++++++++++ examples/tinyds-policy.h | 10 + examples/tinyds-tdm-common.h | 42 ++ examples/tinyds-tdm.c | 1114 +----------------------------------------- examples/tinyds-tdm.h | 64 +++ 6 files changed, 1147 insertions(+), 1103 deletions(-) create mode 100644 examples/tinyds-policy.c create mode 100644 examples/tinyds-policy.h create mode 100644 examples/tinyds-tdm-common.h create mode 100644 examples/tinyds-tdm.h diff --git a/examples/meson.build b/examples/meson.build index dbda372..c5addef 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -21,6 +21,7 @@ tinyds_tdm_files = [ 'pixman-tbm-helper.c', 'tinyds-tdm-renderer.c', 'protocol-trace.c', + 'tinyds-policy.c', ] executable('tinyds-tdm', diff --git a/examples/tinyds-policy.c b/examples/tinyds-policy.c new file mode 100644 index 0000000..5ee56af --- /dev/null +++ b/examples/tinyds-policy.c @@ -0,0 +1,1019 @@ +#include + +#include "tinyds-tdm-common.h" +#include "tinyds-policy.h" + +struct tinyds_policy +{ + policy_free_cb free_cb; + void *data; + + struct ds_tizen_policy *policy; + + struct wl_listener destroy; + struct wl_listener new_surface; + struct wl_listener activate_below_by_univeral_id; + struct wl_listener lower_by_universal_id; + struct wl_listener set_transient_for; + struct wl_listener unset_transient_for; + struct wl_listener place_subsurface_below_parent; + struct wl_listener set_subsurface_stand_alone; + struct wl_listener set_background_state; + struct wl_listener unset_background_state; + struct wl_listener add_activate_above_by_universal_id; + struct wl_listener set_appid; + struct wl_listener set_transient_for_below; + + struct wl_list policy_surfaces; +}; + +struct tinyds_policy_surface +{ + struct ds_tizen_policy_surface *policy_surface; + + struct wl_listener destroy; + struct wl_listener new_visibility; + struct wl_listener new_position; + struct wl_listener activate; + struct wl_listener raise; + struct wl_listener lower; + struct wl_listener set_focus_skip; + struct wl_listener unset_focus_skip; + struct wl_listener set_role; + struct wl_listener set_window_type; + struct wl_listener set_conformant; + struct wl_listener unset_conformant; + struct wl_listener get_conformant; + struct wl_listener set_notification_level; + struct wl_listener set_window_screen_mode; + struct wl_listener get_subsurface; + struct wl_listener iconify; + struct wl_listener uniconify; + struct wl_listener add_aux_hint; + struct wl_listener change_aux_hint; + struct wl_listener delete_aux_hint; + struct wl_listener get_supported_aux_hints; + struct wl_listener set_floating_mode; + struct wl_listener unset_floating_mode; + struct wl_listener set_stack_mode; + struct wl_listener new_subsurface_watcher; + struct wl_listener set_parent; + struct wl_listener ack_conformant_region; + struct wl_listener set_video; + struct wl_listener show; + struct wl_listener hide; + struct wl_listener set_parent_with_below; + + struct wl_list visibilities; + struct wl_list positions; + struct wl_list subsurface_watchers; + + struct wl_list link; //tinyds_policy::policy_surfaces +}; + +struct tinyds_policy_visibility +{ + struct ds_tizen_policy_visibility *visibility; + + struct wl_listener destroy; + + struct wl_list link; //tinyds_policy::visibilities +}; + +struct tinyds_policy_position +{ + struct ds_tizen_policy_position *position; + + struct wl_listener destroy; + struct wl_listener set; + + struct wl_list link; //tinyds_policy::positions +}; + +struct tinyds_policy_subsurface_watcher +{ + struct ds_tizen_policy_subsurface_watcher *subsurface_watcher; + + struct wl_listener destroy; + + struct wl_list link; //tinyds_policy::subsurface_watchers +}; + + +static void +visibility_handle_destroy(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_visibility *visibility; + + visibility = wl_container_of(listener, visibility, destroy); + + ds_inf("Policy Visibility(%p) destroy", visibility); + + wl_list_remove(&visibility->destroy.link); + wl_list_remove(&visibility->link); + free(visibility); +} + +static void +position_handle_destroy(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_position *position; + + position = wl_container_of(listener, position, destroy); + + ds_inf("Policy Position(%p) destroy", position); + + wl_list_remove(&position->destroy.link); + wl_list_remove(&position->set.link); + wl_list_remove(&position->link); + free(position); +} + +static void +position_handle_set(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_position *position; + + position = wl_container_of(listener, position, set); + + ds_inf("Policy Position(%p) set", position); + + // TODO: +} + +static void +subsurface_watcher_handle_destroy(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_subsurface_watcher *subsurface_watcher; + + subsurface_watcher = wl_container_of(listener, subsurface_watcher, destroy); + + ds_inf("Policy Subsurface_Watcher(%p) destroy", subsurface_watcher); + + wl_list_remove(&subsurface_watcher->destroy.link); + wl_list_remove(&subsurface_watcher->link); + free(subsurface_watcher); +} + +static void +policy_surface_handle_destroy(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, destroy); + + ds_inf("Policy Info(%p) destroy", policy_surface); + + wl_list_remove(&policy_surface->destroy.link); + wl_list_remove(&policy_surface->new_visibility.link); + wl_list_remove(&policy_surface->new_position.link); + wl_list_remove(&policy_surface->activate.link); + wl_list_remove(&policy_surface->raise.link); + wl_list_remove(&policy_surface->lower.link); + wl_list_remove(&policy_surface->set_focus_skip.link); + wl_list_remove(&policy_surface->unset_focus_skip.link); + wl_list_remove(&policy_surface->set_role.link); + wl_list_remove(&policy_surface->set_window_type.link); + wl_list_remove(&policy_surface->set_conformant.link); + wl_list_remove(&policy_surface->unset_conformant.link); + wl_list_remove(&policy_surface->get_conformant.link); + wl_list_remove(&policy_surface->set_notification_level.link); + wl_list_remove(&policy_surface->set_window_screen_mode.link); + wl_list_remove(&policy_surface->get_subsurface.link); + wl_list_remove(&policy_surface->iconify.link); + wl_list_remove(&policy_surface->uniconify.link); + wl_list_remove(&policy_surface->add_aux_hint.link); + wl_list_remove(&policy_surface->change_aux_hint.link); + wl_list_remove(&policy_surface->delete_aux_hint.link); + wl_list_remove(&policy_surface->get_supported_aux_hints.link); + wl_list_remove(&policy_surface->set_floating_mode.link); + wl_list_remove(&policy_surface->unset_floating_mode.link); + wl_list_remove(&policy_surface->set_stack_mode.link); + wl_list_remove(&policy_surface->new_subsurface_watcher.link); + wl_list_remove(&policy_surface->set_parent.link); + wl_list_remove(&policy_surface->ack_conformant_region.link); + wl_list_remove(&policy_surface->set_video.link); + wl_list_remove(&policy_surface->show.link); + wl_list_remove(&policy_surface->hide.link); + wl_list_remove(&policy_surface->set_parent_with_below.link); + wl_list_remove(&policy_surface->link); + free(policy_surface); +} + +static void +policy_surface_handle_new_visibility(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + struct tinyds_policy_visibility *visibility; + struct ds_tizen_event_policy_surface_new_visibility *event; + + policy_surface = wl_container_of(listener, policy_surface, new_visibility); + event = (struct ds_tizen_event_policy_surface_new_visibility *)data; + + ds_inf("Policy Info(%p) new_visibility", policy_surface); + + visibility = calloc(1, sizeof *visibility); + if (!visibility) + return; + + visibility->visibility = event->visibility; + + visibility->destroy.notify = visibility_handle_destroy; + ds_tizen_policy_visibility_add_destroy_listener(visibility->visibility, + &visibility->destroy); + + wl_list_insert(&policy_surface->visibilities, &visibility->link); +} + +static void +policy_surface_handle_new_position(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + struct tinyds_policy_position *position; + struct ds_tizen_event_policy_surface_new_position *event; + + policy_surface = wl_container_of(listener, policy_surface, new_position); + event = (struct ds_tizen_event_policy_surface_new_position *)data; + + ds_inf("Policy Info(%p) new_position", policy_surface); + + position = calloc(1, sizeof *position); + if (!position) + return; + + position->position = event->position; + + position->destroy.notify = position_handle_destroy; + ds_tizen_policy_position_add_destroy_listener(position->position, + &position->destroy); + + position->set.notify = position_handle_set; + ds_tizen_policy_position_add_set_listener(position->position, + &position->set); + + wl_list_insert(&policy_surface->positions, &position->link); +} + +static void +policy_surface_handle_activate(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, activate); + + ds_inf("Policy Info(%p) activate", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_raise(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, raise); + + ds_inf("Policy Info(%p) raise", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_lower(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, raise); + + ds_inf("Policy Info(%p) lower", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_set_focus_skip(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, set_focus_skip); + + ds_inf("Policy Info(%p) set_focus_skip", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_unset_focus_skip(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, unset_focus_skip); + + ds_inf("Policy Info(%p) unset_focus_skip", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_set_role(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, set_role); + + ds_inf("Policy Info(%p) set_role", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_set_window_type(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, set_window_type); + + ds_inf("Policy Info(%p) set_window_type", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_set_conformant(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, set_conformant); + + ds_inf("Policy Info(%p) set_conformant", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_unset_conformant(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, unset_conformant); + + ds_inf("Policy Info(%p) unset_conformant", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_get_conformant(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, get_conformant); + + ds_inf("Policy Info(%p) get_conformant", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_set_notification_level(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, set_notification_level); + + ds_inf("Policy Info(%p) set_notification_level", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_set_window_screen_mode(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, set_window_screen_mode); + + ds_inf("Policy Info(%p) set_window_screen_mode", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_get_subsurface(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, get_subsurface); + + ds_inf("Policy Info(%p) get_subsurface", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_iconify(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, iconify); + + ds_inf("Policy Info(%p) iconify", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_uniconify(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, uniconify); + + ds_inf("Policy Info(%p) uniconify", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_add_aux_hint(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, add_aux_hint); + + ds_inf("Policy Info(%p) add_aux_hint", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_change_aux_hint(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, change_aux_hint); + + ds_inf("Policy Info(%p) change_aux_hint", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_delete_aux_hint(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, delete_aux_hint); + + ds_inf("Policy Info(%p) delete_aux_hint", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_get_supported_aux_hints(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, get_supported_aux_hints); + + ds_inf("Policy Info(%p) get_supported_aux_hints", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_set_floating_mode(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, set_floating_mode); + + ds_inf("Policy Info(%p) set_floating_mode", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_unset_floating_mode(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, unset_floating_mode); + + ds_inf("Policy Info(%p) unset_floating_mode", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_set_stack_mode(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, set_stack_mode); + + ds_inf("Policy Info(%p) set_stack_mode", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_new_subsurface_watcher(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + struct tinyds_policy_subsurface_watcher*subsurface_watcher; + struct ds_tizen_event_policy_surface_new_subsurface_watcher *event; + + policy_surface = wl_container_of(listener, policy_surface, new_subsurface_watcher); + event = (struct ds_tizen_event_policy_surface_new_subsurface_watcher *)data; + + ds_inf("Policy Info(%p) new_subsurface_watcher", policy_surface); + + subsurface_watcher = calloc(1, sizeof *subsurface_watcher); + if (!subsurface_watcher) + return; + + subsurface_watcher->subsurface_watcher = event->subsurface_watcher; + + subsurface_watcher->destroy.notify = subsurface_watcher_handle_destroy; + ds_tizen_policy_subsurface_watcher_add_destroy_listener(subsurface_watcher->subsurface_watcher, + &subsurface_watcher->destroy); + + wl_list_insert(&policy_surface->subsurface_watchers, &subsurface_watcher->link); +} + +static void +policy_surface_handle_set_parent(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, set_parent); + + ds_inf("Policy Info(%p) set_parent", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_ack_conformant_region(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, ack_conformant_region); + + ds_inf("Policy Info(%p) ack_conformant_region", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_set_video(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, set_video); + + ds_inf("Policy Info(%p) set_video", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_show(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, show); + + ds_inf("Policy Info(%p) show", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_hide(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, hide); + + ds_inf("Policy Info(%p) hide", policy_surface); + + // TODO: +} + +static void +policy_surface_handle_set_parent_with_below(struct wl_listener *listener, void *data) +{ + struct tinyds_policy_surface *policy_surface; + + policy_surface = wl_container_of(listener, policy_surface, set_parent_with_below); + + ds_inf("Policy Info(%p) set_parent_with_below", policy_surface); + + // TODO: +} + +static void +policy_handle_destroy(struct wl_listener *listener, void *data) +{ + struct tinyds_policy *policy; + + policy = wl_container_of(listener, policy, destroy); + + ds_inf("Policy(%p) destroy", policy); + + policy->free_cb(data); + + wl_list_remove(&policy->destroy.link); + wl_list_remove(&policy->new_surface.link); + wl_list_remove(&policy->activate_below_by_univeral_id.link); + wl_list_remove(&policy->lower_by_universal_id.link); + wl_list_remove(&policy->set_transient_for.link); + wl_list_remove(&policy->unset_transient_for.link); + wl_list_remove(&policy->place_subsurface_below_parent.link); + wl_list_remove(&policy->set_subsurface_stand_alone.link); + wl_list_remove(&policy->set_background_state.link); + wl_list_remove(&policy->unset_background_state.link); + wl_list_remove(&policy->add_activate_above_by_universal_id.link); + wl_list_remove(&policy->set_appid.link); + wl_list_remove(&policy->set_transient_for_below.link); + + free(policy); +} + +static void +policy_handle_new_surface(struct wl_listener *listener, void *data) +{ + struct tinyds_policy *policy; + struct tinyds_policy_surface *policy_surface; + struct ds_tizen_event_policy_new_surface *event; + + policy = wl_container_of(listener, policy, new_surface); + event = (struct ds_tizen_event_policy_new_surface *)data; + + ds_inf("Policy(%p) new_surface", policy); + + policy_surface = calloc(1, sizeof *policy_surface); + if (!policy_surface) + return; + + policy_surface->policy_surface = event->policy_surface; + + policy_surface->destroy.notify = policy_surface_handle_destroy; + ds_tizen_policy_surface_add_destroy_listener(policy_surface->policy_surface, + &policy_surface->destroy); + + policy_surface->new_visibility.notify = policy_surface_handle_new_visibility; + ds_tizen_policy_surface_add_new_visibility_listener(policy_surface->policy_surface, + &policy_surface->new_visibility); + + policy_surface->new_position.notify = policy_surface_handle_new_position; + ds_tizen_policy_surface_add_new_position_listener(policy_surface->policy_surface, + &policy_surface->new_position); + + policy_surface->activate.notify = policy_surface_handle_activate; + ds_tizen_policy_surface_add_activate_listener(policy_surface->policy_surface, + &policy_surface->activate); + + policy_surface->raise.notify = policy_surface_handle_raise; + ds_tizen_policy_surface_add_raise_listener(policy_surface->policy_surface, + &policy_surface->raise); + + policy_surface->lower.notify = policy_surface_handle_lower; + ds_tizen_policy_surface_add_lower_listener(policy_surface->policy_surface, + &policy_surface->lower); + + policy_surface->set_focus_skip.notify = policy_surface_handle_set_focus_skip; + ds_tizen_policy_surface_add_set_focus_skip_listener(policy_surface->policy_surface, + &policy_surface->set_focus_skip); + + policy_surface->unset_focus_skip.notify = policy_surface_handle_unset_focus_skip; + ds_tizen_policy_surface_add_unset_focus_skip_listener(policy_surface->policy_surface, + &policy_surface->unset_focus_skip); + + policy_surface->set_role.notify = policy_surface_handle_set_role; + ds_tizen_policy_surface_add_set_role_listener(policy_surface->policy_surface, + &policy_surface->set_role); + + policy_surface->set_window_type.notify = policy_surface_handle_set_window_type; + ds_tizen_policy_surface_add_set_window_type_listener(policy_surface->policy_surface, + &policy_surface->set_window_type); + + policy_surface->set_conformant.notify = policy_surface_handle_set_conformant; + ds_tizen_policy_surface_add_set_conformant_listener(policy_surface->policy_surface, + &policy_surface->set_conformant); + + policy_surface->unset_conformant.notify = policy_surface_handle_unset_conformant; + ds_tizen_policy_surface_add_unset_conformant_listener(policy_surface->policy_surface, + &policy_surface->unset_conformant); + + policy_surface->get_conformant.notify = policy_surface_handle_get_conformant; + ds_tizen_policy_surface_add_get_conformant_listener(policy_surface->policy_surface, + &policy_surface->get_conformant); + + policy_surface->set_notification_level.notify = + policy_surface_handle_set_notification_level; + ds_tizen_policy_surface_add_set_notification_level_listener( + policy_surface->policy_surface, &policy_surface->set_notification_level); + + policy_surface->set_window_screen_mode.notify = + policy_surface_handle_set_window_screen_mode; + ds_tizen_policy_surface_add_set_window_screen_mode_listener( + policy_surface->policy_surface, &policy_surface->set_window_screen_mode); + + policy_surface->get_subsurface.notify = policy_surface_handle_get_subsurface; + ds_tizen_policy_surface_add_get_subsurface_listener(policy_surface->policy_surface, + &policy_surface->get_subsurface); + + policy_surface->iconify.notify = policy_surface_handle_iconify; + ds_tizen_policy_surface_add_iconify_listener(policy_surface->policy_surface, + &policy_surface->iconify); + + policy_surface->uniconify.notify = policy_surface_handle_uniconify; + ds_tizen_policy_surface_add_uniconify_listener(policy_surface->policy_surface, + &policy_surface->uniconify); + + policy_surface->add_aux_hint.notify = policy_surface_handle_add_aux_hint; + ds_tizen_policy_surface_add_add_aux_hint_listener(policy_surface->policy_surface, + &policy_surface->add_aux_hint); + + policy_surface->change_aux_hint.notify = policy_surface_handle_change_aux_hint; + ds_tizen_policy_surface_add_change_aux_hint_listener(policy_surface->policy_surface, + &policy_surface->change_aux_hint); + + policy_surface->delete_aux_hint.notify = policy_surface_handle_delete_aux_hint; + ds_tizen_policy_surface_add_delete_aux_hint_listener(policy_surface->policy_surface, + &policy_surface->delete_aux_hint); + + policy_surface->get_supported_aux_hints.notify = + policy_surface_handle_get_supported_aux_hints; + ds_tizen_policy_surface_add_get_supported_aux_hints_listener( + policy_surface->policy_surface, &policy_surface->get_supported_aux_hints); + + policy_surface->set_floating_mode.notify = + policy_surface_handle_set_floating_mode; + ds_tizen_policy_surface_add_set_floating_mode_listener( + policy_surface->policy_surface, &policy_surface->set_floating_mode); + + policy_surface->unset_floating_mode.notify = + policy_surface_handle_unset_floating_mode; + ds_tizen_policy_surface_add_unset_floating_mode_listener( + policy_surface->policy_surface, &policy_surface->unset_floating_mode); + + policy_surface->set_stack_mode.notify = policy_surface_handle_set_stack_mode; + ds_tizen_policy_surface_add_set_stack_mode_listener(policy_surface->policy_surface, + &policy_surface->set_stack_mode); + + policy_surface->new_subsurface_watcher.notify = + policy_surface_handle_new_subsurface_watcher; + ds_tizen_policy_surface_add_new_subsurface_watcher_listener( + policy_surface->policy_surface, &policy_surface->new_subsurface_watcher); + + policy_surface->set_parent.notify = policy_surface_handle_set_parent; + ds_tizen_policy_surface_add_set_parent_listener(policy_surface->policy_surface, + &policy_surface->set_parent); + + policy_surface->ack_conformant_region.notify = + policy_surface_handle_ack_conformant_region; + ds_tizen_policy_surface_add_ack_conformant_region_listener( + policy_surface->policy_surface, &policy_surface->ack_conformant_region); + + policy_surface->set_video.notify = policy_surface_handle_set_video; + ds_tizen_policy_surface_add_set_video_listener(policy_surface->policy_surface, + &policy_surface->set_video); + + policy_surface->show.notify = policy_surface_handle_show; + ds_tizen_policy_surface_add_show_listener(policy_surface->policy_surface, + &policy_surface->show); + + policy_surface->hide.notify = policy_surface_handle_hide; + ds_tizen_policy_surface_add_hide_listener(policy_surface->policy_surface, + &policy_surface->hide); + + policy_surface->set_parent_with_below.notify = + policy_surface_handle_set_parent_with_below; + ds_tizen_policy_surface_add_set_parent_with_below_listener( + policy_surface->policy_surface, &policy_surface->set_parent_with_below); + + + wl_list_init(&policy_surface->visibilities); + wl_list_init(&policy_surface->positions); + wl_list_init(&policy_surface->subsurface_watchers); + + wl_list_insert(&policy->policy_surfaces, &policy_surface->link); +} + +static void +policy_handle_activate_below_by_univeral_id(struct wl_listener *listener, void *data) +{ + struct tinyds_policy *policy; + + policy = wl_container_of(listener, policy, activate_below_by_univeral_id); + + ds_inf("Policy(%p) activate_below_by_univeral_id", policy); + + // TODO: +} + +static void +policy_handle_lower_by_universal_id(struct wl_listener *listener, void *data) +{ + struct tinyds_policy *policy; + + policy = wl_container_of(listener, policy, lower_by_universal_id); + + ds_inf("Policy(%p) lower_by_universal_id", policy); + + // TODO: +} + +static void +policy_handle_set_transient_for(struct wl_listener *listener, void *data) +{ + struct tinyds_policy *policy; + + policy = wl_container_of(listener, policy, set_transient_for); + + ds_inf("Policy(%p) set_transient_for", policy); + + // TODO: +} + +static void +policy_handle_unset_transient_for(struct wl_listener *listener, void *data) +{ + struct tinyds_policy *policy; + + policy = wl_container_of(listener, policy, unset_transient_for); + + ds_inf("Policy(%p) unset_transient_for", policy); + + // TODO: +} + +static void +policy_handle_place_subsurface_below_parent(struct wl_listener *listener, void *data) +{ + struct tinyds_policy *policy; + + policy = wl_container_of(listener, policy, place_subsurface_below_parent); + + ds_inf("Policy(%p) place_subsurface_below_parent", policy); + + // TODO: +} + +static void +policy_handle_set_subsurface_stand_alone(struct wl_listener *listener, void *data) +{ + struct tinyds_policy *policy; + + policy = wl_container_of(listener, policy, set_subsurface_stand_alone); + + ds_inf("Policy(%p) set_subsurface_stand_alone", policy); + + // TODO: +} + +static void +policy_handle_set_background_state(struct wl_listener *listener, void *data) +{ + struct tinyds_policy *policy; + + policy = wl_container_of(listener, policy, set_background_state); + + ds_inf("Policy(%p) set_background_state", policy); + + // TODO: +} + +static void +policy_handle_unset_background_state(struct wl_listener *listener, void *data) +{ + struct tinyds_policy *policy; + + policy = wl_container_of(listener, policy, unset_background_state); + + ds_inf("Policy(%p) unset_background_state", policy); + + // TODO: +} + +static void +policy_handle_add_activate_above_by_universal_id(struct wl_listener *listener, void *data) +{ + struct tinyds_policy *policy; + + policy = wl_container_of(listener, policy, add_activate_above_by_universal_id); + + ds_inf("Policy(%p) add_activate_above_by_universal_id", policy); + + // TODO: +} + +static void +policy_handle_set_appid(struct wl_listener *listener, void *data) +{ + struct tinyds_policy *policy; + + policy = wl_container_of(listener, policy, set_appid); + + ds_inf("Policy(%p) set_appid", policy); + + // TODO: +} + +static void +policy_handle_set_transient_for_below(struct wl_listener *listener, void *data) +{ + struct tinyds_policy *policy; + + policy = wl_container_of(listener, policy, set_transient_for_below); + + ds_inf("Policy(%p) set_transient_for_below", policy); + + // TODO: +} + +struct tinyds_policy * +tinyds_policy_init(struct wl_display *display, policy_free_cb free_cb, + void *data) +{ + struct tinyds_policy *policy; + + policy = calloc(1, sizeof *policy); + if (!policy) + return NULL; + + policy->free_cb = free_cb; + data = data; + + policy->policy = ds_tizen_policy_create(display); + if (!policy->policy) { + free(policy); + ds_err("Could not create ds_tizen_policy"); + return NULL; + } + + policy->destroy.notify = policy_handle_destroy; + ds_tizen_policy_add_destroy_listener(policy->policy, &policy->destroy); + + policy->new_surface.notify = policy_handle_new_surface; + ds_tizen_policy_add_new_surface_listener(policy->policy, &policy->new_surface); + + policy->activate_below_by_univeral_id.notify = + policy_handle_activate_below_by_univeral_id; + ds_tizen_policy_add_activate_below_by_univeral_id_listener(policy->policy, + &policy->activate_below_by_univeral_id); + + policy->lower_by_universal_id.notify = policy_handle_lower_by_universal_id; + ds_tizen_policy_add_lower_by_universal_id_listener(policy->policy, + &policy->lower_by_universal_id); + + policy->set_transient_for.notify = policy_handle_set_transient_for; + ds_tizen_policy_add_set_transient_for_listener(policy->policy, + &policy->set_transient_for); + + policy->unset_transient_for.notify = policy_handle_unset_transient_for; + ds_tizen_policy_add_unset_transient_for_listener(policy->policy, + &policy->unset_transient_for); + + policy->place_subsurface_below_parent.notify = + policy_handle_place_subsurface_below_parent; + ds_tizen_policy_add_place_subsurface_below_parent_listener(policy->policy, + &policy->place_subsurface_below_parent); + + policy->set_subsurface_stand_alone.notify = + policy_handle_set_subsurface_stand_alone; + ds_tizen_policy_add_set_subsurface_stand_alone_listener(policy->policy, + &policy->set_subsurface_stand_alone); + + policy->set_background_state.notify = policy_handle_set_background_state; + ds_tizen_policy_add_set_background_state_listener(policy->policy, + &policy->set_background_state); + + policy->unset_background_state.notify = policy_handle_unset_background_state; + ds_tizen_policy_add_unset_background_state_listener(policy->policy, + &policy->unset_background_state); + + policy->add_activate_above_by_universal_id.notify = + policy_handle_add_activate_above_by_universal_id; + ds_tizen_policy_add_activate_above_by_universal_id_listener(policy->policy, + &policy->add_activate_above_by_universal_id); + + policy->set_appid.notify = policy_handle_set_appid; + ds_tizen_policy_add_set_appid_listener(policy->policy, &policy->set_appid); + + policy->set_transient_for_below.notify = + policy_handle_set_transient_for_below; + ds_tizen_policy_add_set_transient_for_below_listener(policy->policy, + &policy->set_transient_for_below); + + wl_list_init(&policy->policy_surfaces); + + ds_inf("Policy (%p) created", policy); + + return policy; +} diff --git a/examples/tinyds-policy.h b/examples/tinyds-policy.h new file mode 100644 index 0000000..1974805 --- /dev/null +++ b/examples/tinyds-policy.h @@ -0,0 +1,10 @@ +#ifndef TINYDS_POLICY_H +#define TINYDS_POLICY_H + +typedef void (*policy_free_cb)(void *data); + +struct tinyds_policy; + +struct tinyds_policy *tinyds_policy_init(struct wl_display *display, policy_free_cb free_cb, void *data); + +#endif diff --git a/examples/tinyds-tdm-common.h b/examples/tinyds-tdm-common.h new file mode 100644 index 0000000..dcd5e59 --- /dev/null +++ b/examples/tinyds-tdm-common.h @@ -0,0 +1,42 @@ +#ifndef TINYDS_TDM_COMMON_H +#define TINYDS_TDM_COMMON_H + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define USE_TDM_BUFFER_QUEUE +#define CURSOR_W 10 +#define CURSOR_H 16 +#define TINYDS_UNUSED __attribute__((unused)) + +#endif diff --git a/examples/tinyds-tdm.c b/examples/tinyds-tdm.c index 2a54e3d..a6a49aa 100644 --- a/examples/tinyds-tdm.c +++ b/examples/tinyds-tdm.c @@ -1,54 +1,4 @@ -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define USE_TDM_BUFFER_QUEUE -#define CURSOR_W 10 -#define CURSOR_H 16 - -#ifdef USE_TDM_BUFFER_QUEUE -#include "pixman-tbm-helper.h" -#include "tinyds-tdm-renderer.h" -#else -#include -#endif - -#include "pixman-helper.h" -#include "protocol-trace.h" - -#define TINYDS_UNUSED __attribute__((unused)) -struct tinyds_keyboard; -struct tinyds_pointer; +#include "tinyds-tdm.h" struct tinyds_output { @@ -93,142 +43,6 @@ struct tinyds_dpms struct wl_listener get_dpms; }; -struct tinyds_policy -{ - struct ds_tizen_policy *policy; - - struct wl_listener destroy; - struct wl_listener new_surface; - struct wl_listener activate_below_by_univeral_id; - struct wl_listener lower_by_universal_id; - struct wl_listener set_transient_for; - struct wl_listener unset_transient_for; - struct wl_listener place_subsurface_below_parent; - struct wl_listener set_subsurface_stand_alone; - struct wl_listener set_background_state; - struct wl_listener unset_background_state; - struct wl_listener add_activate_above_by_universal_id; - struct wl_listener set_appid; - struct wl_listener set_transient_for_below; - - struct wl_list policy_surfaces; -}; - -struct tinyds_policy_surface -{ - struct ds_tizen_policy_surface *policy_surface; - - struct wl_listener destroy; - struct wl_listener new_visibility; - struct wl_listener new_position; - struct wl_listener activate; - struct wl_listener raise; - struct wl_listener lower; - struct wl_listener set_focus_skip; - struct wl_listener unset_focus_skip; - struct wl_listener set_role; - struct wl_listener set_window_type; - struct wl_listener set_conformant; - struct wl_listener unset_conformant; - struct wl_listener get_conformant; - struct wl_listener set_notification_level; - struct wl_listener set_window_screen_mode; - struct wl_listener get_subsurface; - struct wl_listener iconify; - struct wl_listener uniconify; - struct wl_listener add_aux_hint; - struct wl_listener change_aux_hint; - struct wl_listener delete_aux_hint; - struct wl_listener get_supported_aux_hints; - struct wl_listener set_floating_mode; - struct wl_listener unset_floating_mode; - struct wl_listener set_stack_mode; - struct wl_listener new_subsurface_watcher; - struct wl_listener set_parent; - struct wl_listener ack_conformant_region; - struct wl_listener set_video; - struct wl_listener show; - struct wl_listener hide; - struct wl_listener set_parent_with_below; - - struct wl_list visibilities; - struct wl_list positions; - struct wl_list subsurface_watchers; - - struct wl_list link; //tinyds_policy::policy_surfaces -}; - -struct tinyds_policy_visibility -{ - struct ds_tizen_policy_visibility *visibility; - - struct wl_listener destroy; - - struct wl_list link; //tinyds_policy::visibilities -}; - -struct tinyds_policy_position -{ - struct ds_tizen_policy_position *position; - - struct wl_listener destroy; - struct wl_listener set; - - struct wl_list link; //tinyds_policy::positions -}; - -struct tinyds_policy_subsurface_watcher -{ - struct ds_tizen_policy_subsurface_watcher *subsurface_watcher; - - struct wl_listener destroy; - - struct wl_list link; //tinyds_policy::subsurface_watchers -}; - -struct tinyds_server -{ - struct ds_tbm_server *tbm_server; - - struct wl_display *display; - - struct ds_backend *backend; - struct ds_backend *input_backend; - struct ds_compositor *compositor; - struct ds_xdg_shell *xdg_shell; - struct ds_seat *seat; - uint32_t seat_caps; - double output_x, output_y; - struct ds_tizen_input_devicemgr *devicemgr; - struct ds_tizen_launch_effect *effect; - struct ds_tizen_launch_splash *splash; - - struct tinyds_output *output; - struct tinyds_dpms *dpms; - struct tinyds_policy *policy; - - struct wl_event_source *stdin_source; - - struct wl_list views; - - struct wl_listener new_output; - struct wl_listener new_input; - struct wl_listener new_xdg_surface; - struct wl_listener devicemgr_destroy; - struct wl_listener pointer_warp; - struct wl_listener effect_destroy; - struct wl_listener effect_type_set; - struct wl_listener effect_type_unset; - struct wl_listener new_splash; - struct wl_listener splash_owner; - - struct wl_list keyboards; - struct wl_list pointers; - - struct tinyds_text_input *text_input; - struct tinyds_input_method *input_method; -}; - struct tinyds_view { struct tinyds_server *server; @@ -379,7 +193,6 @@ static void server_add_pointer(struct tinyds_server *server, struct ds_input_device *dev); static void server_add_touch(struct tinyds_server *server, struct ds_input_device *dev); -static bool new_policy(struct tinyds_server *server); static struct tinyds_view * server_view_at(struct tinyds_server *server, double lx, double ly, double *sx, double *sy); @@ -926,6 +739,14 @@ launch_effect_handle_new_splash(struct wl_listener *listener, void *data) &server->splash_owner); } +static void +policy_free_func(void *data) +{ + struct tinyds_server *server = (struct tinyds_server *)data; + + server->policy = NULL; +} + static bool init_server(struct tinyds_server *server, struct wl_display *display) { @@ -974,7 +795,8 @@ init_server(struct tinyds_server *server, struct wl_display *display) if (!add_new_dpms(server)) goto err; - if (!new_policy(server)) + server->policy = tinyds_policy_init(server->display, policy_free_func, (void *)server); + if (!server->policy) goto err; server->seat = ds_seat_create(display, "seat0" /* arbitrary name */); @@ -2673,917 +2495,3 @@ add_new_input_method_context(struct tinyds_input_method *input_method, return true; } - -static void -visibility_handle_destroy(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_visibility *visibility; - - visibility = wl_container_of(listener, visibility, destroy); - - ds_inf("Policy Visibility(%p) destroy", visibility); - - wl_list_remove(&visibility->destroy.link); - wl_list_remove(&visibility->link); - free(visibility); -} - -static void -position_handle_destroy(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_position *position; - - position = wl_container_of(listener, position, destroy); - - ds_inf("Policy Position(%p) destroy", position); - - wl_list_remove(&position->destroy.link); - wl_list_remove(&position->set.link); - wl_list_remove(&position->link); - free(position); -} - -static void -position_handle_set(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_position *position; - - position = wl_container_of(listener, position, set); - - ds_inf("Policy Position(%p) set", position); - - // TODO: -} - -static void -subsurface_watcher_handle_destroy(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_subsurface_watcher *subsurface_watcher; - - subsurface_watcher = wl_container_of(listener, subsurface_watcher, destroy); - - ds_inf("Policy Subsurface_Watcher(%p) destroy", subsurface_watcher); - - wl_list_remove(&subsurface_watcher->destroy.link); - wl_list_remove(&subsurface_watcher->link); - free(subsurface_watcher); -} - -static void -policy_surface_handle_destroy(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, destroy); - - ds_inf("Policy Info(%p) destroy", policy_surface); - - wl_list_remove(&policy_surface->destroy.link); - wl_list_remove(&policy_surface->new_visibility.link); - wl_list_remove(&policy_surface->new_position.link); - wl_list_remove(&policy_surface->activate.link); - wl_list_remove(&policy_surface->raise.link); - wl_list_remove(&policy_surface->lower.link); - wl_list_remove(&policy_surface->set_focus_skip.link); - wl_list_remove(&policy_surface->unset_focus_skip.link); - wl_list_remove(&policy_surface->set_role.link); - wl_list_remove(&policy_surface->set_window_type.link); - wl_list_remove(&policy_surface->set_conformant.link); - wl_list_remove(&policy_surface->unset_conformant.link); - wl_list_remove(&policy_surface->get_conformant.link); - wl_list_remove(&policy_surface->set_notification_level.link); - wl_list_remove(&policy_surface->set_window_screen_mode.link); - wl_list_remove(&policy_surface->get_subsurface.link); - wl_list_remove(&policy_surface->iconify.link); - wl_list_remove(&policy_surface->uniconify.link); - wl_list_remove(&policy_surface->add_aux_hint.link); - wl_list_remove(&policy_surface->change_aux_hint.link); - wl_list_remove(&policy_surface->delete_aux_hint.link); - wl_list_remove(&policy_surface->get_supported_aux_hints.link); - wl_list_remove(&policy_surface->set_floating_mode.link); - wl_list_remove(&policy_surface->unset_floating_mode.link); - wl_list_remove(&policy_surface->set_stack_mode.link); - wl_list_remove(&policy_surface->new_subsurface_watcher.link); - wl_list_remove(&policy_surface->set_parent.link); - wl_list_remove(&policy_surface->ack_conformant_region.link); - wl_list_remove(&policy_surface->set_video.link); - wl_list_remove(&policy_surface->show.link); - wl_list_remove(&policy_surface->hide.link); - wl_list_remove(&policy_surface->set_parent_with_below.link); - wl_list_remove(&policy_surface->link); - free(policy_surface); -} - -static void -policy_surface_handle_new_visibility(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - struct tinyds_policy_visibility *visibility; - struct ds_tizen_event_policy_surface_new_visibility *event; - - policy_surface = wl_container_of(listener, policy_surface, new_visibility); - event = (struct ds_tizen_event_policy_surface_new_visibility *)data; - - ds_inf("Policy Info(%p) new_visibility", policy_surface); - - visibility = calloc(1, sizeof *visibility); - if (!visibility) - return; - - visibility->visibility = event->visibility; - - visibility->destroy.notify = visibility_handle_destroy; - ds_tizen_policy_visibility_add_destroy_listener(visibility->visibility, - &visibility->destroy); - - wl_list_insert(&policy_surface->visibilities, &visibility->link); -} - -static void -policy_surface_handle_new_position(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - struct tinyds_policy_position *position; - struct ds_tizen_event_policy_surface_new_position *event; - - policy_surface = wl_container_of(listener, policy_surface, new_position); - event = (struct ds_tizen_event_policy_surface_new_position *)data; - - ds_inf("Policy Info(%p) new_position", policy_surface); - - position = calloc(1, sizeof *position); - if (!position) - return; - - position->position = event->position; - - position->destroy.notify = position_handle_destroy; - ds_tizen_policy_position_add_destroy_listener(position->position, - &position->destroy); - - position->set.notify = position_handle_set; - ds_tizen_policy_position_add_set_listener(position->position, - &position->set); - - wl_list_insert(&policy_surface->positions, &position->link); -} - -static void -policy_surface_handle_activate(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, activate); - - ds_inf("Policy Info(%p) activate", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_raise(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, raise); - - ds_inf("Policy Info(%p) raise", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_lower(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, raise); - - ds_inf("Policy Info(%p) lower", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_set_focus_skip(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, set_focus_skip); - - ds_inf("Policy Info(%p) set_focus_skip", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_unset_focus_skip(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, unset_focus_skip); - - ds_inf("Policy Info(%p) unset_focus_skip", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_set_role(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, set_role); - - ds_inf("Policy Info(%p) set_role", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_set_window_type(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, set_window_type); - - ds_inf("Policy Info(%p) set_window_type", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_set_conformant(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, set_conformant); - - ds_inf("Policy Info(%p) set_conformant", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_unset_conformant(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, unset_conformant); - - ds_inf("Policy Info(%p) unset_conformant", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_get_conformant(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, get_conformant); - - ds_inf("Policy Info(%p) get_conformant", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_set_notification_level(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, set_notification_level); - - ds_inf("Policy Info(%p) set_notification_level", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_set_window_screen_mode(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, set_window_screen_mode); - - ds_inf("Policy Info(%p) set_window_screen_mode", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_get_subsurface(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, get_subsurface); - - ds_inf("Policy Info(%p) get_subsurface", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_iconify(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, iconify); - - ds_inf("Policy Info(%p) iconify", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_uniconify(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, uniconify); - - ds_inf("Policy Info(%p) uniconify", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_add_aux_hint(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, add_aux_hint); - - ds_inf("Policy Info(%p) add_aux_hint", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_change_aux_hint(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, change_aux_hint); - - ds_inf("Policy Info(%p) change_aux_hint", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_delete_aux_hint(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, delete_aux_hint); - - ds_inf("Policy Info(%p) delete_aux_hint", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_get_supported_aux_hints(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, get_supported_aux_hints); - - ds_inf("Policy Info(%p) get_supported_aux_hints", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_set_floating_mode(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, set_floating_mode); - - ds_inf("Policy Info(%p) set_floating_mode", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_unset_floating_mode(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, unset_floating_mode); - - ds_inf("Policy Info(%p) unset_floating_mode", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_set_stack_mode(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, set_stack_mode); - - ds_inf("Policy Info(%p) set_stack_mode", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_new_subsurface_watcher(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - struct tinyds_policy_subsurface_watcher*subsurface_watcher; - struct ds_tizen_event_policy_surface_new_subsurface_watcher *event; - - policy_surface = wl_container_of(listener, policy_surface, new_subsurface_watcher); - event = (struct ds_tizen_event_policy_surface_new_subsurface_watcher *)data; - - ds_inf("Policy Info(%p) new_subsurface_watcher", policy_surface); - - subsurface_watcher = calloc(1, sizeof *subsurface_watcher); - if (!subsurface_watcher) - return; - - subsurface_watcher->subsurface_watcher = event->subsurface_watcher; - - subsurface_watcher->destroy.notify = subsurface_watcher_handle_destroy; - ds_tizen_policy_subsurface_watcher_add_destroy_listener(subsurface_watcher->subsurface_watcher, - &subsurface_watcher->destroy); - - wl_list_insert(&policy_surface->subsurface_watchers, &subsurface_watcher->link); -} - -static void -policy_surface_handle_set_parent(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, set_parent); - - ds_inf("Policy Info(%p) set_parent", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_ack_conformant_region(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, ack_conformant_region); - - ds_inf("Policy Info(%p) ack_conformant_region", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_set_video(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, set_video); - - ds_inf("Policy Info(%p) set_video", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_show(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, show); - - ds_inf("Policy Info(%p) show", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_hide(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, hide); - - ds_inf("Policy Info(%p) hide", policy_surface); - - // TODO: -} - -static void -policy_surface_handle_set_parent_with_below(struct wl_listener *listener, void *data) -{ - struct tinyds_policy_surface *policy_surface; - - policy_surface = wl_container_of(listener, policy_surface, set_parent_with_below); - - ds_inf("Policy Info(%p) set_parent_with_below", policy_surface); - - // TODO: -} - -static void -policy_handle_destroy(struct wl_listener *listener, void *data) -{ - struct tinyds_policy *policy; - - policy = wl_container_of(listener, policy, destroy); - - ds_inf("Policy(%p) destroy", policy); - - wl_list_remove(&policy->destroy.link); - wl_list_remove(&policy->new_surface.link); - wl_list_remove(&policy->activate_below_by_univeral_id.link); - wl_list_remove(&policy->lower_by_universal_id.link); - wl_list_remove(&policy->set_transient_for.link); - wl_list_remove(&policy->unset_transient_for.link); - wl_list_remove(&policy->place_subsurface_below_parent.link); - wl_list_remove(&policy->set_subsurface_stand_alone.link); - wl_list_remove(&policy->set_background_state.link); - wl_list_remove(&policy->unset_background_state.link); - wl_list_remove(&policy->add_activate_above_by_universal_id.link); - wl_list_remove(&policy->set_appid.link); - wl_list_remove(&policy->set_transient_for_below.link); - - free(policy); -} - -static void -policy_handle_new_surface(struct wl_listener *listener, void *data) -{ - struct tinyds_policy *policy; - struct tinyds_policy_surface *policy_surface; - struct ds_tizen_event_policy_new_surface *event; - - policy = wl_container_of(listener, policy, new_surface); - event = (struct ds_tizen_event_policy_new_surface *)data; - - ds_inf("Policy(%p) new_surface", policy); - - policy_surface = calloc(1, sizeof *policy_surface); - if (!policy_surface) - return; - - policy_surface->policy_surface = event->policy_surface; - - policy_surface->destroy.notify = policy_surface_handle_destroy; - ds_tizen_policy_surface_add_destroy_listener(policy_surface->policy_surface, - &policy_surface->destroy); - - policy_surface->new_visibility.notify = policy_surface_handle_new_visibility; - ds_tizen_policy_surface_add_new_visibility_listener(policy_surface->policy_surface, - &policy_surface->new_visibility); - - policy_surface->new_position.notify = policy_surface_handle_new_position; - ds_tizen_policy_surface_add_new_position_listener(policy_surface->policy_surface, - &policy_surface->new_position); - - policy_surface->activate.notify = policy_surface_handle_activate; - ds_tizen_policy_surface_add_activate_listener(policy_surface->policy_surface, - &policy_surface->activate); - - policy_surface->raise.notify = policy_surface_handle_raise; - ds_tizen_policy_surface_add_raise_listener(policy_surface->policy_surface, - &policy_surface->raise); - - policy_surface->lower.notify = policy_surface_handle_lower; - ds_tizen_policy_surface_add_lower_listener(policy_surface->policy_surface, - &policy_surface->lower); - - policy_surface->set_focus_skip.notify = policy_surface_handle_set_focus_skip; - ds_tizen_policy_surface_add_set_focus_skip_listener(policy_surface->policy_surface, - &policy_surface->set_focus_skip); - - policy_surface->unset_focus_skip.notify = policy_surface_handle_unset_focus_skip; - ds_tizen_policy_surface_add_unset_focus_skip_listener(policy_surface->policy_surface, - &policy_surface->unset_focus_skip); - - policy_surface->set_role.notify = policy_surface_handle_set_role; - ds_tizen_policy_surface_add_set_role_listener(policy_surface->policy_surface, - &policy_surface->set_role); - - policy_surface->set_window_type.notify = policy_surface_handle_set_window_type; - ds_tizen_policy_surface_add_set_window_type_listener(policy_surface->policy_surface, - &policy_surface->set_window_type); - - policy_surface->set_conformant.notify = policy_surface_handle_set_conformant; - ds_tizen_policy_surface_add_set_conformant_listener(policy_surface->policy_surface, - &policy_surface->set_conformant); - - policy_surface->unset_conformant.notify = policy_surface_handle_unset_conformant; - ds_tizen_policy_surface_add_unset_conformant_listener(policy_surface->policy_surface, - &policy_surface->unset_conformant); - - policy_surface->get_conformant.notify = policy_surface_handle_get_conformant; - ds_tizen_policy_surface_add_get_conformant_listener(policy_surface->policy_surface, - &policy_surface->get_conformant); - - policy_surface->set_notification_level.notify = - policy_surface_handle_set_notification_level; - ds_tizen_policy_surface_add_set_notification_level_listener( - policy_surface->policy_surface, &policy_surface->set_notification_level); - - policy_surface->set_window_screen_mode.notify = - policy_surface_handle_set_window_screen_mode; - ds_tizen_policy_surface_add_set_window_screen_mode_listener( - policy_surface->policy_surface, &policy_surface->set_window_screen_mode); - - policy_surface->get_subsurface.notify = policy_surface_handle_get_subsurface; - ds_tizen_policy_surface_add_get_subsurface_listener(policy_surface->policy_surface, - &policy_surface->get_subsurface); - - policy_surface->iconify.notify = policy_surface_handle_iconify; - ds_tizen_policy_surface_add_iconify_listener(policy_surface->policy_surface, - &policy_surface->iconify); - - policy_surface->uniconify.notify = policy_surface_handle_uniconify; - ds_tizen_policy_surface_add_uniconify_listener(policy_surface->policy_surface, - &policy_surface->uniconify); - - policy_surface->add_aux_hint.notify = policy_surface_handle_add_aux_hint; - ds_tizen_policy_surface_add_add_aux_hint_listener(policy_surface->policy_surface, - &policy_surface->add_aux_hint); - - policy_surface->change_aux_hint.notify = policy_surface_handle_change_aux_hint; - ds_tizen_policy_surface_add_change_aux_hint_listener(policy_surface->policy_surface, - &policy_surface->change_aux_hint); - - policy_surface->delete_aux_hint.notify = policy_surface_handle_delete_aux_hint; - ds_tizen_policy_surface_add_delete_aux_hint_listener(policy_surface->policy_surface, - &policy_surface->delete_aux_hint); - - policy_surface->get_supported_aux_hints.notify = - policy_surface_handle_get_supported_aux_hints; - ds_tizen_policy_surface_add_get_supported_aux_hints_listener( - policy_surface->policy_surface, &policy_surface->get_supported_aux_hints); - - policy_surface->set_floating_mode.notify = - policy_surface_handle_set_floating_mode; - ds_tizen_policy_surface_add_set_floating_mode_listener( - policy_surface->policy_surface, &policy_surface->set_floating_mode); - - policy_surface->unset_floating_mode.notify = - policy_surface_handle_unset_floating_mode; - ds_tizen_policy_surface_add_unset_floating_mode_listener( - policy_surface->policy_surface, &policy_surface->unset_floating_mode); - - policy_surface->set_stack_mode.notify = policy_surface_handle_set_stack_mode; - ds_tizen_policy_surface_add_set_stack_mode_listener(policy_surface->policy_surface, - &policy_surface->set_stack_mode); - - policy_surface->new_subsurface_watcher.notify = - policy_surface_handle_new_subsurface_watcher; - ds_tizen_policy_surface_add_new_subsurface_watcher_listener( - policy_surface->policy_surface, &policy_surface->new_subsurface_watcher); - - policy_surface->set_parent.notify = policy_surface_handle_set_parent; - ds_tizen_policy_surface_add_set_parent_listener(policy_surface->policy_surface, - &policy_surface->set_parent); - - policy_surface->ack_conformant_region.notify = - policy_surface_handle_ack_conformant_region; - ds_tizen_policy_surface_add_ack_conformant_region_listener( - policy_surface->policy_surface, &policy_surface->ack_conformant_region); - - policy_surface->set_video.notify = policy_surface_handle_set_video; - ds_tizen_policy_surface_add_set_video_listener(policy_surface->policy_surface, - &policy_surface->set_video); - - policy_surface->show.notify = policy_surface_handle_show; - ds_tizen_policy_surface_add_show_listener(policy_surface->policy_surface, - &policy_surface->show); - - policy_surface->hide.notify = policy_surface_handle_hide; - ds_tizen_policy_surface_add_hide_listener(policy_surface->policy_surface, - &policy_surface->hide); - - policy_surface->set_parent_with_below.notify = - policy_surface_handle_set_parent_with_below; - ds_tizen_policy_surface_add_set_parent_with_below_listener( - policy_surface->policy_surface, &policy_surface->set_parent_with_below); - - - wl_list_init(&policy_surface->visibilities); - wl_list_init(&policy_surface->positions); - wl_list_init(&policy_surface->subsurface_watchers); - - wl_list_insert(&policy->policy_surfaces, &policy_surface->link); -} - -static void -policy_handle_activate_below_by_univeral_id(struct wl_listener *listener, void *data) -{ - struct tinyds_policy *policy; - - policy = wl_container_of(listener, policy, activate_below_by_univeral_id); - - ds_inf("Policy(%p) activate_below_by_univeral_id", policy); - - // TODO: -} - -static void -policy_handle_lower_by_universal_id(struct wl_listener *listener, void *data) -{ - struct tinyds_policy *policy; - - policy = wl_container_of(listener, policy, lower_by_universal_id); - - ds_inf("Policy(%p) lower_by_universal_id", policy); - - // TODO: -} - -static void -policy_handle_set_transient_for(struct wl_listener *listener, void *data) -{ - struct tinyds_policy *policy; - - policy = wl_container_of(listener, policy, set_transient_for); - - ds_inf("Policy(%p) set_transient_for", policy); - - // TODO: -} - -static void -policy_handle_unset_transient_for(struct wl_listener *listener, void *data) -{ - struct tinyds_policy *policy; - - policy = wl_container_of(listener, policy, unset_transient_for); - - ds_inf("Policy(%p) unset_transient_for", policy); - - // TODO: -} - -static void -policy_handle_place_subsurface_below_parent(struct wl_listener *listener, void *data) -{ - struct tinyds_policy *policy; - - policy = wl_container_of(listener, policy, place_subsurface_below_parent); - - ds_inf("Policy(%p) place_subsurface_below_parent", policy); - - // TODO: -} - -static void -policy_handle_set_subsurface_stand_alone(struct wl_listener *listener, void *data) -{ - struct tinyds_policy *policy; - - policy = wl_container_of(listener, policy, set_subsurface_stand_alone); - - ds_inf("Policy(%p) set_subsurface_stand_alone", policy); - - // TODO: -} - -static void -policy_handle_set_background_state(struct wl_listener *listener, void *data) -{ - struct tinyds_policy *policy; - - policy = wl_container_of(listener, policy, set_background_state); - - ds_inf("Policy(%p) set_background_state", policy); - - // TODO: -} - -static void -policy_handle_unset_background_state(struct wl_listener *listener, void *data) -{ - struct tinyds_policy *policy; - - policy = wl_container_of(listener, policy, unset_background_state); - - ds_inf("Policy(%p) unset_background_state", policy); - - // TODO: -} - -static void -policy_handle_add_activate_above_by_universal_id(struct wl_listener *listener, void *data) -{ - struct tinyds_policy *policy; - - policy = wl_container_of(listener, policy, add_activate_above_by_universal_id); - - ds_inf("Policy(%p) add_activate_above_by_universal_id", policy); - - // TODO: -} - -static void -policy_handle_set_appid(struct wl_listener *listener, void *data) -{ - struct tinyds_policy *policy; - - policy = wl_container_of(listener, policy, set_appid); - - ds_inf("Policy(%p) set_appid", policy); - - // TODO: -} - -static void -policy_handle_set_transient_for_below(struct wl_listener *listener, void *data) -{ - struct tinyds_policy *policy; - - policy = wl_container_of(listener, policy, set_transient_for_below); - - ds_inf("Policy(%p) set_transient_for_below", policy); - - // TODO: -} - -static bool -new_policy(struct tinyds_server *server) -{ - struct tinyds_policy *policy; - - policy = calloc(1, sizeof *policy); - if (!policy) - return false; - - policy->policy = ds_tizen_policy_create(server->display); - if (!policy->policy) { - free(policy); - ds_err("Could not create ds_tizen_policy"); - return false; - } - - policy->destroy.notify = policy_handle_destroy; - ds_tizen_policy_add_destroy_listener(policy->policy, &policy->destroy); - - policy->new_surface.notify = policy_handle_new_surface; - ds_tizen_policy_add_new_surface_listener(policy->policy, &policy->new_surface); - - policy->activate_below_by_univeral_id.notify = - policy_handle_activate_below_by_univeral_id; - ds_tizen_policy_add_activate_below_by_univeral_id_listener(policy->policy, - &policy->activate_below_by_univeral_id); - - policy->lower_by_universal_id.notify = policy_handle_lower_by_universal_id; - ds_tizen_policy_add_lower_by_universal_id_listener(policy->policy, - &policy->lower_by_universal_id); - - policy->set_transient_for.notify = policy_handle_set_transient_for; - ds_tizen_policy_add_set_transient_for_listener(policy->policy, - &policy->set_transient_for); - - policy->unset_transient_for.notify = policy_handle_unset_transient_for; - ds_tizen_policy_add_unset_transient_for_listener(policy->policy, - &policy->unset_transient_for); - - policy->place_subsurface_below_parent.notify = - policy_handle_place_subsurface_below_parent; - ds_tizen_policy_add_place_subsurface_below_parent_listener(policy->policy, - &policy->place_subsurface_below_parent); - - policy->set_subsurface_stand_alone.notify = - policy_handle_set_subsurface_stand_alone; - ds_tizen_policy_add_set_subsurface_stand_alone_listener(policy->policy, - &policy->set_subsurface_stand_alone); - - policy->set_background_state.notify = policy_handle_set_background_state; - ds_tizen_policy_add_set_background_state_listener(policy->policy, - &policy->set_background_state); - - policy->unset_background_state.notify = policy_handle_unset_background_state; - ds_tizen_policy_add_unset_background_state_listener(policy->policy, - &policy->unset_background_state); - - policy->add_activate_above_by_universal_id.notify = - policy_handle_add_activate_above_by_universal_id; - ds_tizen_policy_add_activate_above_by_universal_id_listener(policy->policy, - &policy->add_activate_above_by_universal_id); - - policy->set_appid.notify = policy_handle_set_appid; - ds_tizen_policy_add_set_appid_listener(policy->policy, &policy->set_appid); - - policy->set_transient_for_below.notify = - policy_handle_set_transient_for_below; - ds_tizen_policy_add_set_transient_for_below_listener(policy->policy, - &policy->set_transient_for_below); - - wl_list_init(&policy->policy_surfaces); - - server->policy = policy; - - ds_inf("Policy (%p) created", policy); - - return true; -} diff --git a/examples/tinyds-tdm.h b/examples/tinyds-tdm.h new file mode 100644 index 0000000..119ea87 --- /dev/null +++ b/examples/tinyds-tdm.h @@ -0,0 +1,64 @@ +#ifndef TINYDS_TDM_H +#define TINYDS_TDM_H + +#include "tinyds-tdm-common.h" + +#ifdef USE_TDM_BUFFER_QUEUE +#include "pixman-tbm-helper.h" +#include "tinyds-tdm-renderer.h" +#else +#include +#endif + +#include "pixman-helper.h" +#include "protocol-trace.h" +#include "tinyds-policy.h" + +struct tinyds_keyboard; +struct tinyds_pointer; + +struct tinyds_server +{ + struct ds_tbm_server *tbm_server; + + struct wl_display *display; + + struct ds_backend *backend; + struct ds_backend *input_backend; + struct ds_compositor *compositor; + struct ds_xdg_shell *xdg_shell; + struct ds_seat *seat; + uint32_t seat_caps; + double output_x, output_y; + struct ds_tizen_input_devicemgr *devicemgr; + struct ds_tizen_launch_effect *effect; + struct ds_tizen_launch_splash *splash; + + struct tinyds_output *output; + struct tinyds_dpms *dpms; + struct tinyds_policy *policy; + + struct wl_event_source *stdin_source; + + struct wl_list views; + + struct wl_listener new_output; + struct wl_listener new_input; + struct wl_listener new_xdg_surface; + struct wl_listener devicemgr_destroy; + struct wl_listener pointer_warp; + struct wl_listener effect_destroy; + struct wl_listener effect_type_set; + struct wl_listener effect_type_unset; + struct wl_listener new_splash; + struct wl_listener splash_owner; + + struct wl_list keyboards; + struct wl_list pointers; + + struct tinyds_text_input *text_input; + struct tinyds_input_method *input_method; +}; + + +#endif -- 2.7.4 From d04ded37fda437fd488de09a6d243720503ad0ec Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 27 Oct 2022 17:14:58 +0900 Subject: [PATCH 03/16] examples: make tinyds-dpms files move the implementation of ds_tizen_dpms at tinyds-tdm.c to tinyds-dpms file. Change-Id: Ia61bb80c4e3b534a569441e365c483d5c66838e0 --- examples/meson.build | 1 + examples/tinyds-dpms.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++ examples/tinyds-dpms.h | 10 +++++ examples/tinyds-tdm.c | 103 +++++-------------------------------------------- examples/tinyds-tdm.h | 1 + 5 files changed, 122 insertions(+), 93 deletions(-) create mode 100644 examples/tinyds-dpms.c create mode 100644 examples/tinyds-dpms.h diff --git a/examples/meson.build b/examples/meson.build index c5addef..85b8165 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -22,6 +22,7 @@ tinyds_tdm_files = [ 'tinyds-tdm-renderer.c', 'protocol-trace.c', 'tinyds-policy.c', + 'tinyds-dpms.c', ] executable('tinyds-tdm', diff --git a/examples/tinyds-dpms.c b/examples/tinyds-dpms.c new file mode 100644 index 0000000..23821a1 --- /dev/null +++ b/examples/tinyds-dpms.c @@ -0,0 +1,100 @@ +#include + +#include "tinyds-tdm-common.h" +#include "tinyds-dpms.h" + +struct tinyds_dpms +{ + dpms_free_cb free_cb; + void *data; + + struct ds_tizen_dpms *ds_dpms; + + struct wl_listener destroy; + struct wl_listener set_dpms; + struct wl_listener get_dpms; +}; + +static void +dpms_handle_destroy(struct wl_listener *listener, void *data) +{ + struct tinyds_dpms *dpms; + + dpms = wl_container_of(listener, dpms, destroy); + + ds_inf("Dpms(%p) destroyed", dpms); + + dpms->free_cb(data); + + wl_list_remove(&dpms->destroy.link); + wl_list_remove(&dpms->set_dpms.link); + wl_list_remove(&dpms->get_dpms.link); + + free(dpms); +} + +static void +dpms_handle_set_dpms(struct wl_listener *listener, void *data) +{ + struct tinyds_dpms *dpms; + struct ds_tizen_dpms_event *event = data; + + dpms = wl_container_of(listener, dpms, set_dpms); + + ds_inf("Dpms(%p) set dpms : %d", dpms, event->mode); + + //To do + //set dpms mode to output + ds_tizen_dpms_send_set_result(dpms->ds_dpms, event->mode, + DS_TIZEN_DPMS_ERROR_NONE); +} + +static void +dpms_handle_get_dpms(struct wl_listener *listener, void *data) +{ + struct tinyds_dpms *dpms; + + dpms = wl_container_of(listener, dpms, get_dpms); + + ds_inf("Dpms(%p) get dpms", dpms); + + //To do + //get dpms mode from output + ds_tizen_dpms_send_get_result(dpms->ds_dpms, DS_TIZEN_DPMS_MODE_ON, + DS_TIZEN_DPMS_ERROR_NONE); +} + + +struct tinyds_dpms * +tinyds_dpms_init(struct wl_display *display, dpms_free_cb free_cb, + void *data) +{ + struct tinyds_dpms *dpms; + + dpms = calloc(1, sizeof *dpms); + if (!dpms) + return NULL; + + dpms->free_cb = free_cb; + data = data; + + dpms->ds_dpms = ds_tizen_dpms_create(display); + if (!dpms->ds_dpms) { + free(dpms); + ds_err("Could not create ds_tizen_dpms"); + return NULL; + } + + dpms->destroy.notify = dpms_handle_destroy; + ds_tizen_dpms_add_destroy_listener(dpms->ds_dpms, &dpms->destroy); + + dpms->set_dpms.notify = dpms_handle_set_dpms; + ds_tizen_dpms_add_set_dpms_listener(dpms->ds_dpms, &dpms->set_dpms); + + dpms->get_dpms.notify = dpms_handle_get_dpms; + ds_tizen_dpms_add_get_dpms_listener(dpms->ds_dpms, &dpms->get_dpms); + + ds_inf("Dpms (%p) added", dpms); + + return dpms; +} diff --git a/examples/tinyds-dpms.h b/examples/tinyds-dpms.h new file mode 100644 index 0000000..226cfb1 --- /dev/null +++ b/examples/tinyds-dpms.h @@ -0,0 +1,10 @@ +#ifndef TINYDS_DPMS_H +#define TINYDS_DPMS_H + +typedef void (*dpms_free_cb)(void *data); + +struct tinyds_dpms; + +struct tinyds_dpms *tinyds_dpms_init(struct wl_display *display, dpms_free_cb free_cb, void *data); + +#endif diff --git a/examples/tinyds-tdm.c b/examples/tinyds-tdm.c index a6a49aa..cb8f2e5 100644 --- a/examples/tinyds-tdm.c +++ b/examples/tinyds-tdm.c @@ -33,16 +33,6 @@ struct tinyds_output #endif }; -struct tinyds_dpms -{ - struct ds_tizen_dpms *ds_dpms; - struct tinyds_server *server; - - struct wl_listener destroy; - struct wl_listener set_dpms; - struct wl_listener get_dpms; -}; - struct tinyds_view { struct tinyds_server *server; @@ -184,9 +174,6 @@ static void output_swapchain_init(struct tinyds_output *output, static void output_draw_with_swapchain(struct tinyds_output *output); static void draw_view(struct tinyds_view *view, pixman_image_t *dst_image); #endif -static void dpms_handle_destroy(struct wl_listener *listener, void *data); -static void dpms_handle_set_dpms(struct wl_listener *listener, void *data); -static void dpms_handle_get_dpms(struct wl_listener *listener, void *data); static void server_add_keyboard(struct tinyds_server *server, struct ds_input_device *dev); static void server_add_pointer(struct tinyds_server *server, @@ -470,38 +457,6 @@ backend_handle_new_output(struct wl_listener *listener, void *data) output_schedule_commit(output); } -static bool -add_new_dpms(struct tinyds_server *server) -{ - struct tinyds_dpms *dpms; - - dpms = calloc(1, sizeof *dpms); - if (!dpms) - return false; - - dpms->ds_dpms = ds_tizen_dpms_create(server->display); - if (!dpms->ds_dpms) { - free(dpms); - ds_err("Could not create ds_tizen_dpms"); - return false; - } - - dpms->destroy.notify = dpms_handle_destroy; - ds_tizen_dpms_add_destroy_listener(dpms->ds_dpms, &dpms->destroy); - - dpms->set_dpms.notify = dpms_handle_set_dpms; - ds_tizen_dpms_add_set_dpms_listener(dpms->ds_dpms, &dpms->set_dpms); - - dpms->get_dpms.notify = dpms_handle_get_dpms; - ds_tizen_dpms_add_get_dpms_listener(dpms->ds_dpms, &dpms->get_dpms); - - server->dpms = dpms; - - ds_inf("Dpms (%p) added", dpms); - - return true; -} - static void backend_handle_new_input(struct wl_listener *listener, void *data) { @@ -740,6 +695,14 @@ launch_effect_handle_new_splash(struct wl_listener *listener, void *data) } static void +dpms_free_func(void *data) +{ + struct tinyds_server *server = (struct tinyds_server *)data; + + server->dpms = NULL; +} + +static void policy_free_func(void *data) { struct tinyds_server *server = (struct tinyds_server *)data; @@ -792,7 +755,8 @@ init_server(struct tinyds_server *server, struct wl_display *display) ds_xdg_shell_add_new_surface_listener(server->xdg_shell, &server->new_xdg_surface); - if (!add_new_dpms(server)) + server->dpms = tinyds_dpms_init(server->display, dpms_free_func, (void *)server); + if (!server->dpms) goto err; server->policy = tinyds_policy_init(server->display, policy_free_func, (void *)server); @@ -1344,53 +1308,6 @@ server_dispatch_stdin(int fd, uint32_t mask, void *data) } static void -dpms_handle_destroy(struct wl_listener *listener, void *data) -{ - struct tinyds_dpms *dpms; - - dpms = wl_container_of(listener, dpms, destroy); - - ds_inf("Dpms(%p) destroyed", dpms); - - wl_list_remove(&dpms->destroy.link); - wl_list_remove(&dpms->set_dpms.link); - wl_list_remove(&dpms->get_dpms.link); - - free(dpms); -} - -static void -dpms_handle_set_dpms(struct wl_listener *listener, void *data) -{ - struct tinyds_dpms *dpms; - struct ds_tizen_dpms_event *event = data; - - dpms = wl_container_of(listener, dpms, set_dpms); - - ds_inf("Dpms(%p) set dpms : %d", dpms, event->mode); - - //To do - //set dpms mode to output - ds_tizen_dpms_send_set_result(dpms->ds_dpms, event->mode, - DS_TIZEN_DPMS_ERROR_NONE); -} - -static void -dpms_handle_get_dpms(struct wl_listener *listener, void *data) -{ - struct tinyds_dpms *dpms; - - dpms = wl_container_of(listener, dpms, get_dpms); - - ds_inf("Dpms(%p) get dpms", dpms); - - //To do - //get dpms mode from output - ds_tizen_dpms_send_get_result(dpms->ds_dpms, DS_TIZEN_DPMS_MODE_ON, - DS_TIZEN_DPMS_ERROR_NONE); -} - -static void keyboard_handle_device_destroy(struct wl_listener *listener, void *data) { struct tinyds_keyboard *kbd; diff --git a/examples/tinyds-tdm.h b/examples/tinyds-tdm.h index 119ea87..0359ec0 100644 --- a/examples/tinyds-tdm.h +++ b/examples/tinyds-tdm.h @@ -13,6 +13,7 @@ #include "pixman-helper.h" #include "protocol-trace.h" #include "tinyds-policy.h" +#include "tinyds-dpms.h" struct tinyds_keyboard; struct tinyds_pointer; -- 2.7.4 From a9dec0abae49810824db59352ae2ff825b8d072e Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 27 Oct 2022 18:00:24 +0900 Subject: [PATCH 04/16] examples: rename tinyds-tdm-renderer to tinyds-renderer Change-Id: I7d897f44a0042fb16d8efe9d6d656aec820d54f2 --- examples/meson.build | 2 +- examples/{tinyds-tdm-renderer.c => tinyds-renderer.c} | 2 +- examples/{tinyds-tdm-renderer.h => tinyds-renderer.h} | 4 ++-- examples/tinyds-tdm.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename examples/{tinyds-tdm-renderer.c => tinyds-renderer.c} (99%) rename examples/{tinyds-tdm-renderer.h => tinyds-renderer.h} (95%) diff --git a/examples/meson.build b/examples/meson.build index 85b8165..23156e1 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -19,7 +19,7 @@ tinyds_tdm_files = [ 'tinyds-tdm.c', 'pixman-helper.c', 'pixman-tbm-helper.c', - 'tinyds-tdm-renderer.c', + 'tinyds-renderer.c', 'protocol-trace.c', 'tinyds-policy.c', 'tinyds-dpms.c', diff --git a/examples/tinyds-tdm-renderer.c b/examples/tinyds-renderer.c similarity index 99% rename from examples/tinyds-tdm-renderer.c rename to examples/tinyds-renderer.c index dd891b6..24c40d3 100644 --- a/examples/tinyds-tdm-renderer.c +++ b/examples/tinyds-renderer.c @@ -5,7 +5,7 @@ #include "pixman-helper.h" #include "pixman-tbm-helper.h" -#include "tinyds-tdm-renderer.h" +#include "tinyds-renderer.h" static void renderer_setup_thread(struct tinyds_renderer *renderer); static void *renderer_thread_func(void *data); diff --git a/examples/tinyds-tdm-renderer.h b/examples/tinyds-renderer.h similarity index 95% rename from examples/tinyds-tdm-renderer.h rename to examples/tinyds-renderer.h index 943e2be..b2dc234 100644 --- a/examples/tinyds-tdm-renderer.h +++ b/examples/tinyds-renderer.h @@ -1,5 +1,5 @@ -#ifndef EXAMPLES_TINYDS_TDM_RENDERER_H -#define EXAMPLES_TINYDS_TDM_RENDERER_H +#ifndef TINYDS_RENDERER_H +#define TINYDS_RENDERER_H #include #include diff --git a/examples/tinyds-tdm.h b/examples/tinyds-tdm.h index 0359ec0..413cebd 100644 --- a/examples/tinyds-tdm.h +++ b/examples/tinyds-tdm.h @@ -5,7 +5,7 @@ #ifdef USE_TDM_BUFFER_QUEUE #include "pixman-tbm-helper.h" -#include "tinyds-tdm-renderer.h" +#include "tinyds-renderer.h" #else #include #endif -- 2.7.4 From 8082f273eb5268c0d52955e8a63db88aa40bc45e Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 27 Oct 2022 18:03:49 +0900 Subject: [PATCH 05/16] rename tinyds-tdm-common to tinyds-common Change-Id: Ic0a78ca9a881e3f60b74036f60f37c5be7fddc90 --- examples/{tinyds-tdm-common.h => tinyds-common.h} | 0 examples/tinyds-dpms.c | 2 +- examples/tinyds-policy.c | 2 +- examples/tinyds-tdm.h | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename examples/{tinyds-tdm-common.h => tinyds-common.h} (100%) diff --git a/examples/tinyds-tdm-common.h b/examples/tinyds-common.h similarity index 100% rename from examples/tinyds-tdm-common.h rename to examples/tinyds-common.h diff --git a/examples/tinyds-dpms.c b/examples/tinyds-dpms.c index 23821a1..b8fabb4 100644 --- a/examples/tinyds-dpms.c +++ b/examples/tinyds-dpms.c @@ -1,6 +1,6 @@ #include -#include "tinyds-tdm-common.h" +#include "tinyds-common.h" #include "tinyds-dpms.h" struct tinyds_dpms diff --git a/examples/tinyds-policy.c b/examples/tinyds-policy.c index 5ee56af..30146c7 100644 --- a/examples/tinyds-policy.c +++ b/examples/tinyds-policy.c @@ -1,6 +1,6 @@ #include -#include "tinyds-tdm-common.h" +#include "tinyds-common.h" #include "tinyds-policy.h" struct tinyds_policy diff --git a/examples/tinyds-tdm.h b/examples/tinyds-tdm.h index 413cebd..1bbad9e 100644 --- a/examples/tinyds-tdm.h +++ b/examples/tinyds-tdm.h @@ -1,7 +1,7 @@ #ifndef TINYDS_TDM_H #define TINYDS_TDM_H -#include "tinyds-tdm-common.h" +#include "tinyds-common.h" #ifdef USE_TDM_BUFFER_QUEUE #include "pixman-tbm-helper.h" -- 2.7.4 From 05dc6f4a75835c893f05535c327cc25849b5ed7f Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Sat, 29 Oct 2022 08:21:05 +0900 Subject: [PATCH 06/16] examples: make tinyds-launch files move the implementation of ds_tizen_launch at tinyds-tdm.c to tinyds-launch file. Change-Id: Id19d390874f725f843fbf8e4553dfd618ee1a7b1 --- examples/meson.build | 1 + examples/tinyds-launch.c | 184 +++++++++++++++++++++++++++++++++++++++++++++++ examples/tinyds-launch.h | 14 ++++ examples/tinyds-tdm.c | 171 +++++-------------------------------------- examples/tinyds-tdm.h | 31 ++++++-- 5 files changed, 241 insertions(+), 160 deletions(-) create mode 100644 examples/tinyds-launch.c create mode 100644 examples/tinyds-launch.h diff --git a/examples/meson.build b/examples/meson.build index 23156e1..9b12dd8 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -23,6 +23,7 @@ tinyds_tdm_files = [ 'protocol-trace.c', 'tinyds-policy.c', 'tinyds-dpms.c', + 'tinyds-launch.c', ] executable('tinyds-tdm', diff --git a/examples/tinyds-launch.c b/examples/tinyds-launch.c new file mode 100644 index 0000000..0e73a7c --- /dev/null +++ b/examples/tinyds-launch.c @@ -0,0 +1,184 @@ +#include + +#include "tinyds-common.h" +#include "tinyds-launch.h" +#include "tinyds-tdm.h" + +struct tinyds_launch +{ + launch_free_cb free_cb; + void *data; + + struct ds_tizen_launch_effect *effect; + struct ds_tizen_launch_splash *splash; + + struct wl_listener effect_destroy; + struct wl_listener effect_type_set; + struct wl_listener effect_type_unset; + struct wl_listener new_splash; + struct wl_listener splash_owner; + + struct tinyds_server *server; +}; + +static void +launch_effect_handle_destroy(struct wl_listener *listener, void *data TINYDS_UNUSED) +{ + struct tinyds_launch *launch = + wl_container_of(listener, launch, effect_destroy); + + launch->free_cb(data); + + wl_list_remove(&launch->effect_destroy.link); + wl_list_remove(&launch->effect_type_set.link); + wl_list_remove(&launch->effect_type_unset.link); + wl_list_remove(&launch->new_splash.link); + + launch->effect = NULL; +} + +static void +launch_effect_handle_type_set(struct wl_listener *listener, void *data) +{ + struct tinyds_launch *launch; + struct ds_tizen_launch_effect_event_type_set *event = data; + struct tinyds_view *view = NULL; + bool existing = false; + + launch = wl_container_of(listener, launch, effect_type_set); + + ds_inf("Launch effect. type_set: pid(%u) type:%s", event->pid, (event->effect_type == 1) ? "depth-in" : "launch"); + + wl_list_for_each(view, &launch->server->views, link) { + if (view->pid == event->pid) { + view->effect_type = event->effect_type; + existing = true; + ds_inf("Launch effect. existing pid"); + } + } + if (existing) { + ds_tizen_launch_effect_unset_effect_type(launch->effect, event->pid); + } else { + ds_tizen_launch_effect_set_effect_type(launch->effect, event->pid, event->effect_type); + } +} + +static void +launch_effect_handle_type_unset(struct wl_listener *listener, void *data) +{ + struct tinyds_launch *launch; + struct ds_tizen_launch_effect_event_type_unset *event = data; + struct tinyds_view *view = NULL; + + launch = wl_container_of(listener, launch, effect_type_unset); + + ds_inf("Launch effect. type_unset: pid(%u)", event->pid); + + wl_list_for_each(view, &launch->server->views, link) { + if (view->pid == event->pid) { + view->effect_type = -1; + ds_inf("Launch effect. pid found"); + } + } + ds_tizen_launch_effect_unset_effect_type(launch->effect, event->pid); +} + +static void +launch_splash_handle_owner(struct wl_listener *listener, void *data) +{ + struct tinyds_launch *launch; + struct ds_tizen_launch_splash_event_owner *event = data; + struct tinyds_view *view = NULL; + + launch = wl_container_of(listener, launch, splash_owner); + + ds_inf("Splash owner. pid(%u)", event->pid); + + wl_list_for_each(view, &launch->server->views, link) { + if (view->pid == event->pid) { + if (event->pid == ds_tizen_launch_splash_get_pid(launch->splash)) + ;// + else { + ds_tizen_launch_splash_set_pid(launch->splash, event->pid); + } + } + } +} + +static void +launch_effect_handle_new_splash(struct wl_listener *listener, void *data) +{ + struct tinyds_launch *launch; + struct ds_tizen_launch_splash *splash = data; + struct tinyds_view *view = NULL; + + launch = wl_container_of(listener, launch, new_splash); + + ds_inf("Launch new splash. splash(%p)", splash); + if (!splash) return; + + launch->splash = splash; + + // new view for "Launchscreen" + view = calloc(1, sizeof *view); + assert(view); + + wl_list_insert(launch->server->views.prev, &view->link); + view->pid = ds_tizen_launch_splash_get_pid(splash); + + launch->splash_owner.notify = launch_splash_handle_owner; + ds_tizen_launch_splash_add_owner_listener(launch->splash, + &launch->splash_owner); +} + +struct tinyds_launch * +tinyds_launch_init(struct wl_display *display, launch_free_cb free_cb, void *data) +{ + struct tinyds_launch *launch; + + launch = calloc(1, sizeof *launch); + if (!launch) + return NULL; + + launch->free_cb = free_cb; + data = data; + + launch->effect = ds_tizen_launch_effect_create(display); + if (!launch->effect) { + return NULL; + } + + launch->effect_destroy.notify = launch_effect_handle_destroy; + ds_tizen_launch_effect_add_destroy_listener(launch->effect, + &launch->effect_destroy); + + launch->effect_type_set.notify = launch_effect_handle_type_set; + ds_tizen_launch_effect_add_type_set_listener(launch->effect, + &launch->effect_type_set); + + launch->effect_type_unset.notify = launch_effect_handle_type_unset; + ds_tizen_launch_effect_add_type_unset_listener(launch->effect, + &launch->effect_type_unset); + + launch->new_splash.notify = launch_effect_handle_new_splash; + ds_tizen_launch_effect_add_new_splash_listener(launch->effect, + &launch->new_splash); + + launch->server = (struct tinyds_server *)data; + + ds_inf("Launch (%p) created", launch); + + return launch; +} + +int +tinyds_launch_get_effect_type(struct tinyds_launch *launch, uint32_t pid) +{ + return ds_tizen_launch_effect_get_effect_type(launch->effect, pid); +} + +void +tinyds_launch_unset_effect_type(struct tinyds_launch *launch, uint32_t pid) +{ + ds_tizen_launch_effect_unset_effect_type(launch->effect, pid); +} diff --git a/examples/tinyds-launch.h b/examples/tinyds-launch.h new file mode 100644 index 0000000..bdbbb08 --- /dev/null +++ b/examples/tinyds-launch.h @@ -0,0 +1,14 @@ +#ifndef TINYDS_LAUNCH_H +#define TINYDS_LAUNCH_H + +struct tinyds_launch; + +typedef void (*launch_free_cb)(void *data); + +struct tinyds_launch *tinyds_launch_init(struct wl_display *display, + launch_free_cb free_cb, void *data); + +int tinyds_launch_get_effect_type(struct tinyds_launch *launch, uint32_t pid); +void tinyds_launch_unset_effect_type(struct tinyds_launch *launch, uint32_t pid); + +#endif diff --git a/examples/tinyds-tdm.c b/examples/tinyds-tdm.c index cb8f2e5..08084e3 100644 --- a/examples/tinyds-tdm.c +++ b/examples/tinyds-tdm.c @@ -33,28 +33,6 @@ struct tinyds_output #endif }; -struct tinyds_view -{ - struct tinyds_server *server; - - struct tinyds_texture *texture; - struct ds_xdg_surface *xdg_surface; - - struct wl_listener xdg_surface_map; - struct wl_listener xdg_surface_unmap; - struct wl_listener xdg_surface_destroy; - struct wl_listener surface_commit; - struct wl_list link; // tinyds_server::views - - struct ds_tdm_output_hwc_window *hwc_window; - - int x, y; - bool mapped; - - pid_t pid; - int effect_type; -}; - struct tinyds_pointer { struct ds_input_device *dev; @@ -246,9 +224,9 @@ main(void) static void view_populate_pid(struct tinyds_view *view) { - pid_t pid; - struct wl_client *client = NULL; struct ds_surface *surface; + struct wl_client *client = NULL; + pid_t pid; surface = ds_xdg_surface_get_surface(view->xdg_surface); if (!surface) @@ -259,12 +237,14 @@ view_populate_pid(struct tinyds_view *view) return; wl_client_get_credentials(client, &pid, NULL, NULL); + view->pid = pid; ds_inf("view pid(%u)", pid); - view->pid = pid; - view->effect_type = ds_tizen_launch_effect_get_effect_type(view->server->effect, pid); - ds_tizen_launch_effect_unset_effect_type(view->server->effect, pid); + view->effect_type = tinyds_launch_get_effect_type( + view->server->launch, pid); + tinyds_launch_unset_effect_type(view->server->launch, pid); + ds_inf("view effect_type(%d)", view->effect_type); } @@ -587,127 +567,29 @@ devicemgr_handle_destroy(struct wl_listener *listener, void *data TINYDS_UNUSED) server->devicemgr = NULL; } -static void -launch_effect_handle_destroy(struct wl_listener *listener, void *data TINYDS_UNUSED) -{ - struct tinyds_server *server = - wl_container_of(listener, server, effect_destroy); - - wl_list_remove(&server->effect_destroy.link); - wl_list_remove(&server->effect_type_set.link); - wl_list_remove(&server->effect_type_unset.link); - wl_list_remove(&server->new_splash.link); - - server->effect = NULL; -} - -static void -launch_effect_handle_type_set(struct wl_listener *listener, void *data) -{ - struct tinyds_server *server; - struct ds_tizen_launch_effect_event_type_set *event = data; - struct tinyds_view *view = NULL; - bool existing = false; - - server = wl_container_of(listener, server, effect_type_set); - - ds_inf("Launch effect. type_set: pid(%u) type:%s", event->pid, (event->effect_type == 1) ? "depth-in" : "launch"); - - wl_list_for_each(view, &server->views, link) { - if (view->pid == event->pid) { - view->effect_type = event->effect_type; - ds_inf("Launch effect. existing pid"); - existing = true; - } - } - if (existing) { - ds_tizen_launch_effect_unset_effect_type(server->effect, event->pid); - } else { - ds_tizen_launch_effect_set_effect_type(server->effect, event->pid, event->effect_type); - } -} - -static void -launch_effect_handle_type_unset(struct wl_listener *listener, void *data) -{ - struct tinyds_server *server; - struct ds_tizen_launch_effect_event_type_unset *event = data; - struct tinyds_view *view = NULL; - - server = wl_container_of(listener, server, effect_type_unset); - - ds_inf("Launch effect. type_unset: pid(%u)", event->pid); - - wl_list_for_each(view, &server->views, link) { - if (view->pid == event->pid) { - view->effect_type = -1; - ds_inf("Launch effect. pid found"); - } - } - ds_tizen_launch_effect_unset_effect_type(server->effect, event->pid); -} - -static void -launch_splash_handle_owner(struct wl_listener *listener, void *data) -{ - struct tinyds_server *server; - struct ds_tizen_launch_splash_event_owner *event = data; - struct tinyds_view *view = NULL; - - server = wl_container_of(listener, server, splash_owner); - - ds_inf("Splash owner. pid(%u)", event->pid); - - wl_list_for_each(view, &server->views, link) { - if (view->pid == event->pid) { - if (event->pid == ds_tizen_launch_splash_get_pid(server->splash)) - ;// - else { - ds_tizen_launch_splash_set_pid(server->splash, event->pid); - } - } - } -} static void -launch_effect_handle_new_splash(struct wl_listener *listener, void *data) +dpms_free_func(void *data) { - struct tinyds_server *server; - struct ds_tizen_launch_splash *splash = data; - struct tinyds_view *view = NULL; - - server = wl_container_of(listener, server, new_splash); - - ds_inf("Launch new splash. splash(%p)", splash); - if (!splash) return; - - server->splash = splash; - - // new view for "Launchscreen" - view = calloc(1, sizeof *view); - assert(view); - wl_list_insert(server->views.prev, &view->link); - view->pid = ds_tizen_launch_splash_get_pid(splash); + struct tinyds_server *server = (struct tinyds_server *)data; - server->splash_owner.notify = launch_splash_handle_owner; - ds_tizen_launch_splash_add_owner_listener(server->splash, - &server->splash_owner); + server->dpms = NULL; } static void -dpms_free_func(void *data) +policy_free_func(void *data) { struct tinyds_server *server = (struct tinyds_server *)data; - server->dpms = NULL; + server->policy = NULL; } static void -policy_free_func(void *data) +launch_free_func(void *data) { struct tinyds_server *server = (struct tinyds_server *)data; - server->policy = NULL; + server->launch = NULL; } static bool @@ -763,6 +645,10 @@ init_server(struct tinyds_server *server, struct wl_display *display) if (!server->policy) goto err; + server->launch = tinyds_launch_init(server->display, launch_free_func, (void *)server); + if (!server->launch) + goto err; + server->seat = ds_seat_create(display, "seat0" /* arbitrary name */); if (!server->seat) goto err; @@ -785,27 +671,6 @@ init_server(struct tinyds_server *server, struct wl_display *display) ds_tizen_input_devicemgr_add_pointer_warp_listener(server->devicemgr, &server->pointer_warp); - server->effect = ds_tizen_launch_effect_create(display); - if (!server->effect) { - goto err; - } - - server->effect_destroy.notify = launch_effect_handle_destroy; - ds_tizen_launch_effect_add_destroy_listener(server->effect, - &server->effect_destroy); - - server->effect_type_set.notify = launch_effect_handle_type_set; - ds_tizen_launch_effect_add_type_set_listener(server->effect, - &server->effect_type_set); - - server->effect_type_unset.notify = launch_effect_handle_type_unset; - ds_tizen_launch_effect_add_type_unset_listener(server->effect, - &server->effect_type_unset); - - server->new_splash.notify = launch_effect_handle_new_splash; - ds_tizen_launch_effect_add_new_splash_listener(server->effect, - &server->new_splash); - if (!add_new_text_input(server)) goto err; diff --git a/examples/tinyds-tdm.h b/examples/tinyds-tdm.h index 1bbad9e..0935b9b 100644 --- a/examples/tinyds-tdm.h +++ b/examples/tinyds-tdm.h @@ -14,6 +14,7 @@ #include "protocol-trace.h" #include "tinyds-policy.h" #include "tinyds-dpms.h" +#include "tinyds-launch.h" struct tinyds_keyboard; struct tinyds_pointer; @@ -32,12 +33,11 @@ struct tinyds_server uint32_t seat_caps; double output_x, output_y; struct ds_tizen_input_devicemgr *devicemgr; - struct ds_tizen_launch_effect *effect; - struct ds_tizen_launch_splash *splash; struct tinyds_output *output; struct tinyds_dpms *dpms; struct tinyds_policy *policy; + struct tinyds_launch *launch; struct wl_event_source *stdin_source; @@ -48,11 +48,7 @@ struct tinyds_server struct wl_listener new_xdg_surface; struct wl_listener devicemgr_destroy; struct wl_listener pointer_warp; - struct wl_listener effect_destroy; - struct wl_listener effect_type_set; - struct wl_listener effect_type_unset; - struct wl_listener new_splash; - struct wl_listener splash_owner; + struct wl_list keyboards; struct wl_list pointers; @@ -61,5 +57,26 @@ struct tinyds_server struct tinyds_input_method *input_method; }; +struct tinyds_view +{ + struct tinyds_server *server; + + struct tinyds_texture *texture; + struct ds_xdg_surface *xdg_surface; + + struct wl_listener xdg_surface_map; + struct wl_listener xdg_surface_unmap; + struct wl_listener xdg_surface_destroy; + struct wl_listener surface_commit; + struct wl_list link; // tinyds_server::views + + struct ds_tdm_output_hwc_window *hwc_window; + + int x, y; + bool mapped; + + pid_t pid; + int effect_type; +}; #endif -- 2.7.4 From 725c549bf957d657faee743e921527880dc4722d Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Sat, 29 Oct 2022 12:22:47 +0900 Subject: [PATCH 07/16] examples: make tinyds-input-devicemgr files move the implementation of ds_tizen_input-devicemgr at tinyds-tdm.c to tinyds-input-devicemgr file. Change-Id: Icc37023b56d556932d5013d321f23f53050c4a6d --- examples/meson.build | 1 + examples/tinyds-input-devicemgr.c | 169 ++++++++++++++++++++++++++++++++++++++ examples/tinyds-input-devicemgr.h | 16 ++++ examples/tinyds-tdm.c | 164 +++++++++--------------------------- examples/tinyds-tdm.h | 12 ++- 5 files changed, 234 insertions(+), 128 deletions(-) create mode 100644 examples/tinyds-input-devicemgr.c create mode 100644 examples/tinyds-input-devicemgr.h diff --git a/examples/meson.build b/examples/meson.build index 9b12dd8..8de3845 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -24,6 +24,7 @@ tinyds_tdm_files = [ 'tinyds-policy.c', 'tinyds-dpms.c', 'tinyds-launch.c', + 'tinyds-input-devicemgr.c', ] executable('tinyds-tdm', diff --git a/examples/tinyds-input-devicemgr.c b/examples/tinyds-input-devicemgr.c new file mode 100644 index 0000000..c2e3b20 --- /dev/null +++ b/examples/tinyds-input-devicemgr.c @@ -0,0 +1,169 @@ +#include + +#include "tinyds-common.h" +#include "tinyds-input-devicemgr.h" +#include "tinyds-tdm.h" + +struct tinyds_input_devicemgr +{ + input_devicemgr_free_cb free_cb; + void *data; + + struct ds_tizen_input_devicemgr *devicemgr; + struct ds_seat *seat; + + struct wl_listener destroy; + struct wl_listener pointer_warp; + + struct tinyds_server *server; +}; + +static void +devicemgr_add_keymap_data(struct wl_list *list, const char *name, int keycode) +{ + struct ds_tizen_input_devicemgr_keymap_data *data; + + data = calloc(1, sizeof *data); + if (!data) { + ds_err("Failed to alloc memory"); + return; + } + + data->name = strdup(name); + data->keycode = keycode; + + wl_list_insert(list, &data->link); +} + +static void +devicemgr_cleanup_keymap_list(struct wl_list *list) +{ + struct ds_tizen_input_devicemgr_keymap_data *data, *tmp; + + wl_list_for_each_safe(data, tmp, list, link) { + wl_list_remove(&data->link); + free(data->name); + free(data); + } +} + +static void +devicemgr_set_keymap(struct ds_tizen_input_devicemgr *devicemgr) +{ + struct wl_list keymap_list; + bool res; + + wl_list_init(&keymap_list); + + devicemgr_add_keymap_data(&keymap_list, "XF86VolumeRaise", 455); + devicemgr_add_keymap_data(&keymap_list, "XF86VolumeLower", 456); + devicemgr_add_keymap_data(&keymap_list, "XF86LightOn", 457); + devicemgr_add_keymap_data(&keymap_list, "XF86LightOff", 458); + + res = ds_tizen_input_devicemgr_set_keymap_list(devicemgr, &keymap_list); + if (!res) + ds_inf("Failed to set keymap"); + + devicemgr_cleanup_keymap_list(&keymap_list); +} + +static void +devicemgr_handle_pointer_warp(struct wl_listener *listener, void *data) +{ + struct ds_tizen_input_devicemgr_event_pointer_warp *event = data; + struct tinyds_input_devicemgr *input_devicemgr = + wl_container_of(listener, input_devicemgr, pointer_warp); + struct tinyds_server *server = input_devicemgr->server; + struct tinyds_view *view = NULL; + double sx = 0.f, sy = 0.f; + int output_w = 0, output_h = 0; + + ds_inf("Pointer warp: surface(%p) x(%.2f) y(%.2f)", event->surface, + event->x, event->y); + + view = tinyds_server_get_focused_view(server); + if (!view) return; + + if (event->surface != ds_xdg_surface_get_surface(view->xdg_surface)) { + ds_inf("Pointer is not on the requested surface"); + return; + } + + tinyds_server_get_output_size(server, &output_w, &output_h); + + server->output_x = view->x + (event->x * output_w); + server->output_y = view->y + (event->y * output_h); + + tinyds_server_view_at(server, server->output_x, server->output_y, &sx, &sy); + + ds_inf("notify motion: sx:%.2f sy:%.2f, output_x:%.1f, output_y:%.1f", + sx, sy, server->output_x, server->output_y); + + ds_seat_pointer_notify_motion(input_devicemgr->seat, event->time_msec, + sx, sy); +} + +static void +devicemgr_handle_destroy(struct wl_listener *listener, void *data TINYDS_UNUSED) +{ + struct tinyds_input_devicemgr *input_devicemgr = + wl_container_of(listener, input_devicemgr, destroy); + + ds_inf("input_devicemgr (%p) destroy", input_devicemgr); + + input_devicemgr->free_cb(data); + + wl_list_remove(&input_devicemgr->destroy.link); + wl_list_remove(&input_devicemgr->pointer_warp.link); + + free(input_devicemgr); +} + +struct tinyds_input_devicemgr * +tinyds_input_devicemgr_init(struct ds_backend *input_backend, + struct ds_seat *seat, input_devicemgr_free_cb free_cb, void *data) +{ + struct tinyds_input_devicemgr *input_devicemgr; + + input_devicemgr = calloc(1, sizeof *input_devicemgr); + if (!input_devicemgr) + return NULL; + + input_devicemgr->free_cb = free_cb; + data = data; + + input_devicemgr->devicemgr = ds_tizen_input_devicemgr_create( + input_backend, seat); + if (!input_devicemgr->devicemgr) { + free(input_devicemgr); + ds_err("Could not create ds_tizen_input_devicemgr"); + return NULL; + } + + input_devicemgr->seat = seat; + + devicemgr_set_keymap(input_devicemgr->devicemgr); + + input_devicemgr->destroy.notify = devicemgr_handle_destroy; + ds_tizen_input_devicemgr_add_destroy_listener(input_devicemgr->devicemgr, + &input_devicemgr->destroy); + + input_devicemgr->pointer_warp.notify = devicemgr_handle_pointer_warp; + ds_tizen_input_devicemgr_add_pointer_warp_listener(input_devicemgr->devicemgr, + &input_devicemgr->pointer_warp); + + input_devicemgr->server = (struct tinyds_server *)data; + + ds_inf("Input Devicemgr (%p) created", input_devicemgr); + + return input_devicemgr; +} + +void +tinyds_input_devicemgr_set_output_size( + struct tinyds_input_devicemgr *input_devicemgr, + uint32_t width, uint32_t height) +{ + ds_tizen_input_devicemgr_set_output_width_height(input_devicemgr->devicemgr, + width, height); +} diff --git a/examples/tinyds-input-devicemgr.h b/examples/tinyds-input-devicemgr.h new file mode 100644 index 0000000..ea40e82 --- /dev/null +++ b/examples/tinyds-input-devicemgr.h @@ -0,0 +1,16 @@ +#ifndef TINYDS_INPUT_DEVICEMGR_H +#define TINYDS_INPUT_DEVICEMGR_H + +typedef void (*input_devicemgr_free_cb)(void *data); + +struct tinyds_input_devicemgr; + +struct tinyds_input_devicemgr *tinyds_input_devicemgr_init( + struct ds_backend *input_backend, struct ds_seat *seat, + input_devicemgr_free_cb free_cb, void *data); + +void tinyds_input_devicemgr_set_output_size( + struct tinyds_input_devicemgr *input_devicemgr, + uint32_t width, uint32_t height); + +#endif diff --git a/examples/tinyds-tdm.c b/examples/tinyds-tdm.c index 08084e3..31c1e2d 100644 --- a/examples/tinyds-tdm.c +++ b/examples/tinyds-tdm.c @@ -158,10 +158,6 @@ static void server_add_pointer(struct tinyds_server *server, struct ds_input_device *dev); static void server_add_touch(struct tinyds_server *server, struct ds_input_device *dev); -static struct tinyds_view * -server_view_at(struct tinyds_server *server, double lx, double ly, - double *sx, double *sy); - static bool add_new_text_input(struct tinyds_server *server); static bool add_new_input_method(struct tinyds_server *server); static bool add_new_input_method_context( @@ -428,7 +424,7 @@ backend_handle_new_output(struct wl_listener *listener, void *data) output->output_frame.notify = output_handle_frame; ds_output_add_frame_listener(ds_output, &output->output_frame); - ds_tizen_input_devicemgr_set_output_width_height(server->devicemgr, (uint32_t)output->width, (uint32_t)output->height); + tinyds_input_devicemgr_set_output_size(server->input_devicemgr, (uint32_t)output->width, (uint32_t)output->height); server->output = output; server->output_x = (double)(output->width) / 2; @@ -470,105 +466,6 @@ backend_handle_new_input(struct wl_listener *listener, void *data) } static void -devicemgr_add_keymap_data(struct wl_list *list, const char *name, int keycode) -{ - struct ds_tizen_input_devicemgr_keymap_data *data; - - data = calloc(1, sizeof *data); - if (!data) { - ds_err("Failed to alloc memory"); - return; - } - - data->name = strdup(name); - data->keycode = keycode; - - wl_list_insert(list, &data->link); -} - -static void -devicemgr_cleanup_keymap_list(struct wl_list *list) -{ - struct ds_tizen_input_devicemgr_keymap_data *data, *tmp; - - wl_list_for_each_safe(data, tmp, list, link) { - wl_list_remove(&data->link); - free(data->name); - free(data); - } -} - -static void -devicemgr_set_keymap(struct ds_tizen_input_devicemgr *devicemgr) -{ - struct wl_list keymap_list; - bool res; - - wl_list_init(&keymap_list); - - devicemgr_add_keymap_data(&keymap_list, "XF86VolumeRaise", 455); - devicemgr_add_keymap_data(&keymap_list, "XF86VolumeLower", 456); - devicemgr_add_keymap_data(&keymap_list, "XF86LightOn", 457); - devicemgr_add_keymap_data(&keymap_list, "XF86LightOff", 458); - - res = ds_tizen_input_devicemgr_set_keymap_list(devicemgr, &keymap_list); - if (!res) - ds_inf("Failed to set keymap"); - - devicemgr_cleanup_keymap_list(&keymap_list); -} - -static void -devicemgr_handle_pointer_warp(struct wl_listener *listener, void *data) -{ - struct tinyds_server *server; - struct tinyds_pointer *pointer; - struct ds_tizen_input_devicemgr_event_pointer_warp *event = data; - double sx = 0.f, sy = 0.f; - struct tinyds_view *view = NULL; - - server = wl_container_of(listener, server, pointer_warp); - - ds_inf("Pointer warp: surface(%p) x(%.2f) y(%.2f)", event->surface, - event->x, event->y); - - wl_list_for_each(pointer, &server->pointers, link){ - if (!pointer->focused_view) continue; - view = pointer->focused_view; - } - if (!view) return; - - if (event->surface != ds_xdg_surface_get_surface(view->xdg_surface)) { - ds_inf("Pointer is not on the requested surface"); - return; - } - - server->output_x = view->x + (event->x * server->output->width); - server->output_y = view->y + (event->y * server->output->height); - - server_view_at(server, server->output_x, server->output_y, &sx, &sy); - - ds_inf("notify motion: sx:%.2f sy:%.2f, output_x:%.1f, output_y:%.1f", - sx, sy, server->output_x, server->output_y); - - ds_seat_pointer_notify_motion(server->seat, - event->time_msec, sx, sy); -} - -static void -devicemgr_handle_destroy(struct wl_listener *listener, void *data TINYDS_UNUSED) -{ - struct tinyds_server *server = - wl_container_of(listener, server, devicemgr_destroy); - - wl_list_remove(&server->devicemgr_destroy.link); - wl_list_remove(&server->pointer_warp.link); - - server->devicemgr = NULL; -} - - -static void dpms_free_func(void *data) { struct tinyds_server *server = (struct tinyds_server *)data; @@ -592,6 +489,14 @@ launch_free_func(void *data) server->launch = NULL; } +static void +input_devicemgr_free_func(void *data) +{ + struct tinyds_server *server = (struct tinyds_server *)data; + + server->input_devicemgr = NULL; +} + static bool init_server(struct tinyds_server *server, struct wl_display *display) { @@ -654,22 +559,10 @@ init_server(struct tinyds_server *server, struct wl_display *display) goto err; server->seat_caps = 0; - server->devicemgr = ds_tizen_input_devicemgr_create( - server->input_backend, server->seat); - if (!server->devicemgr) { - ds_err("Could not create ds_tizen_input_devicemgr"); + server->input_devicemgr = tinyds_input_devicemgr_init(server->input_backend, + server->seat, input_devicemgr_free_func, (void *)server); + if (!server->input_devicemgr) goto err; - } - - devicemgr_set_keymap(server->devicemgr); - - server->devicemgr_destroy.notify = devicemgr_handle_destroy; - ds_tizen_input_devicemgr_add_destroy_listener(server->devicemgr, - &server->devicemgr_destroy); - - server->pointer_warp.notify = devicemgr_handle_pointer_warp; - ds_tizen_input_devicemgr_add_pointer_warp_listener(server->devicemgr, - &server->pointer_warp); if (!add_new_text_input(server)) goto err; @@ -1286,8 +1179,8 @@ err: free(kbd); } -static struct tinyds_view * -server_view_at(struct tinyds_server *server, double lx, double ly, +struct tinyds_view * +tinyds_server_view_at(struct tinyds_server *server, double lx, double ly, double *sx, double *sy) { struct tinyds_view *view; @@ -1349,7 +1242,7 @@ touch_handle_down(struct wl_listener *listener, void *data) ds_inf("Touch(%p) event down: id(%d) x %.3f y %.3f output_x %.1f output_y %.1f", touch->dev, event->id, event->x, event->y, server->output_x, server->output_y); - view = server_view_at(server, server->output_x, server->output_y, &sx, &sy); + view = tinyds_server_view_at(server, server->output_x, server->output_y, &sx, &sy); if (view) { ds_seat_touch_notify_down(touch->server->seat, ds_xdg_surface_get_surface(view->xdg_surface), @@ -1396,7 +1289,7 @@ touch_handle_motion(struct wl_listener *listener, void *data) ds_inf("Touch(%p) event motion: id(%d) x %.3f y %.3f output_x %.1f output_y %.1f", touch->dev, event->id, event->x, event->y, server->output_x, server->output_y); - view = server_view_at(server, server->output_x, server->output_y, &sx, &sy); + view = tinyds_server_view_at(server, server->output_x, server->output_y, &sx, &sy); if (view) { ds_seat_touch_notify_motion(server->seat, event->time_msec, @@ -1506,7 +1399,7 @@ pointer_handle_motion(struct wl_listener *listener, void *data) ds_inf("Pointer(%p) motion: (delta_x %.1f delta_y %.1f) output_x %.1f output_y %.1f", pointer, event->delta_x, event->delta_y, server->output_x, server->output_y); - view = server_view_at(pointer->server, server->output_x, server->output_y, &sx, &sy); + view = tinyds_server_view_at(pointer->server, server->output_x, server->output_y, &sx, &sy); if (pointer->focused_view != view) { if (pointer->focused_view) { @@ -2277,3 +2170,26 @@ add_new_input_method_context(struct tinyds_input_method *input_method, return true; } + +struct tinyds_view * +tinyds_server_get_focused_view(struct tinyds_server *server) +{ + struct tinyds_view *view = NULL; + struct tinyds_pointer *pointer; + + wl_list_for_each(pointer, &server->pointers, link){ + if (!pointer->focused_view) continue; + + view = pointer->focused_view; + } + + return view; +} + +void +tinyds_server_get_output_size(struct tinyds_server *server, + int *output_w, int *output_h) +{ + *output_w = server->output->width; + *output_h = server->output->height; +} \ No newline at end of file diff --git a/examples/tinyds-tdm.h b/examples/tinyds-tdm.h index 0935b9b..95ff044 100644 --- a/examples/tinyds-tdm.h +++ b/examples/tinyds-tdm.h @@ -15,6 +15,7 @@ #include "tinyds-policy.h" #include "tinyds-dpms.h" #include "tinyds-launch.h" +#include "tinyds-input-devicemgr.h" struct tinyds_keyboard; struct tinyds_pointer; @@ -32,12 +33,12 @@ struct tinyds_server struct ds_seat *seat; uint32_t seat_caps; double output_x, output_y; - struct ds_tizen_input_devicemgr *devicemgr; struct tinyds_output *output; struct tinyds_dpms *dpms; struct tinyds_policy *policy; struct tinyds_launch *launch; + struct tinyds_input_devicemgr *input_devicemgr; struct wl_event_source *stdin_source; @@ -46,9 +47,6 @@ struct tinyds_server struct wl_listener new_output; struct wl_listener new_input; struct wl_listener new_xdg_surface; - struct wl_listener devicemgr_destroy; - struct wl_listener pointer_warp; - struct wl_list keyboards; struct wl_list pointers; @@ -79,4 +77,10 @@ struct tinyds_view int effect_type; }; +struct tinyds_view *tinyds_server_view_at(struct tinyds_server *server, + double lx, double ly, double *sx, double *sy); +struct tinyds_view *tinyds_server_get_focused_view(struct tinyds_server *server); +void tinyds_server_get_output_size(struct tinyds_server *server, + int *output_w, int *output_h); + #endif -- 2.7.4 From d9fc2e8b50c6a339e02dd34e569c47b7d2571ac0 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Tue, 11 Oct 2022 18:29:20 +0900 Subject: [PATCH 08/16] video: Add tizen_viewport implementation Change-Id: I56840111bfa69fa4de99c8e12e45088712f6c6df --- include/libds-tizen/video.h | 94 +++++++ src/video/meson.build | 1 + src/video/video-private.h | 10 + src/video/video.c | 20 +- src/video/viewport.c | 606 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 730 insertions(+), 1 deletion(-) create mode 100644 src/video/video-private.h create mode 100644 src/video/viewport.c diff --git a/include/libds-tizen/video.h b/include/libds-tizen/video.h index 0cbf5d7..7358fc8 100644 --- a/include/libds-tizen/video.h +++ b/include/libds-tizen/video.h @@ -12,12 +12,87 @@ struct ds_tizen_video; struct ds_tizen_video_object; +struct ds_tizen_viewport; + +enum ds_tizen_viewport_state_field { + DS_TIZEN_VIEWPORT_STATE_NONE = 0, + DS_TIZEN_VIEWPORT_STATE_TRANSFORM = (1 << 0), + DS_TIZEN_VIEWPORT_STATE_SOURCE = (1 << 1), + DS_TIZEN_VIEWPORT_STATE_DESTINATION = (1 << 2), + DS_TIZEN_VIEWPORT_STATE_FOLLOW_PARENT_TRANSFORM = (1 << 3), +}; + +enum ds_tizen_viewport_destination_type { + DS_TIZEN_VIEWPORT_DESTINATION_TYPE_NONE, + DS_TIZEN_VIEWPORT_DESTINATION_TYPE_RECT, + DS_TIZEN_VIEWPORT_DESTINATION_TYPE_RATIO, + DS_TIZEN_VIEWPORT_DESTINATION_TYPE_MODE, +}; + +enum ds_tizen_viewport_destination_mode_type { + DS_TIZEN_VIEWPORT_DESTINATION_MODE_TYPE_NONE, + DS_TIZEN_VIEWPORT_DESTINATION_MODE_TYPE_LETTER_BOX, + DS_TIZEN_VIEWPORT_DESTINATION_MODE_TYPE_ORIGIN, + DS_TIZEN_VIEWPORT_DESTINATION_MODE_TYPE_FULL, + DS_TIZEN_VIEWPORT_DESTINATION_MODE_TYPE_CROPPED_FULL, + DS_TIZEN_VIEWPORT_DESTINATION_MODE_TYPE_ORIGIN_OR_LETTER, +}; + +struct ds_tizen_viewport_state { + enum ds_tizen_viewport_state_field committed; + + struct { + uint32_t x, y, w, h; + } src; + + struct { + enum ds_tizen_viewport_destination_type type; + + struct { + int32_t x, y; + uint32_t w, h; + } rect; + + struct { + double x, y, w, h; + } ratio; + + struct { + enum ds_tizen_viewport_destination_mode_type type; + + struct { + double h, v; + } ratio; + + struct { + double h, v; + } scale; + + struct { + double h, v; + } align; + + struct { + int x, y, w, h; + } offset; + } mode; + } dst; + + uint32_t transform; + bool follow_parent_transform; +}; + struct ds_event_tizen_video_request_set_property { struct ds_tizen_video_object *object; const char *name; int32_t value; }; +struct ds_tizen_viewport_event_commit { + struct ds_tizen_viewport *viewport; + const struct ds_tizen_viewport_state *state; +}; + struct ds_tizen_video *ds_tizen_video_create(struct wl_display *display); void ds_tizen_video_add_format(struct ds_tizen_video *video, uint32_t format); @@ -35,6 +110,9 @@ void ds_tizen_video_add_destroy_listener(struct ds_tizen_video *video, void ds_tizen_video_add_new_object_listener(struct ds_tizen_video *video, struct wl_listener *listener); +void ds_tizen_video_add_new_viewport_listener(struct ds_tizen_video *video, + struct wl_listener *listener); + struct ds_surface *ds_tizen_video_object_get_surface( struct ds_tizen_video_object *object); @@ -57,6 +135,22 @@ void ds_tizen_video_object_add_request_attribute_allowed_listener( void ds_tizen_video_object_add_request_attribute_disallowed_listener( struct ds_tizen_video_object *object, struct wl_listener *listener); +struct ds_surface *ds_tizen_viewport_get_surface( + struct ds_tizen_viewport *viewport); + +void ds_tizen_viewport_add_destroy_listener(struct ds_tizen_viewport *viewport, + struct wl_listener *listener); + +/* @data: struct ds_tizen_viewport_event_commit */ +void ds_tizen_viewport_add_commit_listener(struct ds_tizen_viewport *viewport, + struct wl_listener *listener); + +void ds_tizen_viewport_add_query_parent_size_listener( + struct ds_tizen_viewport *viewport, struct wl_listener *listener); + +void ds_tizen_viewport_send_parent_size(struct ds_tizen_viewport *viewport, + uint32_t width, uint32_t height); + #ifdef __cplusplus } #endif diff --git a/src/video/meson.build b/src/video/meson.build index e091554..363926b 100644 --- a/src/video/meson.build +++ b/src/video/meson.build @@ -1,5 +1,6 @@ libds_tizen_video_files = [ 'video.c', + 'viewport.c', ] libds_tizen_video_deps = [ diff --git a/src/video/video-private.h b/src/video/video-private.h new file mode 100644 index 0000000..d399603 --- /dev/null +++ b/src/video/video-private.h @@ -0,0 +1,10 @@ +#ifndef DS_TIZEN_VIDEO_PRIVATE_H +#define DS_TIZEN_VIDEO_PRIVATE_H + +#include + +struct ds_tizen_viewport * +create_viewport(struct wl_client *client, struct wl_resource *resource, + uint32_t id, struct wl_resource *surface_resource); + +#endif diff --git a/src/video/video.c b/src/video/video.c index db8bd26..0a258f4 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -11,6 +11,7 @@ #include "libds-tizen/video.h" #include "shared/pixel_format.h" +#include "video-private.h" #define TIZEN_VIDEO_VERSION 1 @@ -32,6 +33,7 @@ struct ds_tizen_video struct { struct wl_signal destroy; struct wl_signal new_object; + struct wl_signal new_viewport; } events; }; @@ -103,6 +105,7 @@ ds_tizen_video_create(struct wl_display *display) wl_signal_init(&video->events.destroy); wl_signal_init(&video->events.new_object); + wl_signal_init(&video->events.new_viewport); video->display_destroy.notify = video_handle_display_destroy; wl_display_add_destroy_listener(display, &video->display_destroy); @@ -183,6 +186,13 @@ ds_tizen_video_add_new_object_listener(struct ds_tizen_video *video, wl_signal_add(&video->events.new_object, listener); } +WL_EXPORT void +ds_tizen_video_add_new_viewport_listener(struct ds_tizen_video *video, + struct wl_listener *listener) +{ + wl_signal_add(&video->events.new_viewport, listener); +} + WL_EXPORT struct ds_surface * ds_tizen_video_object_get_surface(struct ds_tizen_video_object *object) { @@ -294,7 +304,15 @@ video_handle_get_viewport(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface_resource) { - // TODO + struct ds_tizen_video *video; + struct ds_tizen_viewport *viewport; + + viewport = create_viewport(client, resource, id, surface_resource); + if (!viewport) + return; + + video = wl_resource_get_user_data(resource); + wl_signal_emit(&video->events.new_viewport, viewport); } static void diff --git a/src/video/viewport.c b/src/video/viewport.c new file mode 100644 index 0000000..69b3cd7 --- /dev/null +++ b/src/video/viewport.c @@ -0,0 +1,606 @@ +#include +#include +#include + +#include +#include + +#include "libds-tizen/video.h" + +struct ds_tizen_viewport { + struct wl_resource *resource; + struct wl_resource *mode_resource; + struct ds_surface *surface; + struct ds_surface_viewport *surface_viewport; + + struct ds_tizen_viewport_state current, pending; + + struct wl_listener surface_destroy; + struct wl_listener surface_commit; + + struct { + struct wl_signal destroy; + struct wl_signal commit; + struct wl_signal query_parent_size; + } events; + + bool query_parent_size; +}; + +static const struct tizen_viewport_interface viewport_impl; +static const struct tizen_destination_mode_interface destination_mode_impl; + +static void viewport_handle_resource_destroy(struct wl_resource *resource); +static void viewport_handle_surface_destroy(struct wl_listener *listener, + void *data); +static void viewport_handle_surface_commit(struct wl_listener *listener, + void *data); +static void viewport_destroy(struct ds_tizen_viewport *viewport); +static void viewport_set_follow_parent_transform_pending( + struct ds_tizen_viewport *viewport, bool value); +static void destination_mode_resource_destroy(struct wl_resource *resource); +static enum ds_tizen_viewport_destination_mode_type +destination_mode_type_to_ds_enum(uint32_t type); + +WL_EXPORT struct ds_surface * +ds_tizen_viewport_get_surface(struct ds_tizen_viewport *viewport) +{ + return viewport->surface; +} + +WL_EXPORT void +ds_tizen_viewport_add_destroy_listener(struct ds_tizen_viewport *viewport, + struct wl_listener *listener) +{ + wl_signal_add(&viewport->events.destroy, listener); +} + +WL_EXPORT void +ds_tizen_viewport_add_commit_listener(struct ds_tizen_viewport *viewport, + struct wl_listener *listener) +{ + wl_signal_add(&viewport->events.commit, listener); +} + +WL_EXPORT void +ds_tizen_viewport_add_query_parent_size_listener( + struct ds_tizen_viewport *viewport, struct wl_listener *listener) +{ + wl_signal_add(&viewport->events.query_parent_size, listener); +} + +WL_EXPORT void +ds_tizen_viewport_send_parent_size(struct ds_tizen_viewport *viewport, + uint32_t width, uint32_t height) +{ + if (!viewport->query_parent_size) + return; + + tizen_viewport_send_parent_size(viewport->resource, width, height); +} + +struct ds_tizen_viewport * +create_viewport(struct wl_client *client, struct wl_resource *resource, + uint32_t id, struct wl_resource *surface_resource) +{ + struct ds_tizen_viewport *viewport; + struct ds_surface *surface; + struct ds_surface_viewport *surface_viewport; + + surface = ds_surface_from_resource(resource); + surface_viewport = ds_surface_take_viewport(surface); + if (!surface_viewport) { + wl_resource_post_error(resource, TIZEN_VIDEO_ERROR_VIEWPORT_EXISTS, + "a viewport for that surface already exists"); + return NULL; + } + + viewport = calloc(1, sizeof *viewport); + if (!viewport) + goto err_alloc; + + viewport->resource = wl_resource_create(client, &tizen_viewport_interface, + wl_resource_get_version(resource), id); + if (!viewport->resource) + goto err_resource; + + wl_resource_set_implementation(viewport->resource, &viewport_impl, + viewport, viewport_handle_resource_destroy); + + wl_signal_init(&viewport->events.commit); + wl_signal_init(&viewport->events.query_parent_size); + + viewport->surface_viewport = surface_viewport; + + viewport->surface_destroy.notify = viewport_handle_surface_destroy; + ds_surface_add_destroy_listener(surface, &viewport->surface_destroy); + + viewport->surface_commit.notify = viewport_handle_surface_commit; + ds_surface_add_commit_listener(surface, &viewport->surface_commit); + + return viewport; + +err_resource: + free(viewport); +err_alloc: + ds_surface_viewport_release(surface_viewport); + wl_resource_post_no_memory(resource); + + return NULL; +} + +static void +viewport_handle_destroy(struct wl_client *client, struct wl_resource *resource) +{ + wl_resource_destroy(resource); +} + +static void +viewport_handle_set_transform(struct wl_client *client, + struct wl_resource *resource, uint32_t transform) +{ + struct ds_tizen_viewport *viewport; + + if (transform > WL_OUTPUT_TRANSFORM_FLIPPED_270) { + ds_err("Invalid param: transform(%d)", transform); + return; + } + + viewport = wl_resource_get_user_data(resource); + if (viewport->pending.transform == transform) + return; + + viewport->pending.transform = transform; + viewport->pending.committed |= DS_TIZEN_VIEWPORT_STATE_TRANSFORM; +} + +static void +viewport_handle_set_source(struct wl_client *client, + struct wl_resource *resource, + uint32_t x, uint32_t y, uint32_t width, uint32_t height) +{ + struct ds_tizen_viewport *viewport; + + viewport = wl_resource_get_user_data(resource); + if (viewport->pending.src.x == x && + viewport->pending.src.y == y && + viewport->pending.src.w == width && + viewport->pending.src.h == height) { + return; + } + + viewport->pending.src.x = x; + viewport->pending.src.y = y; + viewport->pending.src.w = width; + viewport->pending.src.h = height; + viewport->pending.committed |= DS_TIZEN_VIEWPORT_STATE_SOURCE; +} + +static void +viewport_handle_set_destination(struct wl_client *client, + struct wl_resource *resource, + int32_t x, int32_t y, uint32_t width, uint32_t height) +{ + struct ds_tizen_viewport *viewport; + + if (width == 0 || height == 0) { + ds_err("Invalid param: destination.rect(%d,%d %dx%d)", + x, y, width, height); + return; + } + + viewport = wl_resource_get_user_data(resource); + if (viewport->pending.dst.type == DS_TIZEN_VIEWPORT_DESTINATION_TYPE_RECT && + viewport->pending.dst.rect.x == x && + viewport->pending.dst.rect.y == y && + viewport->pending.dst.rect.w == width && + viewport->pending.dst.rect.h == height) { + return; + } + + viewport->pending.dst.rect.x = x; + viewport->pending.dst.rect.y = y; + viewport->pending.dst.rect.w = width; + viewport->pending.dst.rect.h = height; + viewport->pending.dst.type = DS_TIZEN_VIEWPORT_DESTINATION_TYPE_RECT; + viewport->pending.committed |= DS_TIZEN_VIEWPORT_STATE_DESTINATION; +} + +static void +viewport_handle_set_destination_ratio(struct wl_client *client, + struct wl_resource *resource, + wl_fixed_t x, wl_fixed_t y, wl_fixed_t width, wl_fixed_t height) +{ + struct ds_tizen_viewport *viewport; + double ratio_x, ratio_y, ratio_w, ratio_h; + + viewport = wl_resource_get_user_data(resource); + if (viewport->pending.dst.type == DS_TIZEN_VIEWPORT_DESTINATION_TYPE_MODE) { + ds_err("Couldn't set viewport destination ratio. " + "tizen_viewport@%d has the mode", + wl_resource_get_id(resource)); + return; + } + + ratio_x = wl_fixed_to_double(x); + ratio_y = wl_fixed_to_double(y); + ratio_w = wl_fixed_to_double(width); + ratio_h = wl_fixed_to_double(height); + if (ratio_x < 0.0 || ratio_x >= 1.0 || + ratio_y < 0.0 || ratio_y >= 1.0 || + ratio_w <= 0.0 || ratio_h <= 0.0) { + ds_err("Invalid param: destination.ratio(%.2f,%.2f %.2fx%.2f)", + ratio_x, ratio_y, ratio_w, ratio_h); + return; + } + + if (viewport->pending.dst.type == DS_TIZEN_VIEWPORT_DESTINATION_TYPE_RATIO && + viewport->pending.dst.ratio.x == ratio_x && + viewport->pending.dst.ratio.y == ratio_y && + viewport->pending.dst.ratio.w == ratio_w && + viewport->pending.dst.ratio.h == ratio_h) { + return; + } + + viewport->pending.dst.ratio.x = ratio_x; + viewport->pending.dst.ratio.y = ratio_y; + viewport->pending.dst.ratio.w = ratio_w; + viewport->pending.dst.ratio.h = ratio_h; + viewport->pending.dst.type = DS_TIZEN_VIEWPORT_DESTINATION_TYPE_RATIO; + viewport->pending.committed |= DS_TIZEN_VIEWPORT_STATE_DESTINATION; +} + +static void +viewport_handle_get_destination_mode(struct wl_client *client, + struct wl_resource *resource, uint32_t id) +{ + struct ds_tizen_viewport *viewport; + + viewport = wl_resource_get_user_data(resource); + if (viewport->mode_resource) { + ds_err("Destination mode resource already exists."); + /* WORKAROUND + * Since there is no error protocol for this case, + * it calls wl_resource_post_no_memory() instead. */ + wl_resource_post_no_memory(resource); + return; + } + + viewport->mode_resource = wl_resource_create(client, + &tizen_destination_mode_interface, + wl_resource_get_version(resource), id); + if (!viewport->mode_resource) { + wl_resource_post_no_memory(resource); + return; + } + wl_resource_set_implementation(viewport->mode_resource, + &destination_mode_impl, viewport, + destination_mode_resource_destroy); + + viewport->pending.dst.mode.type = DS_TIZEN_VIEWPORT_DESTINATION_MODE_TYPE_NONE; + viewport->pending.dst.mode.ratio.h = -1.0; + viewport->pending.dst.mode.scale.h = -1.0; + viewport->pending.dst.mode.align.h = -1.0; +} + +static void +viewport_handle_query_parent_size(struct wl_client *client, + struct wl_resource *resource) +{ + struct ds_tizen_viewport *viewport; + + viewport = wl_resource_get_user_data(resource); + viewport->query_parent_size = true; + wl_signal_emit(&viewport->events.query_parent_size, viewport); +} + +static void +viewport_handle_follow_parent_transform(struct wl_client *client, + struct wl_resource *resource) +{ + struct ds_tizen_viewport *viewport; + + viewport = wl_resource_get_user_data(resource); + viewport_set_follow_parent_transform_pending(viewport, true); +} + +static void +viewport_handle_unfollow_parent_transform(struct wl_client *client, + struct wl_resource *resource) +{ + struct ds_tizen_viewport *viewport; + + viewport = wl_resource_get_user_data(resource); + viewport_set_follow_parent_transform_pending(viewport, false); +} + +static const struct tizen_viewport_interface viewport_impl = { + .destroy = viewport_handle_destroy, + .set_transform = viewport_handle_set_transform, + .set_source = viewport_handle_set_source, + .set_destination = viewport_handle_set_destination, + .set_destination_ratio = viewport_handle_set_destination_ratio, + .get_destination_mode = viewport_handle_get_destination_mode, + .query_parent_size = viewport_handle_query_parent_size, + .follow_parent_transform = viewport_handle_follow_parent_transform, + .unfollow_parent_transform = viewport_handle_unfollow_parent_transform, +}; + +static void +viewport_handle_resource_destroy(struct wl_resource *resource) +{ + struct ds_tizen_viewport *viewport; + + viewport = wl_resource_get_user_data(resource); + if (viewport) + viewport_destroy(viewport); +} + +static void +viewport_handle_surface_destroy(struct wl_listener *listener, void *data) +{ + struct ds_tizen_viewport *viewport; + + viewport = wl_container_of(listener, viewport, surface_destroy); + viewport_destroy(viewport); +} + +static void +viewport_handle_surface_commit(struct wl_listener *listener, void *data) +{ + struct ds_tizen_viewport *viewport; + + viewport = wl_container_of(listener, viewport, surface_commit); + if (viewport->pending.committed == DS_TIZEN_VIEWPORT_STATE_NONE) + return; + + viewport->current = viewport->pending; + viewport->pending.committed = DS_TIZEN_VIEWPORT_STATE_NONE; + + wl_signal_emit(&viewport->events.commit, &viewport->current); +} + +static void +viewport_destroy(struct ds_tizen_viewport *viewport) +{ + wl_signal_emit(&viewport->events.destroy, viewport); + + ds_surface_viewport_release(viewport->surface_viewport); + + wl_resource_set_user_data(viewport->resource, NULL); + wl_list_remove(&viewport->surface_commit.link); + wl_list_remove(&viewport->surface_destroy.link); + free(viewport); +} + +static void +viewport_set_follow_parent_transform_pending(struct ds_tizen_viewport *viewport, + bool value) +{ + viewport->pending.follow_parent_transform = value; + viewport->pending.committed |= + DS_TIZEN_VIEWPORT_STATE_FOLLOW_PARENT_TRANSFORM; +} + +static void +destination_mode_handle_destroy(struct wl_client *client, + struct wl_resource *resource) +{ + wl_resource_destroy(resource); +} + +static void +destination_mode_handle_follow_parent_transform(struct wl_client *client, + struct wl_resource *resource) +{ + struct ds_tizen_viewport *viewport; + + viewport = wl_resource_get_user_data(resource); + viewport_set_follow_parent_transform_pending(viewport, true); +} + +static void +destination_mode_handle_unfollow_parent_transform(struct wl_client *client, + struct wl_resource *resource) +{ + struct ds_tizen_viewport *viewport; + + viewport = wl_resource_get_user_data(resource); + viewport_set_follow_parent_transform_pending(viewport, false); +} + +static void +destination_mode_handle_set(struct wl_client *client, + struct wl_resource *resource, uint32_t type) +{ + struct ds_tizen_viewport *viewport; + enum ds_tizen_viewport_destination_mode_type mode_type; + + if (type > TIZEN_DESTINATION_MODE_TYPE_ORIGIN_OR_LETTER) { + ds_err("Invalid param: type(%d)", type); + return; + } + + mode_type = destination_mode_type_to_ds_enum(type); + viewport = wl_resource_get_user_data(resource); + if (viewport->pending.dst.type == DS_TIZEN_VIEWPORT_DESTINATION_TYPE_MODE && + viewport->pending.dst.mode.type == mode_type) { + return; + } + + viewport->pending.dst.mode.type = mode_type; + viewport->pending.dst.type = DS_TIZEN_VIEWPORT_DESTINATION_TYPE_MODE; +} + +static void +destination_mode_handle_set_ratio(struct wl_client *client, + struct wl_resource *resource, + wl_fixed_t horizontal, wl_fixed_t vertical) +{ + struct ds_tizen_viewport *viewport; + double ratio_h, ratio_v; + + viewport = wl_resource_get_user_data(resource); + + ratio_h = wl_fixed_to_double(horizontal); + ratio_v = wl_fixed_to_double(vertical); + if (ratio_h <= 0.0 || ratio_v <= 0.0) { + if (ratio_h == -1.0) { + viewport->pending.dst.mode.ratio.h = ratio_h; + viewport->pending.committed |= DS_TIZEN_VIEWPORT_STATE_DESTINATION; + } + else { + ds_err("Invalid param: ratio_h(%.2f) ratio_v(%.2f)", + ratio_h, ratio_v); + } + + return; + } + + if (viewport->pending.dst.mode.ratio.h == ratio_h && + viewport->pending.dst.mode.ratio.v == ratio_v) + return; + + viewport->pending.dst.mode.ratio.h = ratio_h; + viewport->pending.dst.mode.ratio.v = ratio_v; + viewport->pending.committed |= DS_TIZEN_VIEWPORT_STATE_DESTINATION; +} + +static void +destination_mode_handle_set_scale(struct wl_client *client, + struct wl_resource *resource, + wl_fixed_t horizontal, wl_fixed_t vertical) +{ + struct ds_tizen_viewport *viewport; + double scale_h, scale_v; + + viewport = wl_resource_get_user_data(resource); + + scale_h = wl_fixed_to_double(horizontal); + scale_v = wl_fixed_to_double(vertical); + if (scale_h <= 0 || scale_v <= 0) { + if (scale_h == -1.0) { + viewport->pending.dst.mode.scale.h = scale_h; + viewport->pending.committed = DS_TIZEN_VIEWPORT_STATE_DESTINATION; + } + else { + ds_err("Invalid param: scale_h(%.2f) scale_v(%.2f)", + scale_h, scale_v); + } + + return; + } + + if (viewport->pending.dst.mode.scale.h == scale_h && + viewport->pending.dst.mode.scale.v == scale_v) + return; + + viewport->pending.dst.mode.scale.h = scale_h; + viewport->pending.dst.mode.scale.v = scale_v; + viewport->pending.committed = DS_TIZEN_VIEWPORT_STATE_DESTINATION; +} + +static void +destination_mode_handle_set_align(struct wl_client *client, + struct wl_resource *resource, + wl_fixed_t horizontal, wl_fixed_t vertical) +{ + struct ds_tizen_viewport *viewport; + double align_h, align_v; + + viewport = wl_resource_get_user_data(resource); + + align_h = wl_fixed_to_double(horizontal); + align_v = wl_fixed_to_double(vertical); + if (align_h == -1.0) { + viewport->pending.dst.mode.align.h = align_h; + viewport->pending.committed = DS_TIZEN_VIEWPORT_STATE_DESTINATION; + return; + } + + if (align_h < 0.0) + align_h = 0.0; + else if (align_h > 1.0) + align_h = 1.0; + + if (align_v < 0.0) + align_v = 0.0; + else if (align_v > 1.0) + align_v = 1.0; + + if (viewport->pending.dst.mode.align.h == align_h && + viewport->pending.dst.mode.align.v == align_v) + return; + + viewport->pending.dst.mode.align.h = align_h; + viewport->pending.dst.mode.align.v = align_v; + viewport->pending.committed = DS_TIZEN_VIEWPORT_STATE_DESTINATION; +} + +static void +destination_mode_handle_set_offset(struct wl_client *client, + struct wl_resource *resource, + int32_t x, int32_t y, int32_t w, int32_t h) +{ + struct ds_tizen_viewport *viewport; + + viewport = wl_resource_get_user_data(resource); + + if (viewport->pending.dst.mode.offset.x == x && + viewport->pending.dst.mode.offset.y == y && + viewport->pending.dst.mode.offset.w == w && + viewport->pending.dst.mode.offset.h == h) + return; + + viewport->pending.dst.mode.offset.x = x; + viewport->pending.dst.mode.offset.y = y; + viewport->pending.dst.mode.offset.w = w; + viewport->pending.dst.mode.offset.h = h; + viewport->pending.committed = DS_TIZEN_VIEWPORT_STATE_DESTINATION; +} + +static const struct tizen_destination_mode_interface destination_mode_impl = { + .destroy = destination_mode_handle_destroy, + .follow_parent_transform = destination_mode_handle_follow_parent_transform, + .unfollow_parent_transform = + destination_mode_handle_unfollow_parent_transform, + .set = destination_mode_handle_set, + .set_ratio = destination_mode_handle_set_ratio, + .set_scale = destination_mode_handle_set_scale, + .set_align = destination_mode_handle_set_align, + .set_offset = destination_mode_handle_set_offset, +}; + +static void destination_mode_resource_destroy(struct wl_resource *resource) +{ + struct ds_tizen_viewport *viewport; + + viewport = wl_resource_get_user_data(resource); + viewport->mode_resource = NULL; + + if (viewport->pending.dst.type == DS_TIZEN_VIEWPORT_DESTINATION_TYPE_MODE) { + viewport->pending.dst.type = DS_TIZEN_VIEWPORT_DESTINATION_TYPE_NONE; + viewport->pending.committed |= DS_TIZEN_VIEWPORT_STATE_DESTINATION; + } +} + +static enum ds_tizen_viewport_destination_mode_type +destination_mode_type_to_ds_enum(uint32_t type) +{ + switch (type) { + case TIZEN_DESTINATION_MODE_TYPE_NONE: + return DS_TIZEN_VIEWPORT_DESTINATION_MODE_TYPE_NONE; + case TIZEN_DESTINATION_MODE_TYPE_LETTER_BOX: + return DS_TIZEN_VIEWPORT_DESTINATION_MODE_TYPE_LETTER_BOX; + case TIZEN_DESTINATION_MODE_TYPE_ORIGIN: + return DS_TIZEN_VIEWPORT_DESTINATION_MODE_TYPE_ORIGIN; + case TIZEN_DESTINATION_MODE_TYPE_FULL: + return DS_TIZEN_VIEWPORT_DESTINATION_MODE_TYPE_FULL; + case TIZEN_DESTINATION_MODE_TYPE_CROPPED_FULL: + return DS_TIZEN_VIEWPORT_DESTINATION_MODE_TYPE_CROPPED_FULL; + case TIZEN_DESTINATION_MODE_TYPE_ORIGIN_OR_LETTER: + return DS_TIZEN_VIEWPORT_DESTINATION_MODE_TYPE_ORIGIN_OR_LETTER; + default: + assert(0 && "cannot reach here"); + } +} -- 2.7.4 From c5eb1cf7bc662880402bbf7aa9c78a773e7c8cc7 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Thu, 27 Oct 2022 15:00:25 +0900 Subject: [PATCH 09/16] Rename event types for consistency The event type names should be prefixed with `ds_{submodule}_event_`. Change-Id: I0dcfa36d901b5a89b78af172ce664a81bd1e40a5 --- examples/tinyds-dpms.c | 2 +- examples/tinyds-policy.c | 16 ++-- examples/tinyds-tdm.c | 14 +-- include/libds-tizen/dpms.h | 2 +- include/libds-tizen/policy.h | 88 ++++++++--------- include/libds-tizen/remote_surface.h | 18 ++-- include/libds-tizen/screenshooter.h | 2 +- include/libds-tizen/video.h | 4 +- src/dpms/dpms.c | 2 +- src/input_devicemgr/input_devicemgr.c | 12 +-- src/policy/policy.c | 88 ++++++++--------- src/remote_surface/remote_surface.c | 18 ++-- src/screenshooter/screenshooter.c | 2 +- src/video/video.c | 2 +- tests/tc_policy.cpp | 176 +++++++++++++++++----------------- tests/tc_screenshooter.cpp | 4 +- 16 files changed, 225 insertions(+), 225 deletions(-) diff --git a/examples/tinyds-dpms.c b/examples/tinyds-dpms.c index b8fabb4..2915bde 100644 --- a/examples/tinyds-dpms.c +++ b/examples/tinyds-dpms.c @@ -37,7 +37,7 @@ static void dpms_handle_set_dpms(struct wl_listener *listener, void *data) { struct tinyds_dpms *dpms; - struct ds_tizen_dpms_event *event = data; + struct ds_tizen_dpms_event_set_dpms *event = data; dpms = wl_container_of(listener, dpms, set_dpms); diff --git a/examples/tinyds-policy.c b/examples/tinyds-policy.c index 30146c7..07c0b55 100644 --- a/examples/tinyds-policy.c +++ b/examples/tinyds-policy.c @@ -205,10 +205,10 @@ policy_surface_handle_new_visibility(struct wl_listener *listener, void *data) { struct tinyds_policy_surface *policy_surface; struct tinyds_policy_visibility *visibility; - struct ds_tizen_event_policy_surface_new_visibility *event; + struct ds_tizen_policy_surface_event_new_visibility *event; policy_surface = wl_container_of(listener, policy_surface, new_visibility); - event = (struct ds_tizen_event_policy_surface_new_visibility *)data; + event = (struct ds_tizen_policy_surface_event_new_visibility *)data; ds_inf("Policy Info(%p) new_visibility", policy_surface); @@ -230,10 +230,10 @@ policy_surface_handle_new_position(struct wl_listener *listener, void *data) { struct tinyds_policy_surface *policy_surface; struct tinyds_policy_position *position; - struct ds_tizen_event_policy_surface_new_position *event; + struct ds_tizen_policy_surface_event_new_position *event; policy_surface = wl_container_of(listener, policy_surface, new_position); - event = (struct ds_tizen_event_policy_surface_new_position *)data; + event = (struct ds_tizen_policy_surface_event_new_position *)data; ds_inf("Policy Info(%p) new_position", policy_surface); @@ -523,10 +523,10 @@ policy_surface_handle_new_subsurface_watcher(struct wl_listener *listener, void { struct tinyds_policy_surface *policy_surface; struct tinyds_policy_subsurface_watcher*subsurface_watcher; - struct ds_tizen_event_policy_surface_new_subsurface_watcher *event; + struct ds_tizen_policy_surface_event_new_subsurface_watcher *event; policy_surface = wl_container_of(listener, policy_surface, new_subsurface_watcher); - event = (struct ds_tizen_event_policy_surface_new_subsurface_watcher *)data; + event = (struct ds_tizen_policy_surface_event_new_subsurface_watcher *)data; ds_inf("Policy Info(%p) new_subsurface_watcher", policy_surface); @@ -648,10 +648,10 @@ policy_handle_new_surface(struct wl_listener *listener, void *data) { struct tinyds_policy *policy; struct tinyds_policy_surface *policy_surface; - struct ds_tizen_event_policy_new_surface *event; + struct ds_tizen_policy_event_new_surface *event; policy = wl_container_of(listener, policy, new_surface); - event = (struct ds_tizen_event_policy_new_surface *)data; + event = (struct ds_tizen_policy_event_new_surface *)data; ds_inf("Policy(%p) new_surface", policy); diff --git a/examples/tinyds-tdm.c b/examples/tinyds-tdm.c index 31c1e2d..d7d4ac8 100644 --- a/examples/tinyds-tdm.c +++ b/examples/tinyds-tdm.c @@ -1099,7 +1099,7 @@ static void keyboard_handle_key(struct wl_listener *listener, void *data) { struct tinyds_keyboard *kbd; - struct ds_event_keyboard_key *event = data; + struct ds_keyboard_event_key *event = data; struct ds_keyboard *ds_keyboard; struct xkb_state *xkb_state; const xkb_keysym_t *syms; @@ -1227,7 +1227,7 @@ touch_handle_device_destroy(struct wl_listener *listener, void *data) static void touch_handle_down(struct wl_listener *listener, void *data) { - struct ds_event_touch_down *event = data; + struct ds_touch_event_down *event = data; struct tinyds_touch *touch; struct tinyds_view *view; struct tinyds_server *server; @@ -1260,7 +1260,7 @@ touch_handle_down(struct wl_listener *listener, void *data) static void touch_handle_up(struct wl_listener *listener, void *data) { - struct ds_event_touch_up *event = data; + struct ds_touch_event_up *event = data; struct tinyds_touch *touch; touch = wl_container_of(listener, touch, up); @@ -1274,7 +1274,7 @@ touch_handle_up(struct wl_listener *listener, void *data) static void touch_handle_motion(struct wl_listener *listener, void *data) { - struct ds_event_touch_motion *event = data; + struct ds_touch_event_motion *event = data; struct tinyds_touch *touch; struct tinyds_view *view; struct tinyds_server *server; @@ -1369,7 +1369,7 @@ static void pointer_handle_motion(struct wl_listener *listener, void *data) { struct tinyds_pointer *pointer; - struct ds_event_pointer_motion *event = data; + struct ds_pointer_event_motion *event = data; struct tinyds_view *view; struct tinyds_server *server; int ow = 0, oh = 0; @@ -1433,7 +1433,7 @@ static void pointer_handle_button(struct wl_listener *listener, void *data) { struct tinyds_pointer *pointer; - struct ds_event_pointer_button *event = data; + struct ds_pointer_event_button *event = data; pointer = wl_container_of(listener, pointer, button); @@ -2192,4 +2192,4 @@ tinyds_server_get_output_size(struct tinyds_server *server, { *output_w = server->output->width; *output_h = server->output->height; -} \ No newline at end of file +} diff --git a/include/libds-tizen/dpms.h b/include/libds-tizen/dpms.h index af2ce93..77073a3 100644 --- a/include/libds-tizen/dpms.h +++ b/include/libds-tizen/dpms.h @@ -28,7 +28,7 @@ enum ds_tizen_dpms_error DS_TIZEN_DPMS_ERROR_ALREADY_DONE, }; -struct ds_tizen_dpms_event +struct ds_tizen_dpms_event_set_dpms { struct ds_output *output; enum ds_tizen_dpms_mode mode; diff --git a/include/libds-tizen/policy.h b/include/libds-tizen/policy.h index 5066e41..1151dff 100644 --- a/include/libds-tizen/policy.h +++ b/include/libds-tizen/policy.h @@ -83,77 +83,77 @@ enum ds_tizen_policy_visibility_type }; // policy event structures -struct ds_tizen_event_policy_new_surface +struct ds_tizen_policy_event_new_surface { struct ds_tizen_policy *policy; struct ds_tizen_policy_surface *policy_surface; }; -struct ds_tizen_event_policy_activate_below_by_univeral_id +struct ds_tizen_policy_event_activate_below_by_univeral_id { struct ds_tizen_policy *policy; uint32_t universal_id; uint32_t below_universal_id; }; -struct ds_tizen_event_policy_lower_by_universal_id +struct ds_tizen_policy_event_lower_by_universal_id { struct ds_tizen_policy *policy; uint32_t universal_id; }; -struct ds_tizen_event_policy_set_transient_for +struct ds_tizen_policy_event_set_transient_for { struct ds_tizen_policy *policy; uint32_t child_universal_id; uint32_t parent_universal_id; }; -struct ds_tizen_event_policy_unset_transient_for +struct ds_tizen_policy_event_unset_transient_for { struct ds_tizen_policy *policy; uint32_t child_universal_id; }; -struct ds_tizen_event_policy_place_subsurface_below_parent +struct ds_tizen_policy_event_place_subsurface_below_parent { struct ds_tizen_policy *policy; struct ds_subsurface *subsurface; }; -struct ds_tizen_event_policy_set_subsurface_stand_alone +struct ds_tizen_policy_event_set_subsurface_stand_alone { struct ds_tizen_policy *policy; struct ds_subsurface *subsurface; }; -struct ds_tizen_event_policy_set_background_state +struct ds_tizen_policy_event_set_background_state { struct ds_tizen_policy *policy; int32_t pid; }; -struct ds_tizen_event_policy_unset_background_state +struct ds_tizen_policy_event_unset_background_state { struct ds_tizen_policy *policy; int32_t pid; }; -struct ds_tizen_event_policy_activate_above_by_universal_id +struct ds_tizen_policy_event_activate_above_by_universal_id { struct ds_tizen_policy *policy; uint32_t universal_id; uint32_t above_universal_id; }; -struct ds_tizen_event_policy_set_appid +struct ds_tizen_policy_event_set_appid { struct ds_tizen_policy *policy; int32_t pid; const char *appid; }; -struct ds_tizen_event_policy_set_transient_for_below +struct ds_tizen_policy_event_set_transient_for_below { struct ds_tizen_policy *policy; uint32_t universal_id; @@ -161,99 +161,99 @@ struct ds_tizen_event_policy_set_transient_for_below }; // policy policy_surface event structures -struct ds_tizen_event_policy_surface_new_visibility +struct ds_tizen_policy_surface_event_new_visibility { struct ds_tizen_policy_surface *policy_surface; struct ds_tizen_policy_visibility *visibility; }; -struct ds_tizen_event_policy_surface_new_position +struct ds_tizen_policy_surface_event_new_position { struct ds_tizen_policy_surface *policy_surface; struct ds_tizen_policy_position *position; }; -struct ds_tizen_event_policy_surface_activate +struct ds_tizen_policy_surface_event_activate { struct ds_tizen_policy_surface *policy_surface; }; -struct ds_tizen_event_policy_surface_raise +struct ds_tizen_policy_surface_event_raise { struct ds_tizen_policy_surface *policy_surface; }; -struct ds_tizen_event_policy_surface_lower +struct ds_tizen_policy_surface_event_lower { struct ds_tizen_policy_surface *policy_surface; }; -struct ds_tizen_event_policy_surface_set_focus_skip +struct ds_tizen_policy_surface_event_set_focus_skip { struct ds_tizen_policy_surface *policy_surface; }; -struct ds_tizen_event_policy_surface_unset_focus_skip +struct ds_tizen_policy_surface_event_unset_focus_skip { struct ds_tizen_policy_surface *policy_surface; }; -struct ds_tizen_event_policy_surface_set_role +struct ds_tizen_policy_surface_event_set_role { struct ds_tizen_policy_surface *policy_surface; const char *role; }; -struct ds_tizen_event_policy_surface_set_window_type +struct ds_tizen_policy_surface_event_set_window_type { struct ds_tizen_policy_surface *policy_surface; enum ds_tizen_policy_window_type win_type; }; -struct ds_tizen_event_policy_surface_set_conformant +struct ds_tizen_policy_surface_event_set_conformant { struct ds_tizen_policy_surface *policy_surface; }; -struct ds_tizen_event_policy_surface_unset_conformant +struct ds_tizen_policy_surface_event_unset_conformant { struct ds_tizen_policy_surface *policy_surface; }; -struct ds_tizen_event_policy_surface_get_conformant +struct ds_tizen_policy_surface_event_get_conformant { struct ds_tizen_policy_surface *policy_surface; }; -struct ds_tizen_event_policy_surface_set_notification_level +struct ds_tizen_policy_surface_event_set_notification_level { struct ds_tizen_policy_surface *policy_surface; enum ds_tizen_policy_notification_level level; }; -struct ds_tizen_event_policy_surface_set_window_screen_mode +struct ds_tizen_policy_surface_event_set_window_screen_mode { struct ds_tizen_policy_surface *policy_surface; enum ds_tizen_policy_window_screen_mode mode; }; -struct ds_tizen_event_policy_surface_get_subsurface +struct ds_tizen_policy_surface_event_get_subsurface { struct ds_tizen_policy_surface *policy_surface; uint32_t parent_universal_id; }; -struct ds_tizen_event_policy_surface_iconify +struct ds_tizen_policy_surface_event_iconify { struct ds_tizen_policy_surface *policy_surface; }; -struct ds_tizen_event_policy_surface_uniconify +struct ds_tizen_policy_surface_event_uniconify { struct ds_tizen_policy_surface *policy_surface; }; -struct ds_tizen_event_policy_surface_add_aux_hint +struct ds_tizen_policy_surface_event_add_aux_hint { struct ds_tizen_policy_surface *policy_surface; int32_t id; @@ -261,82 +261,82 @@ struct ds_tizen_event_policy_surface_add_aux_hint const char *value; }; -struct ds_tizen_event_policy_surface_change_aux_hint +struct ds_tizen_policy_surface_event_change_aux_hint { struct ds_tizen_policy_surface *policy_surface; int32_t id; const char *value; }; -struct ds_tizen_event_policy_surface_delete_aux_hint +struct ds_tizen_policy_surface_event_delete_aux_hint { struct ds_tizen_policy_surface *policy_surface; int32_t id; }; -struct ds_tizen_event_policy_surface_get_supported_aux_hints +struct ds_tizen_policy_surface_event_get_supported_aux_hints { struct ds_tizen_policy_surface *policy_surface; }; -struct ds_tizen_event_policy_surface_set_floating_mode +struct ds_tizen_policy_surface_event_set_floating_mode { struct ds_tizen_policy_surface *policy_surface; }; -struct ds_tizen_event_policy_surface_unset_floating_mode +struct ds_tizen_policy_surface_event_unset_floating_mode { struct ds_tizen_policy_surface *policy_surface; }; -struct ds_tizen_event_policy_surface_set_stack_mode +struct ds_tizen_policy_surface_event_set_stack_mode { struct ds_tizen_policy_surface *policy_surface; enum ds_tizen_policy_stack_mode mode; }; -struct ds_tizen_event_policy_surface_new_subsurface_watcher +struct ds_tizen_policy_surface_event_new_subsurface_watcher { struct ds_tizen_policy_surface *policy_surface; struct ds_tizen_policy_subsurface_watcher *subsurface_watcher; }; -struct ds_tizen_event_policy_surface_set_parent +struct ds_tizen_policy_surface_event_set_parent { struct ds_tizen_policy_surface *policy_surface; struct ds_surface *parent_surface; }; -struct ds_tizen_event_policy_surface_ack_conformant_region +struct ds_tizen_policy_surface_event_ack_conformant_region { struct ds_tizen_policy_surface *policy_surface; uint32_t serial; }; -struct ds_tizen_event_policy_surface_set_video +struct ds_tizen_policy_surface_event_set_video { struct ds_tizen_policy_surface *policy_surface; bool video; }; -struct ds_tizen_event_policy_surface_show +struct ds_tizen_policy_surface_event_show { struct ds_tizen_policy_surface *policy_surface; }; -struct ds_tizen_event_policy_surface_hide +struct ds_tizen_policy_surface_event_hide { struct ds_tizen_policy_surface *policy_surface; }; -struct ds_tizen_event_policy_surface_set_parent_with_below +struct ds_tizen_policy_surface_event_set_parent_with_below { struct ds_tizen_policy_surface *policy_surface; struct ds_surface *parent_surface; }; // policy policy_surface event structures -struct ds_tizen_event_policy_position_set +struct ds_tizen_policy_event_position_set { struct ds_tizen_policy_position *position; int32_t x; diff --git a/include/libds-tizen/remote_surface.h b/include/libds-tizen/remote_surface.h index 7e8cf2c..72a409c 100644 --- a/include/libds-tizen/remote_surface.h +++ b/include/libds-tizen/remote_surface.h @@ -72,12 +72,12 @@ enum ds_tizen_remote_surface_changed_buffer_event_filter { DS_TIZEN_REMOTE_SURFACE_CHANGED_BUFFER_EVENT_FILTER_IMAGE_FILE = 0x00000002, }; -struct ds_tizen_remote_surface_manager_bind_surface_event { +struct ds_tizen_remote_surface_manager_event_bind_surface { struct ds_tizen_remote_surface *remote_surface; struct ds_surface *surface; }; -struct ds_tizen_remote_surface_transfer_mouse_event { +struct ds_tizen_remote_surface_event_transfer_mouse { struct ds_tizen_remote_surface *remote_surface; enum ds_tizen_remote_surface_input_event_type event_type; int32_t device; @@ -94,7 +94,7 @@ struct ds_tizen_remote_surface_transfer_mouse_event { uint32_t time; }; -struct ds_tizen_remote_surface_transfer_mouse_wheel_event { +struct ds_tizen_remote_surface_event_transfer_mouse_wheel { struct ds_tizen_remote_surface *remote_surface; uint32_t direction; int32_t z; @@ -104,7 +104,7 @@ struct ds_tizen_remote_surface_transfer_mouse_wheel_event { uint32_t time; }; -struct ds_tizen_remote_surface_transfer_touch_event { +struct ds_tizen_remote_surface_event_transfer_touch { struct ds_tizen_remote_surface *remote_surface; enum ds_tizen_remote_surface_input_event_type event_type; int32_t device; @@ -121,11 +121,11 @@ struct ds_tizen_remote_surface_transfer_touch_event { uint32_t time; }; -struct ds_tizen_remote_surface_transfer_touch_cancel_event { +struct ds_tizen_remote_surface_event_transfer_touch_cancel { struct ds_tizen_remote_surface *remote_surface; }; -struct ds_tizen_remote_surface_transfer_key_event { +struct ds_tizen_remote_surface_event_transfer_key { struct ds_tizen_remote_surface *remote_surface; enum ds_tizen_remote_surface_input_event_type event_type; int32_t keycode; @@ -135,17 +135,17 @@ struct ds_tizen_remote_surface_transfer_key_event { uint32_t time; }; -struct ds_tizen_remote_surface_transfer_visibility_event { +struct ds_tizen_remote_surface_event_transfer_visibility { struct ds_tizen_remote_surface *remote_surface; enum ds_tizen_remote_surface_visibility_type visibility; }; -struct ds_tizen_remote_surface_buffer_release_event { +struct ds_tizen_remote_surface_event_buffer_release { struct ds_tizen_remote_surface *remote_surface; struct ds_buffer *buffer; }; -struct ds_tizen_remote_surface_current_buffer_event { +struct ds_tizen_remote_surface_event_current_buffer { struct ds_tizen_remote_surface *remote_surface; enum ds_tizen_remote_surface_buffer_type buffer_type; uint32_t request_serial; diff --git a/include/libds-tizen/screenshooter.h b/include/libds-tizen/screenshooter.h index d16b899..1452699 100644 --- a/include/libds-tizen/screenshooter.h +++ b/include/libds-tizen/screenshooter.h @@ -24,7 +24,7 @@ enum ds_tizen_screenmirror_content DS_TIZEN_SCREENMIRROR_CONTENT_VIDEO, }; -struct ds_tizen_screenshooter_shoot_event +struct ds_tizen_screenshooter_event_shoot { struct ds_output *output; struct ds_buffer *buffer; diff --git a/include/libds-tizen/video.h b/include/libds-tizen/video.h index 7358fc8..62736ba 100644 --- a/include/libds-tizen/video.h +++ b/include/libds-tizen/video.h @@ -82,7 +82,7 @@ struct ds_tizen_viewport_state { bool follow_parent_transform; }; -struct ds_event_tizen_video_request_set_property { +struct ds_tizen_video_object_event_request_set_property { struct ds_tizen_video_object *object; const char *name; int32_t value; @@ -119,7 +119,7 @@ struct ds_surface *ds_tizen_video_object_get_surface( void ds_tizen_video_object_add_destroy_listener( struct ds_tizen_video_object *object, struct wl_listener *listener); -/* @data: struct ds_event_tizen_video_request_set_property */ +/* @data: struct ds_tizen_video_object_event_request_set_property */ void ds_tizen_video_object_add_request_set_property_listener( struct ds_tizen_video_object *object, struct wl_listener *listener); diff --git a/src/dpms/dpms.c b/src/dpms/dpms.c index c63f175..5bedcee 100644 --- a/src/dpms/dpms.c +++ b/src/dpms/dpms.c @@ -201,7 +201,7 @@ _tizen_dpms_manager_handle_set_dpms(struct wl_client *client, output = wl_resource_get_user_data(wl_output); ds_mode = _ds_tizen_dpms_get_ds_dpms_mode(mode); - struct ds_tizen_dpms_event event = { + struct ds_tizen_dpms_event_set_dpms event = { .output = output, .mode = ds_mode, }; diff --git a/src/input_devicemgr/input_devicemgr.c b/src/input_devicemgr/input_devicemgr.c index d410fa7..2d7e6fb 100644 --- a/src/input_devicemgr/input_devicemgr.c +++ b/src/input_devicemgr/input_devicemgr.c @@ -1124,7 +1124,7 @@ static bool tz_devicemgr_generate_key(struct ds_input_device *device, int keycode, int pressed) { - struct ds_event_keyboard_key ds_event; + struct ds_keyboard_event_key ds_event; struct timeval time; unsigned int timestamp; struct ds_keyboard *kbd; @@ -1222,7 +1222,7 @@ static bool tz_devicemgr_generate_touch_move(struct ds_input_device *device, double x, double y, uint32_t finger) { - struct ds_event_touch_motion ds_event; + struct ds_touch_event_motion ds_event; struct timeval time; unsigned int timestamp; struct ds_touch *touch; @@ -1251,7 +1251,7 @@ static bool tz_devicemgr_generate_touch_down(struct ds_input_device *device, double x, double y, uint32_t finger) { - struct ds_event_touch_down ds_event; + struct ds_touch_event_down ds_event; struct timeval time; unsigned int timestamp; struct ds_touch *touch; @@ -1279,7 +1279,7 @@ tz_devicemgr_generate_touch_down(struct ds_input_device *device, double x, doubl static bool tz_devicemgr_generate_touch_up(struct ds_input_device *device, uint32_t finger) { - struct ds_event_touch_up ds_event; + struct ds_touch_event_up ds_event; struct timeval time; unsigned int timestamp; struct ds_touch *touch; @@ -1305,7 +1305,7 @@ tz_devicemgr_generate_touch_up(struct ds_input_device *device, uint32_t finger) static bool tz_devicemgr_generate_mouse_move(struct ds_input_device *device, double x, double y) { - struct ds_event_pointer_motion ds_event; + struct ds_pointer_event_motion ds_event; struct timeval time; unsigned int timestamp; struct ds_pointer *pointer; @@ -1332,7 +1332,7 @@ tz_devicemgr_generate_mouse_move(struct ds_input_device *device, double x, doubl static bool tz_devicemgr_generate_mouse_button(struct ds_input_device *device, uint32_t button, bool state) { - struct ds_event_pointer_button ds_event; + struct ds_pointer_event_button ds_event; struct timeval time; unsigned int timestamp; struct ds_pointer *pointer; diff --git a/src/policy/policy.c b/src/policy/policy.c index 95b9e02..632bb7d 100644 --- a/src/policy/policy.c +++ b/src/policy/policy.c @@ -989,7 +989,7 @@ tizen_policy_client_get_surface(struct wl_resource *resource, wl_list_insert(&client->policy_surfaces, &policy_surface->link); - struct ds_tizen_event_policy_new_surface event = { + struct ds_tizen_policy_event_new_surface event = { .policy = client->policy, .policy_surface = policy_surface, }; @@ -1084,7 +1084,7 @@ policy_handle_get_visibility(struct wl_client *wl_client, struct wl_resource *re &visibility_impl, visibility, _tizen_policy_visibility_handle_destroy); - struct ds_tizen_event_policy_surface_new_visibility event = { + struct ds_tizen_policy_surface_event_new_visibility event = { .policy_surface = policy_surface, .visibility = visibility, }; @@ -1105,7 +1105,7 @@ position_handle_set(struct wl_client *wl_client, struct wl_resource *resource, position = wl_resource_get_user_data(resource); - struct ds_tizen_event_policy_position_set event = { + struct ds_tizen_policy_event_position_set event = { .position = position, .x = x, .y = y, @@ -1175,7 +1175,7 @@ policy_handle_get_position(struct wl_client *wl_client, struct wl_resource *reso &position_impl, position, _tizen_policy_position_handle_destroy); - struct ds_tizen_event_policy_surface_new_position event = { + struct ds_tizen_policy_surface_event_new_position event = { .policy_surface = policy_surface, .position = position, }; @@ -1195,7 +1195,7 @@ policy_handle_activate(struct wl_client *wl_client, return; } - struct ds_tizen_event_policy_surface_activate event = { + struct ds_tizen_policy_surface_event_activate event = { .policy_surface = policy_surface, }; wl_signal_emit(&policy_surface->events.activate, &event); @@ -1210,7 +1210,7 @@ policy_handle_activate_below_by_res_id(struct wl_client *wl_client, client = wl_resource_get_user_data(resource); - struct ds_tizen_event_policy_activate_below_by_univeral_id event = { + struct ds_tizen_policy_event_activate_below_by_univeral_id event = { .policy = client->policy, .universal_id = universal_id, .below_universal_id = below_universal_id, @@ -1231,7 +1231,7 @@ policy_handle_raise(struct wl_client *wl_client, struct wl_resource *resource, return; } - struct ds_tizen_event_policy_surface_raise event = { + struct ds_tizen_policy_surface_event_raise event = { .policy_surface = policy_surface, }; wl_signal_emit(&policy_surface->events.raise, &event); @@ -1250,7 +1250,7 @@ policy_handle_lower(struct wl_client *wl_client, struct wl_resource *resource, return; } - struct ds_tizen_event_policy_surface_lower event = { + struct ds_tizen_policy_surface_event_lower event = { .policy_surface = policy_surface, }; wl_signal_emit(&policy_surface->events.lower, &event); @@ -1264,7 +1264,7 @@ policy_handle_lower_by_res_id(struct wl_client *wl_client, client = wl_resource_get_user_data(resource); - struct ds_tizen_event_policy_lower_by_universal_id event = { + struct ds_tizen_policy_event_lower_by_universal_id event = { .policy = client->policy, .universal_id = universal_id, }; @@ -1284,7 +1284,7 @@ policy_handle_set_focus_skip(struct wl_client *wl_client, return; } - struct ds_tizen_event_policy_surface_set_focus_skip event = { + struct ds_tizen_policy_surface_event_set_focus_skip event = { .policy_surface = policy_surface, }; wl_signal_emit(&policy_surface->events.set_focus_skip, &event); @@ -1303,7 +1303,7 @@ policy_handle_unset_focus_skip(struct wl_client *wl_client, return; } - struct ds_tizen_event_policy_surface_unset_focus_skip event = { + struct ds_tizen_policy_surface_event_unset_focus_skip event = { .policy_surface = policy_surface, }; wl_signal_emit(&policy_surface->events.unset_focus_skip, &event); @@ -1322,7 +1322,7 @@ policy_handle_set_role(struct wl_client *wl_client, struct wl_resource *resource return; } - struct ds_tizen_event_policy_surface_set_role event = { + struct ds_tizen_policy_surface_event_set_role event = { .policy_surface = policy_surface, .role = role, }; @@ -1391,7 +1391,7 @@ policy_handle_set_type(struct wl_client *wl_client, struct wl_resource *resource break; } - struct ds_tizen_event_policy_surface_set_window_type event = { + struct ds_tizen_policy_surface_event_set_window_type event = { .policy_surface = policy_surface, .win_type = win_type, }; @@ -1414,7 +1414,7 @@ policy_handle_set_conformant(struct wl_client *wl_client, if (!policy_surface->conformant) policy_surface->conformant = true; - struct ds_tizen_event_policy_surface_set_conformant event = { + struct ds_tizen_policy_surface_event_set_conformant event = { .policy_surface = policy_surface, }; wl_signal_emit(&policy_surface->events.set_conformant, &event); @@ -1436,7 +1436,7 @@ policy_handle_unset_conformant(struct wl_client *wl_client, if (policy_surface->conformant) policy_surface->conformant = false; - struct ds_tizen_event_policy_surface_unset_conformant event = { + struct ds_tizen_policy_surface_event_unset_conformant event = { .policy_surface = policy_surface, }; wl_signal_emit(&policy_surface->events.unset_conformant, &event); @@ -1455,7 +1455,7 @@ policy_handle_get_conformant(struct wl_client *wl_client, return; } - struct ds_tizen_event_policy_surface_get_conformant event = { + struct ds_tizen_policy_surface_event_get_conformant event = { .policy_surface = policy_surface, }; wl_signal_emit(&policy_surface->events.get_conformant, &event); @@ -1519,7 +1519,7 @@ policy_handle_set_notification_level(struct wl_client *wl_client, break; } - struct ds_tizen_event_policy_surface_set_notification_level event = { + struct ds_tizen_policy_surface_event_set_notification_level event = { .policy_surface = policy_surface, .level = noti_level, }; @@ -1534,7 +1534,7 @@ policy_handle_set_transient_for(struct wl_client *wl_client, client = wl_resource_get_user_data(resource); - struct ds_tizen_event_policy_set_transient_for event = { + struct ds_tizen_policy_event_set_transient_for event = { .policy = client->policy, .child_universal_id = child_id, .parent_universal_id = parent_id, @@ -1552,7 +1552,7 @@ policy_handle_unset_transient_for(struct wl_client *wl_client, client = wl_resource_get_user_data(resource); - struct ds_tizen_event_policy_unset_transient_for event = { + struct ds_tizen_policy_event_unset_transient_for event = { .policy = client->policy, .child_universal_id = child_id, }; @@ -1599,7 +1599,7 @@ policy_handle_set_window_screen_mode(struct wl_client *wl_client, break; } - struct ds_tizen_event_policy_surface_set_window_screen_mode event = { + struct ds_tizen_policy_surface_event_set_window_screen_mode event = { .policy_surface = policy_surface, .mode = screen_mode, }; @@ -1616,7 +1616,7 @@ policy_handle_place_subsurface_below_parent(struct wl_client *wl_client, client = wl_resource_get_user_data(resource); subsurface = ds_subsurface_from_resource(subsurface_resource); - struct ds_tizen_event_policy_place_subsurface_below_parent event = { + struct ds_tizen_policy_event_place_subsurface_below_parent event = { .policy = client->policy, .subsurface = subsurface, }; @@ -1635,7 +1635,7 @@ policy_handle_set_subsurface_stand_alone(struct wl_client *wl_client, client = wl_resource_get_user_data(resource); subsurface = ds_subsurface_from_resource(subsurface_resource); - struct ds_tizen_event_policy_set_subsurface_stand_alone event = { + struct ds_tizen_policy_event_set_subsurface_stand_alone event = { .policy = client->policy, .subsurface = subsurface, }; @@ -1660,7 +1660,7 @@ policy_handle_get_subsurface(struct wl_client *wl_client, // TODO: How to create the ds_subsurface with a parent_universal_id. - struct ds_tizen_event_policy_surface_get_subsurface event = { + struct ds_tizen_policy_surface_event_get_subsurface event = { .policy_surface = policy_surface, .parent_universal_id = parent_id, }; @@ -1701,7 +1701,7 @@ policy_handle_iconify(struct wl_client *wl_client, struct wl_resource *resource, if (!policy_surface->iconified) policy_surface->iconified = true; - struct ds_tizen_event_policy_surface_iconify event = { + struct ds_tizen_policy_surface_event_iconify event = { .policy_surface = policy_surface, }; wl_signal_emit(&policy_surface->events.iconify, &event); @@ -1723,7 +1723,7 @@ policy_handle_uniconify(struct wl_client *wl_client, struct wl_resource *resourc if (policy_surface->iconified) policy_surface->iconified = false; - struct ds_tizen_event_policy_surface_uniconify event = { + struct ds_tizen_policy_surface_event_uniconify event = { .policy_surface = policy_surface, }; wl_signal_emit(&policy_surface->events.uniconify, &event); @@ -1743,7 +1743,7 @@ policy_handle_add_aux_hint(struct wl_client *wl_client, return; } - struct ds_tizen_event_policy_surface_add_aux_hint event = { + struct ds_tizen_policy_surface_event_add_aux_hint event = { .policy_surface = policy_surface, .id = id, .name = name, @@ -1766,7 +1766,7 @@ policy_handle_change_aux_hint(struct wl_client *wl_client, return; } - struct ds_tizen_event_policy_surface_change_aux_hint event = { + struct ds_tizen_policy_surface_event_change_aux_hint event = { .policy_surface = policy_surface, .id = id, .value = value, @@ -1788,7 +1788,7 @@ policy_handle_delete_aux_hint(struct wl_client *wl_client, return; } - struct ds_tizen_event_policy_surface_delete_aux_hint event = { + struct ds_tizen_policy_surface_event_delete_aux_hint event = { .policy_surface = policy_surface, .id = id, }; @@ -1808,7 +1808,7 @@ policy_handle_get_supported_aux_hints(struct wl_client *wl_client, return; } - struct ds_tizen_event_policy_surface_get_supported_aux_hints event = { + struct ds_tizen_policy_surface_event_get_supported_aux_hints event = { .policy_surface = policy_surface, }; wl_signal_emit(&policy_surface->events.get_supported_aux_hints, &event); @@ -1826,7 +1826,7 @@ policy_handle_set_background_state(struct wl_client *wl_client, wl_list_for_each(client, &policy->clients, link) { if (pid == client->pid) { - struct ds_tizen_event_policy_set_background_state event = { + struct ds_tizen_policy_event_set_background_state event = { .policy = client->policy, .pid = pid, }; @@ -1847,7 +1847,7 @@ policy_handle_unset_background_state(struct wl_client *wl_client, wl_list_for_each(client, &policy->clients, link) { if (pid == client->pid) { - struct ds_tizen_event_policy_unset_background_state event = { + struct ds_tizen_policy_event_unset_background_state event = { .policy = client->policy, .pid = pid, }; @@ -1874,7 +1874,7 @@ policy_handle_set_floating_mode(struct wl_client *wl_client, policy_surface->floating_mode = false; - struct ds_tizen_event_policy_surface_set_floating_mode event = { + struct ds_tizen_policy_surface_event_set_floating_mode event = { .policy_surface = policy_surface, }; wl_signal_emit(&policy_surface->events.set_floating_mode, &event); @@ -1898,7 +1898,7 @@ policy_handle_unset_floating_mode(struct wl_client *wl_client, policy_surface->floating_mode = false; - struct ds_tizen_event_policy_surface_unset_floating_mode event = { + struct ds_tizen_policy_surface_event_unset_floating_mode event = { .policy_surface = policy_surface, }; wl_signal_emit(&policy_surface->events.unset_floating_mode, &event); @@ -1936,7 +1936,7 @@ policy_handle_set_stack_mode(struct wl_client *wl_client, policy_surface->stack_mode = stack_mode; - struct ds_tizen_event_policy_surface_set_stack_mode event = { + struct ds_tizen_policy_surface_event_set_stack_mode event = { .policy_surface = policy_surface, .mode = stack_mode, }; @@ -1952,7 +1952,7 @@ policy_handle_activate_above_by_res_id(struct wl_client *wl_client, client = wl_resource_get_user_data(resource); - struct ds_tizen_event_policy_activate_above_by_universal_id event = { + struct ds_tizen_policy_event_activate_above_by_universal_id event = { .policy = client->policy, .universal_id = universal_id, .above_universal_id = above_universal_id, @@ -2026,7 +2026,7 @@ policy_handle_get_subsurface_watcher(struct wl_client *wl_client, &subsurface_watcher_impl, subsurface_watcher, _tizen_policy_subsurface_watcher_handle_destroy); - struct ds_tizen_event_policy_surface_new_subsurface_watcher event = { + struct ds_tizen_policy_surface_event_new_subsurface_watcher event = { .policy_surface = policy_surface, .subsurface_watcher = subsurface_watcher, }; @@ -2050,7 +2050,7 @@ policy_handle_set_parent(struct wl_client *wl_client, parent_surface = ds_surface_from_resource(parent_surface_resource); - struct ds_tizen_event_policy_surface_set_parent event = { + struct ds_tizen_policy_surface_event_set_parent event = { .policy_surface = policy_surface, .parent_surface = parent_surface, }; @@ -2071,7 +2071,7 @@ policy_handle_ack_conformant_region(struct wl_client *wl_client, return; } - struct ds_tizen_event_policy_surface_ack_conformant_region event = { + struct ds_tizen_policy_surface_event_ack_conformant_region event = { .policy_surface = policy_surface, .serial = serial, }; @@ -2112,7 +2112,7 @@ policy_handle_has_video(struct wl_client *wl_client, policy_surface->video = has; - struct ds_tizen_event_policy_surface_set_video event = { + struct ds_tizen_policy_surface_event_set_video event = { .policy_surface = policy_surface, .video = has, }; @@ -2127,7 +2127,7 @@ policy_handle_set_appid(struct wl_client *wl_client, client = wl_resource_get_user_data(resource); - struct ds_tizen_event_policy_set_appid event = { + struct ds_tizen_policy_event_set_appid event = { .policy = client->policy, .pid = pid, .appid = appid, @@ -2148,7 +2148,7 @@ policy_handle_show(struct wl_client *wl_client, struct wl_resource *resource, return; } - struct ds_tizen_event_policy_surface_show event = { + struct ds_tizen_policy_surface_event_show event = { .policy_surface = policy_surface, }; wl_signal_emit(&policy_surface->events.show, &event); @@ -2167,7 +2167,7 @@ policy_handle_hide(struct wl_client *wl_client, struct wl_resource *resource, return; } - struct ds_tizen_event_policy_surface_hide event = { + struct ds_tizen_policy_surface_event_hide event = { .policy_surface = policy_surface, }; wl_signal_emit(&policy_surface->events.hide, &event); @@ -2182,7 +2182,7 @@ policy_handle_set_transient_for_below(struct wl_client *wl_client, client = wl_resource_get_user_data(resource); - struct ds_tizen_event_policy_set_transient_for_below event = { + struct ds_tizen_policy_event_set_transient_for_below event = { .policy = client->policy, .universal_id = universal_id, .parent_universal_id = parent_universal_id, @@ -2207,7 +2207,7 @@ policy_handle_set_parent_with_below(struct wl_client *wl_client, parent_surface = ds_surface_from_resource(parent_surface_resource); - struct ds_tizen_event_policy_surface_set_parent_with_below event = { + struct ds_tizen_policy_surface_event_set_parent_with_below event = { .policy_surface = policy_surface, .parent_surface = parent_surface, }; diff --git a/src/remote_surface/remote_surface.c b/src/remote_surface/remote_surface.c index a16e34c..a391d4a 100644 --- a/src/remote_surface/remote_surface.c +++ b/src/remote_surface/remote_surface.c @@ -354,7 +354,7 @@ remote_surface_handle_transfer_mouse_event(struct wl_client *wl_client, const char *identifier, uint32_t time) { struct ds_tizen_remote_surface *remote_surface; - struct ds_tizen_remote_surface_transfer_mouse_event event; + struct ds_tizen_remote_surface_event_transfer_mouse event; remote_surface = wl_resource_get_user_data(remote_surface_resource); @@ -383,7 +383,7 @@ remote_surface_handle_transfer_mouse_wheel(struct wl_client *wl_client, const char *identifier, uint32_t time) { struct ds_tizen_remote_surface *remote_surface; - struct ds_tizen_remote_surface_transfer_mouse_wheel_event event; + struct ds_tizen_remote_surface_event_transfer_mouse_wheel event; remote_surface = wl_resource_get_user_data(remote_surface_resource); @@ -406,7 +406,7 @@ remote_surface_handle_transfer_touch_event(struct wl_client *wl_client, uint32_t clas, uint32_t subclas, const char *identifier, uint32_t time) { struct ds_tizen_remote_surface *remote_surface; - struct ds_tizen_remote_surface_transfer_touch_event event; + struct ds_tizen_remote_surface_event_transfer_touch event; remote_surface = wl_resource_get_user_data(remote_surface_resource); @@ -433,7 +433,7 @@ remote_surface_handle_transfer_touch_cancel(struct wl_client *wl_client, struct wl_resource *remote_surface_resource) { struct ds_tizen_remote_surface *remote_surface; - struct ds_tizen_remote_surface_transfer_touch_cancel_event event; + struct ds_tizen_remote_surface_event_transfer_touch_cancel event; remote_surface = wl_resource_get_user_data(remote_surface_resource); @@ -449,7 +449,7 @@ remote_surface_handle_transfer_key_event(struct wl_client *wl_client, const char *identifier, uint32_t time) { struct ds_tizen_remote_surface *remote_surface; - struct ds_tizen_remote_surface_transfer_key_event event; + struct ds_tizen_remote_surface_event_transfer_key event; remote_surface = wl_resource_get_user_data(remote_surface_resource); @@ -470,7 +470,7 @@ remote_surface_handle_transfer_visibility(struct wl_client *wl_client, uint32_t visibility_type) { struct ds_tizen_remote_surface *remote_surface; - struct ds_tizen_remote_surface_transfer_visibility_event event; + struct ds_tizen_remote_surface_event_transfer_visibility event; remote_surface = wl_resource_get_user_data(remote_surface_resource); @@ -599,7 +599,7 @@ remote_surface_handle_release(struct wl_client *wl_client, { struct ds_tizen_remote_surface *remote_surface; struct ds_buffer *buffer; - struct ds_tizen_remote_surface_buffer_release_event event; + struct ds_tizen_remote_surface_event_buffer_release event; remote_surface = wl_resource_get_user_data(remote_surface_resource); buffer = ds_buffer_from_resource(remote_buffer_resource); @@ -648,7 +648,7 @@ remote_surface_handle_get_current_buffer(struct wl_client *wl_client, uint32_t req_serial) { struct ds_tizen_remote_surface *remote_surface; - struct ds_tizen_remote_surface_current_buffer_event event; + struct ds_tizen_remote_surface_event_current_buffer event; remote_surface = wl_resource_get_user_data(remote_surface_resource); @@ -813,7 +813,7 @@ remote_surface_manager_handle_bind_surface(struct wl_client *wl_client, struct wl_resource *surface_resource, struct wl_resource *remote_surface_resource) { - struct ds_tizen_remote_surface_manager_bind_surface_event event; + struct ds_tizen_remote_surface_manager_event_bind_surface event; struct ds_tizen_remote_surface_client *remote_client; struct ds_tizen_remote_surface *remote_surface; struct ds_surface *surface; diff --git a/src/screenshooter/screenshooter.c b/src/screenshooter/screenshooter.c index 890bd2f..3c8e623 100644 --- a/src/screenshooter/screenshooter.c +++ b/src/screenshooter/screenshooter.c @@ -151,7 +151,7 @@ _tizen_screenshooter_handle_shoot(struct wl_client *client, return; } - struct ds_tizen_screenshooter_shoot_event event = { + struct ds_tizen_screenshooter_event_shoot event = { .output = output, .buffer = buffer, .client = shot_client, diff --git a/src/video/video.c b/src/video/video.c index 0a258f4..56f62f1 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -424,7 +424,7 @@ video_object_handle_set_attribute(struct wl_client *client, if (!object) return; - struct ds_event_tizen_video_request_set_property event = { + struct ds_tizen_video_object_event_request_set_property event = { .object = object, .name = name, .value = value, diff --git a/tests/tc_policy.cpp b/tests/tc_policy.cpp index c96c629..4f8a2cf 100644 --- a/tests/tc_policy.cpp +++ b/tests/tc_policy.cpp @@ -133,8 +133,8 @@ public: { MockPolicyPosition *mockPosition = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_position_set *event = - static_cast(data); + struct ds_tizen_policy_event_position_set *event = + static_cast(data); EXPECT_TRUE(mockPosition->mPosition == event->position); mockPosition->mX = event->x; @@ -444,8 +444,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_new_visibility *event = - static_cast(data); + struct ds_tizen_policy_surface_event_new_visibility *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); EXPECT_TRUE(event->visibility != NULL); @@ -462,8 +462,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_new_position *event = - static_cast(data); + struct ds_tizen_policy_surface_event_new_position *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); EXPECT_TRUE(event->position != NULL); @@ -480,8 +480,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_activate *event = - static_cast(data); + struct ds_tizen_policy_surface_event_activate *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -492,8 +492,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_raise *event = - static_cast(data); + struct ds_tizen_policy_surface_event_raise *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -504,8 +504,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_lower *event = - static_cast(data); + struct ds_tizen_policy_surface_event_lower *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -516,8 +516,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_set_focus_skip *event = - static_cast(data); + struct ds_tizen_policy_surface_event_set_focus_skip *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -528,8 +528,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_unset_focus_skip *event = - static_cast(data); + struct ds_tizen_policy_surface_event_unset_focus_skip *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -540,8 +540,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_set_role *event = - static_cast(data); + struct ds_tizen_policy_surface_event_set_role *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); policySurface->mRole = event->role; // char -> string @@ -551,8 +551,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_set_window_type *event = - static_cast(data); + struct ds_tizen_policy_surface_event_set_window_type *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -563,8 +563,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_set_conformant *event = - static_cast(data); + struct ds_tizen_policy_surface_event_set_conformant *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -575,8 +575,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_unset_conformant *event = - static_cast(data); + struct ds_tizen_policy_surface_event_unset_conformant *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -587,8 +587,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_get_conformant *event = - static_cast(data); + struct ds_tizen_policy_surface_event_get_conformant *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -599,8 +599,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_set_notification_level *event = - static_cast(data); + struct ds_tizen_policy_surface_event_set_notification_level *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -611,8 +611,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_set_window_screen_mode *event = - static_cast(data); + struct ds_tizen_policy_surface_event_set_window_screen_mode *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -623,8 +623,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_get_subsurface *event = - static_cast(data); + struct ds_tizen_policy_surface_event_get_subsurface *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -635,8 +635,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_iconify *event = - static_cast(data); + struct ds_tizen_policy_surface_event_iconify *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -647,8 +647,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_uniconify *event = - static_cast(data); + struct ds_tizen_policy_surface_event_uniconify *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -659,8 +659,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_add_aux_hint *event = - static_cast(data); + struct ds_tizen_policy_surface_event_add_aux_hint *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -673,8 +673,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_change_aux_hint *event = - static_cast(data); + struct ds_tizen_policy_surface_event_change_aux_hint *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -686,8 +686,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_delete_aux_hint *event = - static_cast(data); + struct ds_tizen_policy_surface_event_delete_aux_hint *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -698,8 +698,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_get_supported_aux_hints *event = - static_cast(data); + struct ds_tizen_policy_surface_event_get_supported_aux_hints *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -710,8 +710,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_set_floating_mode *event = - static_cast(data); + struct ds_tizen_policy_surface_event_set_floating_mode *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -722,8 +722,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_unset_floating_mode *event = - static_cast(data); + struct ds_tizen_policy_surface_event_unset_floating_mode *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -734,8 +734,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_set_stack_mode *event = - static_cast(data); + struct ds_tizen_policy_surface_event_set_stack_mode *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -746,8 +746,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_new_subsurface_watcher *event = - static_cast(data); + struct ds_tizen_policy_surface_event_new_subsurface_watcher *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); EXPECT_TRUE(event->subsurface_watcher != NULL); @@ -764,8 +764,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_set_parent *event = - static_cast(data); + struct ds_tizen_policy_surface_event_set_parent *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -776,8 +776,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_ack_conformant_region *event = - static_cast(data); + struct ds_tizen_policy_surface_event_ack_conformant_region *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -788,8 +788,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_set_video *event = - static_cast(data); + struct ds_tizen_policy_surface_event_set_video *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -800,8 +800,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_show *event = - static_cast(data); + struct ds_tizen_policy_surface_event_show *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -812,8 +812,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_hide *event = - static_cast(data); + struct ds_tizen_policy_surface_event_hide *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -824,8 +824,8 @@ public: { MockPolicySurface *policySurface = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_surface_set_parent_with_below *event = - static_cast(data); + struct ds_tizen_policy_surface_event_set_parent_with_below *event = + static_cast(data); EXPECT_TRUE(policySurface->mPolicySurface == event->policy_surface); @@ -1309,8 +1309,8 @@ public: MockPolicyCompositor *mockComp = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_new_surface *event = - static_cast(data); + struct ds_tizen_policy_event_new_surface *event = + static_cast(data); struct ds_tizen_policy_surface *policy_surface = event->policy_surface; @@ -1329,8 +1329,8 @@ public: MockPolicyCompositor *mockComp = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_activate_below_by_univeral_id *event = - static_cast(data); + struct ds_tizen_policy_event_activate_below_by_univeral_id *event = + static_cast(data); EXPECT_TRUE(mockComp->mPolicy == event->policy); mockComp->mUniversalId = event->universal_id; @@ -1344,8 +1344,8 @@ public: MockPolicyCompositor *mockComp = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_lower_by_universal_id *event = - static_cast(data); + struct ds_tizen_policy_event_lower_by_universal_id *event = + static_cast(data); EXPECT_TRUE(mockComp->mPolicy == event->policy); mockComp->mUniversalId = event->universal_id; @@ -1358,8 +1358,8 @@ public: MockPolicyCompositor *mockComp = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_set_transient_for *event = - static_cast(data); + struct ds_tizen_policy_event_set_transient_for *event = + static_cast(data); EXPECT_TRUE(mockComp->mPolicy == event->policy); mockComp->mChildUniversalId = event->child_universal_id; @@ -1373,8 +1373,8 @@ public: MockPolicyCompositor *mockComp = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_unset_transient_for *event = - static_cast(data); + struct ds_tizen_policy_event_unset_transient_for *event = + static_cast(data); EXPECT_TRUE(mockComp->mPolicy == event->policy); mockComp->mChildUniversalId = event->child_universal_id; @@ -1387,8 +1387,8 @@ public: MockPolicyCompositor *mockComp = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_place_subsurface_below_parent *event = - static_cast(data); + struct ds_tizen_policy_event_place_subsurface_below_parent *event = + static_cast(data); EXPECT_TRUE(mockComp->mPolicy == event->policy); mockComp->bPlaceSubsurfaceBelowParent = true; @@ -1401,8 +1401,8 @@ public: MockPolicyCompositor *mockComp = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_set_subsurface_stand_alone *event = - static_cast(data); + struct ds_tizen_policy_event_set_subsurface_stand_alone *event = + static_cast(data); EXPECT_TRUE(mockComp->mPolicy == event->policy); mockComp->bSetSubsurfaceStandAlone = true; @@ -1412,8 +1412,8 @@ public: { MockPolicyCompositor *mockComp = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_set_background_state *event = - static_cast(data); + struct ds_tizen_policy_event_set_background_state *event = + static_cast(data); EXPECT_TRUE(mockComp->mPolicy == event->policy); mockComp->mPid = event->pid; @@ -1423,8 +1423,8 @@ public: { MockPolicyCompositor *mockComp = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_unset_background_state *event = - static_cast(data); + struct ds_tizen_policy_event_unset_background_state *event = + static_cast(data); EXPECT_TRUE(mockComp->mPolicy == event->policy); mockComp->mPid = event->pid; @@ -1437,8 +1437,8 @@ public: MockPolicyCompositor *mockComp = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_activate_above_by_universal_id *event = - static_cast(data); + struct ds_tizen_policy_event_activate_above_by_universal_id *event = + static_cast(data); EXPECT_TRUE(mockComp->mPolicy == event->policy); mockComp->mUniversalId = event->universal_id; @@ -1452,8 +1452,8 @@ public: MockPolicyCompositor *mockComp = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_set_appid *event = - static_cast(data); + struct ds_tizen_policy_event_set_appid *event = + static_cast(data); EXPECT_TRUE(mockComp->mPolicy == event->policy); mockComp->mPid = event->pid; @@ -1467,8 +1467,8 @@ public: MockPolicyCompositor *mockComp = reinterpret_cast(listener)->parent; - struct ds_tizen_event_policy_set_transient_for_below *event = - static_cast(data); + struct ds_tizen_policy_event_set_transient_for_below *event = + static_cast(data); EXPECT_TRUE(mockComp->mPolicy == event->policy); mockComp->mUniversalId = event->universal_id; diff --git a/tests/tc_screenshooter.cpp b/tests/tc_screenshooter.cpp index 929ecdf..f2b01f4 100644 --- a/tests/tc_screenshooter.cpp +++ b/tests/tc_screenshooter.cpp @@ -190,8 +190,8 @@ public: MockScreenShooterCompositor *mockComp = reinterpret_cast(listener)->parent; - struct ds_tizen_screenshooter_shoot_event *event = - static_cast(data); + struct ds_tizen_screenshooter_event_shoot *event = + static_cast(data); ds_inf("%s: mockComp(%p), output(%p), buffer(%p), client(%p), auto_rotate:%d", -- 2.7.4 From 24d8244e76b6f4b26a7766ab04c618d5add46d5a Mon Sep 17 00:00:00 2001 From: "duna.oh" Date: Tue, 21 Feb 2023 15:32:23 +0900 Subject: [PATCH 10/16] tinyds: fix the SVACE issue Change-Id: Ibdbdcb07c2c07cc3f3d5b05df62d73e4cfb066e4 --- examples/tinyds-launch.c | 1 + examples/tinyds-tdm.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/tinyds-launch.c b/examples/tinyds-launch.c index 0e73a7c..a5a1124 100644 --- a/examples/tinyds-launch.c +++ b/examples/tinyds-launch.c @@ -145,6 +145,7 @@ tinyds_launch_init(struct wl_display *display, launch_free_cb free_cb, void *dat launch->effect = ds_tizen_launch_effect_create(display); if (!launch->effect) { + free(launch); return NULL; } diff --git a/examples/tinyds-tdm.c b/examples/tinyds-tdm.c index d7d4ac8..8383e80 100644 --- a/examples/tinyds-tdm.c +++ b/examples/tinyds-tdm.c @@ -1236,8 +1236,10 @@ touch_handle_down(struct wl_listener *listener, void *data) touch = wl_container_of(listener, touch, down); server = touch->server; - server->output_x = event->x * server->output->width; - server->output_y = event->y * server->output->height; + if (server->output) { + server->output_x = event->x * server->output->width; + server->output_y = event->y * server->output->height; + } ds_inf("Touch(%p) event down: id(%d) x %.3f y %.3f output_x %.1f output_y %.1f", touch->dev, event->id, event->x, event->y, server->output_x, server->output_y); @@ -1283,8 +1285,10 @@ touch_handle_motion(struct wl_listener *listener, void *data) touch = wl_container_of(listener, touch, motion); server = touch->server; - server->output_x = event->x * server->output->width; - server->output_y = event->y * server->output->height; + if (server->output) { + server->output_x = event->x * server->output->width; + server->output_y = event->y * server->output->height; + } ds_inf("Touch(%p) event motion: id(%d) x %.3f y %.3f output_x %.1f output_y %.1f", touch->dev, event->id, event->x, event->y, server->output_x, server->output_y); -- 2.7.4 From c833131c89ab74b27d7bf713af121116c295ddf0 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Mon, 20 Mar 2023 15:41:29 +0900 Subject: [PATCH 11/16] Fix build warnings which casues build error by -Werror option Change-Id: I05856cfbf303fb2a84266c4fae264914239acb41 --- examples/protocol-trace.c | 32 ++++++------ examples/tinyds-launch.c | 6 +-- examples/tinyds-tdm.c | 6 +-- meson.build | 9 ++++ src/backend/tdm/tdm_output_hwc.c | 10 ++-- src/eom/eom.c | 2 +- src/indicator/indicator.c | 12 ++--- src/input_devicemgr/input_devicemgr.c | 2 +- src/launch/appinfo.c | 2 +- src/policy/policy.c | 92 +++++++++++++++++------------------ src/remote_surface/remote_surface.c | 4 +- tests/tc_scaler.cpp | 4 +- 12 files changed, 94 insertions(+), 87 deletions(-) diff --git a/examples/protocol-trace.c b/examples/protocol-trace.c index 7975b0d..45a3120 100644 --- a/examples/protocol-trace.c +++ b/examples/protocol-trace.c @@ -194,7 +194,7 @@ static bool rule_set(const int argc, const char **argv, char *reply, int *len); char trace_env_path[PATH_MAX + 1]; static FILE *log_fp_ptrace = NULL; static struct wl_protocol_logger *ds_wl_protocol_logger; -static struct protocol_trace_rule_checker *rc = NULL; +static struct protocol_trace_rule_checker *global_rc = NULL; static struct wl_display *display; static struct @@ -583,12 +583,12 @@ logger_validate_rule(struct protocol_trace_protocol_log *log) const char *cmd = ""; int ret; - if (!rc) + if (!global_rc) return false; cmd = logger_cmd_get(log->cmd); - ret = rulechecker_validate_rules(rc, log->type, log->target_id, log->name, + ret = rulechecker_validate_rules(global_rc, log->type, log->target_id, log->name, log->client_pid, cmd); return ret; @@ -1359,7 +1359,7 @@ rule_set(const int argc, const char **argv, char *reply, int *len) ds_dbg("(parameter) argc = %d, argv[0] = %s", argc, argv[0]); if (argc == 0) { - rulechecker_print_rules(rc, reply, len); + rulechecker_print_rules(global_rc, reply, len); return true; } @@ -1406,9 +1406,9 @@ rule_set(const int argc, const char **argv, char *reply, int *len) if (apply == 0) { const char * plus = "|| type=reply || type=error"; int size_plus = strlen(plus); - int len = MIN(size_rule - index, size_plus); + int l = MIN(size_rule - index, size_plus); snprintf(rule, sizeof(rule), "%s", plus); - index += len; + index += l; if (index >size_rule) return false; apply =1; @@ -1421,7 +1421,7 @@ rule_set(const int argc, const char **argv, char *reply, int *len) } ds_dbg("ADD :: rule = %s", rule); - result = rulechecker_rule_add(rc, policy_type, rule); + result = rulechecker_rule_add(global_rc, policy_type, rule); if (result == PROTOCOL_TRACE_RULE_SET_ERR_TOO_MANY_RULES) { ds_err("Error: Too many rules were added."); @@ -1447,9 +1447,9 @@ rule_set(const int argc, const char **argv, char *reply, int *len) remove_idx = argv[i + 1]; if (!strcasecmp(remove_idx, "all")) { ds_dbg("REMOVE :: all"); - rulechecker_destroy(rc); - rc = rulechecker_init(); - if (!rc) { + rulechecker_destroy(global_rc); + global_rc = rulechecker_init(); + if (!global_rc) { ds_err("Error: rules not removed"); return false; } @@ -1461,7 +1461,7 @@ rule_set(const int argc, const char **argv, char *reply, int *len) ds_dbg("REMOVE :: remove idx = %d", index); if (isdigit(*remove_idx) && - rulechecker_rule_remove(rc, index) == 0) + rulechecker_rule_remove(global_rc, index) == 0) ds_dbg("Rule remove success : rule [%d]", index); else ds_err("Rule remove fail : No rule [%s]", remove_idx); @@ -1478,9 +1478,9 @@ rule_set(const int argc, const char **argv, char *reply, int *len) if (!rule_file_set(argv[1], reply, len)) return false; - rulechecker_print_rules(rc, reply, len); + rulechecker_print_rules(global_rc, reply, len); } else if (!strcasecmp(command, "print")) { - rulechecker_print_rules(rc, reply, len); + rulechecker_print_rules(global_rc, reply, len); } else if (!strcasecmp(command, "help")) { ds_dbg( "%s", rulechecker_usage_print()); } else { @@ -1571,7 +1571,7 @@ protocol_trace_init(struct wl_display *d) char *env_path = NULL; display = d; - rc = rulechecker_init(); + global_rc = rulechecker_init(); env_path = getenv("DS_PROTOCOL_RULE_FILE"); ret = rule_init(env_path); @@ -1601,5 +1601,5 @@ protocol_trace_init(struct wl_display *d) void protocol_trace_fini() { - rulechecker_destroy(rc); -} \ No newline at end of file + rulechecker_destroy(global_rc); +} diff --git a/examples/tinyds-launch.c b/examples/tinyds-launch.c index a5a1124..976590f 100644 --- a/examples/tinyds-launch.c +++ b/examples/tinyds-launch.c @@ -50,7 +50,7 @@ launch_effect_handle_type_set(struct wl_listener *listener, void *data) ds_inf("Launch effect. type_set: pid(%u) type:%s", event->pid, (event->effect_type == 1) ? "depth-in" : "launch"); wl_list_for_each(view, &launch->server->views, link) { - if (view->pid == event->pid) { + if ((uint32_t)view->pid == event->pid) { view->effect_type = event->effect_type; existing = true; ds_inf("Launch effect. existing pid"); @@ -75,7 +75,7 @@ launch_effect_handle_type_unset(struct wl_listener *listener, void *data) ds_inf("Launch effect. type_unset: pid(%u)", event->pid); wl_list_for_each(view, &launch->server->views, link) { - if (view->pid == event->pid) { + if ((uint32_t)view->pid == event->pid) { view->effect_type = -1; ds_inf("Launch effect. pid found"); } @@ -95,7 +95,7 @@ launch_splash_handle_owner(struct wl_listener *listener, void *data) ds_inf("Splash owner. pid(%u)", event->pid); wl_list_for_each(view, &launch->server->views, link) { - if (view->pid == event->pid) { + if ((uint32_t)view->pid == event->pid) { if (event->pid == ds_tizen_launch_splash_get_pid(launch->splash)) ;// else { diff --git a/examples/tinyds-tdm.c b/examples/tinyds-tdm.c index 8383e80..9c50c84 100644 --- a/examples/tinyds-tdm.c +++ b/examples/tinyds-tdm.c @@ -623,7 +623,7 @@ output_commit(struct tinyds_output *output) struct ds_tdm_output_hwc_window **changed_hwc_windows = NULL; enum ds_tdm_output_hwc_window_composition composition; struct tinyds_view *view; - int i; + size_t i; bool need_target = false; bool fully_obscured = false; struct ds_buffer *ds_buffer; @@ -764,7 +764,7 @@ output_commit(struct tinyds_output *output) return; } - for (i = 0; i < num_changed; i++) { + for (i = 0; i < (size_t)num_changed; i++) { composition = ds_tdm_output_hwc_window_get_composition(changed_hwc_windows[i]); if (composition == DS_TDM_OUTPUT_HWC_WINDOW_COMPOSITION_CLIENT) { need_target = true; @@ -805,8 +805,6 @@ output_commit(struct tinyds_output *output) output->target_updated = false; wl_list_for_each(view, &output->server->views, link) { - enum ds_tdm_output_hwc_window_composition composition; - if (!view->mapped) continue; diff --git a/meson.build b/meson.build index 5446b25..434f1b9 100644 --- a/meson.build +++ b/meson.build @@ -9,6 +9,15 @@ project('libds_tizen', ] ) +cc = meson.get_compiler('c') + +add_project_arguments(cc.get_supported_arguments([ + '-Wno-missing-field-initializers', + '-Wno-unused-parameter', + '-Wno-pedantic', + '-Wno-missing-braces', +]), language: ['c', 'cpp']) + libds_tizen_version = meson.project_version() version_arr = libds_tizen_version.split('.') libds_tizen_version_major = version_arr[0] diff --git a/src/backend/tdm/tdm_output_hwc.c b/src/backend/tdm/tdm_output_hwc.c index 535fdef..3618aff 100644 --- a/src/backend/tdm/tdm_output_hwc.c +++ b/src/backend/tdm/tdm_output_hwc.c @@ -487,7 +487,7 @@ ds_tdm_output_hwc_validate(struct ds_tdm_output_hwc *hwc, tdm_error terr; tdm_hwc_window **compositied_hwc_windows = NULL; struct ds_tdm_output_hwc_window *hwc_window; - int i; + size_t i; wl_list_for_each(hwc_window, &hwc->hwc_windows, link) hwc_window_update(hwc_window); @@ -497,7 +497,7 @@ ds_tdm_output_hwc_validate(struct ds_tdm_output_hwc *hwc, if (!compositied_hwc_windows) return false; - for (i = 0; i < num_windows; i++) + for (i = 0; i < (size_t)num_windows; i++) compositied_hwc_windows[i] = composited_windows[i]->twindow; } @@ -538,7 +538,7 @@ ds_tdm_output_hwc_get_changed_composition(struct ds_tdm_output_hwc *hwc, uint32_ tdm_hwc_window_composition *compositions = NULL; struct ds_tdm_output_hwc_window *hwc_window; tdm_error terr; - int i; + size_t i; if (!hwc->validate_num_changed) { *num_changed = 0; @@ -564,8 +564,8 @@ ds_tdm_output_hwc_get_changed_composition(struct ds_tdm_output_hwc *hwc, uint32_ return false; } - for (i = 0; i < hwc->validate_num_changed; i++) { - if (i >= *num_changed) + for (i = 0; i < (size_t)hwc->validate_num_changed; i++) { + if (i >= (size_t)*num_changed) break; hwc_window = hwc_get_hwc_window_from_tdm_hwc_window(hwc, changed_thwc_windows[i]); diff --git a/src/eom/eom.c b/src/eom/eom.c index 3c41c3e..4053b38 100644 --- a/src/eom/eom.c +++ b/src/eom/eom.c @@ -564,7 +564,7 @@ _ds_tizen_eom_get_eom_output_by_id(struct ds_tizen_eom *eom, uint32_t id) struct ds_tizen_eom_output *output; wl_list_for_each(output, &eom->outputs, link) { - if (output->id == id) + if ((uint32_t)output->id == id) return output; } diff --git a/src/indicator/indicator.c b/src/indicator/indicator.c index b08dae5..7b8cf67 100644 --- a/src/indicator/indicator.c +++ b/src/indicator/indicator.c @@ -42,9 +42,9 @@ struct ds_tizen_indicator_info { struct ds_surface *surface; - int32_t state; - int32_t opacity_mode; - int32_t visible_type; + enum ds_tizen_indicator_state state; + enum ds_tizen_indicator_opacity_mode opacity_mode; + enum ds_tizen_indicator_visible_type visible_type; struct wl_list link; // ds_tizen_indicator_client::infos }; @@ -263,9 +263,9 @@ tizen_indicator_client_get_info(struct ds_tizen_indicator_client *client, // enum ds_tizen_indicator_opacity_mode and // enum ds_tizen_indicator_opacity_mode // because of the first signal emit for change_state signal. - info->state = -1; - info->opacity_mode = -1; - info->visible_type = -1; + info->state = DS_TIZEN_INDICATOR_STATE_UNKNOWN; + info->opacity_mode = DS_TIZEN_INDICATOR_OPACITY_MODE_UNKNOWN; + info->visible_type = DS_TIZEN_INDICATOR_VISIBLE_TYPE_HIDDEN; wl_list_insert(&client->infos, &info->link); diff --git a/src/input_devicemgr/input_devicemgr.c b/src/input_devicemgr/input_devicemgr.c index 2d7e6fb..d76b1dc 100644 --- a/src/input_devicemgr/input_devicemgr.c +++ b/src/input_devicemgr/input_devicemgr.c @@ -735,7 +735,7 @@ device_manager_handle_generate_touch(struct wl_client *client, goto finish; } - if (finger >= tz_devicemgr->touch_max_count) + if (finger >= (uint32_t)tz_devicemgr->touch_max_count) { ds_err("Invalid fingers: %d\n", finger); ret = TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER; diff --git a/src/launch/appinfo.c b/src/launch/appinfo.c index b079836..944797b 100644 --- a/src/launch/appinfo.c +++ b/src/launch/appinfo.c @@ -509,7 +509,7 @@ appinfo_handle_ready_metadata(struct wl_client *wl_client, return; } - if (info->pid != pid) + if ((uint32_t)info->pid != pid) appinfo_set_pid(info, pid); wl_signal_emit(&client->appinfo_mgr->events.metadata_ready, info); diff --git a/src/policy/policy.c b/src/policy/policy.c index 632bb7d..ab7e9a6 100644 --- a/src/policy/policy.c +++ b/src/policy/policy.c @@ -1825,7 +1825,7 @@ policy_handle_set_background_state(struct wl_client *wl_client, policy = client->policy; wl_list_for_each(client, &policy->clients, link) { - if (pid == client->pid) { + if (pid == (uint32_t)client->pid) { struct ds_tizen_policy_event_set_background_state event = { .policy = client->policy, .pid = pid, @@ -1846,7 +1846,7 @@ policy_handle_unset_background_state(struct wl_client *wl_client, policy = client->policy; wl_list_for_each(client, &policy->clients, link) { - if (pid == client->pid) { + if (pid == (uint32_t)client->pid) { struct ds_tizen_policy_event_unset_background_state event = { .policy = client->policy, .pid = pid, @@ -2216,50 +2216,50 @@ policy_handle_set_parent_with_below(struct wl_client *wl_client, static const struct tizen_policy_interface policy_impl = { - policy_handle_get_visibility, - policy_handle_get_position, - policy_handle_activate, - policy_handle_activate_below_by_res_id, - policy_handle_raise, - policy_handle_lower, - policy_handle_lower_by_res_id, - policy_handle_set_focus_skip, - policy_handle_unset_focus_skip, - policy_handle_set_role, - policy_handle_set_type, - policy_handle_set_conformant, - policy_handle_unset_conformant, - policy_handle_get_conformant, - policy_handle_set_notification_level, - policy_handle_set_transient_for, - policy_handle_unset_transient_for, - policy_handle_set_window_screen_mode, - policy_handle_place_subsurface_below_parent, - policy_handle_set_subsurface_stand_alone, - policy_handle_get_subsurface, - policy_handle_set_opaque_state, - policy_handle_iconify, - policy_handle_uniconify, - policy_handle_add_aux_hint, - policy_handle_change_aux_hint, - policy_handle_delete_aux_hint, - policy_handle_get_supported_aux_hints, - policy_handle_set_background_state, - policy_handle_unset_background_state, - policy_handle_set_floating_mode, - policy_handle_unset_floating_mode, - policy_handle_set_stack_mode, - policy_handle_activate_above_by_res_id, - policy_handle_get_subsurface_watcher, - policy_handle_set_parent, - policy_handle_ack_conformant_region, - policy_handle_destroy, - policy_handle_has_video, - policy_handle_set_appid, - policy_handle_show, - policy_handle_hide, - policy_handle_set_transient_for_below, - policy_handle_set_parent_with_below, + .get_visibility = policy_handle_get_visibility, + .get_position = policy_handle_get_position, + .activate = policy_handle_activate, + .activate_below_by_res_id = policy_handle_activate_below_by_res_id, + .raise = policy_handle_raise, + .lower = policy_handle_lower, + .lower_by_res_id = policy_handle_lower_by_res_id, + .set_focus_skip = policy_handle_set_focus_skip, + .unset_focus_skip = policy_handle_unset_focus_skip, + .set_role = policy_handle_set_role, + .set_type = policy_handle_set_type, + .set_conformant = policy_handle_set_conformant, + .unset_conformant = policy_handle_unset_conformant, + .get_conformant = policy_handle_get_conformant, + .set_notification_level = policy_handle_set_notification_level, + .set_transient_for = policy_handle_set_transient_for, + .unset_transient_for = policy_handle_unset_transient_for, + .set_window_screen_mode = policy_handle_set_window_screen_mode, + .place_subsurface_below_parent = policy_handle_place_subsurface_below_parent, + .set_subsurface_stand_alone = policy_handle_set_subsurface_stand_alone, + .get_subsurface = policy_handle_get_subsurface, + .set_opaque_state = policy_handle_set_opaque_state, + .iconify = policy_handle_iconify, + .uniconify = policy_handle_uniconify, + .add_aux_hint = policy_handle_add_aux_hint, + .change_aux_hint = policy_handle_change_aux_hint, + .del_aux_hint = policy_handle_delete_aux_hint, + .get_supported_aux_hints = policy_handle_get_supported_aux_hints, + .set_background_state = policy_handle_set_background_state, + .unset_background_state = policy_handle_unset_background_state, + .set_floating_mode = policy_handle_set_floating_mode, + .unset_floating_mode = policy_handle_unset_floating_mode, + .set_stack_mode = policy_handle_set_stack_mode, + .activate_above_by_res_id = policy_handle_activate_above_by_res_id, + .get_subsurface_watcher = policy_handle_get_subsurface_watcher, + .set_parent = policy_handle_set_parent, + .ack_conformant_region = policy_handle_ack_conformant_region, + .destroy = policy_handle_destroy, + .has_video = policy_handle_has_video, + .set_appid = policy_handle_set_appid, + .show = policy_handle_show, + .hide = policy_handle_hide, + .set_transient_for_below = policy_handle_set_transient_for_below, + .set_parent_with_below = policy_handle_set_parent_with_below, }; static void diff --git a/src/remote_surface/remote_surface.c b/src/remote_surface/remote_surface.c index a391d4a..b9aaa36 100644 --- a/src/remote_surface/remote_surface.c +++ b/src/remote_surface/remote_surface.c @@ -13,7 +13,7 @@ #define TIZEN_REMOTE_SURFACE_VERSION 6 -static uint32_t resource_id = 1; +static uint32_t global_resource_id = 1; struct ds_tizen_remote_surface_manager { @@ -305,7 +305,7 @@ remote_surface_manager_handle_create_provider(struct wl_client *wl_client, wl_signal_emit(&remote_client->remote_manager->events.new_provider, remote_provider); - remote_provider->resource_id = resource_id++; + remote_provider->resource_id = global_resource_id++; tizen_remote_surface_provider_send_resource_id(remote_provider->resource, remote_provider->resource_id); diff --git a/tests/tc_scaler.cpp b/tests/tc_scaler.cpp index 6a74df5..fde5f9d 100644 --- a/tests/tc_scaler.cpp +++ b/tests/tc_scaler.cpp @@ -198,7 +198,7 @@ class ScalerCompositorBadSourceTest : { }; -INSTANTIATE_TEST_SUITE_P(ScalerBadSourceParamTest, +INSTANTIATE_TEST_CASE_P(ScalerBadSourceParamTest, ScalerCompositorBadSourceTest, testing::Values( Box{0, 0, 0, 0}, @@ -238,7 +238,7 @@ class ScalerCompositorBadDestinationTest : { }; -INSTANTIATE_TEST_SUITE_P(ScalerBadDestinationParamTest, +INSTANTIATE_TEST_CASE_P(ScalerBadDestinationParamTest, ScalerCompositorBadDestinationTest, testing::Values( Size{0, 0}, -- 2.7.4 From 6bc75e4cd04e8e132037d83df6f98bf1eafdcb70 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Thu, 5 Jan 2023 13:45:59 +0900 Subject: [PATCH 12/16] tests: Fix a compile warning This silences a follow warning. [ 155s] /usr/include/bits/string_fortified.h:106:34: warning: 'char* __builtin_strncpy(char*, const char*, unsigned int)' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation] [ 155s] 106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); [ 155s] | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [ 155s] ../tests/tc_screenshooter.cpp: In function 'void client_registry_cb_global(void*, wl_registry*, uint32_t, const char*, uint32_t)': Change-Id: Ibe959f4fdb0117b4b554558d29d79b50da0a6ed9 --- tests/tc_screenshooter.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/tc_screenshooter.cpp b/tests/tc_screenshooter.cpp index f2b01f4..f84583d 100644 --- a/tests/tc_screenshooter.cpp +++ b/tests/tc_screenshooter.cpp @@ -531,25 +531,22 @@ _client_tizen_screenshooter_create_anonymous_file(off_t size) static const char tempname[] = "/shooter-XXXXXX"; const char *path; char *name = NULL; + size_t name_size; int fd = -1; int ret = -1; - int path_len = 0; path = getenv("XDG_RUNTIME_DIR"); if (!path) { errno = ENOENT; return -1; } - path_len = strlen(path); - if (path_len == 0) - return -1; - name = (char *)malloc(path_len + (int)sizeof(tempname)); + name_size = strlen(path) + sizeof(tempname); + name = (char *)malloc(name_size); if (name == NULL) return -1; - strncpy(name, path, path_len); - strncat(name, tempname, (int)sizeof(tempname)); + snprintf(name, name_size, "%s%s", path, tempname); fd = mkstemp(name); if (fd >= 0) -- 2.7.4 From 16b6621b6c127ec3cbe799d8c329eeb80c1412ca Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Tue, 21 Mar 2023 15:17:13 +0900 Subject: [PATCH 13/16] tests: Fix build warning Change-Id: I917c771cfb0528c02f0befc48edc6f8927733591 --- tests/tc_video.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tc_video.cpp b/tests/tc_video.cpp index fc4891d..2d493a0 100644 --- a/tests/tc_video.cpp +++ b/tests/tc_video.cpp @@ -212,7 +212,7 @@ struct property { std::string name; uint32_t value; - property(std::string name, uint32_t value) : name(name), value(value) {} + property(std::string _name, uint32_t _value) : name(_name), value(_value) {} }; static void -- 2.7.4 From 7bb87477f2fa53a5af198c49fb43fcdaaa4c3a39 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Tue, 21 Mar 2023 15:15:03 +0900 Subject: [PATCH 14/16] eom: add xdg-shell-unstable-v6-server dependency Change-Id: I6191a480294887030ecf613eb769f21c5abe0486 --- packaging/libds-tizen.spec | 2 ++ src/eom/meson.build | 1 + 2 files changed, 3 insertions(+) diff --git a/packaging/libds-tizen.spec b/packaging/libds-tizen.spec index c4bfb93..a4efb47 100644 --- a/packaging/libds-tizen.spec +++ b/packaging/libds-tizen.spec @@ -44,6 +44,8 @@ BuildRequires: pkgconfig(scaler-server) BuildRequires: pkgconfig(scaler-client) BuildRequires: pkgconfig(eom-server) BuildRequires: pkgconfig(eom) +BuildRequires: pkgconfig(xdg-shell-unstable-v6-server) + %description Wayland Compositor Library for Tizen diff --git a/src/eom/meson.build b/src/eom/meson.build index 84d6075..a159c2d 100644 --- a/src/eom/meson.build +++ b/src/eom/meson.build @@ -5,6 +5,7 @@ libds_tizen_eom_files = [ libds_tizen_eom_deps = [ deps_libds_tizen, dependency('eom-server', required: true), + dependency('xdg-shell-unstable-v6-server', required: true), ] lib_libds_tizen_eom= shared_library('ds-tizen-eom', libds_tizen_eom_files, -- 2.7.4 From b5afa007adf334eaf7f5e908e3defb3f59088024 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Wed, 29 Mar 2023 10:39:24 +0900 Subject: [PATCH 15/16] tests: Fix build warning of -Wshadow Change-Id: I1867d94617568a75e1378f4ebf70f86dcbe9c784 --- tests/tc_video.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/tc_video.cpp b/tests/tc_video.cpp index 2d493a0..d00883c 100644 --- a/tests/tc_video.cpp +++ b/tests/tc_video.cpp @@ -128,10 +128,10 @@ TEST_F(VideoCompositor, AddFormats) ASSERT_EQ(supported_format.size(), ret_formats.size()); bool found; - for (uint32_t supported_format : supported_format) { + for (uint32_t format : supported_format) { found = false; for (uint32_t ret_format : ret_formats) { - if (supported_format == ret_format) { + if (format == ret_format) { found = true; break; } -- 2.7.4 From 88078eff9cf491db0d365d09da5b4eb83583e96f Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Tue, 21 Feb 2023 13:29:06 +0900 Subject: [PATCH 16/16] Expose ds_tbm_server as ABI Change-Id: I19f37aaad954245ede523299f0c52a6a41390e17 --- include/libds-tizen/types/tbm_server.h | 18 ++++++++++++++++++ packaging/libds-tizen.spec | 1 + src/tbm_server/tbm_server.h | 12 +----------- 3 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 include/libds-tizen/types/tbm_server.h diff --git a/include/libds-tizen/types/tbm_server.h b/include/libds-tizen/types/tbm_server.h new file mode 100644 index 0000000..2f97929 --- /dev/null +++ b/include/libds-tizen/types/tbm_server.h @@ -0,0 +1,18 @@ +#ifndef LIBDS_TIZEN_TYPES_TBM_SERVER_H +#define LIBDS_TIZEN_TYPES_TBM_SERVER_H + +#include +#include + +struct ds_tbm_server +{ + struct wayland_tbm_server *wl_tbm; + + struct wl_listener display_destroy; + + struct { + struct wl_signal destroy; + } events; +}; + +#endif diff --git a/packaging/libds-tizen.spec b/packaging/libds-tizen.spec index a4efb47..6311697 100644 --- a/packaging/libds-tizen.spec +++ b/packaging/libds-tizen.spec @@ -471,6 +471,7 @@ ninja -C builddir install %defattr(-,root,root,-) %license LICENSE %{_includedir}/libds-tizen/tbm_server.h +%{_includedir}/libds-tizen/types/tbm_server.h %{_libdir}/pkgconfig/libds-tizen-tbm-server.pc %{_libdir}/libds-tizen-tbm-server.so diff --git a/src/tbm_server/tbm_server.h b/src/tbm_server/tbm_server.h index 58e391b..3ae00f3 100644 --- a/src/tbm_server/tbm_server.h +++ b/src/tbm_server/tbm_server.h @@ -5,17 +5,7 @@ #include #include #include - -struct ds_tbm_server -{ - struct wayland_tbm_server *wl_tbm; - - struct wl_listener display_destroy; - - struct { - struct wl_signal destroy; - } events; -}; +#include struct ds_tbm_client_buffer { -- 2.7.4