implement tizen_policy 74/280974/1
authorSooChan Lim <sc1.lim@samsung.com>
Fri, 12 Aug 2022 08:07:33 +0000 (17:07 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Wed, 7 Sep 2022 08:11:55 +0000 (17:11 +0900)
Change-Id: I1be6f809cba50e8864e3d7ee6059dcefbdf8840a

include/libds-tizen/policy.h [new file with mode: 0644]
packaging/libds-tizen.spec
src/meson.build
src/policy/meson.build [new file with mode: 0644]
src/policy/policy.c [new file with mode: 0644]

diff --git a/include/libds-tizen/policy.h b/include/libds-tizen/policy.h
new file mode 100644 (file)
index 0000000..f95e7cf
--- /dev/null
@@ -0,0 +1,686 @@
+#ifndef LIBDS_TIZEN_POLICY_H
+#define LIBDS_TIZEN_POLICY_H
+
+#include <stdint.h>
+#include <wayland-server.h>
+#include <libds/surface.h>
+#include <libds/subsurface.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ds_tizen_policy;
+struct ds_tizen_policy_surface;
+struct ds_tizen_policy_visibility;
+struct ds_tizen_policy_position;
+struct ds_tizen_policy_subsurface_watcher;
+
+enum ds_tizen_policy_window_type
+{
+    DS_TIZEN_POLICY_WINDOW_TYPE_NONE,
+    DS_TIZEN_POLICY_WINDOW_TYPE_TOPLEVEL,
+    DS_TIZEN_POLICY_WINDOW_TYPE_FULLLSCREEN,
+    DS_TIZEN_POLICY_WINDOW_TYPE_MAXIMIZED,
+    DS_TIZEN_POLICY_WINDOW_TYPE_TRANSIENT,
+    DS_TIZEN_POLICY_WINDOW_TYPE_MENU,
+    DS_TIZEN_POLICY_WINDOW_TYPE_DND,
+    DS_TIZEN_POLICY_WINDOW_TYPE_CUSTOM,
+    DS_TIZEN_POLICY_WINDOW_TYPE_NOTIFICATION,
+    DS_TIZEN_POLICY_WINDOW_TYPE_UTILITY,
+    DS_TIZEN_POLICY_WINDOW_TYPE_DIALOG,
+    DS_TIZEN_POLICY_WINDOW_TYPE_DOCK,
+    DS_TIZEN_POLICY_WINDOW_TYPE_SPLASH,
+    DS_TIZEN_POLICY_WINDOW_TYPE_DESKTOP,
+};
+
+enum ds_tizen_policy_conformant_part
+{
+    DS_TIZEN_POLICY_CONFORMANT_PART_UNKNOWN,
+    DS_TIZEN_POLICY_CONFORMANT_PART_INDICATOR,
+    DS_TIZEN_POLICY_CONFORMANT_PART_KEYBOARD,
+    DS_TIZEN_POLICY_CONFORMANT_PART_CLIPBOARD,
+};
+
+enum ds_tizen_policy_error_state
+{
+    DS_TIZEN_POLICY_ERROR_STATE_NONE,
+    DS_TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED,
+};
+
+enum ds_tizen_policy_notification_level
+{
+    DS_TIZEN_POLICY_NOTIFICATION_LEVEL_1,
+    DS_TIZEN_POLICY_NOTIFICATION_LEVEL_2,
+    DS_TIZEN_POLICY_NOTIFICATION_LEVEL_3,
+    DS_TIZEN_POLICY_NOTIFICATION_LEVEL_NONE,
+    DS_TIZEN_POLICY_NOTIFICATION_LEVEL_DEFAULT,
+    DS_TIZEN_POLICY_NOTIFICATION_LEVEL_MEDIUM,
+    DS_TIZEN_POLICY_NOTIFICATION_LEVEL_HIGH,
+    DS_TIZEN_POLICY_NOTIFICATION_LEVEL_TOP,
+};
+
+enum ds_tizen_policy_window_screen_mode
+{
+    DS_TIZEN_POLICY_WINDOW_SCREEN_MODE_DEFAULT,
+    DS_TIZEN_POLICY_WINDOW_SCREEN_MODE_ALWAYS_ON,
+};
+
+enum ds_tizen_policy_stack_mode
+{
+    DS_TIZEN_POLICY_STACK_MODE_NONE,
+    DS_TIZEN_POLICY_STACK_MODE_ABOVE,
+    DS_TIZEN_POLICY_STACK_MODE_BELOW,
+};
+
+enum ds_tizen_policy_visibility_type
+{
+    DS_TIZEN_POLICY_VISIBILITY_TYPE_UNKNOWN,
+    DS_TIZEN_POLICY_VISIBILITY_TYPE_UNOBSCURED,
+    DS_TIZEN_POLICY_VISIBILITY_TYPE_PARTIALLY_OBSCURED,
+    DS_TIZEN_POLICY_VISIBILITY_TYPE_FULLY_OBSCURED,
+    DS_TIZEN_POLICY_VISIBILITY_TYPE_PRE_UNOBSCURED,
+};
+
+// policy event structures
+struct ds_tizen_event_policy_get_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 *policy;
+    uint32_t universal_id;
+    uint32_t below_universal_id;
+};
+
+struct ds_tizen_event_policy_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 *policy;
+    uint32_t child_universal_id;
+    uint32_t parent_universal_id;
+};
+
+struct ds_tizen_event_policy_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 *policy;
+    struct ds_subsurface *subsurface;
+};
+
+struct ds_tizen_event_policy_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 *policy;
+    int32_t pid;
+};
+
+struct ds_tizen_event_policy_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 *policy;
+    uint32_t universal_id;
+    uint32_t above_universal_id;
+};
+
+struct ds_tizen_event_policy_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 *policy;
+    uint32_t universal_id;
+    uint32_t parent_universal_id;
+};
+
+// policy policy_surface event structures
+struct ds_tizen_event_policy_surface_get_visibility
+{
+    struct ds_tizen_policy_surface *policy_surface;
+    struct ds_tizen_policy_visibility *visibility;
+};
+
+struct ds_tizen_event_policy_surface_get_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 *policy_surface;
+};
+
+struct ds_tizen_event_policy_surface_raise
+{
+    struct ds_tizen_policy_surface *policy_surface;
+};
+
+struct ds_tizen_event_policy_surface_lower
+{
+    struct ds_tizen_policy_surface *policy_surface;
+};
+
+struct ds_tizen_event_policy_surface_set_focus_skip
+{
+    struct ds_tizen_policy_surface *policy_surface;
+};
+
+struct ds_tizen_event_policy_surface_unset_focus_skip
+{
+    struct ds_tizen_policy_surface *policy_surface;
+};
+
+struct ds_tizen_event_policy_surface_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 *policy_surface;
+    enum ds_tizen_policy_window_type win_type;
+};
+
+struct ds_tizen_event_policy_surface_set_conformant
+{
+    struct ds_tizen_policy_surface *policy_surface;
+};
+
+struct ds_tizen_event_policy_surface_unset_conformant
+{
+    struct ds_tizen_policy_surface *policy_surface;
+};
+
+struct ds_tizen_event_policy_surface_get_conformant
+{
+    struct ds_tizen_policy_surface *policy_surface;
+};
+
+struct ds_tizen_event_policy_surface_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 *policy_surface;
+    enum ds_tizen_policy_window_screen_mode mode;
+};
+
+struct ds_tizen_event_policy_surface_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 *policy_surface;
+};
+
+struct ds_tizen_event_policy_surface_uniconify
+{
+    struct ds_tizen_policy_surface *policy_surface;
+};
+
+struct ds_tizen_event_policy_surface_add_aux_hint
+{
+    struct ds_tizen_policy_surface *policy_surface;
+    int32_t id;
+    const char *name;
+    const char *value;
+};
+
+struct ds_tizen_event_policy_surface_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 *policy_surface;
+    int32_t id;
+};
+
+struct ds_tizen_event_policy_surface_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 *policy_surface;
+};
+
+struct ds_tizen_event_policy_surface_unset_floating_mode
+{
+    struct ds_tizen_policy_surface *policy_surface;
+};
+
+struct ds_tizen_event_policy_surface_set_stack_mode
+{
+    struct ds_tizen_policy_surface *policy_surface;
+    enum ds_tizen_policy_stack_mode mode;
+};
+
+struct ds_tizen_event_policy_surface_get_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 *policy_surface;
+    struct ds_surface *parent_surface;
+};
+
+struct ds_tizen_event_policy_surface_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 *policy_surface;
+    bool video;
+};
+
+struct ds_tizen_event_policy_surface_show
+{
+    struct ds_tizen_policy_surface *policy_surface;
+};
+
+struct ds_tizen_event_policy_surface_hide
+{
+    struct ds_tizen_policy_surface *policy_surface;
+};
+
+struct ds_tizen_event_policy_surface_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_position *position;
+    int32_t x;
+    int32_t y;
+};
+
+struct ds_tizen_policy *
+ds_tizen_policy_create(struct wl_display *display);
+
+// add listeners for ds_tizen_policy
+void
+ds_tizen_policy_add_destroy_listener(struct ds_tizen_policy *policy,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_add_get_surface_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_add_activate_below_by_univeral_id_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_add_lower_by_universal_id_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_add_set_transient_for_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_add_unset_transient_for_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_add_place_subsurface_below_parent_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_add_set_subsurface_stand_alone_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_add_set_background_state_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_add_unset_background_state_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_add_activate_above_by_universal_id_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_add_set_appid_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_add_set_transient_for_below_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener);
+
+// add listeners for ds_tizen_policy_surface
+void
+ds_tizen_policy_surface_add_destroy_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_get_visibility_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_get_position_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_activate_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_raise_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_lower_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_set_focus_skip_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_unset_focus_skip_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_set_role_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_set_window_type_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_set_conformant_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_unset_conformant_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_get_conformant_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_set_notification_level_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_set_window_screen_mode_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_get_subsurface_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_iconify_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_uniconify_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_add_aux_hint_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_change_aux_hint_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_delete_aux_hint_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_get_supported_aux_hints_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_set_floating_mode_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_unset_floating_mode_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_set_stack_mode_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_get_subsurface_watcher_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_set_parent_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_ack_conformant_region_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_set_video_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_show_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_hide_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_surface_add_set_parent_with_below_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener);
+
+// add listeners for ds_tizen_policy_visibility
+void
+ds_tizen_policy_visibility_add_destroy_listener(
+        struct ds_tizen_policy_visibility *visibility,
+        struct wl_listener *listener);
+
+// add listeners for ds_tizen_policy_position
+void
+ds_tizen_policy_position_add_destroy_listener(
+        struct ds_tizen_policy_position *position,
+        struct wl_listener *listener);
+
+void
+ds_tizen_policy_position_add_set_listener(
+        struct ds_tizen_policy_position *position,
+        struct wl_listener *listener);
+
+// add listeners for ds_tizen_policy_subsurface_watcher
+void
+ds_tizen_policy_subsurface_watcher_add_destroy_listener(
+        struct ds_tizen_policy_subsurface_watcher *subsurface_watcher,
+        struct wl_listener *listener);
+
+// policy_surface senders to client
+void
+ds_tizen_policy_surface_send_conformant(struct ds_tizen_policy_surface *policy_surface,
+    bool active);
+
+void
+ds_tizen_policy_surface_send_conformant_area(struct ds_tizen_policy_surface *policy_surface,
+    enum ds_tizen_policy_conformant_part part, bool visible,
+    int32_t x, int32_t y, int32_t w, int32_t h);
+
+void
+ds_tizen_policy_surface_send_notification_done(struct ds_tizen_policy_surface *policy_surface,
+    enum ds_tizen_policy_notification_level level,
+    enum ds_tizen_policy_error_state state);
+
+void
+ds_tizen_policy_surface_send_window_screen_mode_done(struct ds_tizen_policy_surface *policy_surface,
+    enum ds_tizen_policy_window_screen_mode mode,
+    enum ds_tizen_policy_error_state state);
+
+void
+ds_tizen_policy_surface_send_iconify_state_changed(struct ds_tizen_policy_surface *policy_surface,
+    bool iconified, bool force);
+
+void
+ds_tizen_policy_surface_send_supported_aux_hints(struct ds_tizen_policy_surface *policy_surface,
+    struct wl_array *hints, uint32_t force);
+
+void
+ds_tizen_policy_surface_send_allowed_aux_hint(struct ds_tizen_policy_surface *policy_surface,
+    int32_t hint_id);
+
+void
+ds_tizen_policy_surface_send_aux_message(struct ds_tizen_policy_surface *policy_surface,
+    const char *key, const char *value, struct wl_array *options);
+
+void
+ds_tizen_policy_surface_send_conformant_region(struct ds_tizen_policy_surface *policy_surface,
+    enum ds_tizen_policy_conformant_part part, bool visible,
+    int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial);
+
+void
+ds_tizen_policy_surface_send_interactive_move_done(struct ds_tizen_policy_surface *policy_surface,
+    int32_t x, int32_t y, uint32_t w, uint32_t h);
+
+void
+ds_tizen_policy_surface_send_interactive_resize_done(struct ds_tizen_policy_surface *policy_surface,
+    int32_t x, int32_t y, uint32_t w, uint32_t h);
+
+// visibility senders to client
+void
+ds_tizen_policy_visibility_send_notify(
+    struct ds_tizen_policy_visibility *visibility,
+    enum ds_tizen_policy_visibility_type type);
+
+void
+ds_tizen_policy_visibility_send_changed(
+    struct ds_tizen_policy_visibility *visibility,
+    enum ds_tizen_policy_visibility_type type, uint32_t option);
+
+// position senders to client
+void
+ds_tizen_policy_position_send_changed(
+    struct ds_tizen_policy_position *position, int32_t x, int32_t y);
+
+// getters for ds_tizen_policy_surface
+struct ds_surface *
+ds_tizen_policy_surface_get_surface(struct ds_tizen_policy_surface *policy_surface);
+
+bool
+ds_tizen_policy_surface_get_conformant(struct ds_tizen_policy_surface *policy_surface);
+
+int32_t
+ds_tizen_policy_surface_get_opaque_state(struct ds_tizen_policy_surface *policy_surface);
+
+bool
+ds_tizen_policy_surface_get_iconified(struct ds_tizen_policy_surface *policy_surface);
+
+bool
+ds_tizen_policy_surface_get_floating_mode(struct ds_tizen_policy_surface *policy_surface);
+
+enum ds_tizen_policy_stack_mode
+ds_tizen_policy_surface_get_stack_mode(struct ds_tizen_policy_surface *policy_surface);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 82a0fec..1ef64cc 100644 (file)
@@ -312,6 +312,21 @@ Group:   Development/Libraries
 %description hwc-devel
 Development package for tizen hwc
 
+## libds-tizen-policy
+%package policy
+Summary: Library for tizen policy
+Group:   Development/Libraries
+
+%description policy
+Library for tizen policy
+
+%package policy-devel
+Summary: Development package for tizen policy
+Group:   Development/Libraries
+
+%description policy-devel
+Development package for tizen policy
+
 %prep
 %setup -q
 cp %{SOURCE1001} .
@@ -601,3 +616,17 @@ ninja -C builddir install
 %{_libdir}/pkgconfig/libds-tizen-hwc.pc
 %{_libdir}/libds-tizen-hwc.so*
 %{_bindir}/libds-tizen-hwc-tests
+
+%files policy
+%manifest %{name}.manifest
+%defattr(-,root,root,-)
+%license LICENSE
+%{_libdir}/libds-tizen-policy.so.*
+
+%files policy-devel
+%manifest %{name}.manifest
+%defattr(-,root,root,-)
+%license LICENSE
+%{_includedir}/libds-tizen/policy.h
+%{_libdir}/pkgconfig/libds-tizen-policy.pc
+%{_libdir}/libds-tizen-policy.so
index 8d254fa..227b7a9 100644 (file)
@@ -45,3 +45,4 @@ subdir('embedded_compositor')
 subdir('input_method')
 subdir('text_input')
 subdir('hwc')
+subdir('policy')
diff --git a/src/policy/meson.build b/src/policy/meson.build
new file mode 100644 (file)
index 0000000..3f4881f
--- /dev/null
@@ -0,0 +1,31 @@
+libds_tizen_policy_files = [
+  tizen_security_files,
+  'policy.c',
+]
+
+libds_tizen_policy_deps = [
+  deps_libds_tizen,
+  deps_tizen_security,
+  dependency('tizen-extension-server', required: true),
+]
+
+lib_libds_tizen_policy = shared_library('ds-tizen-policy', libds_tizen_policy_files,
+  dependencies: libds_tizen_policy_deps,
+  include_directories: [ common_inc, include_directories('.'), include_directories('..') ],
+  version: meson.project_version(),
+  install: true
+)
+
+deps_libds_tizen_policy = declare_dependency(
+  link_with: lib_libds_tizen_policy,
+  dependencies: libds_tizen_policy_deps,
+  include_directories: [ common_inc, include_directories('.') ],
+)
+
+pkgconfig = import('pkgconfig')
+pkgconfig.generate(lib_libds_tizen_policy,
+  version: meson.project_version(),
+  filebase: 'libds-tizen-policy',
+  name: 'libds-tizen-policy',
+  description: 'tizen policy extension of libds-tizen for tizen platform',
+)
diff --git a/src/policy/policy.c b/src/policy/policy.c
new file mode 100644 (file)
index 0000000..b349d8b
--- /dev/null
@@ -0,0 +1,2313 @@
+#include <assert.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <wayland-server.h>
+#include <tizen-extension-server-protocol.h>
+#include <libds/log.h>
+
+#include "util.h"
+#include "security.h"
+#include "libds-tizen/policy.h"
+
+#define TIZEN_POLICY_VERSION 11
+#define TIZEN_POLICY_PRIVILEGE_SET_NOTIFICATION_LEVEL \
+        "http://tizen.org/privilege/window.priority.set"
+#define TIZEN_POLICY_PRIVILEGE_SET_SCREEN_MODE \
+        "http://tizen.org/privilege/display"
+
+struct ds_tizen_policy
+{
+    struct wl_global *global;
+
+    struct wl_list clients;
+
+    struct wl_listener destroy;
+
+    bool use_security;
+
+    struct {
+        struct wl_signal destroy;
+        struct wl_signal get_surface;
+        struct wl_signal activate_below_by_univeral_id;
+        struct wl_signal lower_by_universal_id;
+        struct wl_signal set_transient_for;
+        struct wl_signal unset_transient_for;
+        struct wl_signal place_subsurface_below_parent;
+        struct wl_signal set_subsurface_stand_alone;
+        struct wl_signal set_background_state;
+        struct wl_signal unset_background_state;
+        struct wl_signal activate_above_by_universal_id;
+        struct wl_signal set_appid;
+        struct wl_signal set_transient_for_below;
+    } events;
+};
+
+struct ds_tizen_policy_client
+{
+    struct ds_tizen_policy *policy;
+
+    struct wl_resource *resource;
+    struct wl_client *wl_client;
+    pid_t pid;
+    uid_t uid;
+
+    struct wl_list policy_surfaces;
+
+    struct wl_list link; // ds_tizen_policy::clients
+};
+
+struct ds_tizen_policy_surface
+{
+    struct ds_tizen_policy_client *client;
+
+    struct ds_surface *surface;
+    pid_t pid;
+    uid_t uid;
+
+    struct wl_list visibilities;
+    struct wl_list positions;
+    struct wl_list subsurface_watchers;
+
+    bool conformant;
+    int32_t opaque_state;
+    bool iconified;
+    bool floating_mode;
+    enum ds_tizen_policy_stack_mode stack_mode;
+    bool video;
+
+    struct {
+        struct wl_signal destroy;
+        struct wl_signal get_visibility;
+        struct wl_signal get_position;
+        struct wl_signal activate;
+        struct wl_signal raise;
+        struct wl_signal lower;
+        struct wl_signal set_focus_skip;
+        struct wl_signal unset_focus_skip;
+        struct wl_signal set_role;
+        struct wl_signal set_window_type;
+        struct wl_signal set_conformant;
+        struct wl_signal unset_conformant;
+        struct wl_signal get_conformant;
+        struct wl_signal set_notification_level;
+        struct wl_signal set_window_screen_mode;
+        struct wl_signal get_subsurface;
+        struct wl_signal iconify;
+        struct wl_signal uniconify;
+        struct wl_signal add_aux_hint;
+        struct wl_signal change_aux_hint;
+        struct wl_signal delete_aux_hint;
+        struct wl_signal get_supported_aux_hints;
+        struct wl_signal set_floating_mode;
+        struct wl_signal unset_floating_mode;
+        struct wl_signal set_stack_mode;
+        struct wl_signal get_subsurface_watcher;
+        struct wl_signal set_parent;
+        struct wl_signal ack_conformant_region;
+        struct wl_signal set_video;
+        struct wl_signal show;
+        struct wl_signal hide;
+        struct wl_signal set_parent_with_below;
+    } events;
+
+    struct wl_list link; // ds_tizen_policy_client::policy_surfaces
+};
+
+struct ds_tizen_policy_visibility
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    struct wl_resource *resource;
+
+    struct {
+        struct wl_signal destroy;
+    } events;
+
+    struct wl_list link; // ds_tizen_policy_surface::visibilities
+};
+
+struct ds_tizen_policy_position
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    struct wl_resource *resource;
+
+    struct {
+        struct wl_signal destroy;
+        struct wl_signal set;
+    } events;
+
+    struct wl_list link; // ds_tizen_policy_surface::positions
+};
+
+struct ds_tizen_policy_subsurface_watcher
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    struct wl_resource *resource;
+
+    struct {
+        struct wl_signal destroy;
+    } events;
+
+    struct wl_list link; // ds_tizen_policy_surface::subsurface_watchers
+};
+
+static void policy_handle_display_destroy(struct wl_listener *listener,
+        void *data);
+
+static void policy_bind(struct wl_client *wl_client, void *data,
+        uint32_t version, uint32_t id);
+
+static struct ds_tizen_policy_surface *tizen_policy_client_find_policy_surface(
+    struct ds_tizen_policy_client *client,
+    struct ds_surface *surface);
+
+static struct ds_tizen_policy_surface *tizen_policy_client_get_surface(
+    struct wl_resource *resource,
+    struct wl_resource *surface_resource);
+
+WL_EXPORT struct ds_tizen_policy *
+ds_tizen_policy_create(struct wl_display *display)
+{
+    struct ds_tizen_policy *policy;
+
+    policy = calloc(1, sizeof *policy);
+    if (!policy) {
+        ds_err("calloc() failed.");
+        return NULL;
+    }
+
+    policy->global = wl_global_create(display, &tizen_policy_interface,
+            TIZEN_POLICY_VERSION, policy, policy_bind);
+    if (!policy->global) {
+        ds_err("wl_global_create() failed. tizen_policy_interface");
+        free(policy);
+        return NULL;
+    }
+
+    wl_list_init(&policy->clients);
+
+    policy->destroy.notify = policy_handle_display_destroy;
+    wl_display_add_destroy_listener(display, &policy->destroy);
+
+    policy->use_security = tizen_security_init();
+    if (!policy->use_security) {
+        ds_inf("tizen_security_init() is not successful. "
+                "policy works without security.");
+    }
+
+    wl_signal_init(&policy->events.destroy);
+    wl_signal_init(&policy->events.get_surface);
+    wl_signal_init(&policy->events.activate_below_by_univeral_id);
+    wl_signal_init(&policy->events.lower_by_universal_id);
+    wl_signal_init(&policy->events.set_transient_for);
+    wl_signal_init(&policy->events.unset_transient_for);
+    wl_signal_init(&policy->events.place_subsurface_below_parent);
+    wl_signal_init(&policy->events.set_subsurface_stand_alone);
+    wl_signal_init(&policy->events.set_background_state);
+    wl_signal_init(&policy->events.unset_background_state);
+    wl_signal_init(&policy->events.activate_above_by_universal_id);
+    wl_signal_init(&policy->events.set_appid);
+    wl_signal_init(&policy->events.set_transient_for_below);
+
+    ds_inf("Global created: tizen_policy(%p)", policy);
+
+    return policy;
+}
+
+WL_EXPORT void
+ds_tizen_policy_add_destroy_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy->events.destroy, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_add_get_surface_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy->events.get_surface, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_add_activate_below_by_univeral_id_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy->events.activate_below_by_univeral_id, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_add_lower_by_universal_id_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy->events.lower_by_universal_id, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_add_set_transient_for_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy->events.set_transient_for, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_add_unset_transient_for_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy->events.unset_transient_for, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_add_place_subsurface_below_parent_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy->events.place_subsurface_below_parent, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_add_set_subsurface_stand_alone_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy->events.set_subsurface_stand_alone, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_add_set_background_state_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy->events.set_background_state, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_add_unset_background_state_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy->events.unset_background_state, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_add_activate_above_by_universal_id_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy->events.activate_above_by_universal_id, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_add_set_appid_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy->events.set_appid, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_add_set_transient_for_below_listener(
+        struct ds_tizen_policy *policy,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy->events.set_transient_for_below, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_destroy_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.destroy, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_get_visibility_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.get_visibility, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_get_position_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.get_position, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_activate_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.activate, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_raise_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.raise, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_lower_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.lower, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_set_focus_skip_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.set_focus_skip, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_unset_focus_skip_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.unset_focus_skip, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_set_role_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.set_role, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_set_window_type_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.set_window_type, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_set_conformant_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.set_conformant, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_unset_conformant_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.unset_conformant, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_get_conformant_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.get_conformant, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_set_notification_level_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.set_notification_level, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_set_window_screen_mode_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.set_window_screen_mode, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_get_subsurface_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.get_subsurface, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_iconify_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.iconify, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_uniconify_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.uniconify, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_add_aux_hint_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.add_aux_hint, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_change_aux_hint_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.change_aux_hint, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_delete_aux_hint_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.delete_aux_hint, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_get_supported_aux_hints_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.get_supported_aux_hints, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_set_floating_mode_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.set_floating_mode, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_unset_floating_mode_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.unset_floating_mode, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_set_stack_mode_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.set_stack_mode, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_get_subsurface_watcher_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.get_subsurface_watcher, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_set_parent_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.set_parent, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_ack_conformant_region_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.ack_conformant_region, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_set_video_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.set_video, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_show_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.show, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_hide_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.hide, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_add_set_parent_with_below_listener(
+        struct ds_tizen_policy_surface *policy_surface,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&policy_surface->events.set_parent_with_below, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_visibility_add_destroy_listener(
+        struct ds_tizen_policy_visibility *visibility,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&visibility->events.destroy, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_position_add_destroy_listener(
+        struct ds_tizen_policy_position *position,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&position->events.destroy, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_position_add_set_listener(
+        struct ds_tizen_policy_position *position,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&position->events.set, listener);
+}
+
+void
+ds_tizen_policy_subsurface_watcher_add_destroy_listener(
+        struct ds_tizen_policy_subsurface_watcher *subsurface_watcher,
+        struct wl_listener *listener)
+{
+    wl_signal_add(&subsurface_watcher->events.destroy, listener);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_send_conformant(struct ds_tizen_policy_surface *policy_surface,
+    bool active)
+{
+   tizen_policy_send_conformant(policy_surface->client->resource,
+    ds_surface_get_wl_resource(policy_surface->surface), active);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_send_conformant_area(struct ds_tizen_policy_surface *policy_surface,
+    enum ds_tizen_policy_conformant_part part, bool visible,
+    int32_t x, int32_t y, int32_t w, int32_t h)
+{
+    uint32_t conformant_part;
+
+    switch (part) {
+        case DS_TIZEN_POLICY_CONFORMANT_PART_INDICATOR:
+            conformant_part = TIZEN_POLICY_CONFORMANT_PART_INDICATOR;
+            break;
+        case DS_TIZEN_POLICY_CONFORMANT_PART_KEYBOARD:
+            conformant_part = TIZEN_POLICY_CONFORMANT_PART_KEYBOARD;
+            break;
+        case DS_TIZEN_POLICY_CONFORMANT_PART_CLIPBOARD:
+            conformant_part = TIZEN_POLICY_CONFORMANT_PART_CLIPBOARD;
+            break;
+        default:
+            ds_err("Not supported conformant_part(%d)", part);
+            return;
+    }
+
+    tizen_policy_send_conformant_area(policy_surface->client->resource,
+        ds_surface_get_wl_resource(policy_surface->surface), conformant_part, visible,
+        x, y, w, h);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_send_notification_done(struct ds_tizen_policy_surface *policy_surface,
+    enum ds_tizen_policy_notification_level level,
+    enum ds_tizen_policy_error_state state)
+{
+    uint32_t notification_level;
+    uint32_t error_state;
+
+    switch (level) {
+        case DS_TIZEN_POLICY_NOTIFICATION_LEVEL_1:
+            notification_level = TIZEN_POLICY_LEVEL_1;
+            break;
+        case DS_TIZEN_POLICY_NOTIFICATION_LEVEL_2:
+            notification_level = TIZEN_POLICY_LEVEL_2;
+            break;
+        case DS_TIZEN_POLICY_NOTIFICATION_LEVEL_3:
+            notification_level = TIZEN_POLICY_LEVEL_3;
+            break;
+        case DS_TIZEN_POLICY_NOTIFICATION_LEVEL_NONE:
+            notification_level = TIZEN_POLICY_LEVEL_NONE;
+            break;
+        case DS_TIZEN_POLICY_NOTIFICATION_LEVEL_DEFAULT:
+            notification_level = TIZEN_POLICY_LEVEL_DEFAULT;
+            break;
+        case DS_TIZEN_POLICY_NOTIFICATION_LEVEL_MEDIUM:
+            notification_level = TIZEN_POLICY_LEVEL_MEDIUM;
+            break;
+        case DS_TIZEN_POLICY_NOTIFICATION_LEVEL_HIGH:
+            notification_level = TIZEN_POLICY_LEVEL_HIGH;
+            break;
+        case DS_TIZEN_POLICY_NOTIFICATION_LEVEL_TOP:
+            notification_level = TIZEN_POLICY_LEVEL_TOP;
+            break;
+        default:
+            ds_err("Not supported notification_level(%d)", level);
+            return;
+    }
+
+    switch (state) {
+        case DS_TIZEN_POLICY_ERROR_STATE_NONE:
+            error_state = TIZEN_POLICY_ERROR_STATE_NONE;
+            break;
+        case DS_TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED:
+            error_state = TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED;
+            break;
+        default:
+            ds_err("Not supported error_state(%d)", state);
+            return;
+    }
+
+    tizen_policy_send_notification_done(policy_surface->client->resource,
+        ds_surface_get_wl_resource(policy_surface->surface),
+        notification_level, error_state);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_send_window_screen_mode_done(struct ds_tizen_policy_surface *policy_surface,
+    enum ds_tizen_policy_window_screen_mode mode,
+    enum ds_tizen_policy_error_state state)
+{
+    uint32_t window_screen_mode;
+    uint32_t error_state;
+
+    switch (mode) {
+        case DS_TIZEN_POLICY_WINDOW_SCREEN_MODE_DEFAULT:
+            window_screen_mode = TIZEN_POLICY_MODE_DEFAULT;
+            break;
+        case DS_TIZEN_POLICY_WINDOW_SCREEN_MODE_ALWAYS_ON:
+            window_screen_mode = TIZEN_POLICY_MODE_ALWAYS_ON;
+            break;
+        default:
+            ds_err("Not supported window_screen_mode(%d)", mode);
+            return;
+    }
+
+    switch (state) {
+        case DS_TIZEN_POLICY_ERROR_STATE_NONE:
+            error_state = TIZEN_POLICY_ERROR_STATE_NONE;
+            break;
+        case DS_TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED:
+            error_state = TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED;
+            break;
+        default:
+            ds_err("Not supported error_state(%d)", state);
+            return;
+    }
+
+    tizen_policy_send_window_screen_mode_done(policy_surface->client->resource,
+        ds_surface_get_wl_resource(policy_surface->surface),
+        window_screen_mode, error_state);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_send_iconify_state_changed(struct ds_tizen_policy_surface *policy_surface,
+    bool iconified, bool force)
+{
+    tizen_policy_send_iconify_state_changed(policy_surface->client->resource,
+        ds_surface_get_wl_resource(policy_surface->surface), iconified, force);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_send_supported_aux_hints(struct ds_tizen_policy_surface *policy_surface,
+    struct wl_array *hints, uint32_t force)
+{
+    // TODO:
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_send_allowed_aux_hint(struct ds_tizen_policy_surface *policy_surface,
+    int32_t hint_id)
+{
+    // TODO:
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_send_aux_message(struct ds_tizen_policy_surface *policy_surface,
+    const char *key, const char *value, struct wl_array *options)
+{
+    // TODO:
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_send_conformant_region(struct ds_tizen_policy_surface *policy_surface,
+    enum ds_tizen_policy_conformant_part part, bool visible,
+    int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial)
+{
+    uint32_t conformant_part;
+
+    switch (part) {
+        case DS_TIZEN_POLICY_CONFORMANT_PART_INDICATOR:
+            conformant_part = TIZEN_POLICY_CONFORMANT_PART_INDICATOR;
+            break;
+        case DS_TIZEN_POLICY_CONFORMANT_PART_KEYBOARD:
+            conformant_part = TIZEN_POLICY_CONFORMANT_PART_KEYBOARD;
+            break;
+        case DS_TIZEN_POLICY_CONFORMANT_PART_CLIPBOARD:
+            conformant_part = TIZEN_POLICY_CONFORMANT_PART_CLIPBOARD;
+            break;
+        default:
+            ds_err("Not supported conformant_part(%d)", part);
+            return;
+    }
+
+    tizen_policy_send_conformant_region(policy_surface->client->resource,
+        ds_surface_get_wl_resource(policy_surface->surface), conformant_part, visible,
+        x, y, w, h, serial);
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_send_interactive_move_done(struct ds_tizen_policy_surface *policy_surface,
+    int32_t x, int32_t y, uint32_t w, uint32_t h)
+{
+    // TODO:
+}
+
+WL_EXPORT void
+ds_tizen_policy_surface_send_interactive_resize_done(struct ds_tizen_policy_surface *policy_surface,
+    int32_t x, int32_t y, uint32_t w, uint32_t h)
+{
+        // TODO:
+}
+
+static int32_t
+tizen_policy_visibility_get_type(enum ds_tizen_policy_visibility_type type)
+{
+    uint32_t vis_type;
+
+    switch (type) {
+        case DS_TIZEN_POLICY_VISIBILITY_TYPE_UNOBSCURED:
+            vis_type = TIZEN_VISIBILITY_VISIBILITY_UNOBSCURED;
+            break;
+        case DS_TIZEN_POLICY_VISIBILITY_TYPE_PARTIALLY_OBSCURED:
+            vis_type = TIZEN_VISIBILITY_VISIBILITY_PARTIALLY_OBSCURED;
+            break;
+        case DS_TIZEN_POLICY_VISIBILITY_TYPE_FULLY_OBSCURED:
+            vis_type = TIZEN_VISIBILITY_VISIBILITY_FULLY_OBSCURED;
+            break;
+        case DS_TIZEN_POLICY_VISIBILITY_TYPE_PRE_UNOBSCURED:
+            vis_type = TIZEN_VISIBILITY_VISIBILITY_PRE_UNOBSCURED;
+            break;
+        default:
+            ds_err("Not supported visible type (%d)", type);
+            vis_type = DS_TIZEN_POLICY_VISIBILITY_TYPE_UNKNOWN;
+            break;
+    }
+
+    return vis_type;
+}
+
+WL_EXPORT void
+ds_tizen_policy_visibility_send_notify(
+    struct ds_tizen_policy_visibility *visibility,
+    enum ds_tizen_policy_visibility_type type)
+{
+    uint32_t vis_type;
+
+    vis_type = tizen_policy_visibility_get_type(type);
+    if (vis_type == DS_TIZEN_POLICY_VISIBILITY_TYPE_UNKNOWN)
+        return;
+
+    tizen_visibility_send_notify(visibility->resource, vis_type);
+}
+
+WL_EXPORT void
+ds_tizen_policy_visibility_send_changed(
+    struct ds_tizen_policy_visibility *visibility,
+    enum ds_tizen_policy_visibility_type type, uint32_t option)
+{
+    uint32_t vis_type;
+
+    vis_type = tizen_policy_visibility_get_type(type);
+    if (vis_type == DS_TIZEN_POLICY_VISIBILITY_TYPE_UNKNOWN)
+        return;
+
+    tizen_visibility_send_changed(visibility->resource, vis_type, option);
+}
+
+WL_EXPORT void
+ds_tizen_policy_position_send_changed(
+    struct ds_tizen_policy_position *position, int32_t x, int32_t y)
+{
+    tizen_position_send_changed(position->resource, x, y);
+}
+
+WL_EXPORT struct ds_surface *
+ds_tizen_policy_surface_get_surface(struct ds_tizen_policy_surface *policy_surface)
+{
+    return policy_surface->surface;
+}
+
+WL_EXPORT bool
+ds_tizen_policy_surface_get_conformant(struct ds_tizen_policy_surface *policy_surface)
+{
+    return policy_surface->conformant;
+}
+
+WL_EXPORT int32_t
+ds_tizen_policy_surface_get_opaque_state(struct ds_tizen_policy_surface *policy_surface)
+{
+    return policy_surface->opaque_state;
+}
+
+WL_EXPORT bool
+ds_tizen_policy_surface_get_iconified(struct ds_tizen_policy_surface *policy_surface)
+{
+    return policy_surface->iconified;
+}
+
+WL_EXPORT bool
+ds_tizen_policy_surface_get_floating_mode(struct ds_tizen_policy_surface *policy_surface)
+{
+    return policy_surface->floating_mode;
+}
+
+WL_EXPORT enum ds_tizen_policy_stack_mode
+ds_tizen_policy_surface_get_stack_mode(struct ds_tizen_policy_surface *policy_surface)
+{
+    return policy_surface->stack_mode;
+}
+
+static struct ds_tizen_policy_surface *
+tizen_policy_client_find_policy_surface(struct ds_tizen_policy_client *client,
+    struct ds_surface *surface)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    wl_list_for_each(policy_surface, &client->policy_surfaces, link) {
+        if (surface == policy_surface->surface)
+            return policy_surface;
+    }
+
+    return NULL;
+}
+
+static struct ds_tizen_policy_surface *
+tizen_policy_client_get_surface(struct wl_resource *resource,
+    struct wl_resource *surface_resource)
+{
+    struct ds_tizen_policy_client *client;
+    struct ds_tizen_policy_surface *policy_surface;
+    struct ds_surface *surface;
+
+    client = wl_resource_get_user_data(resource);
+    surface = ds_surface_from_resource(surface_resource);
+
+    policy_surface = tizen_policy_client_find_policy_surface(client, surface);
+    if (policy_surface)
+        return policy_surface;
+
+    policy_surface = calloc(1, sizeof *policy_surface);
+    if (policy_surface == NULL) {
+        ds_err("calloc() failed. tizen_policy");
+        return NULL;
+    }
+
+    policy_surface->client = client;
+    policy_surface->surface = surface;
+    wl_client_get_credentials(client->wl_client, &policy_surface->pid, &policy_surface->uid, NULL);
+
+    wl_list_init(&policy_surface->visibilities);
+    wl_list_init(&policy_surface->positions);
+    wl_list_init(&policy_surface->subsurface_watchers);
+
+    wl_signal_init(&policy_surface->events.destroy);
+    wl_signal_init(&policy_surface->events.get_visibility);
+    wl_signal_init(&policy_surface->events.get_position);
+    wl_signal_init(&policy_surface->events.activate);
+    wl_signal_init(&policy_surface->events.raise);
+    wl_signal_init(&policy_surface->events.lower);
+    wl_signal_init(&policy_surface->events.set_focus_skip);
+    wl_signal_init(&policy_surface->events.unset_focus_skip);
+    wl_signal_init(&policy_surface->events.set_role);
+    wl_signal_init(&policy_surface->events.set_window_type);
+    wl_signal_init(&policy_surface->events.set_conformant);
+    wl_signal_init(&policy_surface->events.unset_conformant);
+    wl_signal_init(&policy_surface->events.get_conformant);
+    wl_signal_init(&policy_surface->events.set_notification_level);
+    wl_signal_init(&policy_surface->events.set_window_screen_mode);
+    wl_signal_init(&policy_surface->events.get_subsurface);
+    wl_signal_init(&policy_surface->events.iconify);
+    wl_signal_init(&policy_surface->events.uniconify);
+    wl_signal_init(&policy_surface->events.add_aux_hint);
+    wl_signal_init(&policy_surface->events.change_aux_hint);
+    wl_signal_init(&policy_surface->events.delete_aux_hint);
+    wl_signal_init(&policy_surface->events.get_supported_aux_hints);
+    wl_signal_init(&policy_surface->events.set_floating_mode);
+    wl_signal_init(&policy_surface->events.unset_floating_mode);
+    wl_signal_init(&policy_surface->events.set_stack_mode);
+    wl_signal_init(&policy_surface->events.get_subsurface_watcher);
+    wl_signal_init(&policy_surface->events.set_parent);
+    wl_signal_init(&policy_surface->events.ack_conformant_region);
+    wl_signal_init(&policy_surface->events.set_video);
+    wl_signal_init(&policy_surface->events.show);
+    wl_signal_init(&policy_surface->events.hide);
+    wl_signal_init(&policy_surface->events.set_parent_with_below);
+
+    wl_list_insert(&client->policy_surfaces, &policy_surface->link);
+
+    struct ds_tizen_event_policy_get_surface event = {
+        .policy = client->policy,
+        .policy_surface = policy_surface,
+    };
+    wl_signal_emit(&client->policy->events.get_surface, &event);
+
+    return policy_surface;
+}
+
+static void
+policy_handle_display_destroy(struct wl_listener *listener, void *data)
+{
+    struct ds_tizen_policy *policy;
+
+    policy = wl_container_of(listener, policy, destroy);
+
+    ds_inf("Global destroy: policy(%p)", policy);
+
+    wl_signal_emit(&policy->events.destroy, policy);
+
+    if (policy->use_security)
+        tizen_security_finish();
+
+    wl_list_remove(&policy->destroy.link);
+    wl_global_destroy(policy->global);
+    free(policy);
+}
+
+static void
+visibility_handle_destroy(struct wl_client *wl_client,
+    struct wl_resource *resource)
+{
+   wl_resource_destroy(resource);
+}
+
+static const struct tizen_visibility_interface visibility_impl =
+{
+   visibility_handle_destroy,
+};
+
+static void
+_tizen_policy_visibility_handle_destroy(struct wl_resource *resource)
+{
+    struct ds_tizen_policy_visibility *visibility;
+
+    visibility = wl_resource_get_user_data(resource);
+
+    ds_inf("_tizen_policy_visibility_handle_destroy (visibility:%p)",
+        visibility);
+
+    wl_signal_emit(&visibility->events.destroy, visibility);
+    wl_list_remove(&visibility->link);
+    free(visibility);
+}
+
+static void
+policy_handle_get_visibility(struct wl_client *wl_client, struct wl_resource *resource,
+    uint32_t id, struct wl_resource *surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+    struct ds_tizen_policy_visibility *visibility;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    visibility = calloc(1, sizeof *visibility);
+    if (visibility == NULL) {
+        ds_err("calloc() failed. tizen_policy");
+        return;
+    }
+
+    visibility->policy_surface = policy_surface;
+    wl_signal_init(&visibility->events.destroy);
+
+    wl_list_insert(&policy_surface->visibilities, &visibility->link);
+
+    visibility->resource = wl_resource_create(wl_client,
+        &tizen_visibility_interface, wl_resource_get_version(resource),
+        id);
+    if (visibility->resource == NULL) {
+        ds_err("tizen_policy : wl_resource_create() failed.");
+        wl_list_remove(&visibility->link);
+        free(visibility);
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    wl_resource_set_implementation(visibility->resource,
+        &visibility_impl, visibility,
+        _tizen_policy_visibility_handle_destroy);
+
+    struct ds_tizen_event_policy_surface_get_visibility event = {
+        .policy_surface = policy_surface,
+        .visibility = visibility,
+    };
+    wl_signal_emit(&policy_surface->events.get_visibility, &event);
+}
+
+static void
+position_handle_destroy(struct wl_client *wl_client, struct wl_resource *resource)
+{
+   wl_resource_destroy(resource);
+}
+
+static void
+position_handle_set(struct wl_client *wl_client, struct wl_resource *resource,
+    int32_t x, int32_t y)
+{
+    struct ds_tizen_policy_position *position;
+
+    position = wl_resource_get_user_data(resource);
+
+    struct ds_tizen_event_policy_position_set event = {
+        .position = position,
+        .x = x,
+        .y = y,
+    };
+    wl_signal_emit(&position->events.set, &event);
+}
+
+static const struct tizen_position_interface position_impl =
+{
+   position_handle_destroy,
+   position_handle_set,
+};
+
+static void
+_tizen_policy_position_handle_destroy(struct wl_resource *resource)
+{
+    struct ds_tizen_policy_position *position;
+
+    position = wl_resource_get_user_data(resource);
+
+    ds_inf("_tizen_policy_position_handle_destroy (position:%p)",
+        position);
+
+    wl_signal_emit(&position->events.destroy, position);
+    wl_list_remove(&position->link);
+    free(position);
+}
+
+static void
+policy_handle_get_position(struct wl_client *wl_client, struct wl_resource *resource,
+    uint32_t id, struct wl_resource *surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+    struct ds_tizen_policy_position *position;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    position = calloc(1, sizeof *position);
+    if (position == NULL) {
+        ds_err("calloc() failed. tizen_policy");
+        return;
+    }
+
+    position->policy_surface = policy_surface;
+    wl_signal_init(&position->events.destroy);
+    wl_signal_init(&position->events.set);
+
+    wl_list_insert(&policy_surface->positions, &position->link);
+
+    position->resource = wl_resource_create(wl_client,
+        &tizen_position_interface, wl_resource_get_version(resource),
+        id);
+    if (position->resource == NULL) {
+        ds_err("tizen_policy : wl_resource_create() failed.");
+        wl_list_remove(&position->link);
+        free(position);
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    wl_resource_set_implementation(position->resource,
+        &position_impl, position,
+        _tizen_policy_position_handle_destroy);
+
+    struct ds_tizen_event_policy_surface_get_position event = {
+        .policy_surface = policy_surface,
+        .position = position,
+    };
+    wl_signal_emit(&policy_surface->events.get_position, &event);
+}
+
+static void
+policy_handle_activate(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    struct ds_tizen_event_policy_surface_activate event = {
+        .policy_surface = policy_surface,
+    };
+    wl_signal_emit(&policy_surface->events.activate, &event);
+}
+
+static void
+policy_handle_activate_below_by_res_id(struct wl_client *wl_client,
+    struct wl_resource *resource,  uint32_t universal_id,
+    uint32_t below_universal_id)
+{
+    struct ds_tizen_policy_client *client;
+
+    client = wl_resource_get_user_data(resource);
+
+    struct ds_tizen_event_policy_activate_below_by_univeral_id event = {
+        .policy = client->policy,
+        .universal_id = universal_id,
+        .below_universal_id = below_universal_id,
+    };
+    wl_signal_emit(&client->policy->events.activate_below_by_univeral_id, &event);
+}
+
+static void
+policy_handle_raise(struct wl_client *wl_client, struct wl_resource *resource,
+    struct wl_resource *surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    struct ds_tizen_event_policy_surface_raise event = {
+        .policy_surface = policy_surface,
+    };
+    wl_signal_emit(&policy_surface->events.raise, &event);
+}
+
+static void
+policy_handle_lower(struct wl_client *wl_client, struct wl_resource *resource,
+    struct wl_resource *surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    struct ds_tizen_event_policy_surface_lower event = {
+        .policy_surface = policy_surface,
+    };
+    wl_signal_emit(&policy_surface->events.lower, &event);
+}
+
+static void
+policy_handle_lower_by_res_id(struct wl_client *wl_client,
+    struct wl_resource *resource,  uint32_t universal_id)
+{
+    struct ds_tizen_policy_client *client;
+
+    client = wl_resource_get_user_data(resource);
+
+    struct ds_tizen_event_policy_lower_by_universal_id event = {
+        .policy = client->policy,
+        .universal_id = universal_id,
+    };
+    wl_signal_emit(&client->policy->events.lower_by_universal_id, &event);
+}
+
+static void
+policy_handle_set_focus_skip(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    struct ds_tizen_event_policy_surface_set_focus_skip event = {
+        .policy_surface = policy_surface,
+    };
+    wl_signal_emit(&policy_surface->events.set_focus_skip, &event);
+}
+
+static void
+policy_handle_unset_focus_skip(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    struct ds_tizen_event_policy_surface_unset_focus_skip event = {
+        .policy_surface = policy_surface,
+    };
+    wl_signal_emit(&policy_surface->events.unset_focus_skip, &event);
+}
+
+static void
+policy_handle_set_role(struct wl_client *wl_client, struct wl_resource *resource,
+    struct wl_resource *surface_resource, const char *role)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    struct ds_tizen_event_policy_surface_set_role event = {
+        .policy_surface = policy_surface,
+        .role = role,
+    };
+    wl_signal_emit(&policy_surface->events.set_role, &event);
+}
+
+static void
+policy_handle_set_type(struct wl_client *wl_client, struct wl_resource *resource,
+    struct wl_resource *surface_resource, uint32_t type)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+    enum ds_tizen_policy_window_type win_type;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    switch (type) {
+        case TIZEN_POLICY_WIN_TYPE_NONE:
+            win_type = DS_TIZEN_POLICY_WINDOW_TYPE_NONE;
+            break;
+        case TIZEN_POLICY_WIN_TYPE_TOPLEVEL:
+            win_type = DS_TIZEN_POLICY_WINDOW_TYPE_TOPLEVEL;
+            break;
+        case TIZEN_POLICY_WIN_TYPE_FULLSCREEN:
+            win_type = DS_TIZEN_POLICY_WINDOW_TYPE_FULLLSCREEN;
+            break;
+        case TIZEN_POLICY_WIN_TYPE_MAXIMIZED:
+            win_type = DS_TIZEN_POLICY_WINDOW_TYPE_MAXIMIZED;
+            break;
+        case TIZEN_POLICY_WIN_TYPE_TRANSIENT:
+            win_type = DS_TIZEN_POLICY_WINDOW_TYPE_TRANSIENT;
+            break;
+        case TIZEN_POLICY_WIN_TYPE_MENU:
+            win_type = DS_TIZEN_POLICY_WINDOW_TYPE_MENU;
+            break;
+        case TIZEN_POLICY_WIN_TYPE_DND:
+            win_type = DS_TIZEN_POLICY_WINDOW_TYPE_DND;
+            break;
+        case TIZEN_POLICY_WIN_TYPE_CUSTOM:
+            win_type = DS_TIZEN_POLICY_WINDOW_TYPE_CUSTOM;
+            break;
+        case TIZEN_POLICY_WIN_TYPE_NOTIFICATION:
+            win_type = DS_TIZEN_POLICY_WINDOW_TYPE_NOTIFICATION;
+            break;
+        case TIZEN_POLICY_WIN_TYPE_UTILITY:
+            win_type = DS_TIZEN_POLICY_WINDOW_TYPE_UTILITY;
+            break;
+        case TIZEN_POLICY_WIN_TYPE_DIALOG:
+            win_type = DS_TIZEN_POLICY_WINDOW_TYPE_DIALOG;
+            break;
+        case TIZEN_POLICY_WIN_TYPE_DOCK:
+            win_type = DS_TIZEN_POLICY_WINDOW_TYPE_DOCK;
+            break;
+        case TIZEN_POLICY_WIN_TYPE_SPLASH:
+            win_type = DS_TIZEN_POLICY_WINDOW_TYPE_SPLASH;
+            break;
+        case TIZEN_POLICY_WIN_TYPE_DESKTOP:
+            win_type = DS_TIZEN_POLICY_WINDOW_TYPE_DESKTOP;
+            break;
+        default:
+            win_type = DS_TIZEN_POLICY_WINDOW_TYPE_NONE;
+            break;
+    }
+
+    struct ds_tizen_event_policy_surface_set_window_type event = {
+        .policy_surface = policy_surface,
+        .win_type = win_type,
+    };
+    wl_signal_emit(&policy_surface->events.set_window_type, &event);
+}
+
+static void
+policy_handle_set_conformant(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    if (!policy_surface->conformant)
+        policy_surface->conformant = true;
+
+    struct ds_tizen_event_policy_surface_set_conformant event = {
+        .policy_surface = policy_surface,
+    };
+    wl_signal_emit(&policy_surface->events.set_conformant, &event);
+}
+
+static void
+policy_handle_unset_conformant(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    if (policy_surface->conformant)
+        policy_surface->conformant = false;
+
+    struct ds_tizen_event_policy_surface_unset_conformant event = {
+        .policy_surface = policy_surface,
+    };
+    wl_signal_emit(&policy_surface->events.unset_conformant, &event);
+}
+
+static void
+policy_handle_get_conformant(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    struct ds_tizen_event_policy_surface_get_conformant event = {
+        .policy_surface = policy_surface,
+    };
+    wl_signal_emit(&policy_surface->events.get_conformant, &event);
+}
+
+static void
+policy_handle_set_notification_level(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource,
+    int32_t level)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+    enum ds_tizen_policy_notification_level noti_level;
+    bool ret;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    ret = tizen_security_check_privilege(policy_surface->pid, policy_surface->uid,
+            TIZEN_POLICY_PRIVILEGE_SET_NOTIFICATION_LEVEL);
+    if (ret == false) {
+        ds_err("tizen_security_check_privilege() failed. "
+            "Privilege Denied on set_notification_level.");
+
+        tizen_policy_send_notification_done(resource, surface_resource,
+            -1, TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED);
+
+        return;
+    }
+
+    switch (level) {
+        case TIZEN_POLICY_LEVEL_1:
+            noti_level = DS_TIZEN_POLICY_NOTIFICATION_LEVEL_1;
+            break;
+        case TIZEN_POLICY_LEVEL_2:
+            noti_level = DS_TIZEN_POLICY_NOTIFICATION_LEVEL_2;
+            break;
+        case TIZEN_POLICY_LEVEL_3:
+            noti_level = DS_TIZEN_POLICY_NOTIFICATION_LEVEL_3;
+            break;
+        case TIZEN_POLICY_LEVEL_NONE:
+            noti_level = DS_TIZEN_POLICY_NOTIFICATION_LEVEL_NONE;
+            break;
+        case TIZEN_POLICY_LEVEL_DEFAULT:
+            noti_level = DS_TIZEN_POLICY_NOTIFICATION_LEVEL_DEFAULT;
+            break;
+        case TIZEN_POLICY_LEVEL_MEDIUM:
+            noti_level = DS_TIZEN_POLICY_NOTIFICATION_LEVEL_MEDIUM;
+            break;
+        case TIZEN_POLICY_LEVEL_HIGH:
+            noti_level = DS_TIZEN_POLICY_NOTIFICATION_LEVEL_HIGH;
+            break;
+        case TIZEN_POLICY_LEVEL_TOP:
+            noti_level = DS_TIZEN_POLICY_NOTIFICATION_LEVEL_TOP;
+            break;
+        default:
+            noti_level = DS_TIZEN_POLICY_NOTIFICATION_LEVEL_NONE;
+            break;
+    }
+
+    struct ds_tizen_event_policy_surface_set_notification_level event = {
+        .policy_surface = policy_surface,
+        .level = noti_level,
+    };
+    wl_signal_emit(&policy_surface->events.set_notification_level, &event);
+}
+
+static void
+policy_handle_set_transient_for(struct wl_client *wl_client,
+    struct wl_resource *resource, uint32_t child_id, uint32_t parent_id)
+{
+    struct ds_tizen_policy_client *client;
+
+    client = wl_resource_get_user_data(resource);
+
+    struct ds_tizen_event_policy_set_transient_for event = {
+        .policy = client->policy,
+        .child_universal_id = child_id,
+        .parent_universal_id = parent_id,
+    };
+    wl_signal_emit(&client->policy->events.set_transient_for, &event);
+
+    tizen_policy_send_transient_for_done(resource, child_id);
+}
+
+static void
+policy_handle_unset_transient_for(struct wl_client *wl_client,
+    struct wl_resource *resource, uint32_t child_id)
+{
+    struct ds_tizen_policy_client *client;
+
+    client = wl_resource_get_user_data(resource);
+
+    struct ds_tizen_event_policy_unset_transient_for event = {
+        .policy = client->policy,
+        .child_universal_id = child_id,
+    };
+    wl_signal_emit(&client->policy->events.unset_transient_for, &event);
+}
+
+static void
+policy_handle_set_window_screen_mode(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource,
+    uint32_t mode)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+    enum ds_tizen_policy_window_screen_mode screen_mode;
+    bool ret;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    ret = tizen_security_check_privilege(policy_surface->pid, policy_surface->uid,
+            TIZEN_POLICY_PRIVILEGE_SET_SCREEN_MODE);
+    if (ret == false) {
+        ds_err("tizen_security_check_privilege() failed. "
+            "Privilege Denied on set_window_screen_mode.");
+
+        tizen_policy_send_notification_done(resource, surface_resource,
+            -1, TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED);
+
+        return;
+    }
+
+    switch (mode) {
+        case TIZEN_POLICY_MODE_DEFAULT:
+            screen_mode = DS_TIZEN_POLICY_WINDOW_SCREEN_MODE_DEFAULT;
+            break;
+        case TIZEN_POLICY_MODE_ALWAYS_ON:
+            screen_mode = DS_TIZEN_POLICY_WINDOW_SCREEN_MODE_ALWAYS_ON;
+            break;
+        default:
+            screen_mode = DS_TIZEN_POLICY_WINDOW_SCREEN_MODE_DEFAULT;
+            break;
+    }
+
+    struct ds_tizen_event_policy_surface_set_window_screen_mode event = {
+        .policy_surface = policy_surface,
+        .mode = screen_mode,
+    };
+    wl_signal_emit(&policy_surface->events.set_window_screen_mode, &event);
+}
+
+static void
+policy_handle_place_subsurface_below_parent(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *subsurface_resource)
+{
+    struct ds_tizen_policy_client *client;
+    struct ds_subsurface *subsurface;
+
+    client = wl_resource_get_user_data(resource);
+    subsurface = ds_subsurface_from_resource(subsurface_resource);
+
+    struct ds_tizen_event_policy_place_subsurface_below_parent event = {
+        .policy = client->policy,
+        .subsurface = subsurface,
+    };
+    wl_signal_emit(
+        &client->policy->events.place_subsurface_below_parent,
+        &event);
+}
+
+static void
+policy_handle_set_subsurface_stand_alone(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *subsurface_resource)
+{
+    struct ds_tizen_policy_client *client;
+    struct ds_subsurface *subsurface;
+
+    client = wl_resource_get_user_data(resource);
+    subsurface = ds_subsurface_from_resource(subsurface_resource);
+
+    struct ds_tizen_event_policy_set_subsurface_stand_alone event = {
+        .policy = client->policy,
+        .subsurface = subsurface,
+    };
+    wl_signal_emit(
+        &client->policy->events.set_subsurface_stand_alone,
+        &event);
+}
+
+static void
+policy_handle_get_subsurface(struct wl_client *wl_client,
+    struct wl_resource *resource, uint32_t id,
+    struct wl_resource *surface_resource, uint32_t parent_id)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    // TODO: How to create the ds_subsurface with a parent_universal_id.
+
+    struct ds_tizen_event_policy_surface_get_subsurface event = {
+        .policy_surface = policy_surface,
+        .parent_universal_id = parent_id,
+    };
+    wl_signal_emit(&policy_surface->events.get_subsurface, &event);
+}
+
+static void
+policy_handle_set_opaque_state(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource,
+    int32_t state)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    if (policy_surface->opaque_state != state)
+        policy_surface->opaque_state = state;
+}
+
+static void
+policy_handle_iconify(struct wl_client *wl_client, struct wl_resource *resource,
+    struct wl_resource *surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    if (!policy_surface->iconified)
+        policy_surface->iconified = true;
+
+    struct ds_tizen_event_policy_surface_iconify event = {
+        .policy_surface = policy_surface,
+    };
+    wl_signal_emit(&policy_surface->events.iconify, &event);
+}
+
+static void
+policy_handle_uniconify(struct wl_client *wl_client, struct wl_resource *resource,
+    struct wl_resource *surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    if (policy_surface->iconified)
+        policy_surface->iconified = false;
+
+    struct ds_tizen_event_policy_surface_uniconify event = {
+        .policy_surface = policy_surface,
+    };
+    wl_signal_emit(&policy_surface->events.uniconify, &event);
+}
+
+static void
+policy_handle_add_aux_hint(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource,
+    int32_t id, const char *name, const char *value)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    struct ds_tizen_event_policy_surface_add_aux_hint event = {
+        .policy_surface = policy_surface,
+        .id = id,
+        .name = name,
+        .value = value,
+    };
+    wl_signal_emit(&policy_surface->events.add_aux_hint, &event);
+}
+
+static void
+policy_handle_change_aux_hint(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource,
+    int32_t id, const char *value)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    struct ds_tizen_event_policy_surface_change_aux_hint event = {
+        .policy_surface = policy_surface,
+        .id = id,
+        .value = value,
+    };
+    wl_signal_emit(&policy_surface->events.change_aux_hint, &event);
+}
+
+static void
+policy_handle_delete_aux_hint(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource,
+    int32_t id)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    struct ds_tizen_event_policy_surface_delete_aux_hint event = {
+        .policy_surface = policy_surface,
+        .id = id,
+    };
+    wl_signal_emit(&policy_surface->events.delete_aux_hint, &event);
+}
+
+static void
+policy_handle_get_supported_aux_hints(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    struct ds_tizen_event_policy_surface_get_supported_aux_hints event = {
+        .policy_surface = policy_surface,
+    };
+    wl_signal_emit(&policy_surface->events.get_supported_aux_hints, &event);
+}
+
+static void
+policy_handle_set_background_state(struct wl_client *wl_client,
+    struct wl_resource *resource, uint32_t pid)
+{
+    struct ds_tizen_policy_client *client;
+    struct ds_tizen_policy *policy;
+
+    client = wl_resource_get_user_data(resource);
+    policy = client->policy;
+
+    wl_list_for_each(client, &policy->clients, link) {
+        if (pid == client->pid) {
+            struct ds_tizen_event_policy_set_background_state event = {
+                .policy = client->policy,
+                .pid = pid,
+            };
+            wl_signal_emit(&client->policy->events.set_background_state, &event);
+        }
+    }
+}
+
+static void
+policy_handle_unset_background_state(struct wl_client *wl_client,
+    struct wl_resource *resource, uint32_t pid)
+{
+    struct ds_tizen_policy_client *client;
+    struct ds_tizen_policy *policy;
+
+    client = wl_resource_get_user_data(resource);
+    policy = client->policy;
+
+    wl_list_for_each(client, &policy->clients, link) {
+        if (pid == client->pid) {
+            struct ds_tizen_event_policy_unset_background_state event = {
+                .policy = client->policy,
+                .pid = pid,
+            };
+            wl_signal_emit(&client->policy->events.unset_background_state, &event);
+        }
+    }
+}
+
+static void
+policy_handle_set_floating_mode(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    if (policy_surface->floating_mode == false)
+        return;
+
+    policy_surface->floating_mode = false;
+
+    struct ds_tizen_event_policy_surface_set_floating_mode event = {
+        .policy_surface = policy_surface,
+    };
+    wl_signal_emit(&policy_surface->events.set_floating_mode, &event);
+}
+
+static void
+policy_handle_unset_floating_mode(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    if (policy_surface->floating_mode == false)
+        return;
+
+    policy_surface->floating_mode = false;
+
+    struct ds_tizen_event_policy_surface_unset_floating_mode event = {
+        .policy_surface = policy_surface,
+    };
+    wl_signal_emit(&policy_surface->events.unset_floating_mode, &event);
+}
+
+static void
+policy_handle_set_stack_mode(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource,
+    uint32_t mode)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+    enum ds_tizen_policy_stack_mode stack_mode;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    switch (mode) {
+        case TIZEN_POLICY_STACK_MODE_ABOVE:
+            stack_mode = DS_TIZEN_POLICY_STACK_MODE_ABOVE;
+            break;
+        case TIZEN_POLICY_STACK_MODE_BELOW:
+            stack_mode = DS_TIZEN_POLICY_STACK_MODE_BELOW;
+            break;
+        default:
+            stack_mode = DS_TIZEN_POLICY_STACK_MODE_NONE;
+            break;
+    }
+
+    if (policy_surface->stack_mode == stack_mode)
+        return;
+
+    policy_surface->stack_mode = stack_mode;
+
+    struct ds_tizen_event_policy_surface_set_stack_mode event = {
+        .policy_surface = policy_surface,
+        .mode = stack_mode,
+    };
+    wl_signal_emit(&policy_surface->events.set_stack_mode, &event);
+}
+
+static void
+policy_handle_activate_above_by_res_id(struct wl_client *wl_client,
+    struct wl_resource *resource, uint32_t universal_id,
+    uint32_t above_universal_id)
+{
+    struct ds_tizen_policy_client *client;
+
+    client = wl_resource_get_user_data(resource);
+
+    struct ds_tizen_event_policy_activate_above_by_universal_id event = {
+        .policy = client->policy,
+        .universal_id = universal_id,
+        .above_universal_id = above_universal_id,
+    };
+    wl_signal_emit(&client->policy->events.activate_above_by_universal_id, &event);
+}
+
+static void
+subsurface_watcher_handle_destroy(struct wl_client *wl_client,
+    struct wl_resource *resource)
+{
+   wl_resource_destroy(resource);
+}
+
+static const struct tizen_subsurface_watcher_interface subsurface_watcher_impl =
+{
+   subsurface_watcher_handle_destroy,
+};
+
+static void
+_tizen_policy_subsurface_watcher_handle_destroy(struct wl_resource *resource)
+{
+    struct ds_tizen_policy_subsurface_watcher *subsurface_watcher;
+
+    subsurface_watcher = wl_resource_get_user_data(resource);
+
+    ds_inf("_tizen_policy_subsurface_watcher_handle_destroy (subsurface_watcher:%p)",
+        subsurface_watcher);
+
+    wl_signal_emit(&subsurface_watcher->events.destroy, subsurface_watcher);
+    free(subsurface_watcher);
+}
+
+static void
+policy_handle_get_subsurface_watcher(struct wl_client *wl_client,
+    struct wl_resource *resource, uint32_t id,
+    struct wl_resource *surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+    struct ds_tizen_policy_subsurface_watcher *subsurface_watcher;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    subsurface_watcher = calloc(1, sizeof *subsurface_watcher);
+    if (!subsurface_watcher) {
+        ds_err("calloc() failed. tizen_policy");
+        return;
+    }
+
+    subsurface_watcher->policy_surface = policy_surface;
+    wl_signal_init(&subsurface_watcher->events.destroy);
+
+    wl_list_insert(&policy_surface->subsurface_watchers, &subsurface_watcher->link);
+
+    subsurface_watcher->resource = wl_resource_create(wl_client,
+        &tizen_subsurface_watcher_interface, wl_resource_get_version(resource),
+        id);
+    if (subsurface_watcher->resource == NULL) {
+        ds_err("tizen_policy : wl_resource_create() failed.");
+        free(subsurface_watcher);
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    wl_resource_set_implementation(subsurface_watcher->resource,
+        &subsurface_watcher_impl, subsurface_watcher,
+        _tizen_policy_subsurface_watcher_handle_destroy);
+
+    struct ds_tizen_event_policy_surface_get_subsurface_watcher event = {
+        .policy_surface = policy_surface,
+        .subsurface_watcher = subsurface_watcher,
+    };
+    wl_signal_emit(&policy_surface->events.get_subsurface_watcher, &event);
+}
+
+static void
+policy_handle_set_parent(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource,
+    struct wl_resource *parent_surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+    struct ds_surface *parent_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    parent_surface = ds_surface_from_resource(parent_surface_resource);
+
+    struct ds_tizen_event_policy_surface_set_parent event = {
+        .policy_surface = policy_surface,
+        .parent_surface = parent_surface,
+    };
+    wl_signal_emit(&policy_surface->events.set_parent, &event);
+}
+
+static void
+policy_handle_ack_conformant_region(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource,
+    uint32_t serial)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    struct ds_tizen_event_policy_surface_ack_conformant_region event = {
+        .policy_surface = policy_surface,
+        .serial = serial,
+    };
+    wl_signal_emit(&policy_surface->events.ack_conformant_region, &event);
+}
+
+static void
+policy_handle_destroy(struct wl_client *wl_client, struct wl_resource *resource)
+{
+    struct ds_tizen_policy_client *client;
+
+    client = wl_resource_get_user_data(resource);
+
+    if (!wl_list_empty(&client->policy_surfaces)) {
+        ds_err("tizen_policy was destroyed before children");
+        return;
+    }
+
+    wl_resource_destroy(resource);
+}
+
+static void
+policy_handle_has_video(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource,
+    uint32_t has)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    if (policy_surface->video == has)
+        return;
+
+    policy_surface->video = has;
+
+    struct ds_tizen_event_policy_surface_set_video event = {
+        .policy_surface = policy_surface,
+        .video = has,
+    };
+    wl_signal_emit(&policy_surface->events.set_video, &event);
+}
+
+static void
+policy_handle_set_appid(struct wl_client *wl_client,
+    struct wl_resource *resource, int32_t pid, const char *appid)
+{
+    struct ds_tizen_policy_client *client;
+
+    client = wl_resource_get_user_data(resource);
+
+    struct ds_tizen_event_policy_set_appid event = {
+        .policy = client->policy,
+        .pid = pid,
+        .appid = appid,
+    };
+    wl_signal_emit(&client->policy->events.set_appid, &event);
+}
+
+static void
+policy_handle_show(struct wl_client *wl_client, struct wl_resource *resource,
+    struct wl_resource *surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    struct ds_tizen_event_policy_surface_show event = {
+        .policy_surface = policy_surface,
+    };
+    wl_signal_emit(&policy_surface->events.show, &event);
+}
+
+static void
+policy_handle_hide(struct wl_client *wl_client, struct wl_resource *resource,
+    struct wl_resource *surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    struct ds_tizen_event_policy_surface_hide event = {
+        .policy_surface = policy_surface,
+    };
+    wl_signal_emit(&policy_surface->events.hide, &event);
+}
+
+static void
+policy_handle_set_transient_for_below(struct wl_client *wl_client,
+    struct wl_resource *resource, uint32_t universal_id,
+    uint32_t parent_universal_id)
+{
+    struct ds_tizen_policy_client *client;
+
+    client = wl_resource_get_user_data(resource);
+
+    struct ds_tizen_event_policy_set_transient_for_below event = {
+        .policy = client->policy,
+        .universal_id = universal_id,
+        .parent_universal_id = parent_universal_id,
+    };
+    wl_signal_emit(&client->policy->events.set_transient_for_below, &event);
+}
+
+static void
+policy_handle_set_parent_with_below(struct wl_client *wl_client,
+    struct wl_resource *resource, struct wl_resource *surface_resource,
+    struct wl_resource *parent_surface_resource)
+{
+    struct ds_tizen_policy_surface *policy_surface;
+    struct ds_surface *parent_surface;
+
+    policy_surface = tizen_policy_client_get_surface(resource, surface_resource);
+    if (policy_surface == NULL) {
+        ds_err("tizen_policy_client_get_surface() failed.");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    parent_surface = ds_surface_from_resource(parent_surface_resource);
+
+    struct ds_tizen_event_policy_surface_set_parent_with_below event = {
+        .policy_surface = policy_surface,
+        .parent_surface = parent_surface,
+    };
+    wl_signal_emit(&policy_surface->events.set_parent_with_below, &event);
+}
+
+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,
+};
+
+static void
+_tizen_policy_client_handle_destroy(struct wl_resource *resource)
+{
+    struct ds_tizen_policy_client *client;
+    struct ds_tizen_policy_surface *policy_surface, *tmp;
+
+    client = wl_resource_get_user_data(resource);
+
+    ds_inf("_tizen_policy_client_handle_destroy (client:%p)", client);
+
+    wl_list_for_each_safe(policy_surface, tmp, &client->policy_surfaces, link) {
+        wl_signal_emit(&policy_surface->events.destroy, policy_surface);
+        wl_list_remove(&policy_surface->link);
+        free(policy_surface);
+    }
+
+    wl_list_remove(&client->link);
+    free(client);
+}
+
+static void
+policy_bind(struct wl_client *wl_client, void *data, uint32_t version,
+        uint32_t id)
+{
+    struct ds_tizen_policy *policy = data;
+    struct ds_tizen_policy_client *client;
+
+    client = calloc(1, sizeof *client);
+    if (client == NULL) {
+        ds_err("calloc() failed. tizen_policy");
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    ds_inf("tizen_policy_client binds. (client:%p)", client);
+
+    client->policy = policy;
+    client->wl_client = wl_client;
+    wl_client_get_credentials(client->wl_client, &client->pid, &client->uid, NULL);
+
+    wl_list_init(&client->policy_surfaces);
+
+    client->resource = wl_resource_create(wl_client, &tizen_policy_interface,
+            MIN(version, TIZEN_POLICY_VERSION), id);
+
+    if (client->resource == NULL) {
+        ds_err("tizen_policy : wl_resource_create() failed.");
+        free(client);
+        wl_client_post_no_memory(wl_client);
+        return;
+    }
+
+    wl_resource_set_implementation(client->resource, &policy_impl, client,
+            _tizen_policy_client_handle_destroy);
+
+    wl_list_insert(&policy->clients, &client->link);
+}