XdgBaseSurface::~XdgBaseSurface() { if (m_resource && wl_resource_get_client(m_resource)) { wl_resource_set_destructor(m_resource, nullptr); wl_resource_destroy(m_resource); } }
static void pointer_set_cursor (struct wl_client *client, struct wl_resource *resource, uint32_t serial, struct wl_resource *surface_resource, int32_t x, int32_t y) { ClaylandSeat *seat = wl_resource_get_user_data (resource); ClaylandSurface *surface; surface = (surface_resource ? wl_resource_get_user_data (surface_resource) : NULL); if (seat->pointer.focus == NULL) return; if (wl_resource_get_client (seat->pointer.focus->resource) != client) return; if (seat->pointer.focus_serial - serial > G_MAXUINT32 / 2) return; pointer_unmap_sprite (seat); if (!surface) return; wl_resource_add_destroy_listener (surface->resource, &seat->sprite_destroy_listener); seat->sprite = surface; seat->hotspot_x = x; seat->hotspot_y = y; }
static void seat_get_keyboard (struct wl_client *client, struct wl_resource *resource, uint32_t id) { ClaylandSeat *seat = wl_resource_get_user_data (resource); struct wl_resource *cr; cr = wl_client_add_object (client, &wl_keyboard_interface, NULL, id, seat); wl_list_insert (&seat->keyboard.resource_list, wl_resource_get_link (cr)); wl_resource_set_destructor (cr, unbind_resource); wl_keyboard_send_keymap (cr, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, seat->keyboard.xkb_info.keymap_fd, seat->keyboard.xkb_info.keymap_size); if (seat->keyboard.focus && wl_resource_get_client (seat->keyboard.focus->resource) == client) { clayland_keyboard_set_focus (&seat->keyboard, seat->keyboard.focus); clayland_data_device_set_keyboard_focus (seat); } }
static void seat_get_pointer (struct wl_client *client, struct wl_resource *resource, uint32_t id) { ClaylandSeat *seat = wl_resource_get_user_data (resource); struct wl_resource *cr; cr = wl_client_add_object (client, &wl_pointer_interface, &pointer_interface, id, seat); wl_list_insert (&seat->pointer.resource_list, wl_resource_get_link (cr)); wl_resource_set_destructor (cr, unbind_resource); if (seat->pointer.focus && wl_resource_get_client (seat->pointer.focus->resource) == client) { ClaylandSurface *surface; wl_fixed_t sx, sy; surface = (ClaylandSurface *) seat->pointer.focus; transform_stage_point_fixed (surface, seat->pointer.x, seat->pointer.y, &sx, &sy); clayland_pointer_set_focus (&seat->pointer, seat->pointer.focus, sx, sy); } }
static struct wl_resource * weston_data_source_send_offer(struct weston_data_source *source, struct wl_resource *target) { struct weston_data_offer *offer; char **p; offer = malloc(sizeof *offer); if (offer == NULL) return NULL; offer->resource = wl_resource_create(wl_resource_get_client(target), &wl_data_offer_interface, 1, 0); if (offer->resource == NULL) { free(offer); return NULL; } wl_resource_set_implementation(offer->resource, &data_offer_interface, offer, destroy_data_offer); offer->source = source; offer->source_destroy_listener.notify = destroy_offer_data_source; wl_signal_add(&source->destroy_signal, &offer->source_destroy_listener); wl_data_device_send_data_offer(target, offer->resource); wl_array_for_each(p, &source->mime_types) wl_data_offer_send_offer(offer->resource, *p); return offer->resource; }
void XdgBaseSurface::ping(uint32_t serial) { if (!m_resource || !wl_resource_get_client(m_resource)) return; if (!m_pingTimer.isRunning()) { m_pingTimer.start(); m_pingSerial = serial; wl_shell_surface_send_ping(m_resource, serial); } }
void ClipboardManager::selection(Seat *seat) { auto selectionClient = seat->selectionClient(); for (wl_resource *r: m_resources) { auto client = wl_resource_get_client(r); // don't send the selection back to the clipboard client if (selectionClient != client) { seat->sendSelection(client); } } }
static void close(struct window * window) { struct shell_surface * shell_surface = wl_container_of(window, shell_surface, window); struct wl_client * client; pid_t pid; client = wl_resource_get_client(shell_surface->resource); wl_client_get_credentials(client, &pid, NULL, NULL); kill(pid, SIGTERM); }
static void move_resources_for_client(struct wl_list *destination, struct wl_list *source, struct wl_client *client) { struct wl_resource *resource, *tmp; wl_resource_for_each_safe(resource, tmp, source) { if (wl_resource_get_client(resource) == client) { wl_list_remove(wl_resource_get_link(resource)); wl_list_insert(destination, wl_resource_get_link(resource)); } } }
void tag_add(struct tag * tag, struct screen * screen) { struct wl_resource * resource; assert(tag->screen == NULL); /* Add the tag to the end of the tag list to minimize churn of the screen's * active tag, and to prefer recently released tags. */ wl_list_insert(screen ? screen->tags.prev : &velox.unused_tags, &tag->link); if (screen) { screen->mask |= tag->mask; tag->screen = screen; } wl_resource_for_each(resource, &tag->resources) tag_send_screen(tag, wl_resource_get_client(resource), resource, NULL); }
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); } }
/** Resolve an internal compositor error by disconnecting the client. * * This function is used in cases when the dmabuf-based wl_buffer * turns out unusable and there is no fallback path. This is used by * renderers which are the fallback path in the first place. * * It is possible the fault is caused by a compositor bug, the underlying * graphics stack bug or normal behaviour, or perhaps a client mistake. * In any case, the options are to either composite garbage or nothing, * or disconnect the client. This is a helper function for the latter. * * The error is sent as a INVALID_OBJECT error on the client's wl_display. * * \param buffer The linux_dmabuf_buffer that is unusable. * \param msg A custom error message attached to the protocol error. */ WL_EXPORT void linux_dmabuf_buffer_send_server_error(struct linux_dmabuf_buffer *buffer, const char *msg) { struct wl_client *client; struct wl_resource *display_resource; uint32_t id; assert(buffer->buffer_resource); id = wl_resource_get_id(buffer->buffer_resource); client = wl_resource_get_client(buffer->buffer_resource); display_resource = wl_client_get_object(client, 1); assert(display_resource); wl_resource_post_error(display_resource, WL_DISPLAY_ERROR_INVALID_OBJECT, "linux_dmabuf server error with " "wl_buffer@%u: %s", id, msg); }
static void weston_desktop_seat_popup_grab_pointer_focus(struct weston_pointer_grab *grab) { struct weston_desktop_seat *seat = wl_container_of(grab, seat, popup_grab.pointer); struct weston_pointer *pointer = grab->pointer; struct weston_view *view; wl_fixed_t sx, sy; view = weston_compositor_pick_view(pointer->seat->compositor, pointer->x, pointer->y, &sx, &sy); if (view != NULL && view->surface->resource != NULL && wl_resource_get_client(view->surface->resource) == seat->popup_grab.client) weston_pointer_set_focus(pointer, view, sx, sy); else weston_pointer_clear_focus(pointer); }
static struct wl_resource * meta_wayland_data_source_send_offer (MetaWaylandDataSource *source, struct wl_resource *target) { MetaWaylandDataOffer *offer = g_slice_new0 (MetaWaylandDataOffer); char **p; offer->source = source; offer->source_destroy_listener.notify = destroy_offer_data_source; offer->resource = wl_resource_create (wl_resource_get_client (target), &wl_data_offer_interface, wl_resource_get_version (target), 0); wl_resource_set_implementation (offer->resource, &data_offer_interface, offer, destroy_data_offer); wl_resource_add_destroy_listener (source->resource, &offer->source_destroy_listener); wl_data_device_send_data_offer (target, offer->resource); wl_array_for_each (p, &source->mime_types) wl_data_offer_send_offer (offer->resource, *p); return offer->resource; }
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 wlc_view_close_ptr(struct wlc_view *view) { if (!view) return; struct wl_resource *r; if (view->xdg_surface && (r = wl_resource_from_wlc_resource(view->xdg_surface, "xdg-surface"))) { xdg_surface_send_close(r); } else if (is_x11_view(view)) { wlc_x11_window_close(&view->x11); } else if (view->xdg_popup && (r = wl_resource_from_wlc_resource(view->xdg_popup, "xdg-popup"))) { xdg_popup_send_popup_done(r); } else if (view->shell_surface && (r = wl_resource_from_wlc_resource(view->shell_surface, "shell-surface"))) { if (view->type & WLC_BIT_POPUP) { wl_shell_surface_send_popup_done(r); } else { struct wl_client *client = wl_resource_get_client(r); wlc_resource_release(view->shell_surface); wl_client_destroy(client); } } }
static void xdg_surface_role_configure (MetaWaylandSurfaceRoleShellSurface *shell_surface_role, int new_width, int new_height, MetaWaylandSerial *sent_serial) { MetaWaylandXdgSurface *xdg_surface = META_WAYLAND_XDG_SURFACE (shell_surface_role); MetaWaylandSurfaceRole *surface_role = META_WAYLAND_SURFACE_ROLE (shell_surface_role); MetaWaylandSurface *surface = meta_wayland_surface_role_get_surface (surface_role); struct wl_client *client = wl_resource_get_client (xdg_surface->resource); struct wl_display *display = wl_client_get_display (client); uint32_t serial = wl_display_next_serial (display); struct wl_array states; if (!xdg_surface->resource) return; wl_array_init (&states); fill_states (&states, surface->window); xdg_surface_send_configure (xdg_surface->resource, new_width, new_height, &states, serial); wl_array_release (&states); if (sent_serial) { sent_serial->set = TRUE; sent_serial->value = serial; } }
struct wl_client* wlc_view_get_client_ptr(struct wlc_view *view) { struct wl_resource *r = (view ? wl_resource_from_wlc_resource(view->surface, "surface") : NULL); return (r ? wl_resource_get_client(r) : NULL); }