e_server: move the init/deinit of e_explicit_sync
[platform/upstream/enlightenment.git] / src / bin / e_comp_screen.c
index a528350..71b22d1 100644 (file)
@@ -9,6 +9,7 @@
 #include "e_comp_wl_tizen_hwc_intern.h"
 #include "e_comp_intern.h"
 #include "e_input_intern.h"
+#include "e_input_device_intern.h"
 #include "e_error_intern.h"
 #include "e_pointer_intern.h"
 #include "e_output_intern.h"
 #include "e_dbus_conn_intern.h"
 #include "e_main_intern.h"
 #include "e_hwc_planes_intern.h"
+#include "e_linux_dmabuf_intern.h"
+#include "e_comp_input_intern.h"
+#include "e_screen_rotation_intern.h"
+#include "e_server_intern.h"
 
 #include <tizen-extension-server-protocol.h>
 #include <device/board-internal.h>
@@ -44,137 +49,6 @@ enum
    E_COMP_SCREEN_SIGNAL_ROTATION_CHANGED = 0
 };
 
-typedef struct _E_Comp_Screen_Tzsr
-{
-   struct wl_resource *resource; /* tizen_screen_rotation */
-   E_Client           *ec;
-   struct wl_listener ec_destroy;
-} E_Comp_Screen_Tzsr;
-
-static Eina_List *tzsr_list;
-static E_Client_Hook *tzsr_client_hook_del;
-
-static void _tz_screen_rotation_cb_ec_destroy(struct wl_listener *listener, void *data);
-
-static E_Comp_Screen_Tzsr*
-_tz_surface_rotation_find(E_Client *ec)
-{
-   E_Comp_Screen_Tzsr *tzsr = NULL;
-   struct wl_listener *listener;
-
-   listener = e_client_destroy_listener_get(ec, _tz_screen_rotation_cb_ec_destroy);
-   if (listener)
-     return wl_container_of(listener, tzsr, ec_destroy);
-
-   return tzsr;
-}
-
-static void
-_tz_surface_rotation_free(E_Comp_Screen_Tzsr *tzsr)
-{
-   ELOGF("TRANSFORM", "|tzsr(%p) freed", tzsr->ec, tzsr);
-   tzsr_list = eina_list_remove(tzsr_list, tzsr);
-   wl_list_remove(&tzsr->ec_destroy.link);
-   free(tzsr);
-}
-
-static void
-_tz_screen_rotation_cb_ec_destroy(struct wl_listener *listener, void *data)
-{
-   E_Comp_Screen_Tzsr *tzsr;
-
-   tzsr = wl_container_of(listener, tzsr, ec_destroy);
-   _tz_surface_rotation_free(tzsr);
-}
-
-static void
-_tz_screen_rotation_get_ignore_output_transform(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface)
-{
-   E_Comp_Screen_Tzsr *tzsr;
-   E_Client *ec;
-   E_Hwc_Policy hwc_policy;
-   E_Output *output;
-   E_Zone *zone;
-   Eina_Bool ignore = EINA_TRUE;
-
-   ec = e_client_from_surface_resource(surface);
-   EINA_SAFETY_ON_NULL_RETURN(ec);
-
-   tzsr = _tz_surface_rotation_find(ec);
-   if (tzsr) return;
-
-   tzsr = E_NEW(E_Comp_Screen_Tzsr, 1);
-   if (!tzsr)
-     {
-        wl_client_post_no_memory(client);
-        return;
-     }
-
-   tzsr->resource = resource;
-   tzsr->ec = ec;
-
-   tzsr->ec_destroy.notify = _tz_screen_rotation_cb_ec_destroy;
-   e_client_destroy_listener_add(ec, &tzsr->ec_destroy);
-
-   tzsr_list = eina_list_append(tzsr_list, tzsr);
-
-   zone = e_comp_zone_find_by_ec(ec);
-   if (zone)
-     {
-        output = e_output_find(zone->output_id);
-        if (output)
-          {
-             hwc_policy = e_hwc_policy_get(output->hwc);
-             if (hwc_policy == E_HWC_POLICY_WINDOWS)
-               ignore = EINA_FALSE;
-          }
-     }
-
-   ELOGF("TRANSFORM", "|tzsr(%p) client_ignore(%d) ignore(%d)",
-         ec, tzsr, e_config->screen_rotation_client_ignore, ignore);
-
-   e_comp_screen_rotation_ignore_output_transform_send(ec, ignore);
-}
-
-static void
-_tz_screen_rotation_iface_cb_destroy(struct wl_client *client, struct wl_resource *resource)
-{
-   wl_resource_destroy(resource);
-}
-
-static const struct tizen_screen_rotation_interface _tz_screen_rotation_interface =
-{
-   _tz_screen_rotation_get_ignore_output_transform,
-   _tz_screen_rotation_iface_cb_destroy,
-};
-
-static void _tz_screen_rotation_cb_destroy(struct wl_resource *resource)
-{
-   E_Comp_Screen_Tzsr *tzsr;
-   Eina_List *l, *ll;
-
-   EINA_LIST_FOREACH_SAFE(tzsr_list, l, ll, tzsr)
-     {
-        if (tzsr->resource == resource)
-          _tz_surface_rotation_free(tzsr);
-     }
-}
-
-static void
-_tz_screen_rotation_cb_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id)
-{
-   struct wl_resource *res;
-
-   if (!(res = wl_resource_create(client, &tizen_screen_rotation_interface, version, id)))
-     {
-        ERR("Could not create tizen_screen_rotation resource: %m");
-        wl_client_post_no_memory(client);
-        return;
-     }
-
-   wl_resource_set_implementation(res, &_tz_screen_rotation_interface, NULL, _tz_screen_rotation_cb_destroy);
-}
-
 static Eldbus_Message *
 _e_comp_screen_dbus_get_cb(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
 {
@@ -318,11 +192,6 @@ _e_comp_screen_cb_input_device_add(void *data, int type, void *event)
           }
         comp->wl_comp_data->ptr.num_devices++;
      }
-   else if (e->clas == ECORE_DEVICE_CLASS_KEYBOARD)
-     {
-        comp->wl_comp_data->kbd.num_devices++;
-        e_comp_wl_input_keyboard_enabled_set(EINA_TRUE);
-     }
    else if (e->clas == ECORE_DEVICE_CLASS_TOUCH)
      {
         e_comp_wl_input_touch_enabled_set(EINA_TRUE);
@@ -387,14 +256,6 @@ _e_comp_screen_cb_input_device_del(void *data, int type, void *event)
              _e_comp_screen_pointer_renew();
           }
      }
-   else if (e->clas == ECORE_DEVICE_CLASS_KEYBOARD)
-     {
-        comp->wl_comp_data->kbd.num_devices--;
-        if (comp->wl_comp_data->kbd.num_devices == 0)
-          {
-             e_comp_wl_input_keyboard_enabled_set(EINA_FALSE);
-          }
-     }
    else if (e->clas == ECORE_DEVICE_CLASS_TOUCH)
      {
         comp->wl_comp_data->touch.num_devices--;
@@ -728,7 +589,6 @@ _e_comp_screen_deinit_outputs(E_Comp_Screen *e_comp_screen)
         e_output_del(output);
      }
 
-   e_explicit_sync_deinit();
    e_egl_sync_deinit();
    e_hwc_deinit();
    e_hwc_windows_deinit();
@@ -1149,13 +1009,13 @@ e_comp_screen_init()
      }
    e_main_ts_end("\tE_Input Init Done");
 
-   e_main_ts_begin("\tE_Comp_Wl Init");
-   if (!e_comp_wl_init())
+   e_main_ts_begin("\tE_Server Init");
+   if (!e_server_init())
      {
-        e_main_ts_begin("\tE_Comp_Wl Init Failed");
+        e_main_ts_end("\tE_Server Init Failed");
         goto failed_comp_screen;
      }
-   e_main_ts_end("\tE_Comp_Wl Init Done");
+   e_main_ts_end("\tE_Server Init Done");
 
    /* get the current screen geometry */
    ecore_evas_geometry_get(e_comp->ee, NULL, NULL, &w, &h);
@@ -1175,10 +1035,9 @@ e_comp_screen_init()
      ELOGF("E_EGL_SYNC", "Enabled the E_Egl_Sync", NULL);
    e_main_ts_end("\tE_Egl_Sync Init Done");
 
-   e_main_ts_begin("\tE_Explicit_Sync Init");
-   if (e_explicit_sync_init())
-     ELOGF("EX-SYNC", "Enabled the E_Explicit_Sync", NULL);
-   e_main_ts_end("\tE_Explicit_Sync Init Done");
+   e_main_ts_begin("\tE_Linux_Dmabuf Init");
+   e_linux_dmabuf_init(e_comp_wl->wl.disp);
+   e_main_ts_end("\tE_Linux_Dmabuf Init Done");
 
    /* pointer */
    e_input_device_pointer_xy_get(NULL, &ptr_x, &ptr_y);
@@ -1212,11 +1071,9 @@ e_comp_screen_init()
         e_main_ts_begin("\tE_Comp_WL Keymap Init Done");
      }
 
-   /* try to add tizen_video to wayland globals */
-   if (!wl_global_create(e_comp_wl->wl.disp, &tizen_screen_rotation_interface, 1,
-                         NULL, _tz_screen_rotation_cb_bind))
+   if (!e_screen_rotation_init())
      {
-        ERR("Could not add tizen_screen_rotation to wayland globals");
+        e_main_ts_end("\e_screen_rotation_init Init Failed");
         goto failed_comp_screen;
      }
 
@@ -1248,6 +1105,7 @@ e_comp_screen_init()
 
 failed_comp_screen:
 
+   e_screen_rotation_shutdown();
    e_comp_wl_tizen_hwc_shutdown();
    e_input_shutdown();
    _e_comp_screen_engine_deinit();
@@ -1261,6 +1119,7 @@ e_comp_screen_shutdown()
    if (!e_comp) return;
    if (!e_comp->e_comp_screen) return;
 
+   e_screen_rotation_shutdown();
    e_comp_wl_tizen_hwc_shutdown();
 
    if (e_comp_screen_iface)
@@ -1281,9 +1140,6 @@ e_comp_screen_shutdown()
 
    E_FREE_LIST(output_hooks, e_output_hook_del);
 
-   e_client_hook_del(tzsr_client_hook_del);
-   tzsr_client_hook_del = NULL;
-
    E_FREE_LIST(event_handlers, ecore_event_handler_del);
 
    /* delete e_comp_sreen */
@@ -1418,38 +1274,24 @@ e_comp_screen_rotation_setting_set(E_Comp_Screen *e_comp_screen, int rotation)
 E_API void
 e_comp_screen_rotation_ignore_output_transform_send(E_Client *ec, Eina_Bool ignore)
 {
-   E_Comp_Screen_Tzsr *tzsr = _tz_surface_rotation_find(ec);
-   E_Comp_Wl_Client_Data *cdata;
-
-   if (!tzsr) return;
-
    /* if client have to considers the output transform */
    if (!ignore)
      {
         /* exception */
         if (e_config->screen_rotation_client_ignore)
           {
-             ELOGF("TRANSFORM", "|tzsr(%p) ignore_output_transform: client_ignore", ec, tzsr);
+             ELOGF("TRANSFORM", "|ignore_output_transform: client_ignore", ec);
              return;
           }
 
         if (e_policy_client_is_quickpanel(ec))
            {
-              ELOGF("TRANSFORM", "|tzsr(%p) ignore_output_transform: quickpanel", ec, tzsr);
+              ELOGF("TRANSFORM", "|ignore_output_transform: quickpanel", ec);
               return;
            }
      }
 
-   ELOGF("TRANSFORM", "|tzsr(%p) ignore_output_transform(%d)", ec, tzsr, ignore);
-
-   cdata = e_client_cdata_get(ec);
-   tizen_screen_rotation_send_ignore_output_transform(tzsr->resource, cdata->surface, ignore);
-}
-
-EINTERN Eina_Bool
-e_comp_screen_rotation_ignore_output_transform_watch(E_Client *ec)
-{
-   return (_tz_surface_rotation_find(ec)) ? EINA_TRUE : EINA_FALSE;
+   e_screen_rotation_ignore_output_transform_send(ec, ignore);
 }
 
 EINTERN E_Output *