void tag_send_screen(struct tag * tag, struct wl_client * client, struct wl_resource * tag_resource, struct wl_resource * screen_resource) { if (!tag_resource) tag_resource = wl_resource_find_for_client(&tag->resources, client); if (!screen_resource) { screen_resource = tag->screen ? wl_resource_find_for_client(&tag->screen->resources, client) : NULL; } velox_tag_send_screen(tag_resource, screen_resource); }
WL_EXPORT void wl_data_device_set_keyboard_focus(struct weston_seat *seat) { struct wl_resource *data_device, *offer; struct weston_data_source *source; struct weston_surface *focus; if (!seat->keyboard) return; focus = seat->keyboard->focus; if (!focus || !focus->resource) return; data_device = wl_resource_find_for_client(&seat->drag_resource_list, wl_resource_get_client(focus->resource)); if (!data_device) return; source = seat->selection_data_source; if (source) { offer = weston_data_source_send_offer(source, data_device); wl_data_device_send_selection(data_device, offer); } }
static void drag_grab_focus (MetaWaylandPointerGrab *grab, MetaWaylandSurface *surface) { MetaWaylandDragGrab *drag_grab = (MetaWaylandDragGrab*) grab; MetaWaylandSeat *seat = drag_grab->seat; struct wl_client *client; struct wl_resource *data_device_resource, *offer = NULL; struct wl_display *display; guint32 serial; wl_fixed_t sx, sy; if (drag_grab->drag_focus == surface) return; if (drag_grab->drag_focus_data_device) { wl_data_device_send_leave (drag_grab->drag_focus_data_device); wl_list_remove (&drag_grab->drag_focus_listener.link); drag_grab->drag_focus_data_device = NULL; drag_grab->drag_focus = NULL; } if (!surface) return; if (!drag_grab->drag_data_source && wl_resource_get_client (surface->resource) != drag_grab->drag_client) return; client = wl_resource_get_client (surface->resource); data_device_resource = wl_resource_find_for_client (&seat->data_device.resource_list, client); if (!data_device_resource) return; display = wl_client_get_display (client); serial = wl_display_next_serial (display); if (drag_grab->drag_data_source) offer = meta_wayland_data_source_send_offer (drag_grab->drag_data_source, data_device_resource); meta_wayland_pointer_get_relative_coordinates (grab->pointer, surface, &sx, &sy); wl_data_device_send_enter (data_device_resource, serial, surface->resource, sx, sy, offer); drag_grab->drag_focus = surface; drag_grab->drag_focus_data_device = data_device_resource; drag_grab->drag_focus_listener.notify = destroy_drag_focus; wl_resource_add_destroy_listener (data_device_resource, &drag_grab->drag_focus_listener); }
static void weston_drag_set_focus(struct weston_drag *drag, struct weston_seat *seat, struct weston_view *view, wl_fixed_t sx, wl_fixed_t sy) { struct wl_resource *resource, *offer = NULL; struct wl_display *display = seat->compositor->wl_display; uint32_t serial; if (drag->focus && view && drag->focus->surface == view->surface) { drag->focus = view; return; } if (drag->focus_resource) { wl_data_device_send_leave(drag->focus_resource); wl_list_remove(&drag->focus_listener.link); drag->focus_resource = NULL; drag->focus = NULL; } if (!view || !view->surface->resource) return; if (!drag->data_source && wl_resource_get_client(view->surface->resource) != drag->client) return; resource = wl_resource_find_for_client(&seat->drag_resource_list, wl_resource_get_client(view->surface->resource)); if (!resource) return; serial = wl_display_next_serial(display); if (drag->data_source) { offer = weston_data_source_send_offer(drag->data_source, resource); if (offer == NULL) return; } wl_data_device_send_enter(resource, serial, view->surface->resource, sx, sy, offer); drag->focus = view; drag->focus_listener.notify = destroy_drag_focus; wl_resource_add_destroy_listener(resource, &drag->focus_listener); drag->focus_resource = resource; }
static void meta_wayland_data_device_set_selection (MetaWaylandDataDevice *data_device, MetaWaylandDataSource *source, guint32 serial) { MetaWaylandSeat *seat = wl_container_of (data_device, seat, data_device); struct wl_resource *data_device_resource, *offer; struct wl_client *focus_client; if (data_device->selection_data_source && data_device->selection_serial - serial < UINT32_MAX / 2) return; if (data_device->selection_data_source) { wl_data_source_send_cancelled (data_device->selection_data_source->resource); wl_list_remove (&data_device->selection_data_source_listener.link); data_device->selection_data_source = NULL; } data_device->selection_data_source = source; data_device->selection_serial = serial; focus_client = meta_wayland_keyboard_get_focus_client (&seat->keyboard); if (focus_client) { data_device_resource = wl_resource_find_for_client (&data_device->resource_list, focus_client); if (data_device_resource) { if (data_device->selection_data_source) { offer = meta_wayland_data_source_send_offer (data_device->selection_data_source, data_device_resource); wl_data_device_send_selection (data_device_resource, offer); } else { wl_data_device_send_selection (data_device_resource, NULL); } } } if (source) { data_device->selection_data_source_listener.notify = destroy_selection_data_source; wl_resource_add_destroy_listener (source->resource, &data_device->selection_data_source_listener); } }
static void destroy_selection_data_source (struct wl_listener *listener, void *data) { MetaWaylandDataDevice *data_device = wl_container_of (listener, data_device, selection_data_source_listener); MetaWaylandSeat *seat = wl_container_of (data_device, seat, data_device); struct wl_resource *data_device_resource; struct wl_client *focus_client = NULL; data_device->selection_data_source = NULL; focus_client = meta_wayland_keyboard_get_focus_client (&seat->keyboard); if (focus_client) { data_device_resource = wl_resource_find_for_client (&data_device->resource_list, focus_client); if (data_device_resource) wl_data_device_send_selection (data_device_resource, NULL); } }
void data_device_offer_selection(struct data_device * data_device, struct wl_client * client) { struct wl_resource * resource; struct wl_resource * offer; /* Look for the client's data_device resource. */ resource = wl_resource_find_for_client(&data_device->resources, client); /* If the client does not have a data device, there is nothing to do. */ if (!resource) return; /* If we don't have a selection, send NULL to the client. */ offer = data_device->selection ? new_offer(resource, client, data_device->selection) : NULL; wl_data_device_send_selection(resource, offer); }
WL_EXPORT void weston_seat_set_selection(struct weston_seat *seat, struct weston_data_source *source, uint32_t serial) { struct wl_resource *data_device, *offer; struct weston_surface *focus = NULL; if (seat->selection_data_source && seat->selection_serial - serial < UINT32_MAX / 2) return; if (seat->selection_data_source) { seat->selection_data_source->cancel(seat->selection_data_source); wl_list_remove(&seat->selection_data_source_listener.link); seat->selection_data_source = NULL; } seat->selection_data_source = source; seat->selection_serial = serial; if (seat->keyboard) focus = seat->keyboard->focus; if (focus && focus->resource) { data_device = wl_resource_find_for_client(&seat->drag_resource_list, wl_resource_get_client(focus->resource)); if (data_device && source) { offer = weston_data_source_send_offer(seat->selection_data_source, data_device); wl_data_device_send_selection(data_device, offer); } else if (data_device) { wl_data_device_send_selection(data_device, NULL); } } wl_signal_emit(&seat->selection_signal, seat); if (source) { seat->selection_data_source_listener.notify = destroy_selection_data_source; wl_signal_add(&source->destroy_signal, &seat->selection_data_source_listener); } }
static void destroy_selection_data_source(struct wl_listener *listener, void *data) { struct weston_seat *seat = container_of(listener, struct weston_seat, selection_data_source_listener); struct wl_resource *data_device; struct weston_surface *focus = NULL; seat->selection_data_source = NULL; if (seat->keyboard) focus = seat->keyboard->focus; if (focus && focus->resource) { data_device = wl_resource_find_for_client(&seat->drag_resource_list, wl_resource_get_client(focus->resource)); if (data_device) wl_data_device_send_selection(data_device, NULL); } wl_signal_emit(&seat->selection_signal, seat); }
void meta_wayland_data_device_set_keyboard_focus (MetaWaylandDataDevice *data_device) { MetaWaylandSeat *seat = wl_container_of (data_device, seat, data_device); struct wl_client *focus_client; struct wl_resource *data_device_resource, *offer; MetaWaylandDataSource *source; focus_client = meta_wayland_keyboard_get_focus_client (&seat->keyboard); if (!focus_client) return; data_device_resource = wl_resource_find_for_client (&data_device->resource_list, focus_client); if (!data_device_resource) return; source = data_device->selection_data_source; if (source) { offer = meta_wayland_data_source_send_offer (source, data_device_resource); wl_data_device_send_selection (data_device_resource, offer); } }