ecore_wl2: Add ecore_wl2_display_flush() api
authorDerek Foreman <derekf@osg.samsung.com>
Wed, 30 Aug 2017 17:24:16 +0000 (12:24 -0500)
committerDerek Foreman <derekf@osg.samsung.com>
Wed, 30 Aug 2017 19:11:47 +0000 (14:11 -0500)
Allowing engines to explicitly flush at the right times will remove some
awkwardness and bugs from our current display flush paradigm

src/lib/ecore_wl2/Ecore_Wl2.h
src/lib/ecore_wl2/ecore_wl2_display.c

index 069ec15..00fe799 100644 (file)
@@ -1943,6 +1943,18 @@ EAPI void ecore_wl2_window_frame_callback_del(Ecore_Wl2_Frame_Cb_Handle *handle)
  */
 EAPI void ecore_wl2_window_buffer_attach(Ecore_Wl2_Window *win, void *buffer, int x, int y, Eina_Bool implicit);
 
+/**
+ * Push buffered wayland protocol to compositor
+ *
+ * Wayland protocol is only actually sent when a flush occurs,
+ * so the display should be flushed at appropriate times, such
+ * as after a commit.
+ *
+ * @param display
+ * @since 1.20
+ */
+EAPI void ecore_wl2_display_flush(Ecore_Wl2_Display *display);
+
 # endif
 
 # undef EAPI
index 69838f7..d96405c 100644 (file)
@@ -1111,3 +1111,24 @@ ecore_wl2_display_name_get(const Ecore_Wl2_Display *display)
    EINA_SAFETY_ON_NULL_RETURN_VAL(display, NULL);
    return display->name;
 }
+
+EAPI void
+ecore_wl2_display_flush(Ecore_Wl2_Display *display)
+{
+   int ret, code;
+
+   EINA_SAFETY_ON_NULL_RETURN(display);
+
+   ret = wl_display_flush(display->wl.display);
+   if (ret >= 0) return;
+
+   code = errno;
+   if (code == EAGAIN)
+     {
+        ecore_main_fd_handler_active_set(display->fd_hdl,
+                                         (ECORE_FD_READ | ECORE_FD_WRITE));
+        return;
+     }
+
+   _begin_recovery_maybe(display, code);
+}