2012-03-28 18:43:17 -07:00
|
|
|
#include "e.h"
|
2015-01-05 06:09:59 -08:00
|
|
|
#include <Ecore_Drm.h>
|
2012-03-28 18:43:17 -07:00
|
|
|
|
2014-03-11 02:01:01 -07:00
|
|
|
EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Wl_Drm" };
|
2012-03-28 18:43:17 -07:00
|
|
|
|
2015-01-05 06:09:59 -08:00
|
|
|
static Ecore_Event_Handler *activate_handler;
|
|
|
|
static Eina_Bool session_state = EINA_FALSE;
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_e_mod_drm_cb_activate(void *data, int type EINA_UNUSED, void *event)
|
|
|
|
{
|
|
|
|
Ecore_Drm_Event_Activate *e;
|
|
|
|
E_Comp *c;
|
|
|
|
|
|
|
|
if ((!event) || (!data)) goto end;
|
|
|
|
e = event;
|
|
|
|
c = data;
|
|
|
|
|
|
|
|
if (e->active)
|
|
|
|
{
|
|
|
|
E_Client *ec;
|
|
|
|
|
|
|
|
if (session_state) goto end;
|
|
|
|
session_state = EINA_TRUE;
|
|
|
|
|
|
|
|
ecore_evas_show(c->ee);
|
|
|
|
E_CLIENT_FOREACH(c, ec)
|
|
|
|
{
|
|
|
|
if (ec->visible && (!ec->input_only))
|
|
|
|
e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
|
|
|
|
}
|
|
|
|
e_comp_render_queue(c);
|
|
|
|
e_comp_shape_queue_block(c, 0);
|
|
|
|
ecore_event_add(E_EVENT_COMPOSITOR_ENABLE, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
session_state = EINA_FALSE;
|
|
|
|
ecore_evas_hide(c->ee);
|
|
|
|
edje_file_cache_flush();
|
|
|
|
edje_collection_cache_flush();
|
|
|
|
evas_image_cache_flush(c->evas);
|
|
|
|
evas_font_cache_flush(c->evas);
|
|
|
|
evas_render_dump(c->evas);
|
|
|
|
|
|
|
|
e_comp_render_queue(c);
|
|
|
|
e_comp_shape_queue_block(c, 1);
|
|
|
|
ecore_event_add(E_EVENT_COMPOSITOR_DISABLE, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
2012-03-28 18:43:17 -07:00
|
|
|
EAPI void *
|
|
|
|
e_modapi_init(E_Module *m)
|
|
|
|
{
|
2014-03-11 02:01:01 -07:00
|
|
|
E_Comp *comp;
|
2014-09-04 07:05:59 -07:00
|
|
|
int w = 0, h = 0;
|
2012-03-28 18:43:17 -07:00
|
|
|
|
2014-03-11 02:01:01 -07:00
|
|
|
printf("LOAD WL_DRM MODULE\n");
|
2012-03-28 18:43:17 -07:00
|
|
|
|
2014-03-11 02:01:01 -07:00
|
|
|
/* try to init ecore_drm */
|
|
|
|
/* if (!ecore_drm_init()) */
|
|
|
|
/* { */
|
|
|
|
/* fprintf(stderr, "Could not initialize ecore_drm"); */
|
|
|
|
/* return NULL; */
|
|
|
|
/* } */
|
2012-03-28 18:43:17 -07:00
|
|
|
|
2015-01-06 10:04:04 -08:00
|
|
|
if (!(comp = e_comp))
|
|
|
|
{
|
|
|
|
comp = e_comp_new();
|
|
|
|
comp->comp_type = E_PIXMAP_TYPE_WL;
|
|
|
|
}
|
2014-07-16 12:38:40 -07:00
|
|
|
|
2014-09-18 06:10:13 -07:00
|
|
|
if ((e_comp_gl_get()) &&
|
2014-07-16 12:38:40 -07:00
|
|
|
(e_comp_config_get()->engine == E_COMP_ENGINE_GL))
|
|
|
|
{
|
2015-01-15 10:29:43 -08:00
|
|
|
comp->ee = ecore_evas_gl_drm_new(NULL, 0, 0, 0, 1, 1);
|
|
|
|
if (!comp->ee)
|
2015-01-15 10:27:52 -08:00
|
|
|
e_comp_gl_set(EINA_FALSE);
|
2014-07-16 12:38:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* fallback to framebuffer drm (non-accel) */
|
|
|
|
if (!comp->ee)
|
2014-09-04 07:05:59 -07:00
|
|
|
comp->ee = ecore_evas_drm_new(NULL, 0, 0, 0, 1, 1);
|
2014-07-16 12:38:40 -07:00
|
|
|
|
2014-03-11 02:01:01 -07:00
|
|
|
if (!comp->ee)
|
2012-03-28 18:43:17 -07:00
|
|
|
{
|
2014-03-11 02:01:01 -07:00
|
|
|
fprintf(stderr, "Could not create ecore_evas_drm canvas");
|
2012-03-28 18:43:17 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-09-04 07:05:59 -07:00
|
|
|
/* get the current screen geometry */
|
|
|
|
ecore_evas_screen_geometry_get(comp->ee, NULL, NULL, &w, &h);
|
|
|
|
|
|
|
|
/* resize the canvas */
|
|
|
|
ecore_evas_resize(comp->ee, w, h);
|
|
|
|
|
2014-05-09 02:53:53 -07:00
|
|
|
/* TODO: hook ecore_evas_callback_resize_set */
|
|
|
|
|
2014-03-11 02:01:01 -07:00
|
|
|
if (!e_xinerama_fake_screens_exist())
|
2012-03-28 18:43:17 -07:00
|
|
|
{
|
2014-03-11 02:01:01 -07:00
|
|
|
E_Screen *screen;
|
2012-03-28 18:43:17 -07:00
|
|
|
|
2014-03-11 02:01:01 -07:00
|
|
|
screen = E_NEW(E_Screen, 1);
|
|
|
|
screen->escreen = screen->screen = 0;
|
|
|
|
screen->x = 0;
|
|
|
|
screen->y = 0;
|
2014-09-04 07:05:59 -07:00
|
|
|
screen->w = w;
|
|
|
|
screen->h = h;
|
2014-03-11 02:01:01 -07:00
|
|
|
e_xinerama_screens_set(eina_list_append(NULL, screen));
|
2012-03-28 18:43:17 -07:00
|
|
|
}
|
2014-05-09 02:53:53 -07:00
|
|
|
|
2015-02-04 09:33:04 -08:00
|
|
|
comp->man = e_manager_new(ecore_evas_window_get(comp->ee), comp, w, h);
|
2014-05-09 02:53:53 -07:00
|
|
|
if (!e_comp_canvas_init(comp)) return NULL;
|
2014-03-11 02:01:01 -07:00
|
|
|
e_comp_canvas_fake_layers_init(comp);
|
2012-03-28 18:43:17 -07:00
|
|
|
|
2014-05-09 02:53:53 -07:00
|
|
|
/* NB: This needs to be called AFTER the comp canvas has been setup */
|
|
|
|
if (!e_comp_wl_init()) return NULL;
|
|
|
|
|
2014-05-15 02:53:46 -07:00
|
|
|
e_comp_wl_input_pointer_enabled_set(comp->wl_comp_data, EINA_TRUE);
|
|
|
|
e_comp_wl_input_keyboard_enabled_set(comp->wl_comp_data, EINA_TRUE);
|
2014-05-09 02:53:53 -07:00
|
|
|
|
2014-05-12 06:07:06 -07:00
|
|
|
/* comp->pointer = */
|
|
|
|
/* e_pointer_window_new(ecore_evas_window_get(comp->ee), 1); */
|
2014-06-26 06:30:33 -07:00
|
|
|
comp->pointer = e_pointer_canvas_new(comp->ee, EINA_TRUE);
|
|
|
|
comp->pointer->color = EINA_TRUE;
|
2014-03-17 06:57:56 -07:00
|
|
|
|
2014-09-18 06:10:13 -07:00
|
|
|
/* FIXME: We need a way to trap for user changing the keymap inside of E
|
2014-05-12 06:07:06 -07:00
|
|
|
* without the event coming from X11 */
|
|
|
|
|
|
|
|
/* FIXME: We should make a decision here ...
|
2014-09-18 06:10:13 -07:00
|
|
|
*
|
2014-05-12 06:07:06 -07:00
|
|
|
* Fetch the keymap from drm, OR set this to what the E config is....
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* FIXME: This is just for testing at the moment....
|
|
|
|
* happens to jive with what drm does */
|
2014-05-15 02:53:46 -07:00
|
|
|
e_comp_wl_input_keymap_set(comp->wl_comp_data, NULL, NULL, NULL);
|
2014-05-12 06:07:06 -07:00
|
|
|
|
2015-01-05 06:09:59 -08:00
|
|
|
activate_handler =
|
|
|
|
ecore_event_handler_add(ECORE_DRM_EVENT_ACTIVATE,
|
|
|
|
_e_mod_drm_cb_activate, comp);
|
|
|
|
|
|
|
|
|
2014-03-11 02:01:01 -07:00
|
|
|
return m;
|
2012-03-28 18:43:17 -07:00
|
|
|
}
|
|
|
|
|
2014-09-18 06:10:13 -07:00
|
|
|
EAPI int
|
2014-03-11 02:01:01 -07:00
|
|
|
e_modapi_shutdown(E_Module *m EINA_UNUSED)
|
2012-03-28 18:43:17 -07:00
|
|
|
{
|
2014-03-11 02:01:01 -07:00
|
|
|
/* shutdown ecore_drm */
|
|
|
|
/* ecore_drm_shutdown(); */
|
2012-03-28 18:43:17 -07:00
|
|
|
|
2015-01-05 06:09:59 -08:00
|
|
|
if (activate_handler) ecore_event_handler_del(activate_handler);
|
|
|
|
activate_handler = NULL;
|
|
|
|
|
2012-03-28 18:43:17 -07:00
|
|
|
return 1;
|
|
|
|
}
|