Use typesafe server-side stubs

This commit is contained in:
Kristian Høgsberg 2012-03-04 21:57:37 -05:00
parent b41c0810ea
commit 0b5cd0cb4c
4 changed files with 56 additions and 76 deletions

View File

@ -965,7 +965,7 @@ weston_output_repaint(struct weston_output *output, int msecs)
output->repaint_needed = 0; output->repaint_needed = 0;
wl_list_for_each_safe(cb, cnext, &output->frame_callback_list, link) { wl_list_for_each_safe(cb, cnext, &output->frame_callback_list, link) {
wl_resource_post_event(&cb->resource, WL_CALLBACK_DONE, msecs); wl_callback_send_done(&cb->resource, msecs);
wl_resource_destroy(&cb->resource, 0); wl_resource_destroy(&cb->resource, 0);
} }
@ -1765,10 +1765,9 @@ notify_touch(struct wl_input_device *device, uint32_t time, int touch_id,
} }
if (wd->touch_focus_resource && wd->touch_focus) if (wd->touch_focus_resource && wd->touch_focus)
wl_resource_post_event(wd->touch_focus_resource, wl_input_device_send_touch_down(wd->touch_focus_resource,
touch_type, time, time, &wd->touch_focus->resource,
wd->touch_focus, touch_id, sx, sy);
touch_id, sx, sy);
break; break;
case WL_INPUT_DEVICE_TOUCH_MOTION: case WL_INPUT_DEVICE_TOUCH_MOTION:
es = (struct weston_surface *) wd->touch_focus; es = (struct weston_surface *) wd->touch_focus;
@ -1777,17 +1776,16 @@ notify_touch(struct wl_input_device *device, uint32_t time, int touch_id,
weston_surface_from_global(es, x, y, &sx, &sy); weston_surface_from_global(es, x, y, &sx, &sy);
if (wd->touch_focus_resource) if (wd->touch_focus_resource)
wl_resource_post_event(wd->touch_focus_resource, wl_input_device_send_touch_motion(wd->touch_focus_resource,
touch_type, time, time, touch_id, sx, sy);
touch_id, sx, sy);
break; break;
case WL_INPUT_DEVICE_TOUCH_UP: case WL_INPUT_DEVICE_TOUCH_UP:
weston_compositor_idle_release(ec); weston_compositor_idle_release(ec);
wd->num_tp--; wd->num_tp--;
if (wd->touch_focus_resource) if (wd->touch_focus_resource)
wl_resource_post_event(wd->touch_focus_resource, wl_input_device_send_touch_up(wd->touch_focus_resource,
touch_type, time, touch_id); time, touch_id);
if (wd->num_tp == 0) if (wd->num_tp == 0)
touch_set_focus(wd, NULL, time); touch_set_focus(wd, NULL, time);
break; break;
@ -2004,22 +2002,20 @@ bind_output(struct wl_client *client,
resource = wl_client_add_object(client, resource = wl_client_add_object(client,
&wl_output_interface, NULL, id, data); &wl_output_interface, NULL, id, data);
wl_resource_post_event(resource, wl_output_send_geometry(resource,
WL_OUTPUT_GEOMETRY, output->x,
output->x, output->y,
output->y, output->mm_width,
output->mm_width, output->mm_height,
output->mm_height, output->subpixel,
output->subpixel, output->make, output->model);
output->make, output->model);
wl_list_for_each (mode, &output->mode_list, link) { wl_list_for_each (mode, &output->mode_list, link) {
wl_resource_post_event(resource, wl_output_send_mode(resource,
WL_OUTPUT_MODE, mode->flags,
mode->flags, mode->width,
mode->width, mode->height,
mode->height, mode->refresh);
mode->refresh);
} }
} }

View File

@ -292,9 +292,8 @@ resize_grab_motion(struct wl_pointer_grab *grab,
height = resize->height; height = resize->height;
} }
wl_resource_post_event(&resize->shsurf->resource, wl_shell_surface_send_configure(&resize->shsurf->resource,
WL_SHELL_SURFACE_CONFIGURE, time, resize->edges, time, resize->edges, width, height);
width, height);
} }
static void static void
@ -513,11 +512,11 @@ shell_surface_set_maximized(struct wl_client *client,
wlshell = shell_surface_get_shell(shsurf); wlshell = shell_surface_get_shell(shsurf);
panel_height = get_output_panel_height(wlshell, es->output); panel_height = get_output_panel_height(wlshell, es->output);
edges = WL_SHELL_SURFACE_RESIZE_TOP|WL_SHELL_SURFACE_RESIZE_LEFT; edges = WL_SHELL_SURFACE_RESIZE_TOP|WL_SHELL_SURFACE_RESIZE_LEFT;
wl_resource_post_event(&shsurf->resource,
WL_SHELL_SURFACE_CONFIGURE, wl_shell_surface_send_configure(&shsurf->resource,
weston_compositor_get_time(), edges, weston_compositor_get_time(), edges,
es->output->current->width, es->output->current->width,
es->output->current->height - panel_height); es->output->current->height - panel_height);
shsurf->type = SHELL_SURFACE_MAXIMIZED; shsurf->type = SHELL_SURFACE_MAXIMIZED;
} }
@ -641,11 +640,10 @@ shell_surface_set_fullscreen(struct wl_client *client,
if (es->output) if (es->output)
shsurf->surface->force_configure = 1; shsurf->surface->force_configure = 1;
wl_resource_post_event(resource, wl_shell_surface_send_configure(&shsurf->resource,
WL_SHELL_SURFACE_CONFIGURE, weston_compositor_get_time(), 0,
weston_compositor_get_time(), 0, shsurf->output->current->width,
shsurf->output->current->width, shsurf->output->current->height);
shsurf->output->current->height);
} }
static void static void
@ -674,8 +672,7 @@ popup_grab_motion(struct wl_pointer_grab *grab,
resource = grab->input_device->pointer_focus_resource; resource = grab->input_device->pointer_focus_resource;
if (resource) if (resource)
wl_resource_post_event(resource, WL_INPUT_DEVICE_MOTION, wl_input_device_send_motion(resource, time, sx, sy);
time, sx, sy);
} }
static void static void
@ -688,13 +685,11 @@ popup_grab_button(struct wl_pointer_grab *grab,
resource = grab->input_device->pointer_focus_resource; resource = grab->input_device->pointer_focus_resource;
if (resource) { if (resource) {
wl_resource_post_event(resource, WL_INPUT_DEVICE_BUTTON, wl_input_device_send_button(resource, time, button, state);
time, button, state);
} else if (state == 0 && } else if (state == 0 &&
(shsurf->popup.initial_up || (shsurf->popup.initial_up ||
time - shsurf->popup.time > 500)) { time - shsurf->popup.time > 500)) {
wl_resource_post_event(&shsurf->resource, wl_shell_surface_send_popup_done(&shsurf->resource);
WL_SHELL_SURFACE_POPUP_DONE);
wl_input_device_end_pointer_grab(grab->input_device, time); wl_input_device_end_pointer_grab(grab->input_device, time);
shsurf->popup.grab.input_device = NULL; shsurf->popup.grab.input_device = NULL;
} }
@ -962,11 +957,11 @@ desktop_shell_set_background(struct wl_client *client,
weston_surface_set_position(surface, shsurf->output->x, weston_surface_set_position(surface, shsurf->output->x,
shsurf->output->y); shsurf->output->y);
wl_resource_post_event(resource, desktop_shell_send_configure(resource,
DESKTOP_SHELL_CONFIGURE, weston_compositor_get_time(), 0,
weston_compositor_get_time(), 0, surface_resource, surface_resource,
shsurf->output->current->width, shsurf->output->current->width,
shsurf->output->current->height); shsurf->output->current->height);
} }
static void static void
@ -1000,11 +995,11 @@ desktop_shell_set_panel(struct wl_client *client,
weston_surface_set_position(surface, shsurf->output->x, weston_surface_set_position(surface, shsurf->output->x,
shsurf->output->y); shsurf->output->y);
wl_resource_post_event(resource, desktop_shell_send_configure(resource,
DESKTOP_SHELL_CONFIGURE, weston_compositor_get_time(), 0,
weston_compositor_get_time(), 0, surface_resource, surface_resource,
shsurf->output->current->width, shsurf->output->current->width,
shsurf->output->current->height); shsurf->output->current->height);
} }
static void static void
@ -1505,8 +1500,7 @@ unlock(struct weston_shell *base)
if (shell->prepare_event_sent) if (shell->prepare_event_sent)
return; return;
wl_resource_post_event(shell->child.desktop_shell, desktop_shell_send_prepare_lock_surface(shell->child.desktop_shell);
DESKTOP_SHELL_PREPARE_LOCK_SURFACE);
shell->prepare_event_sent = true; shell->prepare_event_sent = true;
} }

View File

@ -120,8 +120,7 @@ tablet_shell_map(struct weston_shell *base, struct weston_surface *surface,
if (shell->state == STATE_STARTING) { if (shell->state == STATE_STARTING) {
tablet_shell_set_state(shell, STATE_LOCKED); tablet_shell_set_state(shell, STATE_LOCKED);
shell->previous_state = STATE_HOME; shell->previous_state = STATE_HOME;
wl_resource_post_event(&shell->resource, tablet_shell_send_show_lockscreen(&shell->resource);
TABLET_SHELL_SHOW_LOCKSCREEN);
} }
} else if (shell->current_client && } else if (shell->current_client &&
shell->current_client->surface != surface && shell->current_client->surface != surface &&
@ -373,12 +372,10 @@ toggle_switcher(struct tablet_shell *shell)
{ {
switch (shell->state) { switch (shell->state) {
case STATE_SWITCHER: case STATE_SWITCHER:
wl_resource_post_event(&shell->resource, tablet_shell_send_hide_switcher(&shell->resource);
TABLET_SHELL_HIDE_SWITCHER);
break; break;
default: default:
wl_resource_post_event(&shell->resource, tablet_shell_send_show_switcher(&shell->resource);
TABLET_SHELL_SHOW_SWITCHER);
tablet_shell_set_state(shell, STATE_SWITCHER); tablet_shell_set_state(shell, STATE_SWITCHER);
break; break;
} }
@ -393,12 +390,9 @@ tablet_shell_lock(struct weston_shell *base)
if (shell->state == STATE_LOCKED) if (shell->state == STATE_LOCKED)
return; return;
if (shell->state == STATE_SWITCHER) if (shell->state == STATE_SWITCHER)
wl_resource_post_event(&shell->resource, tablet_shell_send_hide_switcher(&shell->resource);
TABLET_SHELL_HIDE_SWITCHER);
wl_resource_post_event(&shell->resource, tablet_shell_send_show_lockscreen(&shell->resource);
TABLET_SHELL_SHOW_LOCKSCREEN);
tablet_shell_set_state(shell, STATE_LOCKED); tablet_shell_set_state(shell, STATE_LOCKED);
} }
@ -418,8 +412,7 @@ go_home(struct tablet_shell *shell)
(struct weston_input_device *) shell->compositor->input_device; (struct weston_input_device *) shell->compositor->input_device;
if (shell->state == STATE_SWITCHER) if (shell->state == STATE_SWITCHER)
wl_resource_post_event(&shell->resource, tablet_shell_send_hide_switcher(&shell->resource);
TABLET_SHELL_HIDE_SWITCHER);
weston_surface_activate(shell->home_surface, device, weston_surface_activate(shell->home_surface, device,
weston_compositor_get_time()); weston_compositor_get_time());

View File

@ -856,8 +856,8 @@ weston_wm_send_data(struct weston_wm *wm, xcb_atom_t target, const char *mime_ty
weston_wm_read_data_source, weston_wm_read_data_source,
wm); wm);
wl_resource_post_event(&device->selection_data_source->resource, wl_data_source_send_send(&device->selection_data_source->resource,
WL_DATA_SOURCE_SEND, mime_type, p[1]); mime_type, p[1]);
close(p[1]); close(p[1]);
} }
@ -1277,7 +1277,7 @@ weston_wm_create(struct weston_xserver *wxs)
return NULL; return NULL;
} }
wl_resource_post_event(wxs->resource, XSERVER_CLIENT, sv[1]); xserver_send_client(wxs->resource, sv[1]);
wl_client_flush(wxs->resource->client); wl_client_flush(wxs->resource->client);
close(sv[1]); close(sv[1]);
@ -1556,11 +1556,8 @@ bind_xserver(struct wl_client *client,
fprintf(stderr, "failed to create wm\n"); fprintf(stderr, "failed to create wm\n");
} }
wl_resource_post_event(wxs->resource, xserver_send_listen_socket(wxs->resource, wxs->abstract_fd);
XSERVER_LISTEN_SOCKET, wxs->abstract_fd); xserver_send_listen_socket(wxs->resource, wxs->unix_fd);
wl_resource_post_event(wxs->resource,
XSERVER_LISTEN_SOCKET, wxs->unix_fd);
} }
static int static int