ecore-wl2: Fix setting input region on a window

Previous code here would store incorrect values into the
window->input rectangle. These values should be what is actually
getting set in the wl_region. This code also fixes an issue when
setting input region for transparent/alpha windows by clearing out
any pending input region (wl_surface_set_input_region(surface, null)).

Reviewed-By: Derek Foreman <derekf@osg.samsung.com>

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2017-02-14 11:31:57 -05:00
parent 559490d756
commit 515c2d0374
1 changed files with 37 additions and 22 deletions

View File

@ -941,42 +941,57 @@ ecore_wl2_window_input_region_set(Ecore_Wl2_Window *window, int x, int y, int w,
EINA_SAFETY_ON_NULL_RETURN(window);
if ((window->input_rect.x == x) && (window->input_rect.y == y) &&
(window->input_rect.w == w) && (window->input_rect.h == h))
return;
window->input_rect.x = x;
window->input_rect.y = y;
window->input_rect.w = w;
window->input_rect.h = h;
window->input_set = 1;
if (window->type == ECORE_WL2_WINDOW_TYPE_DND) 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_input_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->input_rect.x = x;
window->input_rect.y = y;
window->input_rect.w = w;
window->input_rect.h = h;
break;
case 90:
wl_region_add(region, y, x, h, w);
window->input_rect.x = y;
window->input_rect.y = x;
window->input_rect.w = h;
window->input_rect.h = w;
break;
case 180:
window->input_rect.x = x;
window->input_rect.y = x + y;
window->input_rect.w = w;
window->input_rect.h = h;
break;
case 270:
wl_region_add(region, x + y, x, h, w);
window->input_rect.x = x + y;
window->input_rect.y = x;
window->input_rect.w = h;
window->input_rect.h = w;
break;
default:
break;
}
window->input_set = EINA_TRUE;
if (!window->surface) return;
if (window->type == ECORE_WL2_WINDOW_TYPE_DND) return;
region = wl_compositor_create_region(window->display->wl.compositor);
if (!region)
{
ERR("Failed to create input region");
return;
}
wl_region_add(region, window->input_rect.x, window->input_rect.y,
window->input_rect.w, window->input_rect.h);
wl_surface_set_input_region(window->surface, region);
wl_region_destroy(region);
}