Feed button events through compositor.

This also generalizes the code to send events to a surface a bit.
dev
Kristian Høgsberg 16 years ago
parent 715a081cf4
commit 5a75c90d01
  1. 8
      egl-compositor.c
  2. 8
      evdev.c
  3. 50
      wayland.c
  4. 12
      wayland.h

@ -758,8 +758,8 @@ notify_pointer_motion(struct wl_compositor *compositor,
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;
@ -784,6 +784,10 @@ notify_pointer_button(struct wl_compositor *compositor,
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);

@ -42,10 +42,18 @@ struct wl_input_device {
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)

@ -212,13 +212,12 @@ void
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];
@ -226,7 +225,6 @@ wl_client_marshal(struct wl_client *client, struct wl_object *sender,
assert(count <= ARRAY_LENGTH(args));
size = 0;
va_start(ap, opcode);
for (i = 2; i < count; i++) {
switch (event->signature[i - 2]) {
case 'u':
@ -249,7 +247,6 @@ wl_client_marshal(struct wl_client *client, struct wl_object *sender,
break;
}
}
va_end(ap);
size += 2 * sizeof args[0];
args[0] = sender->id;
@ -257,6 +254,17 @@ wl_client_marshal(struct wl_client *client, struct wl_object *sender,
wl_connection_write(client->connection, args, size);
}
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)
@ -628,26 +636,16 @@ wl_display_send_event(struct wl_display *display, uint32_t *data, 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
@ -683,18 +681,10 @@ wl_display_post_button_event(struct wl_display *display,
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

@ -135,11 +135,15 @@ wl_display_post_key_event(struct wl_display *display,
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;

Loading…
Cancel
Save