diff --git a/src/compositor.c b/src/compositor.c index 8c8dff0a..417c5083 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -327,6 +327,83 @@ weston_surface_damage_below(struct weston_surface *surface) pixman_region32_fini(&damage); } +static struct wl_resource * +find_resource_for_client(struct wl_list *list, struct wl_client *client) +{ + struct wl_resource *r; + + wl_list_for_each(r, list, link) { + if (r->client == client) + return r; + } + + return NULL; +} + +static void +weston_surface_update_output_mask(struct weston_surface *es, uint32_t mask) +{ + uint32_t different = es->output_mask ^ mask; + uint32_t entered = mask & different; + uint32_t left = es->output_mask & different; + struct weston_output *output; + struct wl_resource *resource = NULL; + struct wl_client *client = es->surface.resource.client; + + es->output_mask = mask; + if (es->surface.resource.client == NULL) + return; + if (different == 0) + return; + + wl_list_for_each(output, &es->compositor->output_list, link) { + if (1 << output->id & different) + resource = + find_resource_for_client(&output->resource_list, + client); + if (resource == NULL) + continue; + if (1 << output->id & entered) + wl_surface_send_enter(&es->surface.resource, resource); + if (1 << output->id & left) + wl_surface_send_leave(&es->surface.resource, resource); + } +} + +static void +weston_surface_assign_output(struct weston_surface *es) +{ + struct weston_compositor *ec = es->compositor; + struct weston_output *output, *new_output; + pixman_region32_t region; + uint32_t max, area, mask; + pixman_box32_t *e; + + new_output = NULL; + max = 0; + mask = 0; + pixman_region32_init(®ion); + wl_list_for_each(output, &ec->output_list, link) { + pixman_region32_intersect(®ion, &es->transform.boundingbox, + &output->region); + + e = pixman_region32_extents(®ion); + area = (e->x2 - e->x1) * (e->y2 - e->y1); + + if (area > 0) + mask |= 1 << output->id; + + if (area >= max) { + new_output = output; + max = area; + } + } + pixman_region32_fini(®ion); + + es->output = new_output; + weston_surface_update_output_mask(es, mask); +} + static void surface_compute_bbox(struct weston_surface *surface, int32_t sx, int32_t sy, int32_t width, int32_t height, @@ -1044,83 +1121,6 @@ surface_destroy(struct wl_client *client, struct wl_resource *resource) wl_resource_destroy(resource); } -static struct wl_resource * -find_resource_for_client(struct wl_list *list, struct wl_client *client) -{ - struct wl_resource *r; - - wl_list_for_each(r, list, link) { - if (r->client == client) - return r; - } - - return NULL; -} - -static void -weston_surface_update_output_mask(struct weston_surface *es, uint32_t mask) -{ - uint32_t different = es->output_mask ^ mask; - uint32_t entered = mask & different; - uint32_t left = es->output_mask & different; - struct weston_output *output; - struct wl_resource *resource = NULL; - struct wl_client *client = es->surface.resource.client; - - es->output_mask = mask; - if (es->surface.resource.client == NULL) - return; - if (different == 0) - return; - - wl_list_for_each(output, &es->compositor->output_list, link) { - if (1 << output->id & different) - resource = - find_resource_for_client(&output->resource_list, - client); - if (resource == NULL) - continue; - if (1 << output->id & entered) - wl_surface_send_enter(&es->surface.resource, resource); - if (1 << output->id & left) - wl_surface_send_leave(&es->surface.resource, resource); - } -} - -WL_EXPORT void -weston_surface_assign_output(struct weston_surface *es) -{ - struct weston_compositor *ec = es->compositor; - struct weston_output *output, *new_output; - pixman_region32_t region; - uint32_t max, area, mask; - pixman_box32_t *e; - - new_output = NULL; - max = 0; - mask = 0; - pixman_region32_init(®ion); - wl_list_for_each(output, &ec->output_list, link) { - pixman_region32_intersect(®ion, &es->transform.boundingbox, - &output->region); - - e = pixman_region32_extents(®ion); - area = (e->x2 - e->x1) * (e->y2 - e->y1); - - if (area > 0) - mask |= 1 << output->id; - - if (area >= max) { - new_output = output; - max = area; - } - } - pixman_region32_fini(®ion); - - es->output = new_output; - weston_surface_update_output_mask(es, mask); -} - static void surface_attach(struct wl_client *client, struct wl_resource *resource, diff --git a/src/compositor.h b/src/compositor.h index 47609934..aea4f8d0 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -646,9 +646,6 @@ weston_surface_set_position(struct weston_surface *surface, int weston_surface_is_mapped(struct weston_surface *surface); -void -weston_surface_assign_output(struct weston_surface *surface); - void weston_surface_schedule_repaint(struct weston_surface *surface);