ecore-wl2: Add support for initial setup of pointer cursor
authorChris Michael <cp.michael@samsung.com>
Thu, 10 Sep 2015 16:09:14 +0000 (12:09 -0400)
committerChris Michael <cp.michael@samsung.com>
Thu, 3 Dec 2015 17:02:40 +0000 (12:02 -0500)
Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/lib/ecore_wl2/ecore_wl2_input.c
src/lib/ecore_wl2/ecore_wl2_private.h

index dc62ae2..9cbd165 100644 (file)
@@ -27,7 +27,12 @@ _seat_cb_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability
         input->wl.pointer = wl_seat_get_pointer(seat);
         wl_pointer_set_user_data(input->wl.pointer, input);
         /* TODO: pointer listener */
-        /* TODO: pointer surface */
+
+        if (!input->cursor.surface)
+          {
+             input->cursor.surface =
+               wl_compositor_create_surface(input->display->wl.compositor);
+          }
      }
    else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && (input->wl.pointer))
      {
@@ -67,6 +72,29 @@ static const struct wl_seat_listener _seat_listener =
    NULL
 };
 
+static void
+_ecore_wl2_input_cursor_setup(Ecore_Wl2_Input *input)
+{
+   char *tmp;
+
+   input->cursor.size = 32;
+   tmp = getenv("ECORE_WL_CURSOR_SIZE");
+   if (tmp) input->cursor.size = atoi(tmp);
+
+   tmp = getenv("ECORE_WL_CURSOR_THEME_NAME");
+   eina_stringshare_replace(&input->cursor.theme_name, tmp);
+
+   if (!input->cursor.name)
+     input->cursor.name = eina_stringshare_add("left_ptr");
+
+   if (input->display->wl.shm)
+     {
+        input->cursor.theme =
+          wl_cursor_theme_load(input->cursor.theme_name, input->cursor.size,
+                               input->display->wl.shm);
+     }
+}
+
 void
 _ecore_wl2_input_add(Ecore_Wl2_Display *display, unsigned int id)
 {
@@ -83,7 +111,8 @@ _ecore_wl2_input_add(Ecore_Wl2_Display *display, unsigned int id)
 
    wl_array_init(&input->data.types);
 
-   /* TODO: setup cursor size and theme */
+   /* setup cursor size and theme */
+   _ecore_wl2_input_cursor_setup(input);
 
    input->wl.seat =
      wl_registry_bind(wl_display_get_registry(display->wl.display),
@@ -116,7 +145,8 @@ _ecore_wl2_input_del(Ecore_Wl2_Input *input)
 
    if (input->cursor.surface) wl_surface_destroy(input->cursor.surface);
    if (input->cursor.name) eina_stringshare_del(input->cursor.name);
-   if (input->cursor.theme) eina_stringshare_del(input->cursor.theme);
+   if (input->cursor.theme_name)
+     eina_stringshare_del(input->cursor.theme_name);
 
    if (input->data.types.data)
      {
index 0f1741a..0b5403f 100644 (file)
@@ -127,9 +127,10 @@ struct _Ecore_Wl2_Input
 
    struct
      {
-        const char *name, *theme;
+        const char *name, *theme_name;
         unsigned int index, size;
         struct wl_cursor *wl_cursor;
+        struct wl_cursor_theme *theme;
         struct wl_surface *surface;
         struct wl_callback *frame_cb;
         Ecore_Timer *timer;