diff --git a/src/compositor-drm.c b/src/compositor-drm.c index e4381422..dccbafef 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -529,12 +529,58 @@ drm_output_prepare_overlay_surface(struct weston_output *output_base, return 0; } +static int +drm_output_set_cursor(struct weston_output *output_base, + struct weston_input_device *eid); + +static void +weston_output_set_cursor(struct weston_output *output, + struct weston_input_device *device, + pixman_region32_t *overlap) +{ + pixman_region32_t cursor_region; + int prior_was_hardware; + + if (device->sprite == NULL) + return; + + pixman_region32_init(&cursor_region); + pixman_region32_intersect(&cursor_region, + &device->sprite->transform.boundingbox, + &output->region); + + if (!pixman_region32_not_empty(&cursor_region)) { + drm_output_set_cursor(output, NULL); + goto out; + } + + prior_was_hardware = device->hw_cursor; + if (pixman_region32_not_empty(overlap) || + drm_output_set_cursor(output, device) < 0) { + if (prior_was_hardware) { + weston_surface_damage(device->sprite); + drm_output_set_cursor(output, NULL); + } + device->hw_cursor = 0; + } else { + if (!prior_was_hardware) + weston_surface_damage_below(device->sprite); + pixman_region32_fini(&device->sprite->damage); + pixman_region32_init(&device->sprite->damage); + device->hw_cursor = 1; + } + +out: + pixman_region32_fini(&cursor_region); +} + static void drm_assign_planes(struct weston_output *output) { struct weston_compositor *ec = output->compositor; struct weston_surface *es; pixman_region32_t overlap, surface_overlap; + struct weston_input_device *device; /* * Find a surface for each sprite in the output using some heuristics: @@ -561,8 +607,16 @@ drm_assign_planes(struct weston_output *output) pixman_region32_intersect(&surface_overlap, &overlap, &es->transform.boundingbox); - if (!drm_output_prepare_overlay_surface(output, es, - &surface_overlap)) { + device = (struct weston_input_device *) ec->input_device; + if (es == device->sprite) { + weston_output_set_cursor(output, device, + &surface_overlap); + + if (!device->hw_cursor) + pixman_region32_union(&overlap, &overlap, + &es->transform.boundingbox); + } else if (!drm_output_prepare_overlay_surface(output, es, + &surface_overlap)) { pixman_region32_fini(&es->damage); pixman_region32_init(&es->damage); } else { @@ -1002,7 +1056,6 @@ create_output_for_connector(struct drm_compositor *ec, output->pending_fs_surf_fb_id = 0; output->base.repaint = drm_output_repaint; - output->base.set_hardware_cursor = drm_output_set_cursor; output->base.destroy = drm_output_destroy; output->base.assign_planes = drm_assign_planes; diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c index 00ad1892..a42e76fc 100644 --- a/src/compositor-wayland.c +++ b/src/compositor-wayland.c @@ -355,13 +355,6 @@ wayland_output_repaint(struct weston_output *output_base) return; } -static int -wayland_output_set_cursor(struct weston_output *output_base, - struct weston_input_device *input) -{ - return -1; -} - static void wayland_output_destroy(struct weston_output *output_base) { @@ -440,7 +433,6 @@ wayland_compositor_create_output(struct wayland_compositor *c, wl_shell_surface_set_toplevel(output->parent.shell_surface); output->base.repaint = wayland_output_repaint; - output->base.set_hardware_cursor = wayland_output_set_cursor; output->base.destroy = wayland_output_destroy; output->base.assign_planes = NULL; diff --git a/src/compositor-x11.c b/src/compositor-x11.c index 9748af79..7243329e 100644 --- a/src/compositor-x11.c +++ b/src/compositor-x11.c @@ -221,13 +221,6 @@ finish_frame_handler(void *data) return 1; } -static int -x11_output_set_cursor(struct weston_output *output_base, - struct weston_input_device *input) -{ - return -1; -} - static void x11_output_destroy(struct weston_output *output_base) { @@ -446,7 +439,6 @@ x11_compositor_create_output(struct x11_compositor *c, int x, int y, wl_event_loop_add_timer(loop, finish_frame_handler, output); output->base.repaint = x11_output_repaint; - output->base.set_hardware_cursor = x11_output_set_cursor; output->base.destroy = x11_output_destroy; output->base.assign_planes = NULL; diff --git a/src/compositor.c b/src/compositor.c index 4cd8d99e..f99afc62 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -268,7 +268,7 @@ surface_to_global_float(struct weston_surface *surface, } } -static void +WL_EXPORT void weston_surface_damage_below(struct weston_surface *surface) { struct weston_surface *below; @@ -902,48 +902,6 @@ fade_frame(struct weston_animation *animation, } } -static void -weston_output_set_cursor(struct weston_output *output, - struct wl_input_device *dev) -{ - struct weston_input_device *device = - (struct weston_input_device *) dev; - pixman_region32_t cursor_region; - int prior_was_hardware; - - if (device->sprite == NULL) - return; - - pixman_region32_init(&cursor_region); - pixman_region32_intersect(&cursor_region, - &device->sprite->transform.boundingbox, - &output->region); - - if (!pixman_region32_not_empty(&cursor_region)) { - output->set_hardware_cursor(output, NULL); - goto out; - } - - prior_was_hardware = device->hw_cursor; - if (device->sprite->overlapped || - output->set_hardware_cursor(output, device) < 0) { - if (prior_was_hardware) { - weston_surface_damage(device->sprite); - output->set_hardware_cursor(output, NULL); - } - device->hw_cursor = 0; - } else { - if (!prior_was_hardware) - weston_surface_damage_below(device->sprite); - pixman_region32_fini(&device->sprite->damage); - pixman_region32_init(&device->sprite->damage); - device->hw_cursor = 1; - } - -out: - pixman_region32_fini(&cursor_region); -} - struct weston_frame_callback { struct wl_resource resource; struct wl_list link; @@ -995,8 +953,6 @@ weston_output_repaint(struct weston_output *output, int msecs) */ output->assign_planes(output); - weston_output_set_cursor(output, ec->input_device); - wl_list_for_each(es, &ec->surface_list, link) { pixman_region32_subtract(&es->damage, &es->damage, &opaque); pixman_region32_union(&new_damage, &new_damage, &es->damage); diff --git a/src/compositor.h b/src/compositor.h index d4f85d46..4a368249 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -84,8 +84,6 @@ struct weston_output { struct wl_list mode_list; void (*repaint)(struct weston_output *output); - int (*set_hardware_cursor)(struct weston_output *output, - struct weston_input_device *input); void (*destroy)(struct weston_output *output); void (*assign_planes)(struct weston_output *output); }; @@ -418,6 +416,9 @@ weston_surface_assign_output(struct weston_surface *surface); void weston_surface_damage(struct weston_surface *surface); +void +weston_surface_damage_below(struct weston_surface *surface); + void weston_buffer_post_release(struct wl_buffer *buffer);