Ecore_Wayland: Backport several fixes to 1.7.
authorantognolli <antognolli@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 23 Nov 2012 18:27:36 +0000 (18:27 +0000)
committerantognolli <antognolli@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 23 Nov 2012 18:27:36 +0000 (18:27 +0000)
These changes will enable the 1.7 branch to work with Wayland 1.0.

The following changesets were backported:
78049
78050
78051
78052
78054
78055
78056
78136

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/branches/ecore-1.7@79566 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
NEWS
src/lib/ecore_wayland/Ecore_Wayland.h
src/lib/ecore_wayland/ecore_wl.c
src/lib/ecore_wayland/ecore_wl_input.c
src/lib/ecore_wayland/ecore_wl_output.c
src/lib/ecore_wayland/ecore_wl_window.c

index 9c4266b..9c6796b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 2012-11-23 Luis Felipe Strano Moraes
 
        1.7.2 release
+
+2012-10-16  Christopher Michael
+
+       * Update Ecore_Wayland to build & work with newest wayland (0.99) from
+       git
diff --git a/NEWS b/NEWS
index 518eac1..ab03c53 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,9 @@ Fixes:
     * ecore_x: send ECORE_X_EVENT_SELECTION_NOTIFY even if there is no data.
     * ecore_imf: ibus module potential segv fixed.
     * ecore: ecore_thread_feedback() memory allocation and corruption fixed.
+    * ecore_wayland:
+     - Update to work with latest wayland (0.99) from git.
+
 
 Changes since Ecore 1.2.0:
 --------------------------
index 02f3c1a..c3268b2 100644 (file)
@@ -75,6 +75,7 @@ struct _Ecore_Wl_Display
    struct 
      {
         struct wl_display *display;
+        struct wl_registry *registry;
         struct wl_compositor *compositor;
         struct wl_shell *shell;
         struct wl_shell *desktop_shell;
index 3bb05e7..4e6218b 100644 (file)
@@ -7,14 +7,18 @@
 
 /* local function prototypes */
 static Eina_Bool _ecore_wl_shutdown(Eina_Bool close);
-static int _ecore_wl_cb_event_mask_update(unsigned int mask, void *data);
-static Eina_Bool _ecore_wl_cb_handle_data(void *data, Ecore_Fd_Handler *hdl __UNUSED__);
-static void _ecore_wl_cb_handle_global(struct wl_display *disp, unsigned int id, const char *interface, unsigned int version __UNUSED__, void *data);
+static Eina_Bool _ecore_wl_cb_handle_data(void *data, Ecore_Fd_Handler *hdl);
+static void _ecore_wl_cb_handle_global(void *data, struct wl_registry *registry, unsigned int id, const char *interface, unsigned int version __UNUSED__);
 static Eina_Bool _ecore_wl_xkb_init(Ecore_Wl_Display *ewd);
 static Eina_Bool _ecore_wl_xkb_shutdown(Ecore_Wl_Display *ewd);
 
 /* local variables */
 static int _ecore_wl_init_count = 0;
+static const struct wl_registry_listener _ecore_wl_registry_listener = 
+{
+   _ecore_wl_cb_handle_global,
+   NULL // handle_global_remove
+};
 
 /* external variables */
 int _ecore_wl_log_dom = -1;
@@ -130,27 +134,23 @@ ecore_wl_init(const char *name)
         return --_ecore_wl_init_count;
      }
 
-   _ecore_wl_disp->fd = 
-     wl_display_get_fd(_ecore_wl_disp->wl.display, 
-                       _ecore_wl_cb_event_mask_update, _ecore_wl_disp);
+   _ecore_wl_disp->fd = wl_display_get_fd(_ecore_wl_disp->wl.display);
 
    _ecore_wl_disp->fd_hdl = 
-     ecore_main_fd_handler_add(_ecore_wl_disp->fd, ECORE_FD_READ, 
+     ecore_main_fd_handler_add(_ecore_wl_disp->fd, 
+                               ECORE_FD_READ | ECORE_FD_WRITE,
                                _ecore_wl_cb_handle_data, _ecore_wl_disp, 
                                NULL, NULL);
 
    wl_list_init(&_ecore_wl_disp->inputs);
    wl_list_init(&_ecore_wl_disp->outputs);
 
-   wl_display_add_global_listener(_ecore_wl_disp->wl.display, 
-                                  _ecore_wl_cb_handle_global, _ecore_wl_disp);
-
-   /* Init egl */
-
-   /* FIXME: Process connection events ?? */
-   /* wl_display_iterate(_ecore_wl_disp->wl.display, WL_DISPLAY_READABLE); */
+   _ecore_wl_disp->wl.registry = 
+     wl_display_get_registry(_ecore_wl_disp->wl.display);
+   wl_registry_add_listener(_ecore_wl_disp->wl.registry, 
+                            &_ecore_wl_registry_listener, _ecore_wl_disp);
 
-   /* TODO: create pointer surfaces */
+   wl_display_dispatch(_ecore_wl_disp->wl.display);
 
    if (!_ecore_wl_xkb_init(_ecore_wl_disp))
      {
@@ -206,8 +206,7 @@ ecore_wl_flush(void)
 {
 //   LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
-   while (_ecore_wl_disp->mask & WL_DISPLAY_WRITABLE)
-     wl_display_iterate(_ecore_wl_disp->wl.display, WL_DISPLAY_WRITABLE);
+   wl_display_flush(_ecore_wl_disp->wl.display);
 }
 
 /**
@@ -323,7 +322,7 @@ ecore_wl_dpi_get(void)
 EAPI void 
 ecore_wl_display_iterate(void)
 {
-   wl_display_iterate(_ecore_wl_disp->wl.display, WL_DISPLAY_READABLE);
+   wl_display_dispatch(_ecore_wl_disp->wl.display);
 }
 
 /**
@@ -396,54 +395,53 @@ _ecore_wl_shutdown(Eina_Bool close)
    return _ecore_wl_init_count;
 }
 
-static int 
-_ecore_wl_cb_event_mask_update(unsigned int mask, void *data)
-{
-   Ecore_Wl_Display *ewd;
-
-//   LOGFN(__FILE__, __LINE__, __FUNCTION__);
-
-   ewd = data;
-   ewd->mask = mask;
-   return 0;
-}
-
 static Eina_Bool 
-_ecore_wl_cb_handle_data(void *data, Ecore_Fd_Handler *hdl __UNUSED__)
+_ecore_wl_cb_handle_data(void *data, Ecore_Fd_Handler *hdl)
 {
    Ecore_Wl_Display *ewd;
 
    /* LOGFN(__FILE__, __LINE__, __FUNCTION__); */
 
    if (!(ewd = data)) return ECORE_CALLBACK_RENEW;
-   wl_display_iterate(ewd->wl.display, ewd->mask);
+
+   /* FIXME: This should also catch ECORE_FD_ERROR and exit */
+
+   /* wl_display_dispatch_pending(ewd->wl.display); */
+
+   if (ecore_main_fd_handler_active_get(hdl, ECORE_FD_READ))
+     wl_display_dispatch(ewd->wl.display);
+   else if (ecore_main_fd_handler_active_get(hdl, ECORE_FD_WRITE))
+     wl_display_flush(ewd->wl.display);
+
    return ECORE_CALLBACK_RENEW;
 }
 
 static void 
-_ecore_wl_cb_handle_global(struct wl_display *disp, unsigned int id, const char *interface, unsigned int version __UNUSED__, void *data)
+_ecore_wl_cb_handle_global(void *data, struct wl_registry *registry, unsigned int id, const char *interface, unsigned int version __UNUSED__)
 {
    Ecore_Wl_Display *ewd;
 
-//   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
    ewd = data;
 
-   /* TODO: Add listener for wl_display so we can catch fatal errors !! */
-
    if (!strcmp(interface, "wl_compositor"))
-     ewd->wl.compositor = wl_display_bind(disp, id, &wl_compositor_interface);
+     {
+        ewd->wl.compositor = 
+          wl_registry_bind(registry, id, &wl_compositor_interface, 1);
+     }
    else if (!strcmp(interface, "wl_output"))
      _ecore_wl_output_add(ewd, id);
    else if (!strcmp(interface, "wl_seat"))
      _ecore_wl_input_add(ewd, id);
    else if (!strcmp(interface, "wl_shell"))
-     ewd->wl.shell = wl_display_bind(disp, id, &wl_shell_interface);
-   /* else if (!strcmp(interface, "desktop_shell")) */
-   /*   ewd->wl.desktop_shell = wl_display_bind(disp, id, &wl_shell_interface); */
+     {
+        ewd->wl.shell = 
+          wl_registry_bind(registry, id, &wl_shell_interface, 1);
+     }
    else if (!strcmp(interface, "wl_shm"))
      {
-        ewd->wl.shm = wl_display_bind(disp, id, &wl_shm_interface);
+        ewd->wl.shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
 
         /* FIXME: We should not hard-code a cursor size here, and we should 
          * also import the theme name from a config or env variable */
@@ -452,7 +450,7 @@ _ecore_wl_cb_handle_global(struct wl_display *disp, unsigned int id, const char
    else if (!strcmp(interface, "wl_data_device_manager"))
      {
         ewd->wl.data_device_manager = 
-          wl_display_bind(disp, id, &wl_data_device_manager_interface);
+          wl_registry_bind(registry, id, &wl_data_device_manager_interface, 1);
      }
 
    if ((ewd->wl.compositor) && (ewd->wl.shm) && (ewd->wl.shell))
index ccb4e5b..d488dcb 100644 (file)
@@ -200,6 +200,7 @@ ecore_wl_input_cursor_from_name_set(Ecore_Wl_Input *input, const char *cursor_na
         wl_surface_attach(input->cursor_surface, buffer, 0, 0);
         wl_surface_damage(input->cursor_surface, 0, 0, 
                           cursor_image->width, cursor_image->height);
+        wl_surface_commit(input->cursor_surface);
 
         if (!input->cursor_frame_cb)
           _ecore_wl_input_cb_pointer_frame(input, NULL, 0);
@@ -234,8 +235,9 @@ _ecore_wl_input_add(Ecore_Wl_Display *ewd, unsigned int id)
    input->keyboard_focus = NULL;
 
    input->seat = 
-     wl_display_bind(ewd->wl.display, id, &wl_seat_interface);
+     wl_registry_bind(ewd->wl.registry, id, &wl_seat_interface, 1);
    wl_list_insert(ewd->inputs.prev, &input->link);
+
    wl_seat_add_listener(input->seat, 
                         &_ecore_wl_seat_listener, input);
    wl_seat_set_user_data(input->seat, input);
@@ -326,6 +328,7 @@ _ecore_wl_input_seat_handle_capabilities(void *data, struct wl_seat *seat, enum
    Ecore_Wl_Input *input;
 
    if (!(input = data)) return;
+
    if ((caps & WL_SEAT_CAPABILITY_POINTER) && (!input->pointer))
      {
         input->pointer = wl_seat_get_pointer(seat);
@@ -694,17 +697,17 @@ _ecore_wl_input_cb_pointer_enter(void *data, struct wl_pointer *pointer __UNUSED
    input->display->serial = serial;
    input->pointer_enter_serial = serial;
 
-   if (!(win = wl_surface_get_user_data(surface))) return;
-
-   win->pointer_device = input;
-   input->pointer_focus = win;
-
-   /* _ecore_wl_input_mouse_move_send(input, win, input->timestamp); */
-   _ecore_wl_input_mouse_in_send(input, win, input->timestamp);
-
    /* The cursor on the surface is undefined until we set it */
    ecore_wl_input_cursor_from_name_set(input, "left_ptr");
 
+   if ((win = wl_surface_get_user_data(surface)))
+     {
+        win->pointer_device = input;
+        input->pointer_focus = win;
+
+        _ecore_wl_input_mouse_in_send(input, win, input->timestamp);
+     }
+
    /* NB: This whole 'if' below is a major HACK due to wayland's stupidness 
     * of not sending a mouse_up (or any notification at all for that matter) 
     * when a move or resize grab is finished */
@@ -1181,12 +1184,12 @@ _ecore_wl_input_mouse_wheel_send(Ecore_Wl_Input *input, unsigned int axis, int v
    if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
      {
         ev->direction = 0;
-        ev->z = -value;
+        ev->z = value;
      }
    else if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
      {
         ev->direction = 1;
-        ev->z = -value;
+        ev->z = value;
      }
 
    if (input->grab)
index 5e6c38d..c30086d 100644 (file)
@@ -35,7 +35,9 @@ _ecore_wl_output_add(Ecore_Wl_Display *ewd, unsigned int id)
 
    output->display = ewd;
 
-   output->output = wl_display_bind(ewd->wl.display, id, &wl_output_interface);
+   output->output = 
+     wl_registry_bind(ewd->wl.registry, id, &wl_output_interface, 1);
+
    wl_list_insert(ewd->outputs.prev, &output->link);
    wl_output_add_listener(output->output, &_ecore_wl_output_listener, output);
 }
index 76524ac..80b443b 100644 (file)
@@ -251,7 +251,10 @@ ecore_wl_window_damage(Ecore_Wl_Window *win, int x, int y, int w, int h)
 
    if (!win) return;
    if (win->surface) 
-     wl_surface_damage(win->surface, x, y, w, h);
+     {
+        wl_surface_damage(win->surface, x, y, w, h);
+        wl_surface_commit(win->surface);
+     }
 }
 
 EAPI void 
@@ -286,6 +289,7 @@ ecore_wl_window_buffer_attach(Ecore_Wl_Window *win, struct wl_buffer *buffer, in
              wl_surface_attach(win->surface, buffer, x, y);
              wl_surface_damage(win->surface, 0, 0, 
                                win->allocation.w, win->allocation.h);
+             wl_surface_commit(win->surface);
 
              win->server_allocation = win->allocation;
           }