ecore-wl2: Add API function to set window opaque region
authorChris Michael <cp.michael@samsung.com>
Mon, 28 Sep 2015 13:25:52 +0000 (09:25 -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.h
src/lib/ecore_wl2/ecore_wl2_private.h
src/lib/ecore_wl2/ecore_wl2_window.c

index 54f0e43..a18df7d 100644 (file)
@@ -378,6 +378,22 @@ EAPI Eina_Bool ecore_wl2_window_alpha_get(Ecore_Wl2_Window *window);
 /* TODO: doxy */
 EAPI void ecore_wl2_window_alpha_set(Ecore_Wl2_Window *window, Eina_Bool alpha);
 
+/* TODO: doxy */
+EAPI void ecore_wl2_window_transparent_set(Ecore_Wl2_Window *window, Eina_Bool transparent);
+
+/**
+ * Set the opaque region of the Ecore_Wl2_Window
+ *
+ * @param win The window
+ * @param x The left point of the region.
+ * @param y The top point of the region.
+ * @param w The width of the region.
+ * @param h The height of the region.
+ *
+ * @ingroup Ecore_Wl2_Window_Group
+ */
+EAPI void ecore_wl2_window_opaque_region_set(Ecore_Wl2_Window *window, int x, int y, int w, int h);
+
 /* # ifdef __cplusplus */
 /* } */
 /* # endif */
index 3701015..800c1ad 100644 (file)
@@ -78,7 +78,7 @@ struct _Ecore_Wl2_Window
 
    Ecore_Wl2_Window *parent;
 
-   int id;
+   int id, rotation;
    const char *title;
    const char *class;
 
@@ -89,6 +89,7 @@ struct _Ecore_Wl2_Window
    struct wl_callback *anim_cb;
 
    Eina_Rectangle geometry;
+   Eina_Rectangle opaque;
 
    Ecore_Wl2_Window_Type type;
 
index dba0307..ed32719 100644 (file)
@@ -507,8 +507,55 @@ ecore_wl2_window_alpha_set(Ecore_Wl2_Window *window, Eina_Bool alpha)
 {
    EINA_SAFETY_ON_NULL_RETURN(window);
 
-   if (win->alpha == alpha) return;
+   if (window->alpha == alpha) return;
 
-   win->alpha = alpha;
-   /* TODO: set opaque region */
+   window->alpha = alpha;
+
+   if (!window->alpha)
+     ecore_wl2_window_opaque_region_set(window, window->opaque.x,
+                                        window->opaque.y, window->opaque.w,
+                                        window->opaque.h);
+   else
+     ecore_wl2_window_opaque_region_set(window, 0, 0, 0, 0);
+}
+
+EAPI void
+ecore_wl2_window_opaque_region_set(Ecore_Wl2_Window *window, int x, int y, int w, int h)
+{
+   struct wl_region *region;
+
+   EINA_SAFETY_ON_NULL_RETURN(window);
+
+   window->opaque.x = x;
+   window->opaque.y = y;
+   window->opaque.w = w;
+   window->opaque.h = h;
+
+   /* TODO: transparent or alpha check ? */
+
+   region = wl_compositor_create_region(window->display->wl.compositor);
+   if (!region)
+     {
+        ERR("Failed to create opaque region: %m");
+        return;
+     }
+
+   switch (window->rotation)
+     {
+      case 0:
+        wl_region_add(region, x, y, w, h);
+        break;
+      case 180:
+        wl_region_add(region, x, x + y, w, h);
+        break;
+      case 90:
+        wl_region_add(region, y, x, h, w);
+        break;
+      case 270:
+        wl_region_add(region, x + y, x, h, w);
+        break;
+     }
+
+   wl_surface_set_opaque_region(window->surface, region);
+   wl_region_destroy(region);
 }