From: Kristian Høgsberg Date: Thu, 21 Jul 2011 18:30:22 +0000 (-0700) Subject: compositor: Pick output for surface based on amount of overlap X-Git-Tag: 0.85.0~395 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4f0df049bbc4e090b4c5d69d5eb9511fe59d866e;p=profile%2Fivi%2Fweston.git compositor: Pick output for surface based on amount of overlap --- diff --git a/compositor/compositor.c b/compositor/compositor.c index 71fab71..4afdea2 100644 --- a/compositor/compositor.c +++ b/compositor/compositor.c @@ -992,25 +992,24 @@ wlsc_surface_assign_output(struct wlsc_surface *es) { struct wlsc_compositor *ec = es->compositor; struct wlsc_output *output; + pixman_region32_t region; + uint32_t max, area; + pixman_box32_t *e; - struct wlsc_output *tmp = es->output; - es->output = NULL; - + max = 0; wl_list_for_each(output, &ec->output_list, link) { - if (pixman_region32_contains_point(&output->region, - es->x, es->y, NULL)) { - if (output != tmp) - printf("assiging surface %p to output %p\n", - es, output); + pixman_region32_init_rect(®ion, + es->x, es->y, es->width, es->height); + pixman_region32_intersect(®ion, ®ion, &output->region); + + e = pixman_region32_extents(®ion); + area = (e->x2 - e->x1) * (e->y2 - e->y1); + + if (area >= max) { es->output = output; + max = area; } } - - if (es->output == NULL) { - printf("no output found\n"); - es->output = container_of(ec->output_list.next, - struct wlsc_output, link); - } } static void