diff options
author | David Walter Seikel | 2012-04-22 09:19:23 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-04-22 09:19:23 +1000 |
commit | c963d75dfdeec11f82e79e727062fbf89afa2c04 (patch) | |
tree | 895633dbf641110be46f117c29890c49b3ffc0bd /libraries/ecore/src/lib/ecore_wayland | |
parent | Adding the new extantz viewer and grid manager. (diff) | |
download | SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.zip SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.gz SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.bz2 SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.xz |
Update EFL to latest beta.
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/lib/ecore_wayland/Ecore_Wayland.h | 271 | ||||
-rw-r--r-- | libraries/ecore/src/lib/ecore_wayland/Makefile.am | 8 | ||||
-rw-r--r-- | libraries/ecore/src/lib/ecore_wayland/Makefile.in | 33 | ||||
-rw-r--r-- | libraries/ecore/src/lib/ecore_wayland/ecore_wl.c | 1322 | ||||
-rw-r--r-- | libraries/ecore/src/lib/ecore_wayland/ecore_wl_private.h | 56 |
5 files changed, 613 insertions, 1077 deletions
diff --git a/libraries/ecore/src/lib/ecore_wayland/Ecore_Wayland.h b/libraries/ecore/src/lib/ecore_wayland/Ecore_Wayland.h index fdf6314..7dab37c 100644 --- a/libraries/ecore/src/lib/ecore_wayland/Ecore_Wayland.h +++ b/libraries/ecore/src/lib/ecore_wayland/Ecore_Wayland.h | |||
@@ -1,8 +1,13 @@ | |||
1 | #ifndef _ECORE_WAYLAND_H_ | 1 | #ifndef _ECORE_WAYLAND_H_ |
2 | # define _ECORE_WAYLAND_H_ | 2 | # define _ECORE_WAYLAND_H_ |
3 | 3 | ||
4 | # define GL_GLEXT_PROTOTYPES | ||
5 | |||
4 | # include <Eina.h> | 6 | # include <Eina.h> |
5 | # include <wayland-client.h> | 7 | # include <wayland-client.h> |
8 | # include <wayland-egl.h> // NB: already includes wayland-client.h | ||
9 | # include <EGL/egl.h> | ||
10 | # include <EGL/eglext.h> | ||
6 | 11 | ||
7 | # ifdef EAPI | 12 | # ifdef EAPI |
8 | # undef EAPI | 13 | # undef EAPI |
@@ -18,71 +23,233 @@ | |||
18 | # define EAPI | 23 | # define EAPI |
19 | # endif | 24 | # endif |
20 | 25 | ||
26 | typedef enum _Ecore_Wl_Window_Type Ecore_Wl_Window_Type; | ||
27 | typedef enum _Ecore_Wl_Window_Buffer_Type Ecore_Wl_Window_Buffer_Type; | ||
28 | |||
29 | typedef struct _Ecore_Wl_Display Ecore_Wl_Display; | ||
30 | typedef struct _Ecore_Wl_Output Ecore_Wl_Output; | ||
31 | typedef struct _Ecore_Wl_Input Ecore_Wl_Input; | ||
32 | # ifndef _ECORE_WAYLAND_WINDOW_PREDEF | ||
33 | typedef struct _Ecore_Wl_Window Ecore_Wl_Window; | ||
34 | # endif | ||
35 | typedef struct _Ecore_Wl_Dnd_Source Ecore_Wl_Dnd_Source; | ||
36 | typedef struct _Ecore_Wl_Dnd_Target Ecore_Wl_Dnd_Target; | ||
37 | |||
21 | typedef struct _Ecore_Wl_Event_Mouse_In Ecore_Wl_Event_Mouse_In; | 38 | typedef struct _Ecore_Wl_Event_Mouse_In Ecore_Wl_Event_Mouse_In; |
22 | typedef struct _Ecore_Wl_Event_Mouse_Out Ecore_Wl_Event_Mouse_Out; | 39 | typedef struct _Ecore_Wl_Event_Mouse_Out Ecore_Wl_Event_Mouse_Out; |
23 | typedef struct _Ecore_Wl_Event_Focus_In Ecore_Wl_Event_Focus_In; | 40 | typedef struct _Ecore_Wl_Event_Focus_In Ecore_Wl_Event_Focus_In; |
24 | typedef struct _Ecore_Wl_Event_Focus_Out Ecore_Wl_Event_Focus_Out; | 41 | typedef struct _Ecore_Wl_Event_Focus_Out Ecore_Wl_Event_Focus_Out; |
42 | typedef struct _Ecore_Wl_Event_Window_Configure Ecore_Wl_Event_Window_Configure; | ||
43 | typedef struct _Ecore_Wl_Event_Dnd_Enter Ecore_Wl_Event_Dnd_Enter; | ||
44 | typedef struct _Ecore_Wl_Event_Dnd_Position Ecore_Wl_Event_Dnd_Position; | ||
45 | typedef struct _Ecore_Wl_Event_Dnd_Leave Ecore_Wl_Event_Dnd_Leave; | ||
46 | typedef struct _Ecore_Wl_Event_Dnd_Drop Ecore_Wl_Event_Dnd_Drop; | ||
47 | typedef struct _Ecore_Wl_Event_Interfaces_Bound Ecore_Wl_Event_Interfaces_Bound; | ||
25 | 48 | ||
26 | typedef struct _Ecore_Wl_Drag_Source Ecore_Wl_Drag_Source; | 49 | enum _Ecore_Wl_Window_Type |
50 | { | ||
51 | ECORE_WL_WINDOW_TYPE_TOPLEVEL, | ||
52 | ECORE_WL_WINDOW_TYPE_FULLSCREEN, | ||
53 | ECORE_WL_WINDOW_TYPE_MAXIMIZED, | ||
54 | ECORE_WL_WINDOW_TYPE_TRANSIENT, | ||
55 | ECORE_WL_WINDOW_TYPE_MENU, | ||
56 | ECORE_WL_WINDOW_TYPE_CUSTOM | ||
57 | }; | ||
27 | 58 | ||
28 | typedef struct _Ecore_Wl_Event_Drag_Start Ecore_Wl_Event_Drag_Start; | 59 | enum _Ecore_Wl_Window_Buffer_Type |
29 | typedef struct _Ecore_Wl_Event_Drag_Stop Ecore_Wl_Event_Drag_Stop; | 60 | { |
61 | ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW, | ||
62 | ECORE_WL_WINDOW_BUFFER_TYPE_EGL_IMAGE, | ||
63 | ECORE_WL_WINDOW_BUFFER_TYPE_SHM | ||
64 | }; | ||
30 | 65 | ||
31 | struct _Ecore_Wl_Event_Mouse_In | 66 | struct _Ecore_Wl_Display |
32 | { | 67 | { |
33 | int modifiers; | 68 | struct |
34 | int x, y; | 69 | { |
70 | struct wl_display *display; | ||
71 | struct wl_compositor *compositor; | ||
72 | struct wl_shell *shell; | ||
73 | struct wl_shm *shm; | ||
74 | struct wl_data_device_manager *data_device_manager; | ||
75 | } wl; | ||
35 | 76 | ||
36 | struct | 77 | struct |
37 | { | 78 | { |
38 | int x, y; | 79 | EGLDisplay display; |
39 | } root; | 80 | EGLConfig rgb_config; |
81 | EGLConfig argb_config; | ||
82 | EGLContext rgb_context; | ||
83 | EGLContext argb_context; | ||
84 | } egl; | ||
85 | |||
86 | int fd; | ||
87 | unsigned int mask; | ||
88 | Ecore_Fd_Handler *fd_hdl; | ||
89 | |||
90 | struct wl_list inputs; | ||
91 | struct wl_list outputs; | ||
92 | |||
93 | struct xkb_desc *xkb; | ||
94 | |||
95 | Ecore_Wl_Output *output; | ||
96 | |||
97 | PFNEGLCREATEIMAGEKHRPROC create_image; | ||
98 | PFNEGLDESTROYIMAGEKHRPROC destroy_image; | ||
99 | |||
100 | void (*output_configure)(Ecore_Wl_Output *output, void *data); | ||
101 | void *data; | ||
102 | }; | ||
103 | |||
104 | struct _Ecore_Wl_Output | ||
105 | { | ||
106 | Ecore_Wl_Display *display; | ||
107 | struct wl_output *output; | ||
108 | Eina_Rectangle allocation; | ||
109 | struct wl_list link; | ||
110 | |||
111 | void (*destroy) (Ecore_Wl_Output *output, void *data); | ||
112 | void *data; | ||
113 | }; | ||
114 | |||
115 | struct _Ecore_Wl_Input | ||
116 | { | ||
117 | Ecore_Wl_Display *display; | ||
118 | struct wl_input_device *input_device; | ||
119 | struct wl_data_device *data_device; | ||
120 | |||
121 | Ecore_Wl_Window *pointer_focus; | ||
122 | Ecore_Wl_Window *keyboard_focus; | ||
123 | |||
124 | unsigned int button; | ||
125 | unsigned int timestamp; | ||
126 | unsigned int modifiers; | ||
127 | int sx, sy; | ||
128 | |||
129 | struct wl_list link; | ||
130 | |||
131 | /* TODO: grab */ | ||
132 | unsigned int grab_button; | ||
133 | |||
134 | Ecore_Wl_Dnd_Source *drag_source; | ||
135 | Ecore_Wl_Dnd_Source *selection_source; | ||
136 | }; | ||
40 | 137 | ||
41 | unsigned int window; | 138 | struct _Ecore_Wl_Window |
139 | { | ||
140 | Ecore_Wl_Display *display; | ||
141 | Ecore_Wl_Window *parent; | ||
142 | |||
143 | struct wl_surface *surface; | ||
144 | struct wl_shell_surface *shell_surface; | ||
145 | |||
146 | int id; | ||
147 | int x, y; | ||
148 | int edges; | ||
149 | |||
150 | Eina_Rectangle allocation, pending_allocation; | ||
151 | Eina_Rectangle saved_allocation, server_allocation; | ||
42 | 152 | ||
43 | unsigned int time; | 153 | /* Eina_Bool redraw_scheduled : 1; */ |
154 | /* Eina_Bool resize_scheduled : 1; */ | ||
155 | Eina_Bool transparent : 1; | ||
156 | |||
157 | Ecore_Wl_Window_Type type; | ||
158 | Ecore_Wl_Window_Buffer_Type buffer_type; | ||
159 | |||
160 | Ecore_Wl_Input *pointer_device; | ||
161 | Ecore_Wl_Input *keyboard_device; | ||
162 | |||
163 | void *data; | ||
44 | }; | 164 | }; |
45 | 165 | ||
46 | struct _Ecore_Wl_Event_Mouse_Out | 166 | struct _Ecore_Wl_Event_Mouse_In |
47 | { | 167 | { |
48 | int modifiers; | 168 | int modifiers; |
49 | int x, y; | 169 | int x, y; |
170 | struct | ||
171 | { | ||
172 | int x, y; | ||
173 | } root; | ||
174 | unsigned int win; | ||
175 | unsigned int event_win; | ||
176 | unsigned int root_win; | ||
177 | unsigned int timestamp; | ||
178 | }; | ||
50 | 179 | ||
180 | struct _Ecore_Wl_Event_Mouse_Out | ||
181 | { | ||
182 | int modifiers; | ||
183 | int x, y; | ||
51 | struct | 184 | struct |
52 | { | 185 | { |
53 | int x, y; | 186 | int x, y; |
54 | } root; | 187 | } root; |
188 | unsigned int win; | ||
189 | unsigned int event_win; | ||
190 | unsigned int root_win; | ||
191 | unsigned int timestamp; | ||
192 | }; | ||
55 | 193 | ||
56 | unsigned int window; | 194 | struct _Ecore_Wl_Event_Focus_In |
195 | { | ||
196 | unsigned int win; | ||
197 | unsigned int timestamp; | ||
198 | }; | ||
57 | 199 | ||
58 | unsigned int time; | 200 | struct _Ecore_Wl_Event_Focus_Out |
201 | { | ||
202 | unsigned int win; | ||
203 | unsigned int timestamp; | ||
59 | }; | 204 | }; |
60 | 205 | ||
61 | struct _Ecore_Wl_Event_Focus_In | 206 | struct _Ecore_Wl_Event_Window_Configure |
62 | { | 207 | { |
63 | unsigned int window; | 208 | unsigned int win; |
64 | /* TODO: mode & detail */ | 209 | unsigned int event_win; |
65 | unsigned int time; | 210 | int x, y, w, h; |
211 | unsigned int timestamp; | ||
66 | }; | 212 | }; |
67 | 213 | ||
68 | struct _Ecore_Wl_Event_Focus_Out | 214 | struct _Ecore_Wl_Event_Dnd_Enter |
69 | { | 215 | { |
70 | unsigned int window; | 216 | unsigned int win, source; |
71 | /* TODO: mode & detail */ | 217 | char **types; |
72 | unsigned int time; | 218 | int num_types; |
219 | struct | ||
220 | { | ||
221 | int x, y; | ||
222 | } position; | ||
73 | }; | 223 | }; |
74 | 224 | ||
75 | struct _Ecore_Wl_Event_Drag_Start | 225 | struct _Ecore_Wl_Event_Dnd_Position |
76 | { | 226 | { |
77 | struct wl_data_device *device; | 227 | unsigned int win, source; |
78 | struct wl_surface *surface; | 228 | struct |
79 | const char *mime_type; | 229 | { |
80 | uint32_t timestamp; | 230 | int x, y; |
231 | } position; | ||
81 | }; | 232 | }; |
82 | 233 | ||
83 | struct _Ecore_Wl_Event_Drag_Stop | 234 | struct _Ecore_Wl_Event_Dnd_Leave |
84 | { | 235 | { |
236 | unsigned int win, source; | ||
237 | }; | ||
85 | 238 | ||
239 | struct _Ecore_Wl_Event_Dnd_Drop | ||
240 | { | ||
241 | unsigned int win, source; | ||
242 | struct | ||
243 | { | ||
244 | int x, y; | ||
245 | } position; | ||
246 | }; | ||
247 | |||
248 | struct _Ecore_Wl_Event_Interfaces_Bound | ||
249 | { | ||
250 | Eina_Bool compositor : 1; | ||
251 | Eina_Bool shm : 1; | ||
252 | Eina_Bool shell : 1; | ||
86 | }; | 253 | }; |
87 | 254 | ||
88 | /** | 255 | /** |
@@ -92,32 +259,46 @@ struct _Ecore_Wl_Event_Drag_Stop | |||
92 | * Ecore_Wl provides a wrapper and convenience functions for using the | 259 | * Ecore_Wl provides a wrapper and convenience functions for using the |
93 | * Wayland window system. Function groups for this part of the library | 260 | * Wayland window system. Function groups for this part of the library |
94 | * include the following: | 261 | * include the following: |
262 | * | ||
95 | * @li @ref Ecore_Wl_Init_Group | 263 | * @li @ref Ecore_Wl_Init_Group |
264 | * @li @ref Ecore_Wl_Display_Group | ||
265 | * @li @ref Ecore_Wl_Flush_Group | ||
266 | * @li @ref Ecore_Wl_Window_Group | ||
96 | */ | 267 | */ |
97 | 268 | ||
269 | EAPI extern int ECORE_WL_EVENT_MOUSE_IN; | ||
270 | EAPI extern int ECORE_WL_EVENT_MOUSE_OUT; | ||
271 | EAPI extern int ECORE_WL_EVENT_FOCUS_IN; | ||
272 | EAPI extern int ECORE_WL_EVENT_FOCUS_OUT; | ||
273 | EAPI extern int ECORE_WL_EVENT_WINDOW_CONFIGURE; | ||
274 | EAPI extern int ECORE_WL_EVENT_DND_ENTER; | ||
275 | EAPI extern int ECORE_WL_EVENT_DND_POSITION; | ||
276 | EAPI extern int ECORE_WL_EVENT_DND_LEAVE; | ||
277 | EAPI extern int ECORE_WL_EVENT_DND_DROP; | ||
278 | EAPI extern int ECORE_WL_EVENT_INTERFACES_BOUND; | ||
279 | |||
98 | EAPI int ecore_wl_init(const char *name); | 280 | EAPI int ecore_wl_init(const char *name); |
99 | EAPI int ecore_wl_shutdown(void); | 281 | EAPI int ecore_wl_shutdown(void); |
100 | |||
101 | EAPI struct wl_display *ecore_wl_display_get(void); | ||
102 | EAPI struct wl_shm *ecore_wl_shm_get(void); | ||
103 | EAPI struct wl_compositor *ecore_wl_compositor_get(void); | ||
104 | EAPI struct wl_shell *ecore_wl_shell_get(void); | ||
105 | EAPI struct wl_input_device *ecore_wl_input_device_get(void); | ||
106 | EAPI void ecore_wl_screen_size_get(int *w, int *h); | ||
107 | EAPI unsigned int ecore_wl_format_get(void); | ||
108 | EAPI void ecore_wl_flush(void); | 282 | EAPI void ecore_wl_flush(void); |
109 | EAPI void ecore_wl_sync(void); | 283 | EAPI void ecore_wl_sync(void); |
284 | EAPI struct wl_shm *ecore_wl_shm_get(void); | ||
285 | EAPI struct wl_display *ecore_wl_display_get(void); | ||
286 | EAPI void ecore_wl_screen_size_get(int *w, int *h); | ||
110 | EAPI void ecore_wl_pointer_xy_get(int *x, int *y); | 287 | EAPI void ecore_wl_pointer_xy_get(int *x, int *y); |
111 | 288 | ||
112 | EAPI Ecore_Wl_Drag_Source *ecore_wl_drag_source_create(int hotspot_x, int hotspot_y, int offset_x, int offset_y, const char *mimetype, unsigned int timestamp, void *data); | 289 | EAPI Ecore_Wl_Window *ecore_wl_window_new(Ecore_Wl_Window *parent, int x, int y, int w, int h, int buffer_type); |
113 | EAPI void ecore_wl_drag_start(Ecore_Wl_Drag_Source *source, struct wl_surface *surface, struct wl_buffer *buffer); | 290 | EAPI void ecore_wl_window_free(Ecore_Wl_Window *win); |
114 | EAPI void ecore_wl_drag_stop(void); | 291 | EAPI void ecore_wl_window_move(Ecore_Wl_Window *win, int x, int y); |
115 | 292 | EAPI void ecore_wl_window_resize(Ecore_Wl_Window *win, int w, int h, int location); | |
116 | EAPI extern int ECORE_WL_EVENT_MOUSE_IN; | 293 | EAPI void ecore_wl_window_damage(Ecore_Wl_Window *win, int x, int y, int w, int h); |
117 | EAPI extern int ECORE_WL_EVENT_MOUSE_OUT; | 294 | EAPI void ecore_wl_window_buffer_attach(Ecore_Wl_Window *win, struct wl_buffer *buffer, int x, int y); |
118 | EAPI extern int ECORE_WL_EVENT_FOCUS_IN; | 295 | EAPI void ecore_wl_window_show(Ecore_Wl_Window *win); |
119 | EAPI extern int ECORE_WL_EVENT_FOCUS_OUT; | 296 | EAPI void ecore_wl_window_hide(Ecore_Wl_Window *win); |
120 | EAPI extern int ECORE_WL_EVENT_DRAG_START; | 297 | EAPI void ecore_wl_window_raise(Ecore_Wl_Window *win); |
121 | EAPI extern int ECORE_WL_EVENT_DRAG_STOP; | 298 | EAPI void ecore_wl_window_maximized_set(Ecore_Wl_Window *win, Eina_Bool maximized); |
299 | EAPI void ecore_wl_window_fullscreen_set(Ecore_Wl_Window *win, Eina_Bool fullscreen); | ||
300 | EAPI void ecore_wl_window_update_size(Ecore_Wl_Window *win, int w, int h); | ||
301 | EAPI struct wl_surface *ecore_wl_window_surface_get(Ecore_Wl_Window *win); | ||
302 | EAPI Ecore_Wl_Window *ecore_wl_window_find(unsigned int id); | ||
122 | 303 | ||
123 | #endif | 304 | #endif |
diff --git a/libraries/ecore/src/lib/ecore_wayland/Makefile.am b/libraries/ecore/src/lib/ecore_wayland/Makefile.am index ea005b2..f6b801d 100644 --- a/libraries/ecore/src/lib/ecore_wayland/Makefile.am +++ b/libraries/ecore/src/lib/ecore_wayland/Makefile.am | |||
@@ -14,9 +14,11 @@ includes_HEADERS = Ecore_Wayland.h | |||
14 | includesdir = $(includedir)/ecore-@VMAJ@ | 14 | includesdir = $(includedir)/ecore-@VMAJ@ |
15 | 15 | ||
16 | libecore_wayland_la_SOURCES = \ | 16 | libecore_wayland_la_SOURCES = \ |
17 | ecore_wl.c | 17 | ecore_wl.c \ |
18 | 18 | ecore_wl_output.c \ | |
19 | ## ecore_wl_window.c | 19 | ecore_wl_input.c \ |
20 | ecore_wl_window.c \ | ||
21 | ecore_wl_dnd.c | ||
20 | 22 | ||
21 | libecore_wayland_la_LIBADD = \ | 23 | libecore_wayland_la_LIBADD = \ |
22 | $(top_builddir)/src/lib/ecore/libecore.la \ | 24 | $(top_builddir)/src/lib/ecore/libecore.la \ |
diff --git a/libraries/ecore/src/lib/ecore_wayland/Makefile.in b/libraries/ecore/src/lib/ecore_wayland/Makefile.in index 411da19..39c633d 100644 --- a/libraries/ecore/src/lib/ecore_wayland/Makefile.in +++ b/libraries/ecore/src/lib/ecore_wayland/Makefile.in | |||
@@ -50,16 +50,15 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_attribute.m4 \ | |||
50 | $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \ | 50 | $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \ |
51 | $(top_srcdir)/m4/efl_threads.m4 $(top_srcdir)/m4/gettext.m4 \ | 51 | $(top_srcdir)/m4/efl_threads.m4 $(top_srcdir)/m4/gettext.m4 \ |
52 | $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \ | 52 | $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \ |
53 | $(top_srcdir)/m4/isc-posix.m4 $(top_srcdir)/m4/lib-ld.m4 \ | 53 | $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ |
54 | $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ | 54 | $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libtool.m4 \ |
55 | $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ | 55 | $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ |
56 | $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ | 56 | $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ |
57 | $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ | 57 | $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \ |
58 | $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ | 58 | $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/configure.ac |
59 | $(top_srcdir)/configure.ac | ||
60 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ | 59 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ |
61 | $(ACLOCAL_M4) | 60 | $(ACLOCAL_M4) |
62 | mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs | 61 | mkinstalldirs = $(install_sh) -d |
63 | CONFIG_HEADER = $(top_builddir)/config.h | 62 | CONFIG_HEADER = $(top_builddir)/config.h |
64 | CONFIG_CLEAN_FILES = | 63 | CONFIG_CLEAN_FILES = |
65 | CONFIG_CLEAN_VPATH_FILES = | 64 | CONFIG_CLEAN_VPATH_FILES = |
@@ -86,7 +85,8 @@ am__base_list = \ | |||
86 | sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | 85 | sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' |
87 | am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includesdir)" | 86 | am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includesdir)" |
88 | LTLIBRARIES = $(lib_LTLIBRARIES) | 87 | LTLIBRARIES = $(lib_LTLIBRARIES) |
89 | am_libecore_wayland_la_OBJECTS = ecore_wl.lo | 88 | am_libecore_wayland_la_OBJECTS = ecore_wl.lo ecore_wl_output.lo \ |
89 | ecore_wl_input.lo ecore_wl_window.lo ecore_wl_dnd.lo | ||
90 | libecore_wayland_la_OBJECTS = $(am_libecore_wayland_la_OBJECTS) | 90 | libecore_wayland_la_OBJECTS = $(am_libecore_wayland_la_OBJECTS) |
91 | AM_V_lt = $(am__v_lt_$(V)) | 91 | AM_V_lt = $(am__v_lt_$(V)) |
92 | am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) | 92 | am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) |
@@ -190,6 +190,8 @@ EVAS_LIBS = @EVAS_LIBS@ | |||
190 | EVIL_CFLAGS = @EVIL_CFLAGS@ | 190 | EVIL_CFLAGS = @EVIL_CFLAGS@ |
191 | EVIL_LIBS = @EVIL_LIBS@ | 191 | EVIL_LIBS = @EVIL_LIBS@ |
192 | EXEEXT = @EXEEXT@ | 192 | EXEEXT = @EXEEXT@ |
193 | EXOTIC_CFLAGS = @EXOTIC_CFLAGS@ | ||
194 | EXOTIC_LIBS = @EXOTIC_LIBS@ | ||
193 | FGREP = @FGREP@ | 195 | FGREP = @FGREP@ |
194 | GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ | 196 | GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ |
195 | GLIB_CFLAGS = @GLIB_CFLAGS@ | 197 | GLIB_CFLAGS = @GLIB_CFLAGS@ |
@@ -245,6 +247,8 @@ PATH_SEPARATOR = @PATH_SEPARATOR@ | |||
245 | PIXMAN_CFLAGS = @PIXMAN_CFLAGS@ | 247 | PIXMAN_CFLAGS = @PIXMAN_CFLAGS@ |
246 | PIXMAN_LIBS = @PIXMAN_LIBS@ | 248 | PIXMAN_LIBS = @PIXMAN_LIBS@ |
247 | PKG_CONFIG = @PKG_CONFIG@ | 249 | PKG_CONFIG = @PKG_CONFIG@ |
250 | PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ | ||
251 | PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ | ||
248 | POSUB = @POSUB@ | 252 | POSUB = @POSUB@ |
249 | RANLIB = @RANLIB@ | 253 | RANLIB = @RANLIB@ |
250 | SCIM_CFLAGS = @SCIM_CFLAGS@ | 254 | SCIM_CFLAGS = @SCIM_CFLAGS@ |
@@ -255,6 +259,7 @@ SDL_LIBS = @SDL_LIBS@ | |||
255 | SED = @SED@ | 259 | SED = @SED@ |
256 | SET_MAKE = @SET_MAKE@ | 260 | SET_MAKE = @SET_MAKE@ |
257 | SHELL = @SHELL@ | 261 | SHELL = @SHELL@ |
262 | SHM_OPEN_LIBS = @SHM_OPEN_LIBS@ | ||
258 | SSL_CFLAGS = @SSL_CFLAGS@ | 263 | SSL_CFLAGS = @SSL_CFLAGS@ |
259 | SSL_LIBS = @SSL_LIBS@ | 264 | SSL_LIBS = @SSL_LIBS@ |
260 | STRIP = @STRIP@ | 265 | STRIP = @STRIP@ |
@@ -482,7 +487,11 @@ lib_LTLIBRARIES = libecore_wayland.la | |||
482 | includes_HEADERS = Ecore_Wayland.h | 487 | includes_HEADERS = Ecore_Wayland.h |
483 | includesdir = $(includedir)/ecore-@VMAJ@ | 488 | includesdir = $(includedir)/ecore-@VMAJ@ |
484 | libecore_wayland_la_SOURCES = \ | 489 | libecore_wayland_la_SOURCES = \ |
485 | ecore_wl.c | 490 | ecore_wl.c \ |
491 | ecore_wl_output.c \ | ||
492 | ecore_wl_input.c \ | ||
493 | ecore_wl_window.c \ | ||
494 | ecore_wl_dnd.c | ||
486 | 495 | ||
487 | libecore_wayland_la_LIBADD = \ | 496 | libecore_wayland_la_LIBADD = \ |
488 | $(top_builddir)/src/lib/ecore/libecore.la \ | 497 | $(top_builddir)/src/lib/ecore/libecore.la \ |
@@ -569,6 +578,10 @@ distclean-compile: | |||
569 | -rm -f *.tab.c | 578 | -rm -f *.tab.c |
570 | 579 | ||
571 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_wl.Plo@am__quote@ | 580 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_wl.Plo@am__quote@ |
581 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_wl_dnd.Plo@am__quote@ | ||
582 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_wl_input.Plo@am__quote@ | ||
583 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_wl_output.Plo@am__quote@ | ||
584 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_wl_window.Plo@am__quote@ | ||
572 | 585 | ||
573 | .c.o: | 586 | .c.o: |
574 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< | 587 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< |
diff --git a/libraries/ecore/src/lib/ecore_wayland/ecore_wl.c b/libraries/ecore/src/lib/ecore_wayland/ecore_wl.c index f62503b..5f1b20d 100644 --- a/libraries/ecore/src/lib/ecore_wayland/ecore_wl.c +++ b/libraries/ecore/src/lib/ecore_wayland/ecore_wl.c | |||
@@ -1,16 +1,11 @@ | |||
1 | #ifdef HAVE_CONFIG_H | 1 | #ifdef HAVE_CONFIG_H |
2 | # include "config.h" | 2 | # include <config.h> |
3 | #endif | 3 | #endif |
4 | 4 | ||
5 | #include "Ecore.h" | 5 | #include <fcntl.h> |
6 | #include "ecore_private.h" | ||
7 | #include "Ecore_Input.h" | ||
8 | #include "ecore_wl_private.h" | ||
9 | #include "Ecore_Wayland.h" | ||
10 | 6 | ||
11 | /* FIXME: This gives BTN_LEFT/RIGHT/MIDDLE for linux systems ... | 7 | /* FIXME: This gives BTN_LEFT/RIGHT/MIDDLE for linux systems ... |
12 | * What about other OSs ?? */ | 8 | * What about other OSs ?? */ |
13 | #include <fcntl.h> | ||
14 | #ifdef __linux__ | 9 | #ifdef __linux__ |
15 | # include <linux/input.h> | 10 | # include <linux/input.h> |
16 | #else | 11 | #else |
@@ -23,150 +18,86 @@ | |||
23 | # define BTN_BACK 0x116 | 18 | # define BTN_BACK 0x116 |
24 | #endif | 19 | #endif |
25 | 20 | ||
26 | #include <X11/extensions/XKBcommon.h> | 21 | #include "Ecore.h" |
22 | #include "ecore_private.h" | ||
23 | #include "Ecore_Input.h" | ||
24 | #include "ecore_wl_private.h" | ||
25 | #include "Ecore_Wayland.h" | ||
27 | 26 | ||
28 | /* local function prototypes */ | 27 | /* local function prototypes */ |
29 | static Eina_Bool _ecore_wl_shutdown(Eina_Bool close_display); | 28 | static Eina_Bool _ecore_wl_shutdown(Eina_Bool close); |
30 | static void _ecore_wl_cb_disp_handle_global(struct wl_display *disp, uint32_t id, const char *interface, uint32_t version __UNUSED__, void *data __UNUSED__); | 29 | static int _ecore_wl_cb_event_mask_update(unsigned int mask, void *data); |
31 | static int _ecore_wl_cb_disp_event_mask_update(uint32_t mask, void *data __UNUSED__); | 30 | static Eina_Bool _ecore_wl_cb_handle_data(void *data, Ecore_Fd_Handler *hdl __UNUSED__); |
32 | static void _ecore_wl_cb_disp_handle_geometry(void *data __UNUSED__, struct wl_output *output __UNUSED__, int x, int y, int pw __UNUSED__, int ph __UNUSED__, int subpixel __UNUSED__, const char *make __UNUSED__, const char *model __UNUSED__); | 31 | static void _ecore_wl_cb_handle_global(struct wl_display *disp, unsigned int id, const char *interface, unsigned int version __UNUSED__, void *data); |
33 | static void _ecore_wl_cb_disp_handle_mode(void *data __UNUSED__, struct wl_output *output __UNUSED__, uint32_t flags, int w, int h, int refresh __UNUSED__); | 32 | static Eina_Bool _ecore_wl_egl_init(Ecore_Wl_Display *ewd); |
34 | static Eina_Bool _ecore_wl_cb_fd_handle(void *data, Ecore_Fd_Handler *hdl __UNUSED__); | 33 | static Eina_Bool _ecore_wl_egl_shutdown(Ecore_Wl_Display *ewd); |
35 | static void _ecore_wl_cb_handle_motion(void *data __UNUSED__, struct wl_input_device *dev, uint32_t t, int32_t x, int32_t y, int32_t sx, int32_t sy); | 34 | static Eina_Bool _ecore_wl_xkb_init(Ecore_Wl_Display *ewd); |
36 | static void _ecore_wl_cb_handle_button(void *data __UNUSED__, struct wl_input_device *dev, uint32_t t, uint32_t btn, uint32_t state); | 35 | static Eina_Bool _ecore_wl_xkb_shutdown(Ecore_Wl_Display *ewd); |
37 | static void _ecore_wl_cb_handle_key(void *data __UNUSED__, struct wl_input_device *dev, uint32_t t __UNUSED__, uint32_t key, uint32_t state); | ||
38 | static void _ecore_wl_cb_handle_pointer_focus(void *data __UNUSED__, struct wl_input_device *dev, uint32_t t, struct wl_surface *surface, int32_t x, int32_t y, int32_t sx, int32_t sy); | ||
39 | static void _ecore_wl_cb_handle_keyboard_focus(void *data __UNUSED__, struct wl_input_device *dev, uint32_t t __UNUSED__, struct wl_surface *surface, struct wl_array *keys); | ||
40 | static void _ecore_wl_cb_handle_touch_down(void *data __UNUSED__, struct wl_input_device *dev __UNUSED__, uint32_t timestamp, struct wl_surface *surface, int32_t id, int32_t x, int32_t y); | ||
41 | static void _ecore_wl_cb_handle_touch_up(void *data __UNUSED__, struct wl_input_device *dev __UNUSED__, uint32_t timestamp, int32_t id); | ||
42 | static void _ecore_wl_cb_handle_touch_motion(void *data __UNUSED__, struct wl_input_device *dev __UNUSED__, uint32_t timestamp, int32_t id, int32_t x, int32_t y); | ||
43 | static void _ecore_wl_cb_handle_touch_frame(void *data __UNUSED__, struct wl_input_device *dev __UNUSED__); | ||
44 | static void _ecore_wl_cb_handle_touch_cancel(void *data __UNUSED__, struct wl_input_device *dev __UNUSED__); | ||
45 | static void _ecore_wl_cb_source_target(void *data, struct wl_data_source *source __UNUSED__, const char *mime_type __UNUSED__); | ||
46 | static void _ecore_wl_cb_source_send(void *data, struct wl_data_source *source, const char *mime_type, int32_t fd); | ||
47 | static void _ecore_wl_cb_source_cancelled(void *data, struct wl_data_source *source __UNUSED__); | ||
48 | static void _ecore_wl_cb_source_offer(void *data, struct wl_data_offer *offer __UNUSED__, const char *type); | ||
49 | static void _ecore_wl_cb_data_offer(void *data, struct wl_data_device *data_dev, uint32_t id); | ||
50 | static void _ecore_wl_cb_data_enter(void *data __UNUSED__, struct wl_data_device *data_dev, uint32_t timestamp, struct wl_surface *surface, int32_t x, int32_t y, struct wl_data_offer *offer); | ||
51 | static void _ecore_wl_cb_data_leave(void *data __UNUSED__, struct wl_data_device *data_dev); | ||
52 | static void _ecore_wl_cb_data_motion(void *data __UNUSED__, struct wl_data_device *data_dev, uint32_t timestamp, int32_t x, int32_t y); | ||
53 | static void _ecore_wl_cb_data_drop(void *data __UNUSED__, struct wl_data_device *data_dev); | ||
54 | static void _ecore_wl_cb_data_selection(void *data, struct wl_data_device *data_dev, struct wl_data_offer *offer); | ||
55 | |||
56 | static void _ecore_wl_mouse_move_send(uint32_t timestamp); | ||
57 | static void _ecore_wl_mouse_out_send(struct wl_surface *surface, uint32_t timestamp); | ||
58 | static void _ecore_wl_mouse_in_send(struct wl_surface *surface, uint32_t timestamp); | ||
59 | static void _ecore_wl_mouse_up_send(struct wl_surface *surface, uint32_t button, uint32_t timestamp); | ||
60 | static void _ecore_wl_mouse_down_send(struct wl_surface *surface, uint32_t button, uint32_t timestamp); | ||
61 | static void _ecore_wl_focus_out_send(struct wl_surface *surface, uint32_t timestamp); | ||
62 | static void _ecore_wl_focus_in_send(struct wl_surface *surface, uint32_t timestamp); | ||
63 | 36 | ||
64 | /* local variables */ | 37 | /* local variables */ |
65 | static int _ecore_wl_init_count = 0; | 38 | static int _ecore_wl_init_count = 0; |
66 | static struct wl_display *_ecore_wl_disp = NULL; | ||
67 | static uint32_t _ecore_wl_disp_mask = 0; | ||
68 | static uint32_t _ecore_wl_disp_format = WL_SHM_FORMAT_ARGB8888; | ||
69 | static Eina_Rectangle _ecore_wl_screen; | ||
70 | static Ecore_Fd_Handler *_ecore_wl_fd_hdl = NULL; | ||
71 | static int _ecore_wl_screen_x = 0; | ||
72 | static int _ecore_wl_screen_y = 0; | ||
73 | static int _ecore_wl_surface_x = 0; | ||
74 | static int _ecore_wl_surface_y = 0; | ||
75 | static int _ecore_wl_touch_x = 0; | ||
76 | static int _ecore_wl_touch_y = 0; | ||
77 | static int _ecore_wl_input_modifiers = 0; | ||
78 | static struct xkb_desc *_ecore_wl_xkb; | ||
79 | static uint32_t _ecore_wl_input_button = 0; | ||
80 | |||
81 | static struct wl_compositor *_ecore_wl_comp; | ||
82 | static struct wl_shm *_ecore_wl_shm; | ||
83 | static struct wl_shell *_ecore_wl_shell; | ||
84 | static struct wl_output *_ecore_wl_output; | ||
85 | static struct wl_input_device *_ecore_wl_input_dev; | ||
86 | static struct wl_surface *_ecore_wl_input_surface; | ||
87 | static struct wl_surface *_ecore_wl_touch_surface; | ||
88 | static struct wl_data_device_manager *_ecore_wl_data_manager; | ||
89 | static struct wl_data_device *_ecore_wl_data_dev; | ||
90 | |||
91 | static const struct wl_output_listener _ecore_wl_output_listener = | ||
92 | { | ||
93 | _ecore_wl_cb_disp_handle_geometry, | ||
94 | _ecore_wl_cb_disp_handle_mode | ||
95 | }; | ||
96 | static const struct wl_input_device_listener _ecore_wl_input_listener = | ||
97 | { | ||
98 | _ecore_wl_cb_handle_motion, | ||
99 | _ecore_wl_cb_handle_button, | ||
100 | _ecore_wl_cb_handle_key, | ||
101 | _ecore_wl_cb_handle_pointer_focus, | ||
102 | _ecore_wl_cb_handle_keyboard_focus, | ||
103 | _ecore_wl_cb_handle_touch_down, | ||
104 | _ecore_wl_cb_handle_touch_up, | ||
105 | _ecore_wl_cb_handle_touch_motion, | ||
106 | _ecore_wl_cb_handle_touch_frame, | ||
107 | _ecore_wl_cb_handle_touch_cancel, | ||
108 | }; | ||
109 | static const struct wl_data_source_listener _ecore_wl_source_listener = | ||
110 | { | ||
111 | _ecore_wl_cb_source_target, | ||
112 | _ecore_wl_cb_source_send, | ||
113 | _ecore_wl_cb_source_cancelled | ||
114 | }; | ||
115 | static const struct wl_data_device_listener _ecore_wl_data_listener = | ||
116 | { | ||
117 | _ecore_wl_cb_data_offer, | ||
118 | _ecore_wl_cb_data_enter, | ||
119 | _ecore_wl_cb_data_leave, | ||
120 | _ecore_wl_cb_data_motion, | ||
121 | _ecore_wl_cb_data_drop, | ||
122 | _ecore_wl_cb_data_selection | ||
123 | }; | ||
124 | static const struct wl_data_offer_listener _ecore_wl_offer_listener = | ||
125 | { | ||
126 | _ecore_wl_cb_source_offer, | ||
127 | }; | ||
128 | 39 | ||
129 | /* external variables */ | 40 | /* external variables */ |
130 | int _ecore_wl_log_dom = -1; | 41 | int _ecore_wl_log_dom = -1; |
42 | Ecore_Wl_Display *_ecore_wl_disp = NULL; | ||
43 | |||
131 | EAPI int ECORE_WL_EVENT_MOUSE_IN = 0; | 44 | EAPI int ECORE_WL_EVENT_MOUSE_IN = 0; |
132 | EAPI int ECORE_WL_EVENT_MOUSE_OUT = 0; | 45 | EAPI int ECORE_WL_EVENT_MOUSE_OUT = 0; |
133 | EAPI int ECORE_WL_EVENT_FOCUS_IN = 0; | 46 | EAPI int ECORE_WL_EVENT_FOCUS_IN = 0; |
134 | EAPI int ECORE_WL_EVENT_FOCUS_OUT = 0; | 47 | EAPI int ECORE_WL_EVENT_FOCUS_OUT = 0; |
135 | EAPI int ECORE_WL_EVENT_DRAG_START = 0; | 48 | EAPI int ECORE_WL_EVENT_WINDOW_CONFIGURE = 0; |
136 | EAPI int ECORE_WL_EVENT_DRAG_STOP = 0; | 49 | EAPI int ECORE_WL_EVENT_DND_ENTER = 0; |
137 | 50 | EAPI int ECORE_WL_EVENT_DND_POSITION = 0; | |
51 | EAPI int ECORE_WL_EVENT_DND_LEAVE = 0; | ||
52 | EAPI int ECORE_WL_EVENT_DND_DROP = 0; | ||
53 | EAPI int ECORE_WL_EVENT_INTERFACES_BOUND = 0; | ||
54 | |||
55 | /** | ||
56 | * @defgroup Ecore_Wl_Init_Group Wayland Library Init and Shutdown Functions | ||
57 | * | ||
58 | * Functions that start and shutdown the Ecore Wayland Library. | ||
59 | */ | ||
60 | |||
61 | /** | ||
62 | * Initialize the Wayland display connection to the given display. | ||
63 | * | ||
64 | * @param name Display target name. if @c NULL, the default display is | ||
65 | * assumed. | ||
66 | * @return The number of times the library has been initialized without being | ||
67 | * shut down. 0 is returned if an error occurs. | ||
68 | * | ||
69 | * @ingroup Ecore_Wl_Init_Group | ||
70 | */ | ||
138 | EAPI int | 71 | EAPI int |
139 | ecore_wl_init(const char *name) | 72 | ecore_wl_init(const char *name) |
140 | { | 73 | { |
141 | struct xkb_rule_names xkb_names; | ||
142 | int fd = 0; | ||
143 | |||
144 | if (++_ecore_wl_init_count != 1) | ||
145 | return _ecore_wl_init_count; | ||
146 | |||
147 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | 74 | LOGFN(__FILE__, __LINE__, __FUNCTION__); |
148 | 75 | ||
76 | if (++_ecore_wl_init_count != 1) return _ecore_wl_init_count; | ||
77 | |||
149 | if (!eina_init()) return --_ecore_wl_init_count; | 78 | if (!eina_init()) return --_ecore_wl_init_count; |
150 | 79 | ||
151 | _ecore_wl_log_dom = | 80 | _ecore_wl_log_dom = |
152 | eina_log_domain_register("ecore_wl", ECORE_WL_DEFAULT_LOG_COLOR); | 81 | eina_log_domain_register("ecore_wl", ECORE_WL_DEFAULT_LOG_COLOR); |
153 | if (_ecore_wl_log_dom < 0) | 82 | if (_ecore_wl_log_dom < 0) |
154 | { | 83 | { |
155 | EINA_LOG_ERR("Cannot create a log domain for Ecore Wayland."); | 84 | EINA_LOG_ERR("Cannot create a log domain for Ecore Wayland"); |
156 | eina_shutdown(); | 85 | eina_shutdown(); |
157 | return --_ecore_wl_init_count; | 86 | return --_ecore_wl_init_count; |
158 | } | 87 | } |
159 | 88 | ||
160 | if (!ecore_init()) | 89 | if (!ecore_init()) |
161 | { | 90 | { |
91 | ERR("Could not initialize ecore"); | ||
162 | eina_log_domain_unregister(_ecore_wl_log_dom); | 92 | eina_log_domain_unregister(_ecore_wl_log_dom); |
163 | _ecore_wl_log_dom = -1; | 93 | _ecore_wl_log_dom = -1; |
164 | eina_shutdown(); | 94 | eina_shutdown(); |
165 | return --_ecore_wl_init_count; | 95 | return --_ecore_wl_init_count; |
166 | } | 96 | } |
167 | 97 | ||
168 | if (!ecore_event_init()) | 98 | if (!ecore_event_init()) |
169 | { | 99 | { |
100 | ERR("Could not initialize ecore_event"); | ||
170 | eina_log_domain_unregister(_ecore_wl_log_dom); | 101 | eina_log_domain_unregister(_ecore_wl_log_dom); |
171 | _ecore_wl_log_dom = -1; | 102 | _ecore_wl_log_dom = -1; |
172 | ecore_shutdown(); | 103 | ecore_shutdown(); |
@@ -174,26 +105,23 @@ ecore_wl_init(const char *name) | |||
174 | return --_ecore_wl_init_count; | 105 | return --_ecore_wl_init_count; |
175 | } | 106 | } |
176 | 107 | ||
177 | if (!ECORE_WL_EVENT_MOUSE_IN) | 108 | if (!ECORE_WL_EVENT_MOUSE_IN) |
178 | { | 109 | { |
179 | ECORE_WL_EVENT_MOUSE_IN = ecore_event_type_new(); | 110 | ECORE_WL_EVENT_MOUSE_IN = ecore_event_type_new(); |
180 | ECORE_WL_EVENT_MOUSE_OUT = ecore_event_type_new(); | 111 | ECORE_WL_EVENT_MOUSE_OUT = ecore_event_type_new(); |
181 | ECORE_WL_EVENT_FOCUS_IN = ecore_event_type_new(); | 112 | ECORE_WL_EVENT_FOCUS_IN = ecore_event_type_new(); |
182 | ECORE_WL_EVENT_FOCUS_OUT = ecore_event_type_new(); | 113 | ECORE_WL_EVENT_FOCUS_OUT = ecore_event_type_new(); |
183 | ECORE_WL_EVENT_DRAG_START = ecore_event_type_new(); | 114 | ECORE_WL_EVENT_WINDOW_CONFIGURE = ecore_event_type_new(); |
184 | ECORE_WL_EVENT_DRAG_STOP = ecore_event_type_new(); | 115 | ECORE_WL_EVENT_DND_ENTER = ecore_event_type_new(); |
116 | ECORE_WL_EVENT_DND_POSITION = ecore_event_type_new(); | ||
117 | ECORE_WL_EVENT_DND_LEAVE = ecore_event_type_new(); | ||
118 | ECORE_WL_EVENT_DND_DROP = ecore_event_type_new(); | ||
119 | ECORE_WL_EVENT_INTERFACES_BOUND = ecore_event_type_new(); | ||
185 | } | 120 | } |
186 | 121 | ||
187 | /* init xkb */ | 122 | if (!(_ecore_wl_disp = malloc(sizeof(Ecore_Wl_Display)))) |
188 | /* FIXME: Somehow make this portable to other languages/countries */ | ||
189 | xkb_names.rules = "evdev"; | ||
190 | xkb_names.model = "evdev"; | ||
191 | xkb_names.layout = "us"; | ||
192 | xkb_names.variant = ""; | ||
193 | xkb_names.options = ""; | ||
194 | if (!(_ecore_wl_xkb = xkb_compile_keymap_from_rules(&xkb_names))) | ||
195 | { | 123 | { |
196 | ERR("Could not compile keymap"); | 124 | ERR("Could not allocate memory for Ecore_Wl_Display structure"); |
197 | eina_log_domain_unregister(_ecore_wl_log_dom); | 125 | eina_log_domain_unregister(_ecore_wl_log_dom); |
198 | _ecore_wl_log_dom = -1; | 126 | _ecore_wl_log_dom = -1; |
199 | ecore_event_shutdown(); | 127 | ecore_event_shutdown(); |
@@ -202,9 +130,11 @@ ecore_wl_init(const char *name) | |||
202 | return --_ecore_wl_init_count; | 130 | return --_ecore_wl_init_count; |
203 | } | 131 | } |
204 | 132 | ||
205 | /* connect to the wayland display */ | 133 | memset(_ecore_wl_disp, 0, sizeof(Ecore_Wl_Display)); |
206 | if (!(_ecore_wl_disp = wl_display_connect(name))) | 134 | |
135 | if (!(_ecore_wl_disp->wl.display = wl_display_connect(name))) | ||
207 | { | 136 | { |
137 | ERR("Could not connect to Wayland display"); | ||
208 | eina_log_domain_unregister(_ecore_wl_log_dom); | 138 | eina_log_domain_unregister(_ecore_wl_log_dom); |
209 | _ecore_wl_log_dom = -1; | 139 | _ecore_wl_log_dom = -1; |
210 | ecore_event_shutdown(); | 140 | ecore_event_shutdown(); |
@@ -213,23 +143,48 @@ ecore_wl_init(const char *name) | |||
213 | return --_ecore_wl_init_count; | 143 | return --_ecore_wl_init_count; |
214 | } | 144 | } |
215 | 145 | ||
216 | /* setup handler for wayland interfaces */ | 146 | _ecore_wl_disp->fd = |
217 | wl_display_add_global_listener(_ecore_wl_disp, | 147 | wl_display_get_fd(_ecore_wl_disp->wl.display, |
218 | _ecore_wl_cb_disp_handle_global, NULL); | 148 | _ecore_wl_cb_event_mask_update, _ecore_wl_disp); |
149 | |||
150 | _ecore_wl_disp->fd_hdl = | ||
151 | ecore_main_fd_handler_add(_ecore_wl_disp->fd, ECORE_FD_READ, | ||
152 | _ecore_wl_cb_handle_data, _ecore_wl_disp, | ||
153 | NULL, NULL); | ||
154 | |||
155 | wl_list_init(&_ecore_wl_disp->inputs); | ||
156 | wl_list_init(&_ecore_wl_disp->outputs); | ||
157 | |||
158 | wl_display_add_global_listener(_ecore_wl_disp->wl.display, | ||
159 | _ecore_wl_cb_handle_global, _ecore_wl_disp); | ||
160 | |||
161 | /* FIXME: Process connection events ?? */ | ||
162 | wl_display_iterate(_ecore_wl_disp->wl.display, WL_DISPLAY_READABLE); | ||
163 | |||
164 | /* if (!_ecore_wl_egl_init(_ecore_wl_disp)) */ | ||
165 | /* { */ | ||
166 | /* ERR("Could not initialize EGL"); */ | ||
167 | /* free(_ecore_wl_disp); */ | ||
168 | /* eina_log_domain_unregister(_ecore_wl_log_dom); */ | ||
169 | /* _ecore_wl_log_dom = -1; */ | ||
170 | /* ecore_event_shutdown(); */ | ||
171 | /* ecore_shutdown(); */ | ||
172 | /* eina_shutdown(); */ | ||
173 | /* return --_ecore_wl_init_count; */ | ||
174 | /* } */ | ||
219 | 175 | ||
220 | /* process connection events */ | 176 | /* _ecore_wl_disp->create_image = */ |
221 | wl_display_iterate(_ecore_wl_disp, WL_DISPLAY_READABLE); | 177 | /* (void *)eglGetProcAddress("eglCreateImageKHR"); */ |
178 | /* _ecore_wl_disp->destroy_image = */ | ||
179 | /* (void *)eglGetProcAddress("eglDestroyImageKHR"); */ | ||
222 | 180 | ||
223 | fd = wl_display_get_fd(_ecore_wl_disp, | 181 | /* TODO: create pointer surfaces */ |
224 | _ecore_wl_cb_disp_event_mask_update, NULL); | ||
225 | 182 | ||
226 | _ecore_wl_fd_hdl = | 183 | if (!_ecore_wl_xkb_init(_ecore_wl_disp)) |
227 | ecore_main_fd_handler_add(fd, ECORE_FD_READ, _ecore_wl_cb_fd_handle, | ||
228 | _ecore_wl_disp, NULL, NULL); | ||
229 | if (!_ecore_wl_fd_hdl) | ||
230 | { | 184 | { |
231 | wl_display_destroy(_ecore_wl_disp); | 185 | ERR("Could not initialize XKB"); |
232 | _ecore_wl_disp = NULL; | 186 | _ecore_wl_egl_shutdown(_ecore_wl_disp); |
187 | free(_ecore_wl_disp); | ||
233 | eina_log_domain_unregister(_ecore_wl_log_dom); | 188 | eina_log_domain_unregister(_ecore_wl_log_dom); |
234 | _ecore_wl_log_dom = -1; | 189 | _ecore_wl_log_dom = -1; |
235 | ecore_event_shutdown(); | 190 | ecore_event_shutdown(); |
@@ -238,976 +193,359 @@ ecore_wl_init(const char *name) | |||
238 | return --_ecore_wl_init_count; | 193 | return --_ecore_wl_init_count; |
239 | } | 194 | } |
240 | 195 | ||
196 | _ecore_wl_window_init(); | ||
197 | |||
241 | return _ecore_wl_init_count; | 198 | return _ecore_wl_init_count; |
242 | } | 199 | } |
243 | 200 | ||
201 | /** | ||
202 | * Shuts down the Ecore Wayland Library | ||
203 | * | ||
204 | * In shutting down the library, the Wayland display connection is terminated | ||
205 | * and any event handlers for it are removed. | ||
206 | * | ||
207 | * @return The number of times the library has been initialized without | ||
208 | * being shut down. | ||
209 | * | ||
210 | * @ingroup Ecore_Wl_Init_Group | ||
211 | */ | ||
244 | EAPI int | 212 | EAPI int |
245 | ecore_wl_shutdown(void) | 213 | ecore_wl_shutdown(void) |
246 | { | 214 | { |
247 | return _ecore_wl_shutdown(EINA_TRUE); | 215 | LOGFN(__FILE__, __LINE__, __FUNCTION__); |
248 | } | ||
249 | |||
250 | EAPI struct wl_display * | ||
251 | ecore_wl_display_get(void) | ||
252 | { | ||
253 | return _ecore_wl_disp; | ||
254 | } | ||
255 | |||
256 | EAPI struct wl_shm * | ||
257 | ecore_wl_shm_get(void) | ||
258 | { | ||
259 | return _ecore_wl_shm; | ||
260 | } | ||
261 | |||
262 | EAPI struct wl_compositor * | ||
263 | ecore_wl_compositor_get(void) | ||
264 | { | ||
265 | return _ecore_wl_comp; | ||
266 | } | ||
267 | 216 | ||
268 | EAPI struct wl_shell * | 217 | return _ecore_wl_shutdown(EINA_TRUE); |
269 | ecore_wl_shell_get(void) | ||
270 | { | ||
271 | return _ecore_wl_shell; | ||
272 | } | 218 | } |
273 | 219 | ||
274 | EAPI struct wl_input_device * | 220 | /** |
275 | ecore_wl_input_device_get(void) | 221 | * @defgroup Ecore_Wl_Flush_Group Wayland Synchronization Functions |
276 | { | 222 | * |
277 | return _ecore_wl_input_dev; | 223 | * Functions that ensure that all commands which have been issued by the |
278 | } | 224 | * Ecore Wayland library have been sent to the server. |
225 | */ | ||
279 | 226 | ||
227 | /** | ||
228 | * Sends all Wayland commands to the Wayland Display. | ||
229 | * | ||
230 | * @ingroup Ecore_Wl_Flush_Group | ||
231 | * @since 1.2 | ||
232 | */ | ||
280 | EAPI void | 233 | EAPI void |
281 | ecore_wl_screen_size_get(int *w, int *h) | 234 | ecore_wl_flush(void) |
282 | { | 235 | { |
283 | if (w) *w = _ecore_wl_screen.w; | 236 | LOGFN(__FILE__, __LINE__, __FUNCTION__); |
284 | if (h) *h = _ecore_wl_screen.h; | ||
285 | } | ||
286 | |||
287 | EAPI unsigned int | ||
288 | ecore_wl_format_get(void) | ||
289 | { | ||
290 | return _ecore_wl_disp_format; | ||
291 | } | ||
292 | 237 | ||
293 | EAPI void | 238 | while (_ecore_wl_disp->mask & WL_DISPLAY_WRITABLE) |
294 | ecore_wl_flush(void) | 239 | wl_display_iterate(_ecore_wl_disp->wl.display, WL_DISPLAY_WRITABLE); |
295 | { | 240 | // wl_display_flush(_ecore_wl_disp->wl.display); // old flush code |
296 | wl_display_flush(_ecore_wl_disp); | ||
297 | } | 241 | } |
298 | 242 | ||
243 | /** | ||
244 | * Flushes the command buffer and waits until all requests have been | ||
245 | * processed by the server. | ||
246 | * | ||
247 | * @ingroup Ecore_Wl_Flush_Group | ||
248 | * @since 1.2 | ||
249 | */ | ||
299 | EAPI void | 250 | EAPI void |
300 | ecore_wl_sync(void) | 251 | ecore_wl_sync(void) |
301 | { | 252 | { |
302 | wl_display_iterate(_ecore_wl_disp, WL_DISPLAY_READABLE); | 253 | LOGFN(__FILE__, __LINE__, __FUNCTION__); |
303 | } | ||
304 | 254 | ||
305 | EAPI void | 255 | wl_display_roundtrip(_ecore_wl_disp->wl.display); |
306 | ecore_wl_pointer_xy_get(int *x, int *y) | 256 | // old sync code |
257 | // wl_display_iterate(_ecore_wl_disp->wl.display, WL_DISPLAY_READABLE); | ||
258 | } | ||
259 | |||
260 | /** | ||
261 | * @defgroup Ecore_Wl_Display_Group Wayland Display Functions | ||
262 | * | ||
263 | * Functions that set and retrieve various information about the Wayland Display. | ||
264 | */ | ||
265 | |||
266 | /** | ||
267 | * Retrieves the Wayland Shm Interface used for the current Wayland connection. | ||
268 | * | ||
269 | * @return The current wayland shm interface | ||
270 | * | ||
271 | * @ingroup Ecore_Wl_Display_Group | ||
272 | * @since 1.2 | ||
273 | */ | ||
274 | EAPI struct wl_shm * | ||
275 | ecore_wl_shm_get(void) | ||
307 | { | 276 | { |
308 | if (x) *x = _ecore_wl_screen_x; | 277 | return _ecore_wl_disp->wl.shm; |
309 | if (y) *y = _ecore_wl_screen_y; | ||
310 | } | 278 | } |
311 | 279 | ||
312 | EAPI Ecore_Wl_Drag_Source * | 280 | /** |
313 | ecore_wl_drag_source_create(int hotspot_x, int hotspot_y, int offset_x, int offset_y, const char *mimetype, unsigned int timestamp, void *data) | 281 | * Retrieves the Wayland Display Interface used for the current Wayland connection. |
282 | * | ||
283 | * @return The current wayland display interface | ||
284 | * | ||
285 | * @ingroup Ecore_Wl_Display_Group | ||
286 | * @since 1.2 | ||
287 | */ | ||
288 | EAPI struct wl_display * | ||
289 | ecore_wl_display_get(void) | ||
314 | { | 290 | { |
315 | Ecore_Wl_Drag_Source *source; | 291 | return _ecore_wl_disp->wl.display; |
316 | |||
317 | if (!(source = calloc(1, sizeof(Ecore_Wl_Drag_Source)))) return NULL; | ||
318 | |||
319 | source->data_dev = _ecore_wl_data_dev; | ||
320 | source->hotspot_x = hotspot_x; | ||
321 | source->hotspot_y = hotspot_y; | ||
322 | source->offset_x = offset_x; | ||
323 | source->offset_y = offset_y; | ||
324 | source->mimetype = mimetype; | ||
325 | source->timestamp = timestamp; | ||
326 | source->data = data; | ||
327 | |||
328 | source->data_source = | ||
329 | wl_data_device_manager_create_data_source(_ecore_wl_data_manager); | ||
330 | |||
331 | wl_data_source_add_listener(source->data_source, | ||
332 | &_ecore_wl_source_listener, source); | ||
333 | |||
334 | wl_data_source_offer(source->data_source, source->mimetype); | ||
335 | |||
336 | /* NB: Do we add some default mimetypes here ?? */ | ||
337 | /* text/plain, etc */ | ||
338 | |||
339 | return source; | ||
340 | } | 292 | } |
341 | 293 | ||
294 | /** | ||
295 | * Retrieves the size of the current screen. | ||
296 | * | ||
297 | * @param w where to return the width. May be NULL. Returns 0 on error. | ||
298 | * @param h where to return the height. May be NULL. Returns 0 on error. | ||
299 | * | ||
300 | * @ingroup Ecore_Wl_Display_Group | ||
301 | * @since 1.2 | ||
302 | */ | ||
342 | EAPI void | 303 | EAPI void |
343 | ecore_wl_drag_start(Ecore_Wl_Drag_Source *source, struct wl_surface *surface, struct wl_buffer *buffer) | 304 | ecore_wl_screen_size_get(int *w, int *h) |
344 | { | 305 | { |
345 | source->buffer = buffer; | 306 | LOGFN(__FILE__, __LINE__, __FUNCTION__); |
346 | 307 | ||
347 | wl_data_device_start_drag(source->data_dev, source->data_source, | 308 | if (w) *w = _ecore_wl_disp->output->allocation.w; |
348 | surface, source->timestamp); | 309 | if (h) *h = _ecore_wl_disp->output->allocation.h; |
349 | } | 310 | } |
350 | 311 | ||
312 | /* @since 1.2 */ | ||
351 | EAPI void | 313 | EAPI void |
352 | ecore_wl_drag_stop(void) | 314 | ecore_wl_pointer_xy_get(int *x, int *y) |
353 | { | 315 | { |
316 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
354 | 317 | ||
318 | _ecore_wl_input_pointer_xy_get(x, y); | ||
355 | } | 319 | } |
356 | 320 | ||
357 | /* local functions */ | 321 | /* local functions */ |
358 | static Eina_Bool | 322 | static Eina_Bool |
359 | _ecore_wl_shutdown(Eina_Bool close_display) | 323 | _ecore_wl_shutdown(Eina_Bool close) |
360 | { | 324 | { |
361 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | 325 | LOGFN(__FILE__, __LINE__, __FUNCTION__); |
362 | 326 | ||
363 | if (--_ecore_wl_init_count != 0) | 327 | if (--_ecore_wl_init_count != 0) return _ecore_wl_init_count; |
364 | return _ecore_wl_init_count; | ||
365 | |||
366 | if (!_ecore_wl_disp) return _ecore_wl_init_count; | 328 | if (!_ecore_wl_disp) return _ecore_wl_init_count; |
367 | 329 | ||
368 | if (_ecore_wl_xkb) free(_ecore_wl_xkb); | 330 | _ecore_wl_window_shutdown(); |
369 | 331 | ||
370 | if (_ecore_wl_fd_hdl) ecore_main_fd_handler_del(_ecore_wl_fd_hdl); | 332 | if (_ecore_wl_disp->fd_hdl) |
371 | _ecore_wl_fd_hdl = NULL; | 333 | ecore_main_fd_handler_del(_ecore_wl_disp->fd_hdl); |
372 | 334 | ||
373 | if (close_display) | 335 | if (close) |
374 | { | 336 | { |
375 | if (_ecore_wl_data_dev) wl_data_device_destroy(_ecore_wl_data_dev); | 337 | Ecore_Wl_Output *out, *tout; |
376 | if (_ecore_wl_input_dev) wl_input_device_destroy(_ecore_wl_input_dev); | 338 | Ecore_Wl_Input *in, *tin; |
377 | if (_ecore_wl_data_manager) | 339 | |
378 | wl_data_device_manager_destroy(_ecore_wl_data_manager); | 340 | wl_list_for_each_safe(out, tout, &_ecore_wl_disp->outputs, link) |
379 | if (_ecore_wl_shell) wl_shell_destroy(_ecore_wl_shell); | 341 | _ecore_wl_output_del(out); |
380 | if (_ecore_wl_shm) wl_shm_destroy(_ecore_wl_shm); | 342 | |
381 | if (_ecore_wl_comp) wl_compositor_destroy(_ecore_wl_comp); | 343 | wl_list_for_each_safe(in, tin, &_ecore_wl_disp->inputs, link) |
382 | if (_ecore_wl_disp) | 344 | _ecore_wl_input_del(in); |
345 | |||
346 | _ecore_wl_xkb_shutdown(_ecore_wl_disp); | ||
347 | /* _ecore_wl_egl_shutdown(_ecore_wl_disp); */ | ||
348 | |||
349 | if (_ecore_wl_disp->wl.shell) | ||
350 | wl_shell_destroy(_ecore_wl_disp->wl.shell); | ||
351 | if (_ecore_wl_disp->wl.shm) wl_shm_destroy(_ecore_wl_disp->wl.shm); | ||
352 | if (_ecore_wl_disp->wl.data_device_manager) | ||
353 | wl_data_device_manager_destroy(_ecore_wl_disp->wl.data_device_manager); | ||
354 | if (_ecore_wl_disp->wl.compositor) | ||
355 | wl_compositor_destroy(_ecore_wl_disp->wl.compositor); | ||
356 | if (_ecore_wl_disp->wl.display) | ||
383 | { | 357 | { |
384 | wl_display_flush(_ecore_wl_disp); | 358 | wl_display_flush(_ecore_wl_disp->wl.display); |
385 | wl_display_destroy(_ecore_wl_disp); | 359 | wl_display_disconnect(_ecore_wl_disp->wl.display); |
386 | } | 360 | } |
387 | _ecore_wl_disp = NULL; | 361 | free(_ecore_wl_disp); |
388 | } | 362 | } |
389 | 363 | ||
390 | eina_log_domain_unregister(_ecore_wl_log_dom); | ||
391 | _ecore_wl_log_dom = -1; | ||
392 | |||
393 | ecore_event_shutdown(); | 364 | ecore_event_shutdown(); |
394 | ecore_shutdown(); | 365 | ecore_shutdown(); |
366 | |||
367 | eina_log_domain_unregister(_ecore_wl_log_dom); | ||
368 | _ecore_wl_log_dom = -1; | ||
395 | eina_shutdown(); | 369 | eina_shutdown(); |
396 | 370 | ||
397 | return _ecore_wl_init_count; | 371 | return _ecore_wl_init_count; |
398 | } | 372 | } |
399 | 373 | ||
400 | static void | ||
401 | _ecore_wl_cb_disp_handle_global(struct wl_display *disp, uint32_t id, const char *interface, uint32_t version __UNUSED__, void *data __UNUSED__) | ||
402 | { | ||
403 | // LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
404 | |||
405 | if (disp != _ecore_wl_disp) return; | ||
406 | if (!strcmp(interface, "wl_compositor")) | ||
407 | { | ||
408 | _ecore_wl_comp = | ||
409 | wl_display_bind(_ecore_wl_disp, id, &wl_compositor_interface); | ||
410 | } | ||
411 | else if (!strcmp(interface, "wl_shm")) | ||
412 | { | ||
413 | _ecore_wl_shm = | ||
414 | wl_display_bind(_ecore_wl_disp, id, &wl_shm_interface); | ||
415 | } | ||
416 | else if (!strcmp(interface, "wl_output")) | ||
417 | { | ||
418 | _ecore_wl_output = | ||
419 | wl_display_bind(_ecore_wl_disp, id, &wl_output_interface); | ||
420 | wl_output_add_listener(_ecore_wl_output, | ||
421 | &_ecore_wl_output_listener, NULL); | ||
422 | } | ||
423 | else if (!strcmp(interface, "wl_shell")) | ||
424 | { | ||
425 | _ecore_wl_shell = | ||
426 | wl_display_bind(_ecore_wl_disp, id, &wl_shell_interface); | ||
427 | } | ||
428 | else if (!strcmp(interface, "wl_input_device")) | ||
429 | { | ||
430 | _ecore_wl_input_dev = | ||
431 | wl_display_bind(_ecore_wl_disp, id, &wl_input_device_interface); | ||
432 | wl_input_device_add_listener(_ecore_wl_input_dev, | ||
433 | &_ecore_wl_input_listener, NULL); | ||
434 | } | ||
435 | else if (!strcmp(interface, "wl_data_device_manager")) | ||
436 | { | ||
437 | _ecore_wl_data_manager = | ||
438 | wl_display_bind(_ecore_wl_disp, id, | ||
439 | &wl_data_device_manager_interface); | ||
440 | } | ||
441 | |||
442 | if ((_ecore_wl_input_dev) && (_ecore_wl_data_manager) && (!_ecore_wl_data_dev)) | ||
443 | { | ||
444 | _ecore_wl_data_dev = | ||
445 | wl_data_device_manager_get_data_device(_ecore_wl_data_manager, | ||
446 | _ecore_wl_input_dev); | ||
447 | wl_data_device_add_listener(_ecore_wl_data_dev, | ||
448 | &_ecore_wl_data_listener, NULL); | ||
449 | } | ||
450 | } | ||
451 | |||
452 | static int | 374 | static int |
453 | _ecore_wl_cb_disp_event_mask_update(uint32_t mask, void *data __UNUSED__) | 375 | _ecore_wl_cb_event_mask_update(unsigned int mask, void *data) |
454 | { | 376 | { |
455 | // LOGFN(__FILE__, __LINE__, __FUNCTION__); | 377 | Ecore_Wl_Display *ewd; |
456 | 378 | ||
457 | _ecore_wl_disp_mask = mask; | 379 | LOGFN(__FILE__, __LINE__, __FUNCTION__); |
458 | 380 | ||
381 | ewd = data; | ||
382 | ewd->mask = mask; | ||
459 | return 0; | 383 | return 0; |
460 | } | 384 | } |
461 | 385 | ||
462 | static void | ||
463 | _ecore_wl_cb_disp_handle_geometry(void *data __UNUSED__, struct wl_output *output __UNUSED__, int x, int y, int pw __UNUSED__, int ph __UNUSED__, int subpixel __UNUSED__, const char *make __UNUSED__, const char *model __UNUSED__) | ||
464 | { | ||
465 | _ecore_wl_screen.x = x; | ||
466 | _ecore_wl_screen.y = y; | ||
467 | } | ||
468 | |||
469 | static void | ||
470 | _ecore_wl_cb_disp_handle_mode(void *data __UNUSED__, struct wl_output *output __UNUSED__, uint32_t flags, int w, int h, int refresh __UNUSED__) | ||
471 | { | ||
472 | if (flags & WL_OUTPUT_MODE_CURRENT) | ||
473 | { | ||
474 | _ecore_wl_screen.w = w; | ||
475 | _ecore_wl_screen.h = h; | ||
476 | } | ||
477 | } | ||
478 | |||
479 | static Eina_Bool | 386 | static Eina_Bool |
480 | _ecore_wl_cb_fd_handle(void *data, Ecore_Fd_Handler *hdl __UNUSED__) | 387 | _ecore_wl_cb_handle_data(void *data, Ecore_Fd_Handler *hdl __UNUSED__) |
481 | { | 388 | { |
482 | struct wl_display *disp; | 389 | Ecore_Wl_Display *ewd; |
483 | |||
484 | // LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
485 | |||
486 | if (!(disp = data)) return ECORE_CALLBACK_RENEW; | ||
487 | if (disp != _ecore_wl_disp) return ECORE_CALLBACK_RENEW; | ||
488 | 390 | ||
489 | if (_ecore_wl_disp_mask & WL_DISPLAY_WRITABLE) | 391 | LOGFN(__FILE__, __LINE__, __FUNCTION__); |
490 | wl_display_iterate(_ecore_wl_disp, WL_DISPLAY_WRITABLE); | ||
491 | |||
492 | if (_ecore_wl_disp_mask & WL_DISPLAY_READABLE) | ||
493 | wl_display_iterate(_ecore_wl_disp, WL_DISPLAY_READABLE); | ||
494 | 392 | ||
393 | if (!(ewd = data)) return ECORE_CALLBACK_RENEW; | ||
394 | wl_display_iterate(ewd->wl.display, ewd->mask); | ||
495 | return ECORE_CALLBACK_RENEW; | 395 | return ECORE_CALLBACK_RENEW; |
496 | } | 396 | } |
497 | 397 | ||
498 | static void | 398 | static void |
499 | _ecore_wl_cb_handle_motion(void *data __UNUSED__, struct wl_input_device *dev, uint32_t t, int32_t x, int32_t y, int32_t sx, int32_t sy) | 399 | _ecore_wl_cb_handle_global(struct wl_display *disp, unsigned int id, const char *interface, unsigned int version __UNUSED__, void *data) |
500 | { | ||
501 | if (dev != _ecore_wl_input_dev) return; | ||
502 | |||
503 | _ecore_wl_screen_x = x; | ||
504 | _ecore_wl_screen_y = y; | ||
505 | _ecore_wl_surface_x = sx; | ||
506 | _ecore_wl_surface_y = sy; | ||
507 | |||
508 | _ecore_wl_mouse_move_send(t); | ||
509 | } | ||
510 | |||
511 | static void | ||
512 | _ecore_wl_cb_handle_button(void *data __UNUSED__, struct wl_input_device *dev, uint32_t t, uint32_t btn, uint32_t state) | ||
513 | { | ||
514 | if (dev != _ecore_wl_input_dev) return; | ||
515 | |||
516 | if ((btn >= BTN_SIDE) && (btn <= BTN_BACK)) | ||
517 | { | ||
518 | Ecore_Event_Mouse_Wheel *ev; | ||
519 | |||
520 | if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Wheel)))) return; | ||
521 | |||
522 | ev->timestamp = t; | ||
523 | ev->x = _ecore_wl_surface_x; | ||
524 | ev->y = _ecore_wl_surface_y; | ||
525 | ev->root.x = _ecore_wl_screen_x; | ||
526 | ev->root.y = _ecore_wl_screen_y; | ||
527 | ev->modifiers = _ecore_wl_input_modifiers; | ||
528 | ev->direction = 0; | ||
529 | |||
530 | if (_ecore_wl_input_surface) | ||
531 | { | ||
532 | unsigned int id = 0; | ||
533 | |||
534 | if ((id = (unsigned int)wl_surface_get_user_data(_ecore_wl_input_surface))) | ||
535 | { | ||
536 | ev->window = id; | ||
537 | ev->event_window = id; | ||
538 | } | ||
539 | } | ||
540 | |||
541 | /* NB: (FIXME) Currently Wayland provides no measure of how much the | ||
542 | * wheel has scrolled (read: delta of movement). So for now, we will | ||
543 | * just assume that the amount scrolled is 1 */ | ||
544 | if ((btn == BTN_EXTRA) || (btn == BTN_FORWARD)) // down | ||
545 | ev->z = 1; | ||
546 | else if ((btn == BTN_SIDE) || (btn == BTN_BACK)) // up | ||
547 | ev->z = -1; | ||
548 | |||
549 | ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, NULL, NULL); | ||
550 | } | ||
551 | else | ||
552 | { | ||
553 | if (state) | ||
554 | { | ||
555 | _ecore_wl_input_button = btn; | ||
556 | _ecore_wl_mouse_down_send(_ecore_wl_input_surface, btn, t); | ||
557 | /* NB: Ideally, this is not the place to check for drags. | ||
558 | * IMO, drags should be handled by the client. EG: we raise the | ||
559 | * mouse_down to the client, and the client can 'request' a | ||
560 | * drag_start from ecore_wl */ | ||
561 | if ((_ecore_wl_input_surface) || (_ecore_wl_touch_surface)) | ||
562 | { | ||
563 | /* record item which was grabbed. | ||
564 | * create drag source. start drag */ | ||
565 | } | ||
566 | } | ||
567 | else | ||
568 | { | ||
569 | if ((_ecore_wl_input_surface) || (_ecore_wl_touch_surface)) | ||
570 | { | ||
571 | /* release grabbed button and finish drag */ | ||
572 | if ((_ecore_wl_input_button) && | ||
573 | (_ecore_wl_input_button == btn)) | ||
574 | { | ||
575 | |||
576 | } | ||
577 | } | ||
578 | _ecore_wl_input_button = 0; | ||
579 | _ecore_wl_mouse_up_send(_ecore_wl_input_surface, btn, t); | ||
580 | } | ||
581 | } | ||
582 | } | ||
583 | |||
584 | static void | ||
585 | _ecore_wl_cb_handle_key(void *data __UNUSED__, struct wl_input_device *dev, uint32_t t __UNUSED__, uint32_t key, uint32_t state) | ||
586 | { | 400 | { |
587 | unsigned int keycode = 0; | 401 | Ecore_Wl_Display *ewd; |
588 | 402 | ||
589 | if (dev != _ecore_wl_input_dev) return; | 403 | LOGFN(__FILE__, __LINE__, __FUNCTION__); |
590 | 404 | ||
591 | keycode = key + _ecore_wl_xkb->min_key_code; | 405 | if ((!strcmp(interface, "wl_display")) || |
406 | (!strcmp(interface, "wl_drm")) || | ||
407 | (!strcmp(interface, "desktop_shell"))) | ||
408 | return; | ||
592 | 409 | ||
593 | if (state) | 410 | ewd = data; |
594 | _ecore_wl_input_modifiers |= _ecore_wl_xkb->map->modmap[keycode]; | ||
595 | else | ||
596 | _ecore_wl_input_modifiers &= ~_ecore_wl_xkb->map->modmap[keycode]; | ||
597 | } | ||
598 | 411 | ||
599 | static void | 412 | if (!strcmp(interface, "wl_compositor")) |
600 | _ecore_wl_cb_handle_pointer_focus(void *data __UNUSED__, struct wl_input_device *dev, uint32_t t, struct wl_surface *surface, int32_t x, int32_t y, int32_t sx, int32_t sy) | 413 | ewd->wl.compositor = wl_display_bind(disp, id, &wl_compositor_interface); |
601 | { | 414 | else if (!strcmp(interface, "wl_output")) |
602 | if (dev != _ecore_wl_input_dev) return; | 415 | _ecore_wl_output_add(ewd, id); |
603 | 416 | else if (!strcmp(interface, "wl_input_device")) | |
604 | /* NB: Wayland pointer focus is weird. It's not pointer focus in the normal | 417 | _ecore_wl_input_add(ewd, id); |
605 | * sense...Wayland 'moving/resizing' (and maybe other stuff) has a habit | 418 | else if (!strcmp(interface, "wl_shell")) |
606 | * of stealing the pointer focus and thus this cannot be used to control | 419 | ewd->wl.shell = wl_display_bind(disp, id, &wl_shell_interface); |
607 | * normal pointer focus. On mouse down, the 'active' surface is stolen | 420 | else if (!strcmp(interface, "wl_shm")) |
608 | * by Wayland for the grab, so 'surface' here ends up being NULL. When a | 421 | ewd->wl.shm = wl_display_bind(disp, id, &wl_shm_interface); |
609 | * move or resize is finished, we get this event again, but this time | 422 | else if (!strcmp(interface, "wl_data_device_manager")) |
610 | * with an active surface */ | ||
611 | _ecore_wl_screen_x = x; | ||
612 | _ecore_wl_screen_y = y; | ||
613 | _ecore_wl_surface_x = sx; | ||
614 | _ecore_wl_surface_y = sy; | ||
615 | |||
616 | if ((_ecore_wl_input_surface) && (_ecore_wl_input_surface != surface)) | ||
617 | { | 423 | { |
618 | if (!_ecore_wl_input_button) | 424 | ewd->wl.data_device_manager = |
619 | _ecore_wl_mouse_out_send(_ecore_wl_input_surface, t); | 425 | wl_display_bind(disp, id, &wl_data_device_manager_interface); |
620 | } | 426 | } |
621 | 427 | ||
622 | if (surface) | 428 | if ((ewd->wl.compositor) && (ewd->wl.shm) && (ewd->wl.shell)) |
623 | { | 429 | { |
624 | if (_ecore_wl_input_button) | 430 | Ecore_Wl_Event_Interfaces_Bound *ev; |
625 | { | ||
626 | _ecore_wl_mouse_up_send(surface, _ecore_wl_input_button, t); | ||
627 | _ecore_wl_input_button = 0; | ||
628 | } | ||
629 | else | ||
630 | _ecore_wl_mouse_in_send(surface, t); | ||
631 | } | ||
632 | } | ||
633 | |||
634 | static void | ||
635 | _ecore_wl_cb_handle_keyboard_focus(void *data __UNUSED__, struct wl_input_device *dev, uint32_t t, struct wl_surface *surface, struct wl_array *keys) | ||
636 | { | ||
637 | unsigned int *keyend = 0, *i = 0; | ||
638 | |||
639 | if (dev != _ecore_wl_input_dev) return; | ||
640 | |||
641 | /* NB: Remove old keyboard focus */ | ||
642 | if ((_ecore_wl_input_surface) && (_ecore_wl_input_surface != surface)) | ||
643 | _ecore_wl_focus_out_send(_ecore_wl_input_surface, t); | ||
644 | 431 | ||
645 | _ecore_wl_input_surface = NULL; | 432 | if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Interfaces_Bound)))) |
433 | return; | ||
646 | 434 | ||
647 | keyend = keys->data + keys->size; | 435 | ev->compositor = (ewd->wl.compositor != NULL); |
648 | _ecore_wl_input_modifiers = 0; | 436 | ev->shm = (ewd->wl.shm != NULL); |
649 | for (i = keys->data; i < keyend; i++) | 437 | ev->shell = (ewd->wl.shell != NULL); |
650 | _ecore_wl_input_modifiers |= _ecore_wl_xkb->map->modmap[*i]; | ||
651 | 438 | ||
652 | if (surface) | 439 | ecore_event_add(ECORE_WL_EVENT_INTERFACES_BOUND, ev, NULL, NULL); |
653 | { | ||
654 | /* set new input surface */ | ||
655 | _ecore_wl_input_surface = surface; | ||
656 | |||
657 | /* send mouse in to new surface */ | ||
658 | /* _ecore_wl_mouse_in_send(surface, t); */ | ||
659 | |||
660 | /* send focus to new surface */ | ||
661 | _ecore_wl_focus_in_send(surface, t); | ||
662 | } | 440 | } |
663 | } | 441 | } |
664 | 442 | ||
665 | static void | 443 | static Eina_Bool |
666 | _ecore_wl_cb_handle_touch_down(void *data __UNUSED__, struct wl_input_device *dev __UNUSED__, uint32_t timestamp, struct wl_surface *surface, int32_t id, int32_t x, int32_t y) | 444 | _ecore_wl_egl_init(Ecore_Wl_Display *ewd) |
667 | { | 445 | { |
668 | Ecore_Event_Mouse_Button *ev; | 446 | EGLint major, minor, n; |
669 | 447 | static const EGLint context_attribs[] = | |
670 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
671 | |||
672 | _ecore_wl_touch_surface = surface; | ||
673 | _ecore_wl_touch_x = x; | ||
674 | _ecore_wl_touch_y = y; | ||
675 | |||
676 | if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Button)))) return; | ||
677 | |||
678 | ev->timestamp = timestamp; | ||
679 | |||
680 | /* NB: Need to verify using x,y for these */ | ||
681 | ev->x = x; | ||
682 | ev->y = y; | ||
683 | ev->root.x = x; | ||
684 | ev->root.y = y; | ||
685 | ev->modifiers = 0; | ||
686 | ev->buttons = 0; | ||
687 | ev->same_screen = 1; | ||
688 | |||
689 | /* FIXME: Need to get these from Wayland somehow */ | ||
690 | ev->double_click = 0; | ||
691 | ev->triple_click = 0; | ||
692 | |||
693 | ev->multi.device = id; | ||
694 | ev->multi.radius = 1; | ||
695 | ev->multi.radius_x = 1; | ||
696 | ev->multi.radius_y = 1; | ||
697 | ev->multi.pressure = 1.0; | ||
698 | ev->multi.angle = 0.0; | ||
699 | /* NB: Need to verify using x,y for these */ | ||
700 | ev->multi.x = x; | ||
701 | ev->multi.y = y; | ||
702 | ev->multi.root.x = x; | ||
703 | ev->multi.root.y = y; | ||
704 | |||
705 | { | 448 | { |
706 | unsigned int id = 0; | 449 | EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE |
707 | 450 | }; | |
708 | if ((id = (unsigned int)wl_surface_get_user_data(surface))) | 451 | static const EGLint argb_attribs[] = |
709 | { | 452 | { |
710 | ev->window = id; | 453 | EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, |
711 | ev->event_window = id; | 454 | EGL_ALPHA_SIZE, 1, EGL_DEPTH_SIZE, 0, EGL_STENCIL_SIZE, 0, |
712 | } | 455 | EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_SURFACE_TYPE, |
713 | } | 456 | EGL_WINDOW_BIT, EGL_NONE |
714 | 457 | }; | |
715 | ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL); | ||
716 | } | ||
717 | |||
718 | static void | ||
719 | _ecore_wl_cb_handle_touch_up(void *data __UNUSED__, struct wl_input_device *dev __UNUSED__, uint32_t timestamp, int32_t id) | ||
720 | { | ||
721 | Ecore_Event_Mouse_Button *ev; | ||
722 | 458 | ||
723 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | 459 | LOGFN(__FILE__, __LINE__, __FUNCTION__); |
724 | 460 | ||
725 | if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Button)))) return; | 461 | ewd->egl.display = eglGetDisplay(ewd->wl.display); |
726 | 462 | if (!eglInitialize(ewd->egl.display, &major, &minor)) | |
727 | ev->timestamp = timestamp; | ||
728 | |||
729 | /* TODO: Need to verify using x,y for these */ | ||
730 | ev->x = _ecore_wl_touch_x; | ||
731 | ev->y = _ecore_wl_touch_y; | ||
732 | ev->root.x = _ecore_wl_touch_x; | ||
733 | ev->root.y = _ecore_wl_touch_y; | ||
734 | ev->modifiers = 0; | ||
735 | ev->buttons = 0; | ||
736 | ev->same_screen = 1; | ||
737 | |||
738 | /* FIXME: Need to get these from Wayland somehow */ | ||
739 | ev->double_click = 0; | ||
740 | ev->triple_click = 0; | ||
741 | |||
742 | ev->multi.device = id; | ||
743 | ev->multi.radius = 1; | ||
744 | ev->multi.radius_x = 1; | ||
745 | ev->multi.radius_y = 1; | ||
746 | ev->multi.pressure = 1.0; | ||
747 | ev->multi.angle = 0.0; | ||
748 | |||
749 | /* TODO: Need to verify using x,y for these */ | ||
750 | ev->multi.x = _ecore_wl_touch_x; | ||
751 | ev->multi.y = _ecore_wl_touch_y; | ||
752 | ev->multi.root.x = _ecore_wl_touch_x; | ||
753 | ev->multi.root.y = _ecore_wl_touch_y; | ||
754 | |||
755 | { | 463 | { |
756 | unsigned int id = 0; | 464 | ERR("Failed to initialize EGL display"); |
757 | 465 | return EINA_FALSE; | |
758 | if ((id = (unsigned int)wl_surface_get_user_data(_ecore_wl_touch_surface))) | ||
759 | { | ||
760 | ev->window = id; | ||
761 | ev->event_window = id; | ||
762 | } | ||
763 | } | 466 | } |
764 | 467 | ||
765 | _ecore_wl_touch_surface = NULL; | 468 | if (!eglBindAPI(EGL_OPENGL_ES_API)) |
766 | |||
767 | ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL); | ||
768 | } | ||
769 | |||
770 | static void | ||
771 | _ecore_wl_cb_handle_touch_motion(void *data __UNUSED__, struct wl_input_device *dev __UNUSED__, uint32_t timestamp, int32_t id, int32_t x, int32_t y) | ||
772 | { | ||
773 | Ecore_Event_Mouse_Move *ev; | ||
774 | |||
775 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
776 | |||
777 | if (!_ecore_wl_touch_surface) return; | ||
778 | |||
779 | if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Move)))) return; | ||
780 | |||
781 | ev->timestamp = timestamp; | ||
782 | /* TODO: Need to verify using x,y for these */ | ||
783 | ev->x = x; | ||
784 | ev->y = y; | ||
785 | ev->root.x = x; | ||
786 | ev->root.y = y; | ||
787 | ev->modifiers = 0; //_ecore_wl_input_modifiers; | ||
788 | ev->same_screen = 1; | ||
789 | |||
790 | ev->multi.device = id; | ||
791 | ev->multi.radius = 1; | ||
792 | ev->multi.radius_x = 1; | ||
793 | ev->multi.radius_y = 1; | ||
794 | ev->multi.pressure = 1.0; | ||
795 | ev->multi.angle = 0.0; | ||
796 | |||
797 | /* TODO: Need to verify using x,y for these */ | ||
798 | ev->multi.x = x; | ||
799 | ev->multi.y = y; | ||
800 | ev->multi.root.x = x; | ||
801 | ev->multi.root.y = y; | ||
802 | |||
803 | { | 469 | { |
804 | unsigned int id = 0; | 470 | ERR("Failed to bind EGL Api"); |
805 | 471 | return EINA_FALSE; | |
806 | if ((id = (unsigned int)wl_surface_get_user_data(_ecore_wl_touch_surface))) | ||
807 | { | ||
808 | ev->window = id; | ||
809 | ev->event_window = id; | ||
810 | } | ||
811 | } | 472 | } |
812 | 473 | ||
813 | ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL); | 474 | if ((!eglChooseConfig(ewd->egl.display, argb_attribs, &ewd->egl.argb_config, |
814 | } | 475 | 1, &n)) || (n == 0)) |
815 | |||
816 | static void | ||
817 | _ecore_wl_cb_handle_touch_frame(void *data __UNUSED__, struct wl_input_device *dev __UNUSED__) | ||
818 | { | ||
819 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
820 | |||
821 | /* FIXME: Need to get a device and actually test what happens here */ | ||
822 | } | ||
823 | |||
824 | static void | ||
825 | _ecore_wl_cb_handle_touch_cancel(void *data __UNUSED__, struct wl_input_device *dev __UNUSED__) | ||
826 | { | ||
827 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
828 | |||
829 | /* FIXME: Need to get a device and actually test what happens here */ | ||
830 | _ecore_wl_touch_surface = NULL; | ||
831 | } | ||
832 | |||
833 | static void | ||
834 | _ecore_wl_cb_source_target(void *data, struct wl_data_source *source __UNUSED__, const char *mime_type __UNUSED__) | ||
835 | { | ||
836 | Ecore_Wl_Drag_Source *s; | ||
837 | |||
838 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
839 | |||
840 | printf("Ecore_Wl Source Target\n"); | ||
841 | if (!(s = data)) return; | ||
842 | printf("\tHave Drag Source\n"); | ||
843 | |||
844 | /* FIXME: buffer here should really be the mouse cursor buffer */ | ||
845 | wl_data_device_attach(s->data_dev, s->timestamp, s->buffer, | ||
846 | s->hotspot_x, s->hotspot_y); | ||
847 | } | ||
848 | |||
849 | static void | ||
850 | _ecore_wl_cb_source_send(void *data, struct wl_data_source *source, const char *mime_type, int32_t fd) | ||
851 | { | ||
852 | Ecore_Wl_Drag_Source *s; | ||
853 | |||
854 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
855 | |||
856 | printf("Ecore_Wl Source Send\n"); | ||
857 | if (!(s = data)) return; | ||
858 | printf("\tHave Drag Source\n"); | ||
859 | |||
860 | /* FIXME: write message to fd */ | ||
861 | |||
862 | /* NB: Wayland really sucks in this regard. Why should selection stuff | ||
863 | * require an 'fd' ?? */ | ||
864 | } | ||
865 | |||
866 | static void | ||
867 | _ecore_wl_cb_source_cancelled(void *data, struct wl_data_source *source __UNUSED__) | ||
868 | { | ||
869 | Ecore_Wl_Drag_Source *s; | ||
870 | |||
871 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
872 | |||
873 | /* The cancelled event usually means source is no longer in use by | ||
874 | * the drag (or selection). */ | ||
875 | |||
876 | printf("Ecore_Wl Source Cancel\n"); | ||
877 | if (!(s = data)) return; | ||
878 | printf("\tHave Drag Source\n"); | ||
879 | |||
880 | /* FIXME: raise this to ecore_evas so the surface/buffer | ||
881 | * of the drag can be destroyed */ | ||
882 | |||
883 | if (s->data_source) wl_data_source_destroy(s->data_source); | ||
884 | s->data_source = NULL; | ||
885 | |||
886 | free(s); | ||
887 | } | ||
888 | |||
889 | static void | ||
890 | _ecore_wl_cb_source_offer(void *data, struct wl_data_offer *offer __UNUSED__, const char *type) | ||
891 | { | ||
892 | Ecore_Wl_Dnd_Source *s; | ||
893 | |||
894 | if (!(s = data)) return; | ||
895 | eina_array_push(s->types, strdup(type)); | ||
896 | } | ||
897 | |||
898 | static void | ||
899 | _ecore_wl_cb_data_offer(void *data, struct wl_data_device *data_dev, uint32_t id) | ||
900 | { | ||
901 | Ecore_Wl_Dnd_Source *source; | ||
902 | |||
903 | /* create a new 'data offer' structure and setup a listener for it */ | ||
904 | if (!(source = calloc(1, sizeof(Ecore_Wl_Dnd_Source)))) return; | ||
905 | |||
906 | source->types = eina_array_new(1); | ||
907 | source->data = data; | ||
908 | source->refs = 1; | ||
909 | |||
910 | /* FIXME: This will need to change when Wayland has typesafe wrappers for this */ | ||
911 | source->offer = (struct wl_data_offer *) | ||
912 | wl_proxy_create_for_id((struct wl_proxy *)data_dev, | ||
913 | id, &wl_data_offer_interface); | ||
914 | |||
915 | wl_data_device_set_user_data(data_dev, source); | ||
916 | wl_data_offer_add_listener(source->offer, &_ecore_wl_offer_listener, source); | ||
917 | } | ||
918 | |||
919 | static void | ||
920 | _ecore_wl_cb_data_enter(void *data __UNUSED__, struct wl_data_device *data_dev, uint32_t timestamp, struct wl_surface *surface, int32_t x, int32_t y, struct wl_data_offer *offer) | ||
921 | { | ||
922 | Ecore_Wl_Dnd_Source *source; | ||
923 | |||
924 | if (!(source = wl_data_device_get_user_data(data_dev))) return; | ||
925 | |||
926 | /* TODO: maybe set pointer focus here ?? */ | ||
927 | |||
928 | source->timestamp = timestamp; | ||
929 | } | ||
930 | |||
931 | static void | ||
932 | _ecore_wl_cb_data_leave(void *data __UNUSED__, struct wl_data_device *data_dev) | ||
933 | { | ||
934 | Ecore_Wl_Dnd_Source *source; | ||
935 | |||
936 | if (!(source = wl_data_device_get_user_data(data_dev))) return; | ||
937 | |||
938 | /* destroy drag offer */ | ||
939 | wl_data_offer_destroy(source->offer); | ||
940 | |||
941 | while (eina_array_count(source->types)) | ||
942 | free(eina_array_pop(source->types)); | ||
943 | |||
944 | eina_array_free(source->types); | ||
945 | free(source); | ||
946 | |||
947 | wl_data_device_set_user_data(data_dev, NULL); | ||
948 | } | ||
949 | |||
950 | static void | ||
951 | _ecore_wl_cb_data_motion(void *data __UNUSED__, struct wl_data_device *data_dev, uint32_t timestamp, int32_t x, int32_t y) | ||
952 | { | ||
953 | Ecore_Wl_Dnd_Source *source; | ||
954 | |||
955 | if (!(source = wl_data_device_get_user_data(data_dev))) return; | ||
956 | /* TODO: Here we should raise motion events for dragging */ | ||
957 | } | ||
958 | |||
959 | static void | ||
960 | _ecore_wl_cb_data_drop(void *data __UNUSED__, struct wl_data_device *data_dev) | ||
961 | { | ||
962 | Ecore_Wl_Dnd_Source *source; | ||
963 | |||
964 | if (!(source = wl_data_device_get_user_data(data_dev))) return; | ||
965 | |||
966 | /* TODO: Raise event for drop */ | ||
967 | |||
968 | wl_data_offer_accept(source->offer, source->timestamp, NULL); | ||
969 | // eina_array_data_get(source->types, 0)); | ||
970 | } | ||
971 | |||
972 | static void | ||
973 | _ecore_wl_cb_data_selection(void *data, struct wl_data_device *data_dev, struct wl_data_offer *offer) | ||
974 | { | ||
975 | Ecore_Wl_Dnd_Source *source; | ||
976 | |||
977 | printf("Ecore_Wl Data Selection\n"); | ||
978 | if ((source = wl_data_device_get_user_data(data_dev))) | ||
979 | { | 476 | { |
980 | /* destroy old source */ | 477 | ERR("Failed to choose ARGB config"); |
981 | wl_data_offer_destroy(source->offer); | 478 | return EINA_FALSE; |
982 | |||
983 | while (eina_array_count(source->types)) | ||
984 | free(eina_array_pop(source->types)); | ||
985 | |||
986 | eina_array_free(source->types); | ||
987 | free(source); | ||
988 | |||
989 | wl_data_device_set_user_data(data_dev, NULL); | ||
990 | } | 479 | } |
991 | } | ||
992 | |||
993 | static void | ||
994 | _ecore_wl_mouse_move_send(uint32_t timestamp) | ||
995 | { | ||
996 | Ecore_Event_Mouse_Move *ev; | ||
997 | |||
998 | // if (!_ecore_wl_input_surface) return; | ||
999 | |||
1000 | if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Move)))) return; | ||
1001 | |||
1002 | ev->timestamp = timestamp; | ||
1003 | ev->x = _ecore_wl_surface_x; | ||
1004 | ev->y = _ecore_wl_surface_y; | ||
1005 | ev->root.x = _ecore_wl_screen_x; | ||
1006 | ev->root.y = _ecore_wl_screen_y; | ||
1007 | ev->modifiers = _ecore_wl_input_modifiers; | ||
1008 | |||
1009 | ev->multi.device = 0; | ||
1010 | ev->multi.radius = 1; | ||
1011 | ev->multi.radius_x = 1; | ||
1012 | ev->multi.radius_y = 1; | ||
1013 | ev->multi.pressure = 1.0; | ||
1014 | ev->multi.angle = 0.0; | ||
1015 | ev->multi.x = _ecore_wl_surface_x; | ||
1016 | ev->multi.y = _ecore_wl_surface_y; | ||
1017 | ev->multi.root.x = _ecore_wl_screen_x; | ||
1018 | ev->multi.root.y = _ecore_wl_screen_y; | ||
1019 | 480 | ||
481 | ewd->egl.argb_context = | ||
482 | eglCreateContext(ewd->egl.display, ewd->egl.argb_config, | ||
483 | EGL_NO_CONTEXT, context_attribs); | ||
484 | if (!ewd->egl.argb_context) | ||
1020 | { | 485 | { |
1021 | unsigned int id = 0; | 486 | ERR("Failed to create ARGB context"); |
1022 | 487 | return EINA_FALSE; | |
1023 | if ((id = (unsigned int)wl_surface_get_user_data(_ecore_wl_input_surface))) | ||
1024 | { | ||
1025 | ev->window = id; | ||
1026 | ev->event_window = id; | ||
1027 | } | ||
1028 | } | 488 | } |
1029 | 489 | ||
1030 | ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL); | 490 | if (!eglMakeCurrent(ewd->egl.display, EGL_NO_SURFACE, |
1031 | } | 491 | EGL_NO_SURFACE, ewd->egl.argb_context)) |
1032 | |||
1033 | static void | ||
1034 | _ecore_wl_mouse_out_send(struct wl_surface *surface, uint32_t timestamp) | ||
1035 | { | ||
1036 | Ecore_Wl_Event_Mouse_Out *ev; | ||
1037 | |||
1038 | if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Mouse_Out)))) return; | ||
1039 | |||
1040 | ev->x = _ecore_wl_surface_x; | ||
1041 | ev->y = _ecore_wl_surface_y; | ||
1042 | ev->root.x = _ecore_wl_screen_x; | ||
1043 | ev->root.y = _ecore_wl_screen_y; | ||
1044 | ev->modifiers = _ecore_wl_input_modifiers; | ||
1045 | ev->time = timestamp; | ||
1046 | |||
1047 | if (surface) | ||
1048 | { | 492 | { |
1049 | unsigned int id = 0; | 493 | ERR("Failed to make ARGB context current"); |
1050 | 494 | return EINA_FALSE; | |
1051 | if ((id = (unsigned int)wl_surface_get_user_data(surface))) | ||
1052 | ev->window = id; | ||
1053 | } | 495 | } |
1054 | 496 | ||
1055 | ecore_event_add(ECORE_WL_EVENT_MOUSE_OUT, ev, NULL, NULL); | 497 | return EINA_TRUE; |
1056 | } | 498 | } |
1057 | 499 | ||
1058 | static void | 500 | static Eina_Bool |
1059 | _ecore_wl_mouse_in_send(struct wl_surface *surface, uint32_t timestamp) | 501 | _ecore_wl_egl_shutdown(Ecore_Wl_Display *ewd) |
1060 | { | 502 | { |
1061 | Ecore_Wl_Event_Mouse_In *ev; | 503 | LOGFN(__FILE__, __LINE__, __FUNCTION__); |
1062 | |||
1063 | if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Mouse_In)))) return; | ||
1064 | |||
1065 | ev->x = _ecore_wl_surface_x; | ||
1066 | ev->y = _ecore_wl_surface_y; | ||
1067 | ev->root.x = _ecore_wl_screen_x; | ||
1068 | ev->root.y = _ecore_wl_screen_y; | ||
1069 | ev->modifiers = _ecore_wl_input_modifiers; | ||
1070 | ev->time = timestamp; | ||
1071 | 504 | ||
1072 | if (surface) | 505 | eglMakeCurrent(ewd->egl.display, |
1073 | { | 506 | EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |
1074 | unsigned int id = 0; | ||
1075 | 507 | ||
1076 | if ((id = (unsigned int)wl_surface_get_user_data(surface))) | 508 | eglDestroyContext(ewd->egl.display, ewd->egl.argb_context); |
1077 | ev->window = id; | ||
1078 | } | ||
1079 | |||
1080 | ecore_event_add(ECORE_WL_EVENT_MOUSE_IN, ev, NULL, NULL); | ||
1081 | } | ||
1082 | 509 | ||
1083 | static void | 510 | /* NB: This is hanging when we run elm apps as wayland clients |
1084 | _ecore_wl_mouse_up_send(struct wl_surface *surface, uint32_t button, uint32_t timestamp) | 511 | * inside the weston compositor */ |
1085 | { | ||
1086 | Ecore_Event_Mouse_Button *ev; | ||
1087 | |||
1088 | if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Button)))) return; | ||
1089 | |||
1090 | if (button == BTN_LEFT) | ||
1091 | ev->buttons = 1; | ||
1092 | else if (button == BTN_MIDDLE) | ||
1093 | ev->buttons = 2; | ||
1094 | else if (button == BTN_RIGHT) | ||
1095 | ev->buttons = 3; | ||
1096 | |||
1097 | ev->timestamp = timestamp; | ||
1098 | ev->x = _ecore_wl_surface_x; | ||
1099 | ev->y = _ecore_wl_surface_y; | ||
1100 | ev->root.x = _ecore_wl_screen_x; | ||
1101 | ev->root.y = _ecore_wl_screen_y; | ||
1102 | ev->modifiers = _ecore_wl_input_modifiers; | ||
1103 | |||
1104 | /* FIXME: Need to get these from Wayland somehow */ | ||
1105 | ev->double_click = 0; | ||
1106 | ev->triple_click = 0; | ||
1107 | |||
1108 | ev->multi.device = 0; | ||
1109 | ev->multi.radius = 1; | ||
1110 | ev->multi.radius_x = 1; | ||
1111 | ev->multi.radius_y = 1; | ||
1112 | ev->multi.pressure = 1.0; | ||
1113 | ev->multi.angle = 0.0; | ||
1114 | ev->multi.x = _ecore_wl_surface_x; | ||
1115 | ev->multi.y = _ecore_wl_surface_y; | ||
1116 | ev->multi.root.x = _ecore_wl_screen_x; | ||
1117 | ev->multi.root.y = _ecore_wl_screen_y; | ||
1118 | 512 | ||
1119 | { | 513 | /* printf("Egl Terminate\n"); */ |
1120 | unsigned int id = 0; | 514 | /* eglTerminate(ewd->egl.display); */ |
515 | /* printf("Egl Terminate Done\n"); */ | ||
1121 | 516 | ||
1122 | if ((id = (unsigned int)wl_surface_get_user_data(surface))) | 517 | eglReleaseThread(); |
1123 | { | ||
1124 | ev->window = id; | ||
1125 | ev->event_window = id; | ||
1126 | } | ||
1127 | } | ||
1128 | 518 | ||
1129 | ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL); | 519 | return EINA_TRUE; |
1130 | } | 520 | } |
1131 | 521 | ||
1132 | static void | 522 | static Eina_Bool |
1133 | _ecore_wl_mouse_down_send(struct wl_surface *surface, uint32_t button, uint32_t timestamp) | 523 | _ecore_wl_xkb_init(Ecore_Wl_Display *ewd) |
1134 | { | 524 | { |
1135 | Ecore_Event_Mouse_Button *ev; | 525 | struct xkb_rule_names names; |
1136 | |||
1137 | if (!(ev = malloc(sizeof(Ecore_Event_Mouse_Button)))) return; | ||
1138 | |||
1139 | if (button == BTN_LEFT) | ||
1140 | ev->buttons = 1; | ||
1141 | else if (button == BTN_MIDDLE) | ||
1142 | ev->buttons = 2; | ||
1143 | else if (button == BTN_RIGHT) | ||
1144 | ev->buttons = 3; | ||
1145 | |||
1146 | ev->timestamp = timestamp; | ||
1147 | ev->x = _ecore_wl_surface_x; | ||
1148 | ev->y = _ecore_wl_surface_y; | ||
1149 | ev->root.x = _ecore_wl_screen_x; | ||
1150 | ev->root.y = _ecore_wl_screen_y; | ||
1151 | ev->modifiers = _ecore_wl_input_modifiers; | ||
1152 | |||
1153 | /* FIXME: Need to get these from Wayland somehow */ | ||
1154 | ev->double_click = 0; | ||
1155 | ev->triple_click = 0; | ||
1156 | |||
1157 | ev->multi.device = 0; | ||
1158 | ev->multi.radius = 1; | ||
1159 | ev->multi.radius_x = 1; | ||
1160 | ev->multi.radius_y = 1; | ||
1161 | ev->multi.pressure = 1.0; | ||
1162 | ev->multi.angle = 0.0; | ||
1163 | ev->multi.x = _ecore_wl_surface_x; | ||
1164 | ev->multi.y = _ecore_wl_surface_y; | ||
1165 | ev->multi.root.x = _ecore_wl_screen_x; | ||
1166 | ev->multi.root.y = _ecore_wl_screen_y; | ||
1167 | 526 | ||
1168 | { | 527 | LOGFN(__FILE__, __LINE__, __FUNCTION__); |
1169 | unsigned int id = 0; | ||
1170 | |||
1171 | if ((id = (unsigned int)wl_surface_get_user_data(surface))) | ||
1172 | { | ||
1173 | ev->window = id; | ||
1174 | ev->event_window = id; | ||
1175 | } | ||
1176 | } | ||
1177 | 528 | ||
1178 | ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL); | 529 | names.rules = "evdev"; |
1179 | } | 530 | names.model = "evdev"; |
531 | names.layout = "us"; | ||
532 | names.variant = ""; | ||
533 | names.options = ""; | ||
1180 | 534 | ||
1181 | static void | 535 | if (!(ewd->xkb = xkb_compile_keymap_from_rules(&names))) |
1182 | _ecore_wl_focus_out_send(struct wl_surface *surface, uint32_t timestamp) | ||
1183 | { | ||
1184 | Ecore_Wl_Event_Focus_Out *ev; | ||
1185 | |||
1186 | if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Focus_Out)))) return; | ||
1187 | ev->time = timestamp; | ||
1188 | if (surface) | ||
1189 | { | 536 | { |
1190 | unsigned int id = 0; | 537 | ERR("Failed to compile keymap"); |
1191 | 538 | return EINA_FALSE; | |
1192 | if ((id = (unsigned int)wl_surface_get_user_data(surface))) | ||
1193 | ev->window = id; | ||
1194 | } | 539 | } |
1195 | ecore_event_add(ECORE_WL_EVENT_FOCUS_OUT, ev, NULL, NULL); | 540 | |
541 | return EINA_TRUE; | ||
1196 | } | 542 | } |
1197 | 543 | ||
1198 | static void | 544 | static Eina_Bool |
1199 | _ecore_wl_focus_in_send(struct wl_surface *surface, uint32_t timestamp) | 545 | _ecore_wl_xkb_shutdown(Ecore_Wl_Display *ewd) |
1200 | { | 546 | { |
1201 | Ecore_Wl_Event_Focus_In *ev; | 547 | LOGFN(__FILE__, __LINE__, __FUNCTION__); |
1202 | |||
1203 | if (!(ev = calloc(1, sizeof(Ecore_Wl_Event_Focus_In)))) return; | ||
1204 | ev->time = timestamp; | ||
1205 | if (surface) | ||
1206 | { | ||
1207 | unsigned int id = 0; | ||
1208 | 548 | ||
1209 | if ((id = (unsigned int)wl_surface_get_user_data(surface))) | 549 | if (ewd->xkb) xkb_free_keymap(ewd->xkb); |
1210 | ev->window = id; | 550 | return EINA_TRUE; |
1211 | } | ||
1212 | ecore_event_add(ECORE_WL_EVENT_FOCUS_IN, ev, NULL, NULL); | ||
1213 | } | 551 | } |
diff --git a/libraries/ecore/src/lib/ecore_wayland/ecore_wl_private.h b/libraries/ecore/src/lib/ecore_wayland/ecore_wl_private.h index eec5ffe..31956a1 100644 --- a/libraries/ecore/src/lib/ecore_wayland/ecore_wl_private.h +++ b/libraries/ecore/src/lib/ecore_wayland/ecore_wl_private.h | |||
@@ -2,6 +2,9 @@ | |||
2 | # define _ECORE_WAYLAND_PRIVATE_H | 2 | # define _ECORE_WAYLAND_PRIVATE_H |
3 | 3 | ||
4 | # include <limits.h> | 4 | # include <limits.h> |
5 | # include <xkbcommon/xkbcommon.h> | ||
6 | |||
7 | # include "Ecore_Wayland.h" | ||
5 | 8 | ||
6 | //# define LOGFNS 1 | 9 | //# define LOGFNS 1 |
7 | 10 | ||
@@ -13,6 +16,7 @@ | |||
13 | # endif | 16 | # endif |
14 | 17 | ||
15 | extern int _ecore_wl_log_dom; | 18 | extern int _ecore_wl_log_dom; |
19 | extern Ecore_Wl_Display *_ecore_wl_disp; | ||
16 | 20 | ||
17 | # ifdef ECORE_WL_DEFAULT_LOG_COLOR | 21 | # ifdef ECORE_WL_DEFAULT_LOG_COLOR |
18 | # undef ECORE_WL_DEFAULT_LOG_COLOR | 22 | # undef ECORE_WL_DEFAULT_LOG_COLOR |
@@ -44,42 +48,40 @@ extern int _ecore_wl_log_dom; | |||
44 | # endif | 48 | # endif |
45 | # define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_wl_log_dom, __VA_ARGS__) | 49 | # define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_wl_log_dom, __VA_ARGS__) |
46 | 50 | ||
47 | typedef struct _Ecore_Wl_Dnd_Source | 51 | struct _Ecore_Wl_Dnd_Source |
48 | { | 52 | { |
49 | struct wl_data_offer *offer; | 53 | struct wl_data_offer *offer; |
50 | int refs; | 54 | Ecore_Wl_Input *input; |
51 | 55 | struct wl_array types; | |
52 | Eina_Array *types; | 56 | int refcount; |
57 | int fd; | ||
58 | int x, y; | ||
53 | 59 | ||
54 | uint32_t timestamp; | 60 | /* TODO: task & data_func */ |
55 | void *data; | 61 | void *data; |
56 | } Ecore_Wl_Dnd_Source; | 62 | }; |
57 | 63 | ||
58 | typedef struct _Ecore_Wl_Dnd_Target | 64 | struct _Ecore_Wl_Dnd_Target |
59 | { | 65 | { |
60 | /* NB: These are not the real fields for this structure, | 66 | Ecore_Wl_Dnd_Source *source; |
61 | * and it is Bound to change....soon */ | 67 | }; |
62 | struct wl_data_offer *offer; | ||
63 | int refs; | ||
64 | |||
65 | Eina_Array *types; | ||
66 | 68 | ||
67 | uint32_t timestamp; | 69 | void _ecore_wl_window_init(void); |
68 | void *data; | 70 | void _ecore_wl_window_shutdown(void); |
69 | } Ecore_Wl_Dnd_Target; | ||
70 | 71 | ||
71 | struct _Ecore_Wl_Drag_Source | 72 | void _ecore_wl_output_add(Ecore_Wl_Display *ewd, unsigned int id); |
72 | { | 73 | void _ecore_wl_output_del(Ecore_Wl_Output *output); |
73 | struct wl_data_device *data_dev; | ||
74 | struct wl_buffer *buffer; | ||
75 | 74 | ||
76 | int32_t hotspot_x, hotspot_y; | 75 | void _ecore_wl_input_add(Ecore_Wl_Display *ewd, unsigned int id); |
77 | int32_t offset_x, offset_y; | 76 | void _ecore_wl_input_del(Ecore_Wl_Input *input); |
78 | const char *mimetype; | 77 | void _ecore_wl_input_pointer_xy_get(int *x, int *y); |
79 | uint32_t timestamp; | ||
80 | void *data; | ||
81 | 78 | ||
82 | struct wl_data_source *data_source; | 79 | void _ecore_wl_dnd_add(Ecore_Wl_Input *input, struct wl_data_device *data_device, unsigned int id); |
83 | }; | 80 | void _ecore_wl_dnd_enter(void *data, struct wl_data_device *data_device __UNUSED__, unsigned int timestamp __UNUSED__, struct wl_surface *surface, int x, int y, struct wl_data_offer *offer); |
81 | void _ecore_wl_dnd_leave(void *data, struct wl_data_device *data_device __UNUSED__); | ||
82 | void _ecore_wl_dnd_motion(void *data, struct wl_data_device *data_device __UNUSED__, unsigned int timestamp __UNUSED__, int x, int y); | ||
83 | void _ecore_wl_dnd_drop(void *data, struct wl_data_device *data_device __UNUSED__); | ||
84 | void _ecore_wl_dnd_selection(void *data, struct wl_data_device *data_device __UNUSED__, struct wl_data_offer *offer); | ||
85 | void _ecore_wl_dnd_del(Ecore_Wl_Dnd_Source *source); | ||
84 | 86 | ||
85 | #endif | 87 | #endif |