diff --git a/src/modules/Makefile_wl_wl.mk b/src/modules/Makefile_wl_wl.mk index 1721a3f32..5a7e71cb1 100644 --- a/src/modules/Makefile_wl_wl.mk +++ b/src/modules/Makefile_wl_wl.mk @@ -9,8 +9,7 @@ src_modules_wl_wl_module_la_CPPFLAGS = $(MOD_CPPFLAGS) @WAYLAND_CFLAGS@ src_modules_wl_wl_module_la_LIBADD = $(LIBS) @WAYLAND_LIBS@ src_modules_wl_wl_module_la_LDFLAGS = $(MOD_LDFLAGS) src_modules_wl_wl_module_la_SOURCES = \ -src/modules/wl_wl/e_mod_main.c \ -src/modules/wl_wl/wl.c +src/modules/wl_wl/e_mod_main.c PHONIES += wl_wl install-wl_wl wl_wl: $(wl_wlpkg_LTLIBRARIES) $(wl_wl_DATA) diff --git a/src/modules/wl_wl/e_mod_main.c b/src/modules/wl_wl/e_mod_main.c index 35bac199b..d3decfae8 100644 --- a/src/modules/wl_wl/e_mod_main.c +++ b/src/modules/wl_wl/e_mod_main.c @@ -1,7 +1,5 @@ #include "e.h" -EINTERN void wl_wl_init(void); - E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Wl_Wl" }; static void @@ -10,11 +8,27 @@ _cb_delete_request(Ecore_Evas *ee EINA_UNUSED) ecore_main_loop_quit(); } +static Eina_Bool +_cb_sync_done(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) +{ + Ecore_Wl2_Event_Sync_Done *ev; + int w = 0, h = 0; + + ev = event; + if (ev->display != e_comp_wl->wl.client_disp) + return ECORE_CALLBACK_PASS_ON; + + ecore_evas_screen_geometry_get(e_comp->ee, NULL, NULL, &w, &h); + if ((w < 1) || (h < 1)) return ECORE_CALLBACK_PASS_ON; + + e_comp_canvas_resize(w / 4, h / 4); + + return ECORE_CALLBACK_PASS_ON; +} + E_API void * e_modapi_init(E_Module *m) { - int w = 0, h = 0; - printf("LOAD WL_WL MODULE\n"); if (e_comp_config_get()->engine == E_COMP_ENGINE_GL) @@ -38,17 +52,17 @@ e_modapi_init(E_Module *m) return NULL; } } + + ecore_evas_data_set(e_comp->ee, "comp", e_comp); ecore_evas_callback_delete_request_set(e_comp->ee, _cb_delete_request); ecore_evas_title_set(e_comp->ee, "Enlightenment: WL-WL"); ecore_evas_name_class_set(e_comp->ee, "E", "compositor"); - ecore_evas_screen_geometry_get(e_comp->ee, NULL, NULL, &w, &h); + ecore_event_handler_add(ECORE_WL2_EVENT_SYNC_DONE, _cb_sync_done, NULL); if (!e_comp_wl_init()) return NULL; - if (!e_comp_canvas_init(w * 3 / 4, h * 3 / 4)) return NULL; + if (!e_comp_canvas_init(1024, 768)) return NULL; - ecore_evas_pointer_xy_get(e_comp->ee, &e_comp_wl->ptr.x, - &e_comp_wl->ptr.y); e_comp_wl_input_pointer_enabled_set(EINA_TRUE); e_comp_wl_input_keyboard_enabled_set(EINA_TRUE); e_comp_wl_input_touch_enabled_set(EINA_TRUE); @@ -59,7 +73,10 @@ e_modapi_init(E_Module *m) e_comp->pointer->color = EINA_TRUE; e_comp_wl_input_keymap_set(NULL, NULL, NULL, NULL, NULL); - wl_wl_init(); + + ecore_evas_pointer_xy_get(e_comp->ee, &e_comp_wl->ptr.x, + &e_comp_wl->ptr.y); + evas_event_feed_mouse_in(e_comp->evas, 0, NULL); return m; } diff --git a/src/modules/wl_wl/wl.c b/src/modules/wl_wl/wl.c deleted file mode 100644 index 324277072..000000000 --- a/src/modules/wl_wl/wl.c +++ /dev/null @@ -1,119 +0,0 @@ -#include "e.h" - -static struct wl_display *disp; -static Ecore_Fd_Handler *wl_fdh; - -static void -_wl_handle_global(void *data EINA_UNUSED, struct wl_registry *registry EINA_UNUSED, unsigned int id, const char *interface, unsigned int version) -{ - Ecore_Wl_Global *global; - - if (!(global = calloc(1, sizeof(Ecore_Wl_Global)))) return; - - global->id = id; - global->interface = strdup(interface); - global->version = version; - e_comp_wl->wl.globals = eina_inlist_append(e_comp_wl->wl.globals, EINA_INLIST_GET(global)); - - if (!strcmp(interface, "wl_shm")) - e_comp_wl->wl.shm = wl_registry_bind(registry, id, &wl_shm_interface, 1); - ecore_event_add(E_EVENT_WAYLAND_GLOBAL_ADD, NULL, NULL, NULL); -} - -static void -_wl_handle_global_remove(void *data EINA_UNUSED, struct wl_registry *registry EINA_UNUSED, unsigned int id) -{ - Ecore_Wl_Global *global; - Eina_Inlist *tmp; - - EINA_INLIST_FOREACH_SAFE(e_comp_wl->wl.globals, tmp, global) - { - if (global->id != id) continue; - e_comp_wl->wl.globals = - eina_inlist_remove(e_comp_wl->wl.globals, EINA_INLIST_GET(global)); - free(global->interface); - free(global); - } -} - -static const struct wl_registry_listener _global_registry_listener = -{ - _wl_handle_global, - _wl_handle_global_remove -}; - - -static Eina_Bool -_ecore_wl_cb_idle_enterer(void *data EINA_UNUSED) -{ - int ret = 0; - - ret = wl_display_get_error(disp); - if (ret < 0) goto err; - - ret = wl_display_dispatch_pending(disp); - if (ret < 0) goto err; - - ret = wl_display_flush(disp); - if ((ret < 0) && (errno == EAGAIN)) - ecore_main_fd_handler_active_set(wl_fdh, ECORE_FD_READ | ECORE_FD_WRITE); - - return ECORE_CALLBACK_RENEW; - -err: - if ((ret < 0) && ((errno != EAGAIN) && (errno != EINVAL))) - { - /* raise exit signal */ - fprintf(stderr, "Wayland socket error: %s\n", strerror(errno)); - abort(); - - return ECORE_CALLBACK_CANCEL; - } - - return ECORE_CALLBACK_RENEW; -} - - -static Eina_Bool -_ecore_wl_cb_handle_data(void *data EINA_UNUSED, Ecore_Fd_Handler *hdl) -{ - int ret = 0; - - if (ecore_main_fd_handler_active_get(hdl, ECORE_FD_ERROR)) - { - fprintf(stderr, "Received error on wayland display fd\n"); - abort(); - - return ECORE_CALLBACK_CANCEL; - } - - if (ecore_main_fd_handler_active_get(hdl, ECORE_FD_READ)) - ret = wl_display_dispatch(disp); - else if (ecore_main_fd_handler_active_get(hdl, ECORE_FD_WRITE)) - { - ret = wl_display_flush(disp); - if (ret == 0) - ecore_main_fd_handler_active_set(hdl, ECORE_FD_READ); - } - - if ((ret < 0) && ((errno != EAGAIN) && (errno != EINVAL))) - { - /* raise exit signal */ - abort(); - - return ECORE_CALLBACK_CANCEL; - } - - return ECORE_CALLBACK_RENEW; -} - -EINTERN void -wl_wl_init(void) -{ - disp = wl_display_connect(getenv("WAYLAND_DISPLAY")); - ecore_main_fd_handler_add(wl_display_get_fd(disp), ECORE_FD_READ | ECORE_FD_WRITE | ECORE_FD_ERROR, - _ecore_wl_cb_handle_data, NULL, NULL, NULL); - e_comp_wl->wl.registry = wl_display_get_registry(disp); - wl_registry_add_listener(e_comp_wl->wl.registry, &_global_registry_listener, NULL); - ecore_idle_enterer_add(_ecore_wl_cb_idle_enterer, NULL); -}