e_hwc_window: compare cursor buffer instead image pointer 09/213909/3
authorChangyeon Lee <cyeon.lee@samsung.com>
Mon, 16 Sep 2019 09:25:40 +0000 (18:25 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Tue, 17 Sep 2019 05:01:55 +0000 (05:01 +0000)
Change-Id: I862e3422443d646db0a2fc94d0124b5725ec9b2e

src/bin/e_hwc_window.c
src/bin/e_hwc_window.h

index 951b8d951a6e28255a05a1d607d5e81385e5c32d..83aa0a791ac6c55961f6d804863bd099c72e0271 100644 (file)
@@ -457,6 +457,22 @@ _e_hwc_window_client_surface_acquire(E_Hwc_Window *hwc_window)
    return tsurface;
 }
 
+static void
+_e_hwc_window_cb_cursor_buffer_destroy(struct wl_listener *listener, void *data)
+{
+   E_Hwc_Window *hwc_window = NULL;
+
+   hwc_window = container_of(listener, E_Hwc_Window, cursor_buffer_destroy_listener);
+   EINA_SAFETY_ON_NULL_RETURN(hwc_window);
+
+   if ((E_Comp_Wl_Buffer *)data != hwc_window->cursor.buffer) return;
+
+   if (hwc_window->cursor.buffer)
+     wl_list_remove(&hwc_window->cursor_buffer_destroy_listener.link);
+
+   hwc_window->cursor.buffer = NULL;
+}
+
 static Eina_Bool
 _e_hwc_window_cursor_image_update(E_Hwc_Window *hwc_window)
 {
@@ -468,10 +484,8 @@ _e_hwc_window_cursor_image_update(E_Hwc_Window *hwc_window)
    tdm_error error;
 
    pointer = e_pointer_get(ec);
-   if (!pointer) return EINA_FALSE;
-
    buffer = _e_hwc_window_comp_wl_buffer_get(hwc_window);
-   if (!buffer)
+   if (!buffer || !pointer)
      {
         if (hwc_window->cursor.img_ptr)
           {
@@ -482,6 +496,10 @@ _e_hwc_window_cursor_image_update(E_Hwc_Window *hwc_window)
                   return EINA_FALSE;
                }
 
+             if (hwc_window->cursor.buffer)
+               wl_list_remove(&hwc_window->cursor_buffer_destroy_listener.link);
+
+             hwc_window->cursor.buffer = NULL;
              hwc_window->cursor.rotation = 0;
              hwc_window->cursor.img_ptr = NULL;
              hwc_window->cursor.img_w = 0;
@@ -514,7 +532,7 @@ _e_hwc_window_cursor_image_update(E_Hwc_Window *hwc_window)
      }
 
    /* no changes, no need to update the cursor image */
-   if ((hwc_window->cursor.img_ptr == img_ptr) &&
+   if ((hwc_window->cursor.buffer == buffer) &&
        (hwc_window->cursor.rotation == pointer->rotation))
      return EINA_FALSE;
 
@@ -525,6 +543,12 @@ _e_hwc_window_cursor_image_update(E_Hwc_Window *hwc_window)
         return EINA_FALSE;
      }
 
+   if (hwc_window->cursor.buffer)
+     wl_list_remove(&hwc_window->cursor_buffer_destroy_listener.link);
+
+   hwc_window->cursor.buffer = buffer;
+   wl_signal_add(&buffer->destroy_signal, &hwc_window->cursor_buffer_destroy_listener);
+   hwc_window->cursor_buffer_destroy_listener.notify = _e_hwc_window_cb_cursor_buffer_destroy;
    hwc_window->cursor.rotation = pointer->rotation;
    hwc_window->cursor.img_ptr = img_ptr;
    hwc_window->cursor.img_w = img_w;
@@ -629,6 +653,9 @@ _e_hwc_window_free(E_Hwc_Window *hwc_window)
    EHWINF("Free", NULL, hwc_window->hwc, hwc_window);
 
 done:
+   if (hwc_window->cursor.buffer)
+     wl_list_remove(&hwc_window->cursor_buffer_destroy_listener.link);
+
    if (hwc_window->queue)
      wl_list_remove(&hwc_window->queue_destroy_listener.link);
 
index ba87f04405ffdd38cf71da38bc79c231ebdaa208..496d422e83e8f5505a68688c5b35b7bd41fbc862 100644 (file)
@@ -112,11 +112,13 @@ struct _E_Hwc_Window
    struct
    {
       int                         rotation;
+      E_Comp_Wl_Buffer           *buffer;
       void                       *img_ptr;
       int                         img_w;
       int                         img_h;
       int                         img_stride;
    } cursor;
+   struct wl_listener             cursor_buffer_destroy_listener;
 
    struct
    {