support 'conformant' for wayland 66/42866/1
authorDuna Oh <duna.oh@samsung.com>
Fri, 3 Jul 2015 08:38:52 +0000 (17:38 +0900)
committerDuna Oh <duna.oh@samsung.com>
Fri, 3 Jul 2015 08:40:44 +0000 (17:40 +0900)
if the window is conformant, send keyboard's state and geometry

Change-Id: If6cd26227bd86ae7ff6d5a5565e76c6bd654b436
Signed-off-by: Duna Oh <duna.oh@samsung.com>
src/e_mod_main.c
src/e_mod_main.h
src/e_mod_wl.c
src/e_mod_wl.h
src/e_tizen_policy_server_protocol.c
src/e_tizen_policy_server_protocol.h

index ece3fd4..0626633 100644 (file)
@@ -619,9 +619,28 @@ static Eina_Bool
 _pol_cb_client_resize(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
 {
    E_Event_Client *ev;
+   E_Client *ec;
 
    ev = event;
+   ec = ev->ec;
    if (!ev) return ECORE_CALLBACK_PASS_ON;
+      if (e_mod_pol_client_is_keyboard(ec) ||
+       e_mod_pol_client_is_keyboard_sub(ec))
+     {
+#ifdef HAVE_WAYLAND_ONLY
+        E_Client *comp_ec;
+        E_CLIENT_REVERSE_FOREACH(e_comp, comp_ec)
+          {
+             if (e_client_util_ignored_get(comp_ec)) continue;
+             if (!e_mod_pol_client_is_conformant(comp_ec)) continue;
+             if (ec->visible)
+               e_mod_pol_wl_keyboard_send(comp_ec, EINA_TRUE, ec->x, ec->y, ec->client.w, ec->client.h);
+             else
+               e_mod_pol_wl_keyboard_send(comp_ec, EINA_FALSE, ec->x, ec->y, ec->client.w, ec->client.h);
+          }
+#endif
+     }
+
    /* calculate e_client visibility */
    e_mod_pol_visibility_calc();
 
@@ -828,6 +847,23 @@ e_mod_pol_client_is_quickpanel(E_Client *ec)
    return EINA_FALSE;
 }
 
+Eina_Bool
+e_mod_pol_client_is_conformant(E_Client *ec)
+{
+   E_OBJECT_CHECK_RETURN(ec, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
+
+#ifdef HAVE_WAYLAND_ONLY
+   E_Comp_Wl_Client_Data * cdata = ec->comp_data;
+   if (cdata->conformant == 1)
+     {
+        return EINA_TRUE;
+     }
+#endif
+
+   return EINA_FALSE;
+}
+
 #undef E_CLIENT_HOOK_APPEND
 #define E_CLIENT_HOOK_APPEND(l, t, cb, d) \
   do                                      \
index d085b09..dcc928c 100644 (file)
@@ -110,6 +110,7 @@ EINTERN Pol_Client      *e_mod_pol_client_launcher_get(E_Zone *zone);
 EINTERN Eina_Bool        e_mod_pol_client_is_lock_screen(E_Client *ec);
 EINTERN Eina_Bool        e_mod_pol_client_is_home_screen(E_Client *ec);
 EINTERN Eina_Bool        e_mod_pol_client_is_quickpanel(E_Client *ec);
+EINTERN Eina_Bool        e_mod_pol_client_is_conformant(E_Client *ec);
 
 EINTERN Pol_Softkey     *e_mod_pol_softkey_add(E_Zone *zone);
 EINTERN void             e_mod_pol_softkey_del(Pol_Softkey *softkey);
index a5ca485..f2a9e02 100644 (file)
@@ -19,9 +19,16 @@ typedef struct _Notification_Level
    struct wl_resource *surface;
 } Notification_Level;
 
+typedef struct _Policy_Conformant
+{
+   struct wl_resource *interface;
+   struct wl_resource *surface;
+} Policy_Conformant;
+
 static Eina_Hash *hash_pol_wayland = NULL;
 static Eina_Hash *hash_notification_levels = NULL;
 static Eina_Hash *hash_notification_interfaces = NULL;
+static Eina_Hash *hash_policy_conformants = NULL;
 
 static Pol_Wayland*
 _pol_wayland_get_info (E_Pixmap *ep)
@@ -313,6 +320,103 @@ _e_tizen_policy_cb_role_set(struct wl_client *client EINA_UNUSED,
      }
 }
 
+static void
+_e_tizen_policy_cb_conformant_set(struct wl_client *client,
+                                struct wl_resource *policy,
+                                struct wl_resource *surface_resource)
+{
+   E_Pixmap *ep;
+   E_Client *ec;
+   E_Comp_Wl_Client_Data *cdata;
+   Policy_Conformant *pn;
+
+   ep = wl_resource_get_user_data(surface_resource);
+   EINA_SAFETY_ON_NULL_RETURN(ep);
+
+   ec = e_pixmap_client_get(ep);
+   if (ec)
+     {
+        if (!ec->comp_data->conformant)
+          {
+             ec->comp_data->conformant = 1;
+             EC_CHANGED(ec);
+          }
+     }
+   else
+     {
+        cdata = e_pixmap_cdata_get(ep);
+        EINA_SAFETY_ON_NULL_RETURN(cdata);
+        cdata->conformant = 1;
+     }
+   pn = eina_hash_find(hash_policy_conformants, &surface_resource);
+   if (!pn)
+     {
+        pn = E_NEW(Policy_Conformant, 1);
+        EINA_SAFETY_ON_NULL_RETURN(pn);
+        eina_hash_add(hash_policy_conformants, &surface_resource, pn);
+     }
+
+   pn->interface = policy;
+   pn->surface = surface_resource;
+}
+
+static void
+_e_tizen_policy_cb_conformant_unset(struct wl_client *client,
+                                struct wl_resource *policy,
+                                struct wl_resource *surface_resource)
+{
+   E_Pixmap *ep;
+   E_Client *ec;
+   E_Comp_Wl_Client_Data *cdata;
+
+   ep = wl_resource_get_user_data(surface_resource);
+   EINA_SAFETY_ON_NULL_RETURN(ep);
+
+   ec = e_pixmap_client_get(ep);
+   if (ec)
+     {
+        if (ec->comp_data->conformant)
+          {
+             ec->comp_data->conformant = 0;
+             EC_CHANGED(ec);
+          }
+     }
+   else
+     {
+        cdata = e_pixmap_cdata_get(ep);
+        EINA_SAFETY_ON_NULL_RETURN(cdata);
+        cdata->conformant = 0;
+     }
+}
+
+static void
+_e_tizen_policy_cb_conformant_get(struct wl_client *client,
+                                struct wl_resource *policy,
+                                struct wl_resource *surface_resource)
+{
+   E_Pixmap *ep;
+   E_Client *ec;
+   E_Comp_Wl_Client_Data *cdata;
+   Policy_Conformant *pn;
+
+   ep = wl_resource_get_user_data(surface_resource);
+   EINA_SAFETY_ON_NULL_RETURN(ep);
+
+   pn = eina_hash_find(hash_policy_conformants, &surface_resource);
+   if (pn)
+     {
+        ec = e_pixmap_client_get(ep);
+        if (ec)
+          tizen_policy_send_conformant(pn->interface, surface_resource, ec->comp_data->conformant);
+        else
+          {
+             cdata = e_pixmap_cdata_get(ep);
+             EINA_SAFETY_ON_NULL_RETURN(cdata);
+             tizen_policy_send_conformant(pn->interface, surface_resource, cdata->conformant);
+          }
+     }
+}
+
 static const struct tizen_policy_interface _e_tizen_policy_interface =
 {
    _e_tizen_policy_cb_visibility_get,
@@ -322,6 +426,9 @@ static const struct tizen_policy_interface _e_tizen_policy_interface =
    _e_tizen_policy_cb_focus_skip_set,
    _e_tizen_policy_cb_focus_skip_unset,
    _e_tizen_policy_cb_role_set,
+   _e_tizen_policy_cb_conformant_set,
+   _e_tizen_policy_cb_conformant_unset,
+   _e_tizen_policy_cb_conformant_get,
 };
 
 static void
@@ -469,6 +576,7 @@ e_mod_pol_wl_init(void)
    hash_pol_wayland = eina_hash_pointer_new(free);
    hash_notification_levels = eina_hash_pointer_new(free);
    hash_notification_interfaces = eina_hash_pointer_new(NULL); // do not free by hash_del by key.
+   hash_policy_conformants = eina_hash_pointer_new(free);
 
    return EINA_TRUE;
 }
@@ -479,6 +587,7 @@ e_mod_pol_wl_shutdown(void)
    E_FREE_FUNC(hash_pol_wayland, eina_hash_free);
    E_FREE_FUNC(hash_notification_levels, eina_hash_free);
    E_FREE_FUNC(hash_notification_interfaces, eina_hash_free);
+   E_FREE_FUNC(hash_policy_conformants, eina_hash_free);
 }
 
 void
@@ -569,3 +678,24 @@ e_mod_pol_wl_notification_level_fetch(E_Client *ec)
         eina_hash_del_by_key(hash_notification_levels, &surface);
      }
 }
+
+void
+e_mod_pol_wl_keyboard_send(E_Client *ec, Eina_Bool state, int x, int y, int w, int h)
+{
+   E_Comp_Client_Data *cdata;
+   struct wl_resource *surface;
+   Policy_Conformant *pn;
+   struct wl_resource *policy_interface;
+
+   EINA_SAFETY_ON_NULL_RETURN(ec);
+   cdata = e_pixmap_cdata_get(ec->pixmap);
+   EINA_SAFETY_ON_NULL_RETURN(cdata);
+   surface = cdata->wl_surface;
+   EINA_SAFETY_ON_NULL_RETURN(surface);
+
+   pn = eina_hash_find(hash_policy_conformants, &surface);
+   if (pn)
+     {
+        tizen_policy_send_conformant_area(pn->interface, pn->surface, TIZEN_POLICY_CONFORMANT_PART_KEYBOARD, state, x, y, w, h);
+     }
+}
index 0f9e5dd..0db1f16 100644 (file)
@@ -19,5 +19,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_send(E_Client *ec, Eina_Bool state, int x, int y, int w, int h);
 #endif /* HAVE_WAYLAND_ONLY */
 #endif /* E_MOD_WL_H */
index 33bb698..6538a55 100644 (file)
@@ -19,6 +19,18 @@ static const struct wl_interface *types[] = {
        &wl_surface_interface,
        &wl_surface_interface,
        NULL,
+       &wl_surface_interface,
+       &wl_surface_interface,
+       &wl_surface_interface,
+       &wl_surface_interface,
+       NULL,
+       &wl_surface_interface,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
 };
 
 static const struct wl_message tizen_policy_requests[] = {
@@ -29,12 +41,20 @@ static const struct wl_message tizen_policy_requests[] = {
        { "focus_skip_set", "o", types + 8 },
        { "focus_skip_unset", "o", types + 9 },
        { "role_set", "os", types + 10 },
+       { "conformant_set", "o", types + 12 },
+       { "conformant_unset", "o", types + 13 },
+       { "conformant_get", "o", types + 14 },
+};
+
+static const struct wl_message tizen_policy_events[] = {
+       { "conformant", "ou", types + 15 },
+       { "conformant_area", "ouuiiii", types + 17 },
 };
 
 WL_EXPORT const struct wl_interface tizen_policy_interface = {
        "tizen_policy", 1,
-       7, tizen_policy_requests,
-       0, NULL,
+       10, tizen_policy_requests,
+       2, tizen_policy_events,
 };
 
 static const struct wl_message tizen_visibility_requests[] = {
index 06ac0b8..c4eae41 100644 (file)
@@ -18,8 +18,18 @@ struct tizen_visibility;
 struct wl_surface;
 
 extern const struct wl_interface tizen_policy_interface;
-extern const struct wl_interface tizen_visibility_interface;
 extern const struct wl_interface tizen_position_interface;
+extern const struct wl_interface tizen_visibility_interface;
+extern const struct wl_interface wl_surface_interface;
+
+#ifndef TIZEN_POLICY_CONFORMANT_PART_ENUM
+#define TIZEN_POLICY_CONFORMANT_PART_ENUM
+enum tizen_policy_conformant_part {
+       TIZEN_POLICY_CONFORMANT_PART_INDICATOR = 0,
+       TIZEN_POLICY_CONFORMANT_PART_KEYBOARD = 1,
+       TIZEN_POLICY_CONFORMANT_PART_CLIPBOARD = 2,
+};
+#endif /* TIZEN_POLICY_CONFORMANT_PART_ENUM */
 
 struct tizen_policy_interface {
        /**
@@ -77,8 +87,46 @@ struct tizen_policy_interface {
                         struct wl_resource *resource,
                         struct wl_resource *surface,
                         const char *role);
+       /**
+        * conformant_set - (none)
+        * @surface: surface object
+        */
+       void (*conformant_set)(struct wl_client *client,
+                              struct wl_resource *resource,
+                              struct wl_resource *surface);
+       /**
+        * conformant_unset - (none)
+        * @surface: surface object
+        */
+       void (*conformant_unset)(struct wl_client *client,
+                                struct wl_resource *resource,
+                                struct wl_resource *surface);
+       /**
+        * conformant_get - (none)
+        * @surface: surface object
+        */
+       void (*conformant_get)(struct wl_client *client,
+                              struct wl_resource *resource,
+                              struct wl_resource *surface);
 };
 
+#define TIZEN_POLICY_CONFORMANT        0
+#define TIZEN_POLICY_CONFORMANT_AREA   1
+
+#define TIZEN_POLICY_CONFORMANT_SINCE_VERSION  1
+#define TIZEN_POLICY_CONFORMANT_AREA_SINCE_VERSION     1
+
+static inline void
+tizen_policy_send_conformant(struct wl_resource *resource_, struct wl_resource *surface, uint32_t is_conformant)
+{
+       wl_resource_post_event(resource_, TIZEN_POLICY_CONFORMANT, surface, is_conformant);
+}
+
+static inline void
+tizen_policy_send_conformant_area(struct wl_resource *resource_, struct wl_resource *surface, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h)
+{
+       wl_resource_post_event(resource_, TIZEN_POLICY_CONFORMANT_AREA, surface, conformant_part, state, x, y, w, h);
+}
 
 #ifndef TIZEN_VISIBILITY_VISIBILITY_ENUM
 #define TIZEN_VISIBILITY_VISIBILITY_ENUM