Port to wayland 1.0 rusty
authorRusty Lynch <rusty.lynch@intel.com>
Fri, 16 Nov 2012 00:04:43 +0000 (16:04 -0800)
committerRusty Lynch <rusty.lynch@intel.com>
Fri, 16 Nov 2012 23:16:03 +0000 (15:16 -0800)
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 5ff3293..be305b0 100644 (file)
@@ -72,6 +72,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;
@@ -310,7 +311,6 @@ EAPI struct wl_display *ecore_wl_display_get(void);
 EAPI void ecore_wl_screen_size_get(int *w, int *h);
 EAPI void ecore_wl_pointer_xy_get(int *x, int *y);
 EAPI int ecore_wl_dpi_get(void);
-EAPI void ecore_wl_display_iterate(void);
 EAPI struct wl_cursor *ecore_wl_cursor_get(const char *cursor_name);
 
 EAPI void ecore_wl_input_grab(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsigned int button);
index c21c102..a59fc08 100644 (file)
@@ -7,14 +7,15 @@
 
 /* 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_flush_events(void *data, Ecore_Fd_Handler *hdl __UNUSED__);
+static void _ecore_wl_cb_handle_global(void *data, struct wl_registry *reg, 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;
 
 /* external variables */
 int _ecore_wl_log_dom = -1;
@@ -122,25 +123,25 @@ 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_wl_cb_handle_data, _ecore_wl_disp, 
-                               NULL, NULL);
+                               _ecore_wl_cb_flush_events, _ecore_wl_disp);
 
    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);
+   _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);
+   wl_display_roundtrip(_ecore_wl_disp->wl.display);
 
    /* Init egl */
 
    /* FIXME: Process connection events ?? */
-   /* wl_display_iterate(_ecore_wl_disp->wl.display, WL_DISPLAY_READABLE); */
+   /* wl_display_dispatch(_ecore_wl_disp->wl.display); */
 
    /* TODO: create pointer surfaces */
 
@@ -198,8 +199,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_dispatch(_ecore_wl_disp->wl.display);
 }
 
 /**
@@ -315,7 +315,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);
 }
 
 /**
@@ -388,32 +388,33 @@ _ecore_wl_shutdown(Eina_Bool close)
    return _ecore_wl_init_count;
 }
 
-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__)
 {
    Ecore_Wl_Display *ewd;
 
-//   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+   /* LOGFN(__FILE__, __LINE__, __FUNCTION__); */
 
-   ewd = data;
-   ewd->mask = mask;
-   return 0;
+   if (!(ewd = data)) return ECORE_CALLBACK_RENEW;
+   wl_display_dispatch(ewd->wl.display);
+   return ECORE_CALLBACK_RENEW;
 }
 
 static Eina_Bool 
-_ecore_wl_cb_handle_data(void *data, Ecore_Fd_Handler *hdl __UNUSED__)
+_ecore_wl_cb_flush_events(void *data, Ecore_Fd_Handler *hdl __UNUSED__)
 {
    Ecore_Wl_Display *ewd;
 
    /* LOGFN(__FILE__, __LINE__, __FUNCTION__); */
 
    if (!(ewd = data)) return ECORE_CALLBACK_RENEW;
-   wl_display_iterate(ewd->wl.display, ewd->mask);
+   wl_display_dispatch_pending(ewd->wl.display);
+   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 *reg, unsigned int id, const char *interface, unsigned int version __UNUSED__)
 {
    Ecore_Wl_Display *ewd;
 
@@ -424,24 +425,24 @@ _ecore_wl_cb_handle_global(struct wl_display *disp, unsigned int id, const char
    /* 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(reg, 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);
+     ewd->wl.shell = wl_registry_bind(reg, id, &wl_shell_interface, 1);
    /* else if (!strcmp(interface, "desktop_shell")) */
-   /*   ewd->wl.desktop_shell = wl_display_bind(disp, id, &wl_shell_interface); */
+   /*   ewd->wl.desktop_shell = wl_registry_bind(reg, 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(reg, id, &wl_shm_interface, 1);
         ewd->cursor_theme = wl_cursor_theme_load(NULL, 32, ewd->wl.shm);
      }
    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(reg, id, &wl_data_device_manager_interface, 1);
      }
 
    if ((ewd->wl.compositor) && (ewd->wl.shm) && (ewd->wl.shell))
@@ -459,6 +460,16 @@ _ecore_wl_cb_handle_global(struct wl_display *disp, unsigned int id, const char
      }
 }
 
+static void 
+_ecore_wl_cb_handle_global_remove(void *data, struct wl_registry *reg, unsigned int id)
+{
+}
+
+static const struct wl_registry_listener _ecore_wl_registry_listener = {
+   _ecore_wl_cb_handle_global,
+   _ecore_wl_cb_handle_global_remove
+};
+
 static Eina_Bool 
 _ecore_wl_xkb_init(Ecore_Wl_Display *ewd)
 {
index 9d82f60..1948d55 100644 (file)
@@ -223,7 +223,7 @@ _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);
index 5e6c38d..027dea4 100644 (file)
@@ -35,7 +35,7 @@ _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 ab72a01..ec98ae0 100644 (file)
@@ -298,6 +298,8 @@ ecore_wl_window_buffer_attach(Ecore_Wl_Window *win, struct wl_buffer *buffer, in
         wl_region_destroy(win->region.opaque);
         win->region.opaque = NULL;
      }
+
+   wl_surface_commit(win->surface);
 }
 
 /**