Drop wl_surface_post_event() helper

Now wl_client_post_event() is the only entry point for sending out events.
This commit is contained in:
Kristian Høgsberg 2010-09-07 21:08:59 -04:00
parent 7cd36185d7
commit 50038e4757
3 changed files with 61 additions and 75 deletions

View File

@ -665,13 +665,13 @@ wlsc_input_device_set_keyboard_focus(struct wlsc_input_device *device,
if (device->keyboard_focus && if (device->keyboard_focus &&
(!surface || device->keyboard_focus->base.client != surface->base.client)) (!surface || device->keyboard_focus->base.client != surface->base.client))
wl_surface_post_event(&device->keyboard_focus->base, wl_client_post_event(device->keyboard_focus->base.client,
&device->base.base, &device->base.base,
WL_INPUT_DEVICE_KEYBOARD_FOCUS, WL_INPUT_DEVICE_KEYBOARD_FOCUS,
time, NULL, &device->keys); time, NULL, &device->keys);
if (surface) if (surface)
wl_surface_post_event(&surface->base, wl_client_post_event(surface->base.client,
&device->base.base, &device->base.base,
WL_INPUT_DEVICE_KEYBOARD_FOCUS, WL_INPUT_DEVICE_KEYBOARD_FOCUS,
time, &surface->base, &device->keys); time, &surface->base, &device->keys);
@ -691,12 +691,12 @@ wlsc_input_device_set_pointer_focus(struct wlsc_input_device *device,
if (device->pointer_focus && if (device->pointer_focus &&
(!surface || device->pointer_focus->base.client != surface->base.client)) (!surface || device->pointer_focus->base.client != surface->base.client))
wl_surface_post_event(&device->pointer_focus->base, wl_client_post_event(device->pointer_focus->base.client,
&device->base.base, &device->base.base,
WL_INPUT_DEVICE_POINTER_FOCUS, WL_INPUT_DEVICE_POINTER_FOCUS,
time, NULL, 0, 0, 0, 0); time, NULL, 0, 0, 0, 0);
if (surface) if (surface)
wl_surface_post_event(&surface->base, wl_client_post_event(surface->base.client,
&device->base.base, &device->base.base,
WL_INPUT_DEVICE_POINTER_FOCUS, WL_INPUT_DEVICE_POINTER_FOCUS,
time, &surface->base, time, &surface->base,
@ -758,7 +758,8 @@ notify_motion(struct wlsc_input_device *device, uint32_t time, int x, int y)
wlsc_input_device_set_pointer_focus(device, es, wlsc_input_device_set_pointer_focus(device, es,
time, x, y, sx, sy); time, x, y, sx, sy);
if (es) if (es)
wl_surface_post_event(&es->base, &device->base.base, wl_client_post_event(es->base.client,
&device->base.base,
WL_INPUT_DEVICE_MOTION, WL_INPUT_DEVICE_MOTION,
time, x, y, sx, sy); time, x, y, sx, sy);
break; break;
@ -766,7 +767,8 @@ notify_motion(struct wlsc_input_device *device, uint32_t time, int x, int y)
case WLSC_DEVICE_GRAB_MOTION: case WLSC_DEVICE_GRAB_MOTION:
es = device->pointer_focus; es = device->pointer_focus;
wlsc_surface_transform(es, x, y, &sx, &sy); wlsc_surface_transform(es, x, y, &sx, &sy);
wl_surface_post_event(&es->base, &device->base.base, wl_client_post_event(es->base.client,
&device->base.base,
WL_INPUT_DEVICE_MOTION, WL_INPUT_DEVICE_MOTION,
time, x, y, sx, sy); time, x, y, sx, sy);
break; break;
@ -775,7 +777,8 @@ notify_motion(struct wlsc_input_device *device, uint32_t time, int x, int y)
es = device->grab_surface; es = device->grab_surface;
es->x = x + device->grab_dx; es->x = x + device->grab_dx;
es->y = y + device->grab_dy;; es->y = y + device->grab_dy;;
wl_surface_post_event(&es->base, &ec->shell.base, wl_client_post_event(es->base.client,
&ec->shell.base,
WL_SHELL_CONFIGURE, WL_SHELL_CONFIGURE,
time, device->grab, time, device->grab,
&es->base, es->x, es->y, &es->base, es->x, es->y,
@ -818,7 +821,8 @@ notify_motion(struct wlsc_input_device *device, uint32_t time, int x, int y)
height = device->grab_height; height = device->grab_height;
} }
wl_surface_post_event(&es->base, &ec->shell.base, wl_client_post_event(es->base.client,
&ec->shell.base,
WL_SHELL_CONFIGURE, time, device->grab, WL_SHELL_CONFIGURE, time, device->grab,
&es->base, sx, sy, width, height); &es->base, sx, sy, width, height);
break; break;
@ -828,7 +832,7 @@ notify_motion(struct wlsc_input_device *device, uint32_t time, int x, int y)
wl_drag_set_pointer_focus(device->drag, wl_drag_set_pointer_focus(device->drag,
es, time, x, y, sx, sy); es, time, x, y, sx, sy);
if (es) if (es)
wl_surface_post_event(&es->base, wl_client_post_event(es->base.client,
&device->drag->drag_offer.base, &device->drag->drag_offer.base,
WL_DRAG_OFFER_MOTION, WL_DRAG_OFFER_MOTION,
time, x, y, sx, sy); time, x, y, sx, sy);
@ -903,7 +907,7 @@ notify_button(struct wlsc_input_device *device,
WLSC_DEVICE_GRAB_RESIZE_BOTTOM_RIGHT); WLSC_DEVICE_GRAB_RESIZE_BOTTOM_RIGHT);
else if (device->grab == WLSC_DEVICE_GRAB_NONE || else if (device->grab == WLSC_DEVICE_GRAB_NONE ||
device->grab == WLSC_DEVICE_GRAB_MOTION) device->grab == WLSC_DEVICE_GRAB_MOTION)
wl_surface_post_event(&surface->base, wl_client_post_event(surface->base.client,
&device->base.base, &device->base.base,
WL_INPUT_DEVICE_BUTTON, WL_INPUT_DEVICE_BUTTON,
time, button, state); time, button, state);
@ -969,7 +973,7 @@ notify_key(struct wlsc_input_device *device,
} }
if (device->keyboard_focus != NULL) if (device->keyboard_focus != NULL)
wl_surface_post_event(&device->keyboard_focus->base, wl_client_post_event(device->keyboard_focus->base.client,
&device->base.base, &device->base.base,
WL_INPUT_DEVICE_KEY, time, key, state); WL_INPUT_DEVICE_KEY, time, key, state);
} }
@ -1041,7 +1045,7 @@ wl_drag_set_pointer_focus(struct wl_drag *drag,
if (drag->pointer_focus && if (drag->pointer_focus &&
(!surface || drag->pointer_focus->client != surface->base.client)) (!surface || drag->pointer_focus->client != surface->base.client))
wl_surface_post_event(drag->pointer_focus, wl_client_post_event(drag->pointer_focus->client,
&drag->drag_offer.base, &drag->drag_offer.base,
WL_DRAG_OFFER_POINTER_FOCUS, WL_DRAG_OFFER_POINTER_FOCUS,
time, NULL, 0, 0, 0, 0); time, NULL, 0, 0, 0, 0);
@ -1054,13 +1058,13 @@ wl_drag_set_pointer_focus(struct wl_drag *drag,
end = drag->types.data + drag->types.size; end = drag->types.data + drag->types.size;
for (p = drag->types.data; p < end; p++) for (p = drag->types.data; p < end; p++)
wl_surface_post_event(&surface->base, wl_client_post_event(surface->base.client,
&drag->drag_offer.base, &drag->drag_offer.base,
WL_DRAG_OFFER_OFFER, *p); WL_DRAG_OFFER_OFFER, *p);
} }
if (surface) { if (surface) {
wl_surface_post_event(&surface->base, wl_client_post_event(surface->base.client,
&drag->drag_offer.base, &drag->drag_offer.base,
WL_DRAG_OFFER_POINTER_FOCUS, WL_DRAG_OFFER_POINTER_FOCUS,
time, &surface->base, time, &surface->base,
@ -1095,7 +1099,7 @@ drag_offer_accept(struct wl_client *client,
if (type && strcmp(*p, type) == 0) if (type && strcmp(*p, type) == 0)
drag->type = *p; drag->type = *p;
wl_surface_post_event(drag->source, &drag->resource.base, wl_client_post_event(drag->source->client, &drag->resource.base,
WL_DRAG_TARGET, drag->type); WL_DRAG_TARGET, drag->type);
} }
@ -1105,7 +1109,7 @@ drag_offer_receive(struct wl_client *client,
{ {
struct wl_drag *drag = container_of(offer, struct wl_drag, drag_offer); struct wl_drag *drag = container_of(offer, struct wl_drag, drag_offer);
wl_surface_post_event(drag->source, &drag->resource.base, wl_client_post_event(drag->source->client, &drag->resource.base,
WL_DRAG_FINISH, fd); WL_DRAG_FINISH, fd);
close(fd); close(fd);
} }

View File

@ -81,6 +81,10 @@ wl_client_post_event(struct wl_client *client, struct wl_object *sender,
{ {
va_list ap; va_list ap;
if (client == NULL)
/* wl_grab_surface case */
return;
va_start(ap, opcode); va_start(ap, opcode);
wl_connection_vmarshal(client->connection, wl_connection_vmarshal(client->connection,
sender, opcode, ap, sender, opcode, ap,
@ -401,23 +405,6 @@ wl_display_add_global(struct wl_display *display,
return 0; return 0;
} }
WL_EXPORT void
wl_surface_post_event(struct wl_surface *surface,
struct wl_object *sender,
uint32_t event, ...)
{
va_list ap;
if (surface == &wl_grab_surface)
return;
va_start(ap, event);
wl_connection_vmarshal(surface->client->connection,
sender, event, ap,
&sender->interface->events[event]);
va_end(ap);
}
WL_EXPORT void WL_EXPORT void
wl_display_post_frame(struct wl_display *display, uint32_t time) wl_display_post_frame(struct wl_display *display, uint32_t time)
{ {

View File

@ -148,11 +148,6 @@ wl_client_post_event(struct wl_client *client,
struct wl_object *sender, struct wl_object *sender,
uint32_t event, ...); uint32_t event, ...);
void
wl_surface_post_event(struct wl_surface *surface,
struct wl_object *sender,
uint32_t event, ...);
int int
wl_display_set_compositor(struct wl_display *display, wl_display_set_compositor(struct wl_display *display,
struct wl_compositor *compositor, struct wl_compositor *compositor,