swc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/swc
Log | Files | Refs | README | LICENSE

commit 13e0a59afe5f9a09efba119d7600ec3c29606889
parent 98a2f5d57001e28821937c7f4a76e56ccbd97409
Author: Michael Forney <mforney@mforney.org>
Date:   Thu, 12 Sep 2013 16:59:54 -0700

surface: Fix input region

Diffstat:
Mlibswc/compositor.c | 12+++++++-----
Mlibswc/surface.c | 10++--------
Mlibswc/util.h | 7+++++++
3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/libswc/compositor.c b/libswc/compositor.c @@ -204,7 +204,7 @@ static void handle_focus(struct swc_pointer * pointer) struct swc_seat * seat; struct swc_compositor * compositor; struct swc_surface * surface; - int32_t surface_x, surface_y; + int32_t x, y; seat = swc_container_of(pointer, typeof(*seat), pointer); compositor = swc_container_of(seat, typeof(*compositor), seat); @@ -217,11 +217,13 @@ static void handle_focus(struct swc_pointer * pointer) (&region, surface->geometry.x, surface->geometry.y, surface->geometry.width, surface->geometry.height); - surface_x = wl_fixed_to_int(pointer->x) - surface->geometry.x; - surface_y = wl_fixed_to_int(pointer->y) - surface->geometry.y; + x = wl_fixed_to_int(pointer->x); + y = wl_fixed_to_int(pointer->y); - if (pixman_region32_contains_point(&surface->state.input, - surface_x, surface_y, NULL)) + if (swc_rectangle_contains_point(&surface->geometry, x, y) + && pixman_region32_contains_point(&surface->state.input, + x - surface->geometry.x, + y - surface->geometry.y, NULL)) { swc_pointer_set_focus(pointer, surface); return; diff --git a/libswc/surface.c b/libswc/surface.c @@ -270,10 +270,8 @@ static void commit(struct wl_client * client, struct wl_resource * resource) /* Input */ if (surface->pending.commit & SWC_SURFACE_COMMIT_INPUT) { - pixman_region32_intersect_rect(&surface->state.input, - &surface->pending.state.input, 0, 0, - surface->geometry.width, - surface->geometry.height); + pixman_region32_copy(&surface->state.input, + &surface->pending.state.input); } /* Frame */ @@ -362,10 +360,6 @@ struct swc_surface * swc_surface_new(struct wl_client * client, uint32_t id) state_initialize(&surface->state); state_initialize(&surface->pending.state); - /* The input region should be intersected with the surface's geometry, - * which at this point is empty. */ - pixman_region32_clear(&surface->state.input); - wl_signal_init(&surface->event_signal); /* Add the surface to the client. */ diff --git a/libswc/util.h b/libswc/util.h @@ -17,6 +17,13 @@ void swc_remove_resource(struct wl_resource * resource); +static inline bool swc_rectangle_contains_point + (pixman_rectangle32_t * rectangle, int32_t x, int32_t y) +{ + return x > rectangle->x && x < rectangle->x + rectangle->width + && y > rectangle->y && y < rectangle->y + rectangle->height; +} + static inline bool swc_rectangle_overlap (pixman_rectangle32_t * r1, pixman_rectangle32_t * r2) {