GLuint texture;
struct wl_map map;
EGLSurface surface;
-
+ struct wl_surface *wl_surface;
+ int width, height;
struct wl_list link;
};
return;
es->surface = EGL_NO_SURFACE;
+ es->wl_surface = surface;
wl_surface_set_data(surface, es);
wl_list_insert(ec->surface_list.prev, &es->link);
if (es->surface != EGL_NO_SURFACE)
eglDestroySurface(ec->display, es->surface);
+ es->width = width;
+ es->height = height;
es->surface = eglCreateSurfaceForName(ec->display, ec->config,
name, width, height, stride, NULL);
return ec->current_frame;
}
-static void
-notify_pointer_motion(struct wl_compositor *compositor,
- struct wl_object *source, int x, int y)
-{
- struct egl_compositor *ec = (struct egl_compositor *) compositor;
- const int hotspot_x = 16, hotspot_y = 16;
-
- ec->pointer->map.x = x - hotspot_x;
- ec->pointer->map.y = y - hotspot_y;
- schedule_repaint(ec);
-}
-
static struct egl_surface *
pick_surface(struct egl_compositor *ec, int32_t x, int32_t y)
{
}
static void
+notify_pointer_motion(struct wl_compositor *compositor,
+ struct wl_object *source, int x, int y)
+{
+ struct egl_compositor *ec = (struct egl_compositor *) compositor;
+ struct egl_surface *es;
+ const int hotspot_x = 16, hotspot_y = 16;
+ int32_t sx, sy;
+
+ es = pick_surface(ec, x, y);
+ if (es) {
+ sx = (x - es->map.x) * es->width / es->map.width;
+ sy = (y - es->map.y) * es->height / es->map.height;
+ wl_display_post_surface_motion(ec->wl_display, es->wl_surface,
+ source, x, y, sx, sy);
+ }
+
+ ec->pointer->map.x = x - hotspot_x;
+ ec->pointer->map.y = y - hotspot_y;
+ schedule_repaint(ec);
+}
+
+static void
notify_pointer_button(struct wl_compositor *compositor,
struct wl_object *source,
int32_t button, int32_t state)
struct wl_surface {
struct wl_object base;
+ struct wl_client *client;
/* provided by client */
int width, height;
int buffer;
};
static struct wl_surface *
-wl_surface_create(struct wl_display *display, uint32_t id)
+wl_surface_create(struct wl_display *display,
+ struct wl_client *client, uint32_t id)
{
struct wl_surface *surface;
const struct wl_compositor_interface *interface;
surface->base.id = id;
surface->base.interface = &surface_interface;
+ surface->client = client;
wl_list_insert(display->surface_list.prev, &surface->link);
struct wl_surface *surface;
struct wl_object_ref *ref;
- surface = wl_surface_create(display, id);
+ surface = wl_surface_create(display, client, id);
ref = malloc(sizeof *ref);
if (ref == NULL) {
#define WL_INPUT_KEY 2
WL_EXPORT void
+wl_display_post_surface_motion(struct wl_display *display,
+ struct wl_surface *surface,
+ struct wl_object *source,
+ int32_t x, int32_t y, int32_t sx, int32_t sy)
+{
+ uint32_t p[6];
+
+ p[0] = source->id;
+ p[1] = (sizeof p << 16) | WL_INPUT_MOTION;
+ p[2] = x;
+ p[3] = y;
+ p[4] = sx;
+ p[5] = sy;
+
+ wl_connection_write(surface->client->connection, p, sizeof p);
+}
+
+WL_EXPORT void
wl_display_post_relative_event(struct wl_display *display,
struct wl_object *source, int dx, int dy)
{
const struct wl_compositor_interface *interface;
- uint32_t p[4];
display->pointer_x += dx;
display->pointer_y += dy;
interface = display->compositor->interface;
interface->notify_pointer_motion(display->compositor, source,
display->pointer_x, display->pointer_y);
-
- p[0] = source->id;
- p[1] = (sizeof p << 16) | WL_INPUT_MOTION;
- p[2] = display->pointer_x;
- p[3] = display->pointer_y;
-
- wl_display_send_event(display, p, sizeof p);
}
WL_EXPORT void
struct wl_object *source, int x, int y)
{
const struct wl_compositor_interface *interface;
- uint32_t p[4];
display->pointer_x = x;
display->pointer_y = y;
interface = display->compositor->interface;
interface->notify_pointer_motion(display->compositor, source,
display->pointer_x, display->pointer_y);
-
- p[0] = source->id;
- p[1] = (sizeof p << 16) | WL_INPUT_MOTION;
- p[2] = display->pointer_x;
- p[3] = display->pointer_y;
-
- wl_display_send_event(display, p, sizeof p);
}
WL_EXPORT void
void
wl_display_post_frame(struct wl_display *display,
uint32_t frame, uint32_t msecs);
+void
+wl_display_post_surface_motion(struct wl_display *display,
+ struct wl_surface *surface,
+ struct wl_object *source,
+ int x, int y, int sx, int sy);
struct wl_compositor {
const struct wl_compositor_interface *interface;