summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2008-12-11 23:27:27 -0500
committerKristian Høgsberg <krh@redhat.com>2008-12-11 23:27:27 -0500
commit29573bc56985ea8256c7c042f6aebc209a13b386 (patch)
tree6f4138e96a6aa6689173beb9a9db2bf316e97c46
parent5ee1a60f1a03b3176332f6d4f27744d0dfdb0601 (diff)
downloadwayland-29573bc56985ea8256c7c042f6aebc209a13b386.tar.gz
wayland-29573bc56985ea8256c7c042f6aebc209a13b386.tar.xz
wayland-29573bc56985ea8256c7c042f6aebc209a13b386.zip
Implement passive grabs on button clicks.
-rw-r--r--egl-compositor.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/egl-compositor.c b/egl-compositor.c
index 77b9fbb..be25849 100644
--- a/egl-compositor.c
+++ b/egl-compositor.c
@@ -54,7 +54,10 @@ struct egl_input_device {
struct wl_object base;
int32_t x, y;
struct egl_compositor *ec;
- struct egl_surface *surface;
+ struct egl_surface *pointer_surface;
+
+ int grab;
+ struct egl_surface *grab_surface;
};
struct egl_compositor {
@@ -589,7 +592,7 @@ repaint(void *data)
draw_surface(ec->overlay);
- draw_surface(ec->input_device->surface);
+ draw_surface(ec->input_device->pointer_surface);
eglSwapBuffers(ec->display, ec->surface);
ec->repaint_needed = 0;
@@ -767,7 +770,11 @@ notify_motion(struct egl_input_device *device, int x, int y)
const int hotspot_x = 16, hotspot_y = 16;
int32_t sx, sy;
- es = pick_surface(device);
+ if (device->grab > 0)
+ es = device->grab_surface;
+ else
+ es = pick_surface(device);
+
if (es) {
sx = (x - es->map.x) * es->width / es->map.width;
sy = (y - es->map.y) * es->height / es->map.height;
@@ -777,8 +784,8 @@ notify_motion(struct egl_input_device *device, int x, int y)
device->x = x;
device->y = y;
- device->surface->map.x = x - hotspot_x;
- device->surface->map.y = y - hotspot_y;
+ device->pointer_surface->map.x = x - hotspot_x;
+ device->pointer_surface->map.y = y - hotspot_y;
schedule_repaint(device->ec);
}
@@ -794,6 +801,13 @@ notify_button(struct egl_input_device *device,
wl_list_remove(&es->link);
wl_list_insert(device->ec->surface_list.prev, &es->link);
+ if (state) {
+ device->grab++;
+ device->grab_surface = es;
+ } else {
+ device->grab--;
+ }
+
/* FIXME: Swallow click on raise? */
wl_surface_post_event(es->wl_surface, &device->base,
WL_INPUT_BUTTON, button, state);
@@ -864,7 +878,7 @@ create_input_devices(struct egl_compositor *ec)
ec->input_device = device;
device->x = 100;
device->y = 100;
- device->surface = pointer_create(device->x, device->y, 64, 64);
+ device->pointer_surface = pointer_create(device->x, device->y, 64, 64);
device->ec = ec;
path = getenv("WAYLAND_POINTER");