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); }
void ShellSeat::popup_grab_button(struct weston_pointer_grab *grab, uint32_t time, uint32_t button, uint32_t state_w) { ShellSeat *shseat = static_cast<PopupGrab *>(container_of(grab, PopupGrab, grab))->seat; struct wl_resource *resource = grab->pointer->focus_resource; if (resource) { struct wl_display *display = wl_client_get_display(resource->client); uint32_t serial = wl_display_get_serial(display); wl_pointer_send_button(resource, serial, time, button, state_w); } else if (state_w == WL_POINTER_BUTTON_STATE_RELEASED && (shseat->m_popupGrab.initial_up || time - shseat->m_seat->pointer->grab_time > 500)) { shseat->endPopupGrab(); } if (state_w == WL_POINTER_BUTTON_STATE_RELEASED) shseat->m_popupGrab.initial_up = 1; }
static void drag_grab_focus(struct wl_pointer_grab *grab, struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y) { struct wl_seat *seat = container_of(grab, struct wl_seat, drag_grab); struct wl_resource *resource, *offer = NULL; struct wl_display *display; uint32_t serial; if (seat->drag_focus_resource) { wl_data_device_send_leave(seat->drag_focus_resource); wl_list_remove(&seat->drag_focus_listener.link); seat->drag_focus_resource = NULL; seat->drag_focus = NULL; } if (!surface) return; if (!seat->drag_data_source && surface->resource.client != seat->drag_client) return; resource = find_resource(&seat->drag_resource_list, surface->resource.client); if (!resource) return; display = wl_client_get_display(resource->client); serial = wl_display_next_serial(display); if (seat->drag_data_source) offer = wl_data_source_send_offer(seat->drag_data_source, resource); wl_data_device_send_enter(resource, serial, &surface->resource, x, y, offer); seat->drag_focus = surface; seat->drag_focus_listener.notify = destroy_drag_focus; wl_signal_add(&resource->destroy_signal, &seat->drag_focus_listener); seat->drag_focus_resource = resource; grab->focus = surface; }
static int format_is_supported(struct wl_client *client, uint32_t format) { struct wl_display *display = wl_client_get_display(client); struct wl_array *formats; uint32_t *p; switch (format) { case WL_SHM_FORMAT_ARGB8888: case WL_SHM_FORMAT_XRGB8888: return 1; default: formats = wl_display_get_additional_shm_formats(display); wl_array_for_each(p, formats) if(*p == format) return 1; } return 0; }
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; } }
static void bind_shm(struct wl_client *client, void *data, uint32_t version, uint32_t id) { struct wl_resource *resource; struct wl_display *display = wl_client_get_display(client); struct wl_array *additional_formats; uint32_t *p; resource = wl_resource_create(client, &wl_shm_interface, 1, id); if (!resource) { wl_client_post_no_memory(client); return; } wl_resource_set_implementation(resource, &shm_interface, data, NULL); wl_shm_send_format(resource, WL_SHM_FORMAT_ARGB8888); wl_shm_send_format(resource, WL_SHM_FORMAT_XRGB8888); additional_formats = wl_display_get_additional_shm_formats(display); wl_array_for_each(p, additional_formats) wl_shm_send_format(resource, *p); }