summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Michael <cpmichael@osg.samsung.com>2016-01-05 13:15:56 -0500
committerMike Blumenkrantz <zmike@osg.samsung.com>2016-02-02 13:32:31 -0500
commit9400e33bab093a8b69286ffb83e1a1982b939944 (patch)
treeadb2626132cb128c6faf22372cee2a963f6ad8d4
parent59762676a8046fd671ecdcb00f2b794e575c94df (diff)
Fix issue of nested compositors not working with Ecore_Wl2 library
Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
-rw-r--r--src/modules/Makefile_wl_wl.mk3
-rw-r--r--src/modules/wl_wl/e_mod_main.c35
-rw-r--r--src/modules/wl_wl/wl.c119
3 files changed, 27 insertions, 130 deletions
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@
9src_modules_wl_wl_module_la_LIBADD = $(LIBS) @WAYLAND_LIBS@ 9src_modules_wl_wl_module_la_LIBADD = $(LIBS) @WAYLAND_LIBS@
10src_modules_wl_wl_module_la_LDFLAGS = $(MOD_LDFLAGS) 10src_modules_wl_wl_module_la_LDFLAGS = $(MOD_LDFLAGS)
11src_modules_wl_wl_module_la_SOURCES = \ 11src_modules_wl_wl_module_la_SOURCES = \
12src/modules/wl_wl/e_mod_main.c \ 12src/modules/wl_wl/e_mod_main.c
13src/modules/wl_wl/wl.c
14 13
15PHONIES += wl_wl install-wl_wl 14PHONIES += wl_wl install-wl_wl
16wl_wl: $(wl_wlpkg_LTLIBRARIES) $(wl_wl_DATA) 15wl_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 5cc0aaa4a..5f151e75e 100644
--- a/src/modules/wl_wl/e_mod_main.c
+++ b/src/modules/wl_wl/e_mod_main.c
@@ -1,7 +1,5 @@
1#include "e.h" 1#include "e.h"
2 2
3EINTERN void wl_wl_init(void);
4
5E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Wl_Wl" }; 3E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Wl_Wl" };
6 4
7static void 5static void
@@ -10,11 +8,27 @@ _cb_delete_request(Ecore_Evas *ee EINA_UNUSED)
10 ecore_main_loop_quit(); 8 ecore_main_loop_quit();
11} 9}
12 10
13E_API void * 11static Eina_Bool
14e_modapi_init(E_Module *m) 12_cb_sync_done(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
15{ 13{
14 Ecore_Wl2_Event_Sync_Done *ev;
16 int w = 0, h = 0; 15 int w = 0, h = 0;
17 16
17 ev = event;
18 if (ev->display != e_comp_wl->wl.client_disp)
19 return ECORE_CALLBACK_PASS_ON;
20
21 ecore_evas_screen_geometry_get(e_comp->ee, NULL, NULL, &w, &h);
22 if ((w < 1) || (h < 1)) return ECORE_CALLBACK_PASS_ON;
23
24 e_comp_canvas_resize(w / 4, h / 4);
25
26 return ECORE_CALLBACK_PASS_ON;
27}
28
29E_API void *
30e_modapi_init(E_Module *m)
31{
18 printf("LOAD WL_WL MODULE\n"); 32 printf("LOAD WL_WL MODULE\n");
19 33
20 if (e_comp_config_get()->engine == E_COMP_ENGINE_GL) 34 if (e_comp_config_get()->engine == E_COMP_ENGINE_GL)
@@ -38,17 +52,17 @@ e_modapi_init(E_Module *m)
38 return NULL; 52 return NULL;
39 } 53 }
40 } 54 }
55
56 ecore_evas_data_set(e_comp->ee, "comp", e_comp);
41 ecore_evas_callback_delete_request_set(e_comp->ee, _cb_delete_request); 57 ecore_evas_callback_delete_request_set(e_comp->ee, _cb_delete_request);
42 ecore_evas_title_set(e_comp->ee, "Enlightenment: WL-WL"); 58 ecore_evas_title_set(e_comp->ee, "Enlightenment: WL-WL");
43 ecore_evas_name_class_set(e_comp->ee, "E", "compositor"); 59 ecore_evas_name_class_set(e_comp->ee, "E", "compositor");
44 60
45 ecore_evas_screen_geometry_get(e_comp->ee, NULL, NULL, &w, &h); 61 ecore_event_handler_add(ECORE_WL2_EVENT_SYNC_DONE, _cb_sync_done, NULL);
46 62
47 if (!e_comp_wl_init()) return NULL; 63 if (!e_comp_wl_init()) return NULL;
48 if (!e_comp_canvas_init(w * 3 / 4, h * 3 / 4)) return NULL; 64 if (!e_comp_canvas_init(1024, 768)) return NULL;
49 65
50 ecore_evas_pointer_xy_get(e_comp->ee, &e_comp_wl->ptr.x,
51 &e_comp_wl->ptr.y);
52 e_comp_wl_input_pointer_enabled_set(EINA_TRUE); 66 e_comp_wl_input_pointer_enabled_set(EINA_TRUE);
53 e_comp_wl_input_keyboard_enabled_set(EINA_TRUE); 67 e_comp_wl_input_keyboard_enabled_set(EINA_TRUE);
54 e_comp_wl_input_touch_enabled_set(EINA_TRUE); 68 e_comp_wl_input_touch_enabled_set(EINA_TRUE);
@@ -59,7 +73,10 @@ e_modapi_init(E_Module *m)
59 e_comp->pointer->color = EINA_TRUE; 73 e_comp->pointer->color = EINA_TRUE;
60 74
61 e_comp_wl_input_keymap_set(NULL, NULL, NULL); 75 e_comp_wl_input_keymap_set(NULL, NULL, NULL);
62 wl_wl_init(); 76
77 ecore_evas_pointer_xy_get(e_comp->ee, &e_comp_wl->ptr.x,
78 &e_comp_wl->ptr.y);
79 evas_event_feed_mouse_in(e_comp->evas, 0, NULL);
63 80
64 return m; 81 return m;
65} 82}
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 @@
1#include "e.h"
2
3static struct wl_display *disp;
4static Ecore_Fd_Handler *wl_fdh;
5
6static void
7_wl_handle_global(void *data EINA_UNUSED, struct wl_registry *registry EINA_UNUSED, unsigned int id, const char *interface, unsigned int version)
8{
9 Ecore_Wl_Global *global;
10
11 if (!(global = calloc(1, sizeof(Ecore_Wl_Global)))) return;
12
13 global->id = id;
14 global->interface = strdup(interface);
15 global->version = version;
16 e_comp_wl->wl.globals = eina_inlist_append(e_comp_wl->wl.globals, EINA_INLIST_GET(global));
17
18 if (!strcmp(interface, "wl_shm"))
19 e_comp_wl->wl.shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
20 ecore_event_add(E_EVENT_WAYLAND_GLOBAL_ADD, NULL, NULL, NULL);
21}
22
23static void
24_wl_handle_global_remove(void *data EINA_UNUSED, struct wl_registry *registry EINA_UNUSED, unsigned int id)
25{
26 Ecore_Wl_Global *global;
27 Eina_Inlist *tmp;
28
29 EINA_INLIST_FOREACH_SAFE(e_comp_wl->wl.globals, tmp, global)
30 {
31 if (global->id != id) continue;
32 e_comp_wl->wl.globals =
33 eina_inlist_remove(e_comp_wl->wl.globals, EINA_INLIST_GET(global));
34 free(global->interface);
35 free(global);
36 }
37}
38
39static const struct wl_registry_listener _global_registry_listener =
40{
41 _wl_handle_global,
42 _wl_handle_global_remove
43};
44
45
46static Eina_Bool
47_ecore_wl_cb_idle_enterer(void *data EINA_UNUSED)
48{
49 int ret = 0;
50
51 ret = wl_display_get_error(disp);
52 if (ret < 0) goto err;
53
54 ret = wl_display_dispatch_pending(disp);
55 if (ret < 0) goto err;
56
57 ret = wl_display_flush(disp);
58 if ((ret < 0) && (errno == EAGAIN))
59 ecore_main_fd_handler_active_set(wl_fdh, ECORE_FD_READ | ECORE_FD_WRITE);
60
61 return ECORE_CALLBACK_RENEW;
62
63err:
64 if ((ret < 0) && ((errno != EAGAIN) && (errno != EINVAL)))
65 {
66 /* raise exit signal */
67 fprintf(stderr, "Wayland socket error: %s\n", strerror(errno));
68 abort();
69
70 return ECORE_CALLBACK_CANCEL;
71 }
72
73 return ECORE_CALLBACK_RENEW;
74}
75
76
77static Eina_Bool
78_ecore_wl_cb_handle_data(void *data EINA_UNUSED, Ecore_Fd_Handler *hdl)
79{
80 int ret = 0;
81
82 if (ecore_main_fd_handler_active_get(hdl, ECORE_FD_ERROR))
83 {
84 fprintf(stderr, "Received error on wayland display fd\n");
85 abort();
86
87 return ECORE_CALLBACK_CANCEL;
88 }
89
90 if (ecore_main_fd_handler_active_get(hdl, ECORE_FD_READ))
91 ret = wl_display_dispatch(disp);
92 else if (ecore_main_fd_handler_active_get(hdl, ECORE_FD_WRITE))
93 {
94 ret = wl_display_flush(disp);
95 if (ret == 0)
96 ecore_main_fd_handler_active_set(hdl, ECORE_FD_READ);
97 }
98
99 if ((ret < 0) && ((errno != EAGAIN) && (errno != EINVAL)))
100 {
101 /* raise exit signal */
102 abort();
103
104 return ECORE_CALLBACK_CANCEL;
105 }
106
107 return ECORE_CALLBACK_RENEW;
108}
109
110EINTERN void
111wl_wl_init(void)
112{
113 disp = wl_display_connect(getenv("WAYLAND_DISPLAY"));
114 ecore_main_fd_handler_add(wl_display_get_fd(disp), ECORE_FD_READ | ECORE_FD_WRITE | ECORE_FD_ERROR,
115 _ecore_wl_cb_handle_data, NULL, NULL, NULL);
116 e_comp_wl->wl.registry = wl_display_get_registry(disp);
117 wl_registry_add_listener(e_comp_wl->wl.registry, &_global_registry_listener, NULL);
118 ecore_idle_enterer_add(_ecore_wl_cb_idle_enterer, NULL);
119}