From 559490d7568bac10a9cfe2449ec4af29d8d6cfc0 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Tue, 14 Feb 2017 09:58:49 -0500 Subject: [PATCH] ecore-wl2: Fix setting opaque region on a window Previous code here would store incorrect values into the window->opaque rectangle. These values should be what is actually getting set in the wl_region. This code also fixes an issue when setting opaque region for transparent/alpha windows by clearing out any pending opaque region (wl_surface_set_opaque_region(surface, null)). Reviewed-By: Derek Foreman @fix Signed-off-by: Chris Michael --- src/lib/ecore_wl2/ecore_wl2_window.c | 58 ++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/src/lib/ecore_wl2/ecore_wl2_window.c b/src/lib/ecore_wl2/ecore_wl2_window.c index fb75bf5..d087014 100644 --- a/src/lib/ecore_wl2/ecore_wl2_window.c +++ b/src/lib/ecore_wl2/ecore_wl2_window.c @@ -880,42 +880,56 @@ ecore_wl2_window_opaque_region_set(Ecore_Wl2_Window *window, int x, int y, int w EINA_SAFETY_ON_NULL_RETURN(window); - if ((window->opaque.x == x) && (window->opaque.y == y) && - (window->opaque.w == w) && (window->opaque.h == h)) - return; - - window->opaque.x = x; - window->opaque.y = y; - window->opaque.w = w; - window->opaque.h = h; - window->opaque_set = 1; - - if ((window->transparent) || (window->alpha)) return; - if (!window->surface) return; //surface not created yet - - region = wl_compositor_create_region(window->display->wl.compositor); - if (!region) + if ((x == 0) && (y == 0) && (w == 0) && (h == 0)) { - ERR("Failed to create opaque region"); + if (window->surface) + wl_surface_set_opaque_region(window->surface, NULL); 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); + window->opaque.x = x; + window->opaque.y = y; + window->opaque.w = w; + window->opaque.h = h; break; case 90: - wl_region_add(region, y, x, h, w); + window->opaque.x = y; + window->opaque.y = x; + window->opaque.w = h; + window->opaque.h = w; + break; + case 180: + window->opaque.x = x; + window->opaque.y = x + y; + window->opaque.w = w; + window->opaque.h = h; break; case 270: - wl_region_add(region, x + y, x, h, w); + window->opaque.x = x + y; + window->opaque.y = x; + window->opaque.w = h; + window->opaque.h = w; + break; + default: break; } + window->opaque_set = EINA_TRUE; + + if (!window->surface) return; + + region = wl_compositor_create_region(window->display->wl.compositor); + if (!region) + { + ERR("Failed to create opaque region"); + return; + } + + wl_region_add(region, window->opaque.x, window->opaque.y, + window->opaque.w, window->opaque.h); wl_surface_set_opaque_region(window->surface, region); wl_region_destroy(region); } -- 2.7.4