From 35cbc0d7374c4686e223724d0a71280e798eefcd Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Mon, 28 Sep 2015 09:25:52 -0400 Subject: [PATCH] ecore-wl2: Add API function to set window opaque region Signed-off-by: Chris Michael --- src/lib/ecore_wl2/Ecore_Wl2.h | 16 ++++++++ src/lib/ecore_wl2/ecore_wl2_private.h | 3 +- src/lib/ecore_wl2/ecore_wl2_window.c | 53 +++++++++++++++++++++++++-- 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h index 54f0e43a1e..a18df7d346 100644 --- a/src/lib/ecore_wl2/Ecore_Wl2.h +++ b/src/lib/ecore_wl2/Ecore_Wl2.h @@ -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 */ diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h b/src/lib/ecore_wl2/ecore_wl2_private.h index 3701015923..800c1ad95b 100644 --- a/src/lib/ecore_wl2/ecore_wl2_private.h +++ b/src/lib/ecore_wl2/ecore_wl2_private.h @@ -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; diff --git a/src/lib/ecore_wl2/ecore_wl2_window.c b/src/lib/ecore_wl2/ecore_wl2_window.c index dba0307db9..ed32719538 100644 --- a/src/lib/ecore_wl2/ecore_wl2_window.c +++ b/src/lib/ecore_wl2/ecore_wl2_window.c @@ -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); }