3 #include "e_mod_main.h"
4 #include "eom-server-protocol.h"
7 typedef struct _E_Eom E_Eom, *E_EomPtr;
12 struct wl_global *global;
13 struct wl_resource *resource;
17 E_EomPtr g_eom = NULL;
19 EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "EOM Module" };
21 static E_Comp_Wl_Output *
22 _e_eom_e_comp_wl_output_get(Eina_List *outputs, const char *id)
25 E_Comp_Wl_Output *output;
27 EINA_LIST_FOREACH(outputs, l, output)
29 if (!strcmp(output->id, id))
37 _e_eom_e_client_remove_cb(void *data, int type, void *event)
39 E_Event_Client *ev = event;
40 E_Client *ec = ev->ec;
46 EOM_DBG("e_client: %p is died\n", ec);
48 return ECORE_CALLBACK_PASS_ON;
53 _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
55 Ecore_Drm_Event_Output *e;
58 E_Comp_Wl_Output *output;
60 struct wl_resource *output_resource;
61 enum wl_eom_type eom_type = WL_EOM_TYPE_NONE;
64 if (!(e = event)) goto end;
66 if (!e->plug) goto end;
68 EOM_DBG("id:%d (x,y,w,h):(%d,%d,%d,%d) (w_mm,h_mm):(%d,%d) refresh:%d subpixel_order:%d transform:%d make:%s model:%s plug:%d\n",
69 e->id, e->x, e->y, e->w, e->h, e->phys_width, e->phys_height, e->refresh, e->subpixel_order, e->transform, e->make, e->model, e->plug);
71 if (!(cdata = e_comp->wl_comp_data)) goto end;
73 snprintf(buff, sizeof(buff), "%d", e->id);
75 /* get the e_comp_wl_output */
76 output = _e_eom_e_comp_wl_output_get(cdata->outputs, buff);
79 EOM_ERR("no e_comp_wl_outputs.\n");
83 /* TODO: we need ecore_drm_output_connector_get()/ecore_drm_output_conn_name_get() function to get the connector type */
86 /* send notify in each outputs associated with e_comp_wl_output */
87 EINA_LIST_FOREACH(output->resources, l2, output_resource)
90 wl_eom_send_output_type(eom->resource, output_resource, eom_type, WL_EOM_STATUS_CONNECTION);
92 wl_eom_send_output_type(eom->resource, output_resource, eom_type, WL_EOM_STATUS_DISCONNECTION);
96 e_comp_wl_output_init(buff, e->make, e->model, e->x, e->y, e->w, e->h,
97 e->phys_width, e->phys_height, e->refresh,
98 e->subpixel_order, e->transform);
102 return ECORE_CALLBACK_PASS_ON;
106 _e_eom_ecore_drm_activate_cb(void *data, int type EINA_UNUSED, void *event)
108 Ecore_Drm_Event_Activate *e = NULL;
111 if ((!event) || (!data)) goto end;
117 /* TODO: something do */
121 /* TODO: something do */
125 return ECORE_CALLBACK_PASS_ON;
129 /* wl_eom_set_keygrab request handler */
131 _e_eom_wl_request_set_attribute_cb(struct wl_client *client,
132 struct wl_resource *resource,
133 struct wl_resource *output,
139 EOM_DBG("attribute:%d\n", attribute);
141 wl_eom_send_output_attribute(resource, output, attribute, WL_EOM_ATTRIBUTE_STATE_ACTIVE, WL_EOM_ERROR_NONE);
144 static const struct wl_eom_interface _e_eom_wl_implementation = {
145 _e_eom_wl_request_set_attribute_cb
148 /* wl_eom global object destroy function */
150 _e_eom_wl_resource_destory_cb(struct wl_resource *resource)
153 /* TODO : destroy resources if exist */
157 /* wl_eom global object bind function */
159 _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32_t id)
162 struct wl_resource *resource;
164 resource = wl_resource_create(client, &wl_eom_interface, MIN(version, 1), id);
167 EOM_ERR("error. resource is null. (version :%d, id:%d)\n", version, id);
168 wl_client_post_no_memory(client);
172 wl_resource_set_implementation(resource, &_e_eom_wl_implementation, eom, _e_eom_wl_resource_destory_cb);
174 eom->resource = resource;
176 EOM_DBG("create wl_eom global resource.\n");
182 Ecore_Event_Handler *h = NULL;
186 /* remove event handlers */
189 EINA_LIST_FREE(g_eom->handlers, h)
190 ecore_event_handler_del(h);
193 if (g_eom->global) wl_global_destroy(g_eom->global);
202 E_Comp_Data *cdata = NULL;
204 g_eom = E_NEW(E_Eom, 1);
207 EOM_ERR("error. fail to allocate the memory.\n");
213 EOM_ERR("error. e_comp is null.\n");
217 cdata = e_comp->wl_comp_data;
220 EOM_ERR("error. e_comp->wl_comp_data is null.\n");
224 g_eom->cdata = cdata;
225 g_eom->global = wl_global_create(cdata->wl.disp, &wl_eom_interface, 1, g_eom, _e_eom_wl_bind_cb);
228 EOM_ERR("error. g_eom->global is null.\n");
232 /* add event hanlders */
233 E_LIST_HANDLER_APPEND(g_eom->handlers, ECORE_DRM_EVENT_ACTIVATE, _e_eom_ecore_drm_activate_cb, g_eom);
234 E_LIST_HANDLER_APPEND(g_eom->handlers, ECORE_DRM_EVENT_OUTPUT, _e_eom_ecore_drm_output_cb, g_eom);
235 E_LIST_HANDLER_APPEND(g_eom->handlers, E_EVENT_CLIENT_REMOVE, _e_eom_e_client_remove_cb, g_eom);
246 e_modapi_init(E_Module *m)
248 return (_e_eom_init() ? m : NULL);
252 e_modapi_shutdown(E_Module *m EINA_UNUSED)
260 e_modapi_save(E_Module *m EINA_UNUSED)
262 /* Save something to be kept */