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);
+ wl_surface_post_event(es->wl_surface, source,
+ WL_INPUT_MOTION, x, y, sx, sy);
}
ec->pointer->map.x = x - hotspot_x;
if (es) {
wl_list_remove(&es->link);
wl_list_insert(ec->surface_list.prev, &es->link);
+
+ /* FIXME: Swallow click on raise? */
+ wl_surface_post_event(es->wl_surface, source,
+ WL_INPUT_BUTTON, button, state);
}
schedule_repaint(ec);
static const struct wl_method input_device_methods[] = {
};
+static const struct wl_event input_device_events[] = {
+ { "motion", "ii" },
+ { "button", "uu" },
+ { "key", "uu" },
+};
+
static const struct wl_interface input_device_interface = {
"input_device", 1,
ARRAY_LENGTH(input_device_methods),
input_device_methods,
+ ARRAY_LENGTH(input_device_events),
+ input_device_events,
};
static void wl_input_device_data(int fd, uint32_t mask, void *data)
wl_client_destroy(struct wl_client *client);
static void
-wl_client_marshal(struct wl_client *client, struct wl_object *sender,
- uint32_t opcode, ...)
+wl_client_vmarshal(struct wl_client *client, struct wl_object *sender,
+ uint32_t opcode, va_list ap)
{
const struct wl_event *event;
struct wl_object *object;
uint32_t args[10], size;
- va_list ap;
int i, count;
event = &sender->interface->events[opcode];
assert(count <= ARRAY_LENGTH(args));
size = 0;
- va_start(ap, opcode);
for (i = 2; i < count; i++) {
switch (event->signature[i - 2]) {
case 'u':
break;
}
}
- va_end(ap);
size += 2 * sizeof args[0];
args[0] = sender->id;
}
static void
+wl_client_marshal(struct wl_client *client, struct wl_object *sender,
+ uint32_t opcode, ...)
+{
+ va_list ap;
+
+ va_start(ap, opcode);
+ wl_client_vmarshal(client, sender, opcode, ap);
+ va_end(ap);
+}
+
+static void
wl_client_demarshal(struct wl_client *client, struct wl_object *target,
const struct wl_method *method, size_t size)
{
}
}
-#define WL_INPUT_MOTION 0
-#define WL_INPUT_BUTTON 1
-#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)
+wl_surface_post_event(struct wl_surface *surface,
+ struct wl_object *sender,
+ uint32_t event, ...)
{
- 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;
+ va_list ap;
- wl_connection_write(surface->client->connection, p, sizeof p);
+ va_start(ap, event);
+ wl_client_vmarshal(surface->client, sender, event, ap);
+ va_end(ap);
}
WL_EXPORT void
struct wl_object *source, int button, int state)
{
const struct wl_compositor_interface *interface;
- uint32_t p[4];
interface = display->compositor->interface;
interface->notify_pointer_button(display->compositor, source,
button, state);
-
- p[0] = source->id;
- p[1] = (sizeof p << 16) | WL_INPUT_BUTTON;
- p[2] = button;
- p[3] = state;
-
- 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);
+
+#define WL_INPUT_MOTION 0
+#define WL_INPUT_BUTTON 1
+#define WL_INPUT_KEY 2
+
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);
+wl_surface_post_event(struct wl_surface *surface,
+ struct wl_object *sender,
+ uint32_t event, ...);
struct wl_compositor {
const struct wl_compositor_interface *interface;