send output id intead of wl_output. add handling of user requests 65/65365/2
authorRoman Peresipkyn <r.peresipkyn@samsung.com>
Fri, 8 Apr 2016 16:26:08 +0000 (19:26 +0300)
committerSooChan Lim <sc1.lim@samsung.com>
Fri, 15 Apr 2016 00:22:21 +0000 (17:22 -0700)
Change-Id: I7a490a70a7e1e88b2867f3968be35ed0a810742a
Signed-off-by: Roman Peresipkyn <r.peresipkyn@samsung.com>
protocol/eom-client-protocol.h
protocol/eom-protocol.c
protocol/eom-server-protocol.h
protocol/eom.xml
src/e_mod_main.c

index 9f91c45..8b295fe 100644 (file)
@@ -154,34 +154,34 @@ enum wl_eom_attribute_state {
 struct wl_eom_listener {
        /**
         * output_type - (none)
-        * @output: (none)
+        * @output_id: (none)
         * @type: (none)
         * @status: (none)
         */
        void (*output_type)(void *data,
                            struct wl_eom *wl_eom,
-                           struct wl_output *output,
+                           uint32_t output_id,
                            uint32_t type,
                            uint32_t status);
        /**
         * output_mode - (none)
-        * @output: (none)
+        * @output_id: (none)
         * @mode: (none)
         */
        void (*output_mode)(void *data,
                            struct wl_eom *wl_eom,
-                           struct wl_output *output,
+                           uint32_t output_id,
                            uint32_t mode);
        /**
         * output_attribute - (none)
-        * @output: (none)
+        * @output_id: (none)
         * @attribute: (none)
         * @attribute_state: (none)
         * @error: (none)
         */
        void (*output_attribute)(void *data,
                                 struct wl_eom *wl_eom,
-                                struct wl_output *output,
+                                uint32_t output_id,
                                 uint32_t attribute,
                                 uint32_t attribute_state,
                                 uint32_t error);
@@ -197,6 +197,8 @@ wl_eom_add_listener(struct wl_eom *wl_eom,
 
 #define WL_EOM_SET_ATTRIBUTE   0
 
+#define WL_EOM_SET_ATTRIBUTE_SINCE_VERSION     1
+
 static inline void
 wl_eom_set_user_data(struct wl_eom *wl_eom, void *user_data)
 {
@@ -209,6 +211,12 @@ wl_eom_get_user_data(struct wl_eom *wl_eom)
        return wl_proxy_get_user_data((struct wl_proxy *) wl_eom);
 }
 
+static inline uint32_t
+wl_eom_get_version(struct wl_eom *wl_eom)
+{
+       return wl_proxy_get_version((struct wl_proxy *) wl_eom);
+}
+
 static inline void
 wl_eom_destroy(struct wl_eom *wl_eom)
 {
@@ -216,10 +224,10 @@ wl_eom_destroy(struct wl_eom *wl_eom)
 }
 
 static inline void
-wl_eom_set_attribute(struct wl_eom *wl_eom, struct wl_output *output, uint32_t attribute)
+wl_eom_set_attribute(struct wl_eom *wl_eom, uint32_t output_id, uint32_t attribute)
 {
        wl_proxy_marshal((struct wl_proxy *) wl_eom,
-                        WL_EOM_SET_ATTRIBUTE, output, attribute);
+                        WL_EOM_SET_ATTRIBUTE, output_id, attribute);
 }
 
 #ifdef  __cplusplus
index fc7ccc7..265c780 100644 (file)
@@ -2,30 +2,22 @@
 #include <stdint.h>
 #include "wayland-util.h"
 
-extern const struct wl_interface wl_output_interface;
 
 static const struct wl_interface *types[] = {
-       &wl_output_interface,
        NULL,
-       &wl_output_interface,
-       NULL,
-       NULL,
-       &wl_output_interface,
-       NULL,
-       &wl_output_interface,
        NULL,
        NULL,
        NULL,
 };
 
 static const struct wl_message wl_eom_requests[] = {
-       { "set_attribute", "ou", types + 0 },
+       { "set_attribute", "uu", types + 0 },
 };
 
 static const struct wl_message wl_eom_events[] = {
-       { "output_type", "ouu", types + 2 },
-       { "output_mode", "ou", types + 5 },
-       { "output_attribute", "ouuu", types + 7 },
+       { "output_type", "uuu", types + 0 },
+       { "output_mode", "uu", types + 0 },
+       { "output_attribute", "uuuu", types + 0 },
 };
 
 WL_EXPORT const struct wl_interface wl_eom_interface = {
index 18801cb..1fa8d74 100644 (file)
@@ -152,12 +152,12 @@ enum wl_eom_attribute_state {
 struct wl_eom_interface {
        /**
         * set_attribute - (none)
-        * @output: (none)
+        * @output_id: (none)
         * @attribute: (none)
         */
        void (*set_attribute)(struct wl_client *client,
                              struct wl_resource *resource,
-                             struct wl_resource *output,
+                             uint32_t output_id,
                              uint32_t attribute);
 };
 
@@ -170,21 +170,21 @@ struct wl_eom_interface {
 #define WL_EOM_OUTPUT_ATTRIBUTE_SINCE_VERSION  1
 
 static inline void
-wl_eom_send_output_type(struct wl_resource *resource_, struct wl_resource *output, uint32_t type, uint32_t status)
+wl_eom_send_output_type(struct wl_resource *resource_, uint32_t output_id, uint32_t type, uint32_t status)
 {
-       wl_resource_post_event(resource_, WL_EOM_OUTPUT_TYPE, output, type, status);
+       wl_resource_post_event(resource_, WL_EOM_OUTPUT_TYPE, output_id, type, status);
 }
 
 static inline void
-wl_eom_send_output_mode(struct wl_resource *resource_, struct wl_resource *output, uint32_t mode)
+wl_eom_send_output_mode(struct wl_resource *resource_, uint32_t output_id, uint32_t mode)
 {
-       wl_resource_post_event(resource_, WL_EOM_OUTPUT_MODE, output, mode);
+       wl_resource_post_event(resource_, WL_EOM_OUTPUT_MODE, output_id, mode);
 }
 
 static inline void
-wl_eom_send_output_attribute(struct wl_resource *resource_, struct wl_resource *output, uint32_t attribute, uint32_t attribute_state, uint32_t error)
+wl_eom_send_output_attribute(struct wl_resource *resource_, uint32_t output_id, uint32_t attribute, uint32_t attribute_state, uint32_t error)
 {
-       wl_resource_post_event(resource_, WL_EOM_OUTPUT_ATTRIBUTE, output, attribute, attribute_state, error);
+       wl_resource_post_event(resource_, WL_EOM_OUTPUT_ATTRIBUTE, output_id, attribute, attribute_state, error);
 }
 
 #ifdef  __cplusplus
index 94d5ce6..b84cf7c 100644 (file)
     </enum>
 
     <request name="set_attribute">
-      <arg name="output" type="object" interface="wl_output"/>
+      <arg name="output_id" type="uint"/>
       <arg name="attribute" type="uint"/>
     </request>
 
     <event name="output_type">
-      <arg name="output" type="object" interface="wl_output"/>
+      <arg name="output_id" type="uint"/>
       <arg name="type" type="uint"/>
       <arg name="status" type="uint"/>
     </event>
 
     <event name="output_mode">
-      <arg name="output" type="object" interface="wl_output"/>
+      <arg name="output_id" type="uint"/>
       <arg name="mode" type="uint"/>
     </event>
 
     <event name="output_attribute">
-      <arg name="output" type="object" interface="wl_output"/>
+      <arg name="output_id" type="uint"/>
       <arg name="attribute" type="uint"/>
       <arg name="attribute_state" type="uint"/>
       <arg name="error" type="uint"/>
index 3c3e15c..bbf0fce 100644 (file)
@@ -36,6 +36,7 @@ struct _E_Eom
    tbm_bufmgr bufmgr;
    int fd;
 
+   /* eom state */
    enum wl_eom_mode eom_mode;
    enum wl_eom_attribute eom_attribute;
    enum wl_eom_attribute_state eom_attribute_state;
@@ -44,12 +45,13 @@ struct _E_Eom
    /* external output data */
    char *ext_output_name;
    int is_external_init;
+   int id;
    E_EomOutMode src_mode;
    E_Comp_Wl_Output *wl_output;
 
    /* internal output data */
-   int is_internal_grab;
    char *int_output_name;
+   int is_internal_grab;
    E_EomOutMode dst_mode;
 };
 
@@ -125,7 +127,7 @@ _e_eom_get_eom_attribute()
 static inline int
 _e_eom_set_eom_attribute(enum wl_eom_attribute attribute)
 {
-   if (attribute == WL_EOM_ATTRIBUTE_NONE)
+   if (attribute == WL_EOM_ATTRIBUTE_NONE || g_eom->eom_attribute == WL_EOM_ATTRIBUTE_NONE)
      {
         g_eom->eom_attribute = attribute;
         return 1;
@@ -158,8 +160,6 @@ _e_eom_pp_cb(tbm_surface_h surface, void *user_data)
    E_EomDataPtr eom_data = NULL;
    tdm_error tdm_err = TDM_ERROR_NONE;
 
-   EOM_DBG("PP EVENT: get\n");
-
    if (!user_data)
      {
         EOM_DBG("ERROR: PP EVENT: user data is NULL\n");
@@ -180,7 +180,6 @@ _e_eom_pp_cb(tbm_surface_h surface, void *user_data)
      }
 
    g_eom_data.pp_buffer = !g_eom_data.current_buffer;
-   EOM_DBG("ERROR: PP EVENT: pp:%d  curr:%d\n", g_eom_data.pp_buffer, g_eom_data.current_buffer);
 
    tdm_err = tdm_buffer_add_release_handler(g_eom_data.dst_buffers[g_eom_data.pp_buffer],
                                             _e_eom_pp_cb, &g_eom_data);
@@ -203,8 +202,6 @@ _e_eom_pp_cb(tbm_surface_h surface, void *user_data)
         EOM_DBG ("ERROR: PP EVENT: pp commit:%d\n", tdm_err );
         return;
      }
-
-   EOM_DBG ("PP EVENT: ok\n");
 }
 
 static void
@@ -215,8 +212,6 @@ _e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EI
    E_EomDataPtr eom_data;
    tdm_error err = TDM_ERROR_NONE;
 
-   EOM_DBG("Event 1\n");
-
    if (!user_data)
      {
         EOM_ERR("ERROR: EVENT: user_data is NULL\n");
@@ -225,10 +220,6 @@ _e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EI
 
    eom_data = (E_EomDataPtr)user_data;
 
-   EOM_DBG("Event 2\n");
-
-   EOM_DBG("EVENT: pp:%d  curr:%d\n", eom_data->pp_buffer, eom_data->current_buffer);
-
    if (eom_data->current_buffer == 1)
      {
         eom_data->current_buffer = 0;
@@ -240,8 +231,6 @@ _e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EI
             EOM_ERR("ERROR: EVENT: set buffer 0\n");
             return;
          }
-
-       EOM_DBG("Event 3\n");
      }
    else
      {
@@ -254,8 +243,6 @@ _e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EI
              EOM_ERR("ERROR: EVENT: set buffer 1\n");
              return;
           }
-
-        EOM_DBG("Event 4\n");
      }
 
    err = tdm_output_commit(eom_data->output, 0, _e_eom_output_commit_cb, eom_data);
@@ -264,8 +251,6 @@ _e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EI
         EOM_ERR("ERROR: EVENT: commit\n");
         return;
      }
-
-   EOM_DBG("Event 5\n");
 }
 
 static E_Comp_Wl_Output *
@@ -874,6 +859,7 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e
               }
 
             g_eom->is_external_init = 1;
+            g_eom->id = e->id;
 
             _e_eom_set_eom_attribute_state(WL_EOM_ATTRIBUTE_STATE_ACTIVE);
             _e_eom_set_eom_status(WL_EOM_STATUS_CONNECTION);
@@ -884,6 +870,7 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e
          {
             g_eom->is_external_init = 0;
             g_eom->is_internal_grab = 0;
+            g_eom->id = -1;
 
             _e_eom_set_eom_attribute_state(WL_EOM_ATTRIBUTE_STATE_INACTIVE);
             _e_eom_set_eom_status(WL_EOM_STATUS_DISCONNECTION);
@@ -1068,18 +1055,41 @@ end:
 
 /* wl_eom_set_keygrab request handler */
 static void
-_e_eom_wl_request_set_attribute_cb(struct wl_client *client, struct wl_resource *resource, struct wl_resource *output, uint32_t attribute)
+_e_eom_wl_request_set_attribute_cb(struct wl_client *client, struct wl_resource *resource, uint32_t output_id, uint32_t attribute)
 {
+   int ret = 0;
+       /*
    (void) client;
    (void) attribute;
+   */
+
+   EOM_DBG("attribute:%d +++ output:%d\n", attribute, output_id);
+
+   /*
+    * TODO: check output_id
+    */
+   ret = _e_eom_set_eom_attribute(attribute);
+   if (ret == 0)
+     {
+           EOM_DBG("set attribute FAILED\n");
 
-   EOM_DBG("attribute:%d\n", attribute);
+           wl_eom_send_output_attribute(resource,
+                                     g_eom->id,
+                                     _e_eom_get_eom_attribute(),
+                                     _e_eom_get_eom_attribute_state(),
+                                     WL_EOM_ERROR_OUTPUT_OCCUPIED);
+     }
+   else
+     {
+           EOM_DBG("set attribute OK\n");
+
+           wl_eom_send_output_attribute(resource,
+                                     g_eom->id,
+                                     _e_eom_get_eom_attribute(),
+                                     _e_eom_get_eom_attribute_state(),
+                                     WL_EOM_ERROR_NONE);
+     }
 
-   wl_eom_send_output_attribute(resource,
-                        output,
-                        attribute,
-                        WL_EOM_ATTRIBUTE_STATE_ACTIVE,
-                        WL_EOM_ERROR_NONE);
 }
 
 static const struct wl_eom_interface _e_eom_wl_implementation =
@@ -1137,24 +1147,20 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32
         return;
      }
 
-   EINA_LIST_FOREACH(wl_output->resources, l, output_resource)
-     {
-        wl_eom_send_output_type(eom->resource,
-                                output_resource,
-                                eom_type,
-                                _e_eom_get_eom_status());
-
+   wl_eom_send_output_type(eom->resource,
+                           eom->id,
+                           eom_type,
+                           _e_eom_get_eom_status());
 
-        wl_eom_send_output_attribute(eom->resource,
-                                     output_resource,
-                                     _e_eom_get_eom_attribute(),
-                                     _e_eom_get_eom_attribute_state(),
-                                     WL_EOM_ERROR_NONE);
+   wl_eom_send_output_attribute(eom->resource,
+                                eom->id,
+                                _e_eom_get_eom_attribute(),
+                                _e_eom_get_eom_attribute_state(),
+                                WL_EOM_ERROR_NONE);
 
-        wl_eom_send_output_mode(eom->resource,
-                                output_resource,
-                                _e_eom_get_eom_mode());
-     }
+   wl_eom_send_output_mode(eom->resource,
+                           eom->id,
+                           _e_eom_get_eom_mode());
 
    EOM_DBG("create wl_eom global resource.\n");
 }