conformant: Add module to handle conformant.
authorSeunghun Lee <shiin.lee@samsung.com>
Thu, 23 Jun 2016 06:13:09 +0000 (15:13 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Tue, 28 Jun 2016 08:41:55 +0000 (17:41 +0900)
Change-Id: I5339a73b97c58897e56801680e55a0bfebdefa46

src/Makefile.am
src/e_mod_conformant.c [new file with mode: 0644]
src/e_mod_conformant.h [new file with mode: 0644]
src/e_mod_main.c
src/e_mod_wl.c
src/e_mod_wl.h

index f0de5cac756954bcbc839a91bf2ed57d7c988167..24e2aaf6f53d60ac249a7e48cf09db30c6110747 100644 (file)
@@ -59,6 +59,8 @@ module_la_SOURCES      = e_mod_config.c \
                          e_mod_private_data.h \
                          e_mod_transform_mode.c \
                          e_mod_transform_mode.h \
+                         e_mod_conformant.c \
+                         e_mod_conformant.h \
                          $(WL_SRC) \
                          $(ROT_SRC) \
                          $(SRVS_SRC)
diff --git a/src/e_mod_conformant.c b/src/e_mod_conformant.c
new file mode 100644 (file)
index 0000000..9352761
--- /dev/null
@@ -0,0 +1,508 @@
+#include "e_mod_main.h"
+
+#include <wayland-server.h>
+#include <tizen-extension-server-protocol.h>
+
+#define CFDBG(f, x...)  DBG("Conformant|"f, ##x)
+#define CFINF(f, x...)  INF("Conformant|"f, ##x)
+#define CFERR(f, x...)  ERR("Conformant|"f, ##x)
+
+#define CONF_DATA_GET(ptr)             \
+   Conformant *ptr = _conf_data_get()
+#define CONF_DATA_GET_OR_RETURN(ptr)   \
+   CONF_DATA_GET(ptr);                 \
+   if (!ptr)                           \
+   {                                   \
+      CFERR("no conformant data");     \
+      return;                          \
+   }
+#define CONF_DATA_GET_OR_RETURN_VAL(ptr, val)   \
+   CONF_DATA_GET(ptr);                          \
+   if (!ptr)                                    \
+   {                                            \
+      CFERR("no conformant data");              \
+      return val;                               \
+   }
+
+typedef struct
+{
+   E_Client *vkbd;
+   Eina_Hash *client_hash;
+   Eina_List *handlers;
+   E_Client_Hook *client_del_hook;
+   Ecore_Idle_Enterer *idle_enterer;
+
+   struct
+   {
+      Eina_Bool restore;
+      Eina_Bool visible;
+      int x, y, w, h;
+   } state;
+
+   Eina_Bool changed : 1;
+} Conformant;
+
+typedef struct
+{
+   E_Client *ec;
+   Eina_List *res_list;
+} Conformant_Client;
+
+typedef struct
+{
+   Conformant_Client *cfc;
+   struct wl_resource *res;
+   struct wl_listener destroy_listener;
+} Conformant_Wl_Res;
+
+Conformant *_conf = NULL;
+
+static Conformant *
+_conf_data_get()
+{
+   return _conf;
+}
+
+static void
+_conf_cb_vkbd_obj_del(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   Conformant *conf;
+
+   CFDBG("VKBD Deleted");
+   conf = data;
+   conf->vkbd = NULL;
+}
+
+static void
+_conf_cb_vkbd_obj_show(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   Conformant *conf;
+
+   CFDBG("VKBD Show");
+   conf = data;
+   conf->changed = 1;
+}
+
+static void
+_conf_cb_vkbd_obj_hide(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   Conformant *conf;
+
+   CFDBG("VKBD Hide");
+   conf = data;
+   conf->changed = 1;
+}
+
+static void
+_conf_cb_vkbd_obj_move(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   Conformant *conf;
+
+   CFDBG("VKBD Move");
+   conf = data;
+   conf->changed = 1;
+}
+
+static void
+_conf_cb_vkbd_obj_resize(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   Conformant *conf;
+
+   CFDBG("VKBD Resize");
+   conf = data;
+   conf->changed = 1;
+}
+
+static void
+_conf_client_del(Conformant_Client *cfc)
+{
+   Conformant_Wl_Res *cres;
+
+   EINA_LIST_FREE(cfc->res_list, cres)
+     {
+        wl_list_remove(&cres->destroy_listener.link);
+        free(cres);
+     }
+
+   free(cfc);
+}
+
+static void
+_conf_client_resource_destroy(struct wl_listener *listener, void *data)
+{
+   Conformant_Wl_Res *cres;
+
+   cres = container_of(listener, Conformant_Wl_Res, destroy_listener);
+   if (!cres)
+     return;
+
+   CFDBG("Destroy Wl Resource res %p owner %s(%p)",
+         cres->res, cres->cfc->ec->icccm.name ? cres->cfc->ec->icccm.name : "", cres->cfc->ec);
+
+   cres->cfc->res_list = eina_list_remove(cres->cfc->res_list, cres);
+
+   free(cres);
+}
+
+static void
+_conf_client_resource_add(Conformant_Client *cfc, struct wl_resource *res)
+{
+   Conformant_Wl_Res *cres;
+   Eina_List *l;
+
+   if (cfc->res_list)
+     {
+        EINA_LIST_FOREACH(cfc->res_list, l, cres)
+          {
+             if (cres->res == res)
+               {
+                  CFERR("Already Added Resource, Nothing to do. res: %p", res);
+                  return;
+               }
+          }
+     }
+
+   cres = E_NEW(Conformant_Wl_Res, 1);
+   if (!cres)
+     return;
+
+   cres->cfc = cfc;
+   cres->res = res;
+   cres->destroy_listener.notify = _conf_client_resource_destroy;
+   wl_resource_add_destroy_listener(res, &cres->destroy_listener);
+
+   cfc->res_list = eina_list_append(cfc->res_list, cres);
+}
+
+static Conformant_Client *
+_conf_client_add(Conformant *conf, E_Client *ec, struct wl_resource *res)
+{
+   Conformant_Client *cfc;
+
+   cfc = E_NEW(Conformant_Client, 1);
+   if (!cfc)
+     return NULL;
+
+   cfc->ec = ec;
+
+   _conf_client_resource_add(cfc, res);
+
+   return cfc;
+}
+
+static void
+_conf_state_update(Conformant *conf, Eina_Bool visible, int x, int y, int w, int h)
+{
+   Conformant_Client *cfc;
+   Conformant_Wl_Res *cres;
+   Eina_Iterator *itr;
+   Eina_List *l;
+
+   if ((conf->state.visible == visible) &&
+       (conf->state.x == x) && (conf->state.x == y) &&
+       (conf->state.x == w) && (conf->state.x == h))
+     return;
+
+   CFDBG("Update Conformant State\n");
+   CFDBG("\tprev: v %d geom %d %d %d %d\n",
+       conf->state.visible, conf->state.x, conf->state.y, conf->state.w, conf->state.h);
+   CFDBG("\tnew : v %d geom %d %d %d %d\n", visible, x, y, w, h);
+
+   itr = eina_hash_iterator_data_new(conf->client_hash);
+   EINA_ITERATOR_FOREACH(itr, cfc)
+     {
+        if (!cfc->ec) continue;
+        if (!cfc->ec->comp_data) continue;
+
+        CFDBG("\t=> '%s'(%p)", cfc->ec ? (cfc->ec->icccm.name ?:"") : "", cfc->ec);
+        EINA_LIST_FOREACH(cfc->res_list, l, cres)
+          {
+             tizen_policy_send_conformant_area
+                (cres->res,
+                 cfc->ec->comp_data->surface,
+                 TIZEN_POLICY_CONFORMANT_PART_KEYBOARD,
+                 (unsigned int)visible, x, y, w, h);
+          }
+     }
+   eina_iterator_free(itr);
+
+   conf->state.visible = visible;
+   conf->state.x = x;
+   conf->state.y = y;
+   conf->state.w = w;
+   conf->state.h = h;
+}
+
+static void
+_conf_vkbd_register(Conformant *conf, E_Client *ec)
+{
+   CFINF("VKBD Registered");
+   if (conf->vkbd)
+     {
+        CFERR("Something strange error, VKBD Already Registered.");
+        return;
+     }
+   conf->vkbd = ec;
+
+   evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_DEL,      _conf_cb_vkbd_obj_del,     conf);
+   evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW,     _conf_cb_vkbd_obj_show,    conf);
+   evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE,     _conf_cb_vkbd_obj_hide,    conf);
+   evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE,     _conf_cb_vkbd_obj_move,    conf);
+   evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_RESIZE,   _conf_cb_vkbd_obj_resize,  conf);
+}
+
+static Eina_Bool
+_conf_cb_client_add(void *data, int type EINA_UNUSED, void *event)
+{
+   Conformant *conf;
+   E_Event_Client *ev;
+
+   conf = data;
+   ev = event;
+
+   if (ev->ec->vkbd.vkbd)
+     _conf_vkbd_register(conf, ev->ec);
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_conf_cb_client_rot_change_begin(void *data, int type EINA_UNUSED, void *event)
+{
+   Conformant *conf;
+   E_Event_Client *ev;
+
+   ev = event;
+   conf = data;
+
+   if (ev->ec != conf->vkbd)
+     goto end;
+
+   /* set conformant area to non-visible state before starting rotation.
+    * this is to prevent to apply wrong area of conformant area after rotation.
+    * Suppose conformant area will be set later according to changes of vkbd such as resize or move.
+    * if there is no being called rot_change_cancel and nothing changes vkbd,
+    * that is unexpected case.
+    */
+   if (conf->state.visible)
+     {
+        CFDBG("Rotation Begin");
+        _conf_state_update(conf, EINA_FALSE, conf->state.x, conf->state.y, conf->state.w, conf->state.h);
+        conf->state.restore = EINA_TRUE;
+     }
+
+end:
+   return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_conf_cb_client_rot_change_cancel(void *data, int type EINA_UNUSED, void *event)
+{
+   Conformant *conf;
+   E_Event_Client *ev;
+
+   ev = event;
+   conf = data;
+
+   if (ev->ec != conf->vkbd)
+     goto end;
+
+   if (conf->state.restore)
+     {
+        CFDBG("Rotation Cancel");
+        _conf_state_update(conf, EINA_FALSE, conf->state.x, conf->state.y, conf->state.w, conf->state.h);
+        conf->state.restore = EINA_TRUE;
+     }
+
+end:
+   return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_conf_cb_client_rot_change_end(void *data, int type EINA_UNUSED, void *event)
+{
+   Conformant *conf;
+   E_Event_Client *ev;
+
+   ev = event;
+   conf = data;
+
+   if (ev->ec != conf->vkbd)
+     goto end;
+
+   conf->state.restore = EINA_FALSE;
+
+end:
+   return ECORE_CALLBACK_PASS_ON;
+}
+
+static void
+_conf_cb_client_del(void *data, E_Client *ec)
+{
+   Conformant *conf;
+   Conformant_Client *cfc;
+
+   conf = data;
+   if (!conf->client_hash)
+     return;
+
+   cfc = eina_hash_find(conf->client_hash, &ec);
+   if (!cfc)
+     return;
+
+   eina_hash_del(conf->client_hash, &ec, cfc);
+   _conf_client_del(cfc);
+}
+
+static Eina_Bool
+_conf_idle_enter(void *data)
+{
+   Conformant *conf;
+   Eina_Bool visible;
+   int x, y, w, h;
+
+   conf = data;
+   if (!conf->vkbd)
+     goto end;
+
+   if (conf->changed)
+     {
+        visible = evas_object_visible_get(conf->vkbd->frame);
+        evas_object_geometry_get(conf->vkbd->frame, &x, &y, &w, &h);
+
+        _conf_state_update(conf, visible, x, y, w, h);
+
+        conf->changed = EINA_FALSE;
+     }
+
+end:
+   return ECORE_CALLBACK_PASS_ON;
+}
+
+static void
+_conf_event_init(Conformant *conf)
+{
+   E_LIST_HANDLER_APPEND(conf->handlers, E_EVENT_CLIENT_ADD,                     _conf_cb_client_add,                conf);
+   E_LIST_HANDLER_APPEND(conf->handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN,   _conf_cb_client_rot_change_begin,   conf);
+   E_LIST_HANDLER_APPEND(conf->handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL,  _conf_cb_client_rot_change_cancel,  conf);
+   E_LIST_HANDLER_APPEND(conf->handlers, E_EVENT_CLIENT_ROTATION_CHANGE_END,     _conf_cb_client_rot_change_end,     conf);
+
+   conf->client_del_hook = e_client_hook_add(E_CLIENT_HOOK_DEL, _conf_cb_client_del, conf);
+   conf->idle_enterer = ecore_idle_enterer_add(_conf_idle_enter, conf);
+}
+
+static void
+_conf_event_shutdown(Conformant *conf)
+{
+   E_FREE_LIST(conf->handlers, ecore_event_handler_del);
+   E_FREE_FUNC(conf->client_del_hook, e_client_hook_del);
+   E_FREE_FUNC(conf->idle_enterer, ecore_idle_enterer_del);
+}
+
+EINTERN void
+e_mod_conformant_client_add(E_Client *ec, struct wl_resource *res)
+{
+   Conformant_Client *cfc;
+
+   CONF_DATA_GET_OR_RETURN(conf);
+
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+
+   CFDBG("Client Add '%s'(%p)", ec->icccm.name ? ec->icccm.name : "", ec);
+
+   if (conf->client_hash)
+     {
+        cfc = eina_hash_find(conf->client_hash, &ec);
+        if (cfc)
+          {
+             CFDBG("Already Added Client, Just Add Resource");
+             _conf_client_resource_add(cfc, res);
+             return;
+          }
+     }
+
+   cfc = _conf_client_add(conf, ec, res);
+
+   /* do we need to send conformant state if vkbd is visible ? */
+
+   if (!conf->client_hash)
+     conf->client_hash = eina_hash_pointer_new(NULL);
+
+   eina_hash_add(conf->client_hash, &ec, cfc);
+}
+
+EINTERN void
+e_mod_conformant_client_del(E_Client *ec)
+{
+   Conformant_Client *cfc;
+
+   CONF_DATA_GET_OR_RETURN(conf);
+
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+
+   CFDBG("Client Del '%s'(%p)", ec->icccm.name ? ec->icccm.name : "", ec);
+
+   cfc = eina_hash_find(conf->client_hash, &ec);
+   if (cfc)
+     {
+        eina_hash_del(conf->client_hash, &ec, cfc);
+        _conf_client_del(cfc);
+     }
+}
+
+EINTERN Eina_Bool
+e_mod_conformant_client_check(E_Client *ec)
+{
+   CONF_DATA_GET_OR_RETURN_VAL(conf, EINA_FALSE);
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
+
+   if (!conf->client_hash)
+     return EINA_FALSE;
+
+   return !!eina_hash_find(conf->client_hash, &ec);
+}
+
+EINTERN Eina_Bool
+e_mod_conformant_init(void)
+{
+   Conformant *conf;
+
+   if (_conf)
+     return EINA_TRUE;
+
+   CFINF("Conformant Module Init");
+
+   conf = E_NEW(Conformant, 1);
+   if (!conf)
+     return EINA_FALSE;
+
+   _conf_event_init(conf);
+
+   _conf = conf;
+
+   return EINA_TRUE;
+}
+
+EINTERN void
+e_mod_conformant_shutdown(void)
+{
+   Conformant_Client *cfc;
+   Eina_Iterator *itr;
+
+   if (!_conf)
+     return;
+
+   CFINF("Conformant Module Shutdown");
+
+   _conf_event_shutdown(_conf);
+
+   itr = eina_hash_iterator_data_new(_conf->client_hash);
+   EINA_ITERATOR_FOREACH(itr, cfc)
+      _conf_client_del(cfc);
+   eina_iterator_free(itr);
+
+   E_FREE_FUNC(_conf->client_hash, eina_hash_free);
+
+   E_FREE(_conf);
+}
diff --git a/src/e_mod_conformant.h b/src/e_mod_conformant.h
new file mode 100644 (file)
index 0000000..01c60a0
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef _E_MOD_CONFORMANT_H_
+#define _E_MOD_CONFORMANT_H_
+
+EINTERN Eina_Bool  e_mod_conformant_init(void);
+EINTERN void       e_mod_conformant_shutdown(void);
+EINTERN void       e_mod_conformant_client_add(E_Client *ec, struct wl_resource *res);
+EINTERN void       e_mod_conformant_client_del(E_Client *ec);
+EINTERN Eina_Bool  e_mod_conformant_client_check(E_Client *ec);
+
+#endif
index 806ee1342577e3069c437275e53d6d79282c88dc..da55d015883a38d2dd7c9a62dbab2ec745087d06 100644 (file)
@@ -2,6 +2,7 @@
 #include "e_mod_rotation.h"
 #include "e_mod_keyboard.h"
 #include "e_mod_transform_mode.h"
+#include "e_mod_conformant.h"
 #ifdef HAVE_WAYLAND_ONLY
 #include "e_mod_wl.h"
 #endif
@@ -36,7 +37,6 @@ static void        _pol_cb_hook_client_eval_pre_post_fetch(void *d EINA_UNUSED,
 static void        _pol_cb_hook_client_eval_post_fetch(void *d EINA_UNUSED, E_Client *ec);
 static void        _pol_cb_hook_client_eval_post_new_client(void *d EINA_UNUSED, E_Client *ec);
 static void        _pol_cb_hook_client_desk_set(void *d EINA_UNUSED, E_Client *ec);
-static void        _pol_cb_hook_client_eval_end(void *d EINA_UNUSED, E_Client *ec);
 static void        _pol_cb_hook_client_fullscreen_pre(void *data EINA_UNUSED, E_Client *ec);
 
 static void        _pol_cb_hook_pixmap_del(void *data EINA_UNUSED, E_Pixmap *cp);
@@ -51,7 +51,6 @@ static Eina_Bool   _pol_cb_zone_desk_count_set(void *data EINA_UNUSED, int type
 static Eina_Bool   _pol_cb_zone_display_state_change(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
 static Eina_Bool   _pol_cb_desk_show(void *data EINA_UNUSED, int type EINA_UNUSED, void *event);
 static Eina_Bool   _pol_cb_client_add(void *data EINA_UNUSED, int type, void *event);
-static Eina_Bool   _pol_cb_client_iconify(void *data EINA_UNUSED, int type, void *event);
 static Eina_Bool   _pol_cb_client_move(void *data EINA_UNUSED, int type, void *event);
 static Eina_Bool   _pol_cb_client_resize(void *data EINA_UNUSED, int type, void *event);
 static Eina_Bool   _pol_cb_client_stack(void *data EINA_UNUSED, int type, void *event);
@@ -595,28 +594,6 @@ _pol_cb_hook_client_desk_set(void *d EINA_UNUSED, E_Client *ec)
      _pol_client_maximize_policy_cancel(pc);
 }
 
-static void
-_pol_cb_hook_client_eval_end(void *d EINA_UNUSED, E_Client *ec)
-{
-   Pol_Client *pc;
-
-   /* calculate e_client visibility */
-   e_client_visibility_calculate();
-
-   if (e_mod_pol_client_is_keyboard(ec))
-     {
-        pc = eina_hash_find(hash_pol_clients, &ec);
-        if (pc)
-          {
-             if (pc->changes.vkbd_state)
-               {
-                  e_mod_pol_wl_keyboard_geom_broadcast(ec);
-                  pc->changes.vkbd_state = 0;
-               }
-          }
-     }
-}
-
 static void
 _pol_cb_hook_client_fullscreen_pre(void* data EINA_UNUSED, E_Client *ec)
 {
@@ -882,110 +859,16 @@ _pol_cb_client_add(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
    return ECORE_CALLBACK_PASS_ON;
 }
 
-static Eina_Bool
-_pol_cb_client_iconify(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
-{
-   E_Event_Client *ev;
-   Pol_Client *pc;
-
-   ev = event;
-   EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON);
-
-#ifdef HAVE_WAYLAND_ONLY
-   if (e_mod_pol_client_is_keyboard(ev->ec))
-     {
-        pc = eina_hash_find(hash_pol_clients, &ev->ec);
-        if (pc)
-          {
-             if (!pc->changes.already_hide)
-               {
-                  pc->changes.vkbd_state = 1;
-                  pc->changes.already_hide = 1;
-                  EC_CHANGED(ev->ec);
-               }
-          }
-     }
-#endif
-
-   return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool
-_pol_cb_client_show(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
-{
-   E_Event_Client *ev;
-   Pol_Client *pc;
-
-   ev = event;
-   if (!ev) goto end;
-
-#ifdef HAVE_WAYLAND_ONLY
-   if (e_mod_pol_client_is_keyboard(ev->ec))
-     {
-        pc = eina_hash_find(hash_pol_clients, &ev->ec);
-        if (pc)
-          {
-             pc->changes.vkbd_state = 1;
-             pc->changes.already_hide = 0;
-             EC_CHANGED(ev->ec);
-          }
-     }
-#endif
-
-end:
-   return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool
-_pol_cb_client_hide(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
-{
-   E_Event_Client *ev;
-   Pol_Client *pc;
-
-   ev = event;
-   if (!ev) goto end;
-
-#ifdef HAVE_WAYLAND_ONLY
-   if (e_mod_pol_client_is_keyboard(ev->ec))
-     {
-        pc = eina_hash_find(hash_pol_clients, &ev->ec);
-        if (pc)
-          {
-             if (!pc->changes.already_hide)
-               {
-                  pc->changes.vkbd_state = 1;
-                  pc->changes.already_hide = 1;
-                  EC_CHANGED(ev->ec);
-               }
-          }
-     }
-#endif
-
-end:
-   return ECORE_CALLBACK_PASS_ON;
-}
-
 static Eina_Bool
 _pol_cb_client_move(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
 {
    E_Event_Client *ev;
-   Pol_Client *pc;
 
    ev = event;
    if (!ev) goto end;
 
 #ifdef HAVE_WAYLAND_ONLY
    e_mod_pol_wl_position_send(ev->ec);
-
-   if (e_mod_pol_client_is_keyboard(ev->ec))
-     {
-        pc = eina_hash_find(hash_pol_clients, &ev->ec);
-        if (pc)
-          {
-             pc->changes.vkbd_state = 1;
-             EC_CHANGED(ev->ec);
-          }
-     }
 #endif
    e_client_visibility_calculate();
 
@@ -998,7 +881,6 @@ _pol_cb_client_resize(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
 {
    E_Event_Client *ev;
    E_Client *ec;
-   Pol_Client *pc;
    int zh = 0;
 
    ev = (E_Event_Client *)event;
@@ -1007,20 +889,6 @@ _pol_cb_client_resize(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
    ec = ev->ec;
    EINA_SAFETY_ON_NULL_RETURN_VAL(ec, ECORE_CALLBACK_PASS_ON);
 
-   if (e_mod_pol_client_is_keyboard(ec))
-     {
-#ifdef HAVE_WAYLAND_ONLY
-        pc = eina_hash_find(hash_pol_clients, &ec);
-        if (pc)
-          {
-             pc->changes.vkbd_state = 1;
-             EC_CHANGED(ec);
-          }
-#else
-        ;
-#endif
-     }
-
    /* re-calculate window's position with changed size */
    if (e_mod_pol_client_is_volume_tv(ec))
      {
@@ -1497,14 +1365,11 @@ e_modapi_init(E_Module *m)
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_DISPLAY_STATE_CHANGE, _pol_cb_zone_display_state_change,       NULL);
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_DESK_SHOW,                 _pol_cb_desk_show,                       NULL);
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ADD,                _pol_cb_client_add,                      NULL);
-   E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_SHOW,               _pol_cb_client_show,                     NULL);
-   E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_HIDE,               _pol_cb_client_hide,                     NULL);
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_MOVE,               _pol_cb_client_move,                     NULL);
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_RESIZE,             _pol_cb_client_resize,                   NULL);
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_STACK,              _pol_cb_client_stack,                    NULL);
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_PROPERTY,           _pol_cb_client_property,                 NULL);
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_VISIBILITY_CHANGE,  _pol_cb_client_vis_change,               NULL);
-   E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ICONIFY,            _pol_cb_client_iconify,                  NULL);
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_MODULE_DEFER_JOB,          _pol_cb_module_defer_job,                NULL);
 
    E_CLIENT_HOOK_APPEND(hooks_ec,  E_CLIENT_HOOK_NEW_CLIENT,          _pol_cb_hook_client_new,                 NULL);
@@ -1515,7 +1380,6 @@ e_modapi_init(E_Module *m)
    E_CLIENT_HOOK_APPEND(hooks_ec,  E_CLIENT_HOOK_EVAL_POST_FETCH,     _pol_cb_hook_client_eval_post_fetch,     NULL);
    E_CLIENT_HOOK_APPEND(hooks_ec,  E_CLIENT_HOOK_EVAL_POST_NEW_CLIENT,_pol_cb_hook_client_eval_post_new_client,NULL);
    E_CLIENT_HOOK_APPEND(hooks_ec,  E_CLIENT_HOOK_DESK_SET,            _pol_cb_hook_client_desk_set,            NULL);
-   E_CLIENT_HOOK_APPEND(hooks_ec,  E_CLIENT_HOOK_EVAL_END,            _pol_cb_hook_client_eval_end,            NULL);
    E_CLIENT_HOOK_APPEND(hooks_ec,  E_CLIENT_HOOK_FULLSCREEN_PRE,      _pol_cb_hook_client_fullscreen_pre,      NULL);
    E_CLIENT_HOOK_APPEND(hooks_ec,  E_CLIENT_HOOK_EVAL_VISIBILITY,     _pol_cb_hook_client_visibility,          NULL);
 
@@ -1524,6 +1388,7 @@ e_modapi_init(E_Module *m)
 
    e_mod_pol_rotation_init();
    e_mod_transform_mode_init();
+   e_mod_conformant_init();
 
    return mod;
 }
@@ -1564,6 +1429,7 @@ e_modapi_shutdown(E_Module *m)
 
    e_mod_pol_conf_shutdown(mod);
    e_mod_transform_mode_shutdown();
+   e_mod_conformant_shutdown();
 
    E_FREE(mod);
 
index bca97375c9e437032a25ca52bef5934714788cb9..28a276105ef8668fe73e6db453da3930c916ee7b 100644 (file)
@@ -4,6 +4,7 @@
 #include "e_mod_volume.h"
 #include "e_mod_lockscreen.h"
 #include "e_mod_wl_display.h"
+#include "e_mod_conformant.h"
 
 #include <device/display.h>
 #include <wayland-server.h>
@@ -164,13 +165,6 @@ typedef struct _Pol_Wl
 #endif
 } Pol_Wl;
 
-typedef struct _Pol_Wl_Conformant
-{
-   Eina_Bool saved_visible;
-   Eina_Bool visible;
-   Eina_Rectangle rect;
-} Pol_Wl_Conformant;
-
 typedef struct _E_Tzsh_QP_Event
 {
    int type;
@@ -183,13 +177,6 @@ static Eina_List *handlers = NULL;
 static Eina_List *hooks_cw = NULL;
 static struct wl_resource *_scrsaver_mng_res = NULL; // TODO
 
-static Pol_Wl_Conformant conformant =
-{
-   EINA_FALSE,
-   EINA_FALSE,
-   {0, 0, 0, 0},
-};
-
 enum _WM_Policy_Hint_Type
 {
    WM_POLICY_HINT_USER_GEOMETRY = 0,
@@ -1480,132 +1467,37 @@ _tzpol_iface_cb_type_set(struct wl_client *client EINA_UNUSED, struct wl_resourc
 // --------------------------------------------------------
 // conformant
 // --------------------------------------------------------
-
-/* TODO
- * It's better to place calling tizen_policy_send_conformant_area() in idle enterer.
- * that's how we reduce the IPC which can make unnecessary job to client side.
- */
-static void
-_tzpol_conformant_state_send(Pol_Wl_Surface *psurf)
-{
-   if (EINA_UNLIKELY(!psurf->tzpol))
-     return;
-
-   if (EINA_UNLIKELY(!psurf->tzpol->res_tzpol))
-     return;
-
-   DBG("Conformant: Send State Changed \"%s\" %d %d %d %d",
-       conformant.visible? "SHOW" : "HIDDEN",
-       conformant.rect.x, conformant.rect.y, conformant.rect.w, conformant.rect.h);
-
-   tizen_policy_send_conformant_area
-      (psurf->tzpol->res_tzpol,
-       psurf->surf,
-       TIZEN_POLICY_CONFORMANT_PART_KEYBOARD,
-       (unsigned int)conformant.visible,
-       conformant.rect.x, conformant.rect.y,
-       conformant.rect.w, conformant.rect.h);
-}
-
-static void
-_tzpol_conformant_state_set(Eina_Bool visible, Eina_Rectangle *rect)
-{
-   Pol_Wl_Tzpol *tzpol;
-   Pol_Wl_Surface *psurf;
-   E_Client *ec;
-   Eina_Bool r;
-   Eina_List *l;
-   Eina_Iterator *it;
-
-   if ((conformant.visible == visible) &&
-       (conformant.rect.x == rect->x) &&
-       (conformant.rect.y == rect->h) &&
-       (conformant.rect.w == rect->w) &&
-       (conformant.rect.h == rect->h))
-     return;
-
-   conformant.visible = conformant.saved_visible = visible;
-   EINA_RECTANGLE_SET(&conformant.rect, rect->x, rect->y, rect->w, rect->h);
-
-   it = eina_hash_iterator_data_new(polwl->tzpols);
-   EINA_ITERATOR_FOREACH(it, tzpol)
-     EINA_LIST_FOREACH(tzpol->psurfs, l, psurf)
-       {
-          ec = e_pixmap_client_get(psurf->cp);
-          if (!ec) continue;
-
-          r = e_client_util_ignored_get(ec);
-          if (r) continue;
-
-          r = e_mod_pol_client_is_conformant(ec);
-          if (!r) continue;
-
-          _tzpol_conformant_state_send(psurf);
-       }
-   eina_iterator_free(it);
-}
-
 static void
 _tzpol_iface_cb_conformant_set(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf)
 {
    E_Client *ec;
-   Pol_Wl_Surface *psurf;
 
    ec = wl_resource_get_user_data(surf);
    EINA_SAFETY_ON_NULL_RETURN(ec);
 
-   psurf = _pol_wl_surf_add(ec, res_tzpol);
-   EINA_SAFETY_ON_NULL_RETURN(psurf);
-
-   if (!ec->comp_data->conformant)
-     {
-        ec->comp_data->conformant = 1;
-        EC_CHANGED(ec);
-        /* do we need to send conformant state if vkbd is visible ? */
-     }
+   e_mod_conformant_client_add(ec, res_tzpol);
 }
 
 static void
 _tzpol_iface_cb_conformant_unset(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol EINA_UNUSED, struct wl_resource *surf)
 {
    E_Client *ec;
-   Pol_Wl_Surface *psurf;
 
    ec = wl_resource_get_user_data(surf);
    EINA_SAFETY_ON_NULL_RETURN(ec);
 
-   psurf = _pol_wl_surf_add(ec, res_tzpol);
-   EINA_SAFETY_ON_NULL_RETURN(psurf);
-
-   if (ec->comp_data->conformant)
-     {
-        ec->comp_data->conformant = 0;
-        EC_CHANGED(ec);
-     }
+   e_mod_conformant_client_del(ec);
 }
 
 static void
 _tzpol_iface_cb_conformant_get(struct wl_client *client EINA_UNUSED, struct wl_resource *res_tzpol, struct wl_resource *surf)
 {
    E_Client *ec;
-   Pol_Wl_Surface *psurf;
 
    ec = wl_resource_get_user_data(surf);
    EINA_SAFETY_ON_NULL_RETURN(ec);
 
-   psurf = _pol_wl_surf_add(ec, res_tzpol);
-   EINA_SAFETY_ON_NULL_RETURN(psurf);
-
-   tizen_policy_send_conformant(res_tzpol, surf, ec->comp_data->conformant);
-}
-
-void
-e_mod_pol_wl_keyboard_geom_broadcast(E_Client *ec)
-{
-   Eina_Rectangle rect;
-
-   EINA_RECTANGLE_SET(&rect, ec->x, ec->y, ec->client.w, ec->client.h);
-   _tzpol_conformant_state_set(evas_object_visible_get(ec->frame), &rect);
+   tizen_policy_send_conformant(res_tzpol, surf, e_mod_conformant_client_check(ec));
 }
 
 // --------------------------------------------------------
@@ -4307,55 +4199,6 @@ _pol_wl_cb_scrsaver_off(void *data EINA_UNUSED, int type EINA_UNUSED, void *even
    return ECORE_CALLBACK_PASS_ON;
 }
 
-static Eina_Bool
-_pol_wl_cb_client_rot_change_begin(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
-{
-   E_Event_Client *ev;
-
-   ev = event;
-   if (EINA_UNLIKELY((!ev) || (!ev->ec)))
-     goto end;
-
-   if (!ev->ec->vkbd.vkbd)
-     goto end;
-
-   /* set conformant area to non-visible state before starting rotation.
-    * this is to prevent to apply wrong area of conformant area after rotation.
-    * Suppose conformant area will be set later according to changes of vkbd
-    * such as resize or move.
-    * if there is no being called rot_change_cancel and nothing changes vkbd,
-    * that is unexpected case.
-    * TODO we need to add handler of rotation_change_end for handling
-    * in case nothing changes in vkbd.
-    */
-   if (conformant.visible)
-     {
-        _tzpol_conformant_state_set(EINA_FALSE, &conformant.rect);
-        conformant.saved_visible = EINA_TRUE;
-     }
-end:
-   return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool
-_pol_wl_cb_client_rot_change_cancel(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
-{
-   E_Event_Client *ev;
-
-   ev = event;
-   if (EINA_UNLIKELY((!ev) || (!ev->ec)))
-     goto end;
-
-   if (!ev->ec->vkbd.vkbd)
-     goto end;
-
-   /* restore conformant visible state */
-   if (conformant.saved_visible != conformant.visible)
-     _tzpol_conformant_state_set(conformant.saved_visible, &conformant.rect);
-end:
-   return ECORE_CALLBACK_PASS_ON;
-}
-
 static void
 _pol_wl_cb_hook_shell_surface_ready(void *d, E_Client *ec)
 {
@@ -4515,9 +4358,6 @@ e_mod_pol_wl_init(void)
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREENSAVER_ON,  _pol_wl_cb_scrsaver_on,  NULL);
    E_LIST_HANDLER_APPEND(handlers, E_EVENT_SCREENSAVER_OFF, _pol_wl_cb_scrsaver_off, NULL);
 
-   E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN,  _pol_wl_cb_client_rot_change_begin, NULL);
-   E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _pol_wl_cb_client_rot_change_cancel, NULL);
-
    E_COMP_WL_HOOK_APPEND(hooks_cw, E_COMP_WL_HOOK_SHELL_SURFACE_READY, _pol_wl_cb_hook_shell_surface_ready, NULL);
 
    e_mod_pol_display_init();
index cd28679c9e169648930cfc4787ef777563ff5bf7..29d976fe86a0f2d5efd6e9c902e09bb93cac230d 100644 (file)
@@ -23,7 +23,6 @@ void      e_mod_pol_wl_position_send(E_Client *ec);
 
 /* notification */
 void      e_mod_pol_wl_notification_level_fetch(E_Client *ec);
-void      e_mod_pol_wl_keyboard_geom_broadcast(E_Client *ec);
 
 /* window screenmode */
 void      e_mod_pol_wl_win_scrmode_apply(void);