static void weston_desktop_seat_popup_grab_end(struct weston_desktop_seat *seat) { struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat->seat); struct weston_pointer *pointer = weston_seat_get_pointer(seat->seat); struct weston_touch *touch = weston_seat_get_touch(seat->seat); while (!wl_list_empty(&seat->popup_grab.surfaces)) { struct wl_list *link = seat->popup_grab.surfaces.prev; struct weston_desktop_surface *surface = weston_desktop_surface_from_grab_link(link); wl_list_remove(link); wl_list_init(link); weston_desktop_surface_popup_dismiss(surface); } if (keyboard != NULL && keyboard->grab->interface == &weston_desktop_seat_keyboard_popup_grab_interface) weston_keyboard_end_grab(keyboard); if (pointer != NULL && pointer->grab->interface == &weston_desktop_seat_pointer_popup_grab_interface) weston_pointer_end_grab(pointer); if (touch != NULL && touch->grab->interface == &weston_desktop_seat_touch_popup_grab_interface) weston_touch_end_grab(touch); seat->popup_grab.client = NULL; }
bool weston_desktop_seat_popup_grab_start(struct weston_desktop_seat *seat, struct wl_client *client, uint32_t serial) { assert(seat->popup_grab.client == NULL || seat->popup_grab.client == client); struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat->seat); struct weston_pointer *pointer = weston_seat_get_pointer(seat->seat); struct weston_touch *touch = weston_seat_get_touch(seat->seat); if ((keyboard == NULL || keyboard->grab_serial != serial) && (pointer == NULL || pointer->grab_serial != serial) && (touch == NULL || touch->grab_serial != serial)) { return false; } if (keyboard != NULL && keyboard->grab->interface != &weston_desktop_seat_keyboard_popup_grab_interface) weston_keyboard_start_grab(keyboard, &seat->popup_grab.keyboard); if (pointer != NULL && pointer->grab->interface != &weston_desktop_seat_pointer_popup_grab_interface) weston_pointer_start_grab(pointer, &seat->popup_grab.pointer); if (touch != NULL && touch->grab->interface != &weston_desktop_seat_touch_popup_grab_interface) weston_touch_start_grab(touch, &seat->popup_grab.touch); seat->popup_grab.initial_up = (pointer == NULL || pointer->button_count == 0); seat->popup_grab.client = client; return true; }
/** * Get the current x,y coordinate of the compositor pointer. **/ void Globals::pointerXY(wl_fixed_t *x, wl_fixed_t *y) { struct weston_seat *seat(Globals::seat()); #if WESTON_SDK_AT_LEAST(1, 8, 91) struct weston_pointer *pointer = weston_seat_get_pointer(seat); *x = pointer->x; *y = pointer->y; #else *x = seat->pointer->x; *y = seat->pointer->y; #endif }
WL_EXPORT void weston_output_update_zoom(struct weston_output *output) { struct weston_seat *seat = output->zoom.seat; struct weston_pointer *pointer = weston_seat_get_pointer(seat); assert(output->zoom.active); output->zoom.current.x = wl_fixed_to_double(pointer->x); output->zoom.current.y = wl_fixed_to_double(pointer->y); weston_zoom_transition(output); weston_output_update_zoom_transform(output); }
WL_EXPORT void weston_output_activate_zoom(struct weston_output *output, struct weston_seat *seat) { struct weston_pointer *pointer = weston_seat_get_pointer(seat); if (output->zoom.active) return; output->zoom.active = true; output->zoom.seat = seat; output->disable_planes++; wl_signal_add(&pointer->motion_signal, &output->zoom.motion_listener); }
static void device_added(struct udev_input *input, struct libinput_device *libinput_device) { struct weston_compositor *c; struct evdev_device *device; struct weston_output *output; const char *output_name; struct weston_seat *seat; struct udev_seat *udev_seat; struct weston_pointer *pointer; c = input->compositor; udev_seat = get_udev_seat(input, libinput_device); if (!udev_seat) return; seat = &udev_seat->base; device = evdev_device_create(libinput_device, seat); if (device == NULL) return; if (input->configure_device != NULL) input->configure_device(c, device->device); evdev_device_set_calibration(device); udev_seat = (struct udev_seat *) seat; wl_list_insert(udev_seat->devices_list.prev, &device->link); pointer = weston_seat_get_pointer(seat); if (seat->output && pointer) weston_pointer_clamp(pointer, &pointer->x, &pointer->y); output_name = libinput_device_get_output_name(libinput_device); if (output_name) { device->output_name = strdup(output_name); wl_list_for_each(output, &c->output_list, link) if (output->name && strcmp(output->name, device->output_name) == 0) evdev_device_set_output(device, output); } else if (device->output == NULL && !wl_list_empty(&c->output_list)) {
static void trigger_binding(struct weston_keyboard *keyboard, const struct timespec *time, uint32_t key, void *data) { const char *prefix = "surfaceshot-"; const char *suffix = ".pam"; char fname[1024]; struct weston_surface *surface; struct weston_seat *seat = keyboard->seat; struct weston_pointer *pointer = weston_seat_get_pointer(seat); int width, height; char desc[512]; void *pixels; const size_t bytespp = 4; /* PIXMAN_a8b8g8r8 */ size_t sz; int ret; FILE *fp; if (!pointer || !pointer->focus) return; surface = pointer->focus->surface; weston_surface_get_content_size(surface, &width, &height); if (!surface->get_label || surface->get_label(surface, desc, sizeof(desc)) < 0) snprintf(desc, sizeof(desc), "(unknown)"); weston_log("surface screenshot of %p: '%s', %dx%d\n", surface, desc, width, height); sz = width * bytespp * height; if (sz == 0) { weston_log("no content for %p\n", surface); return; } pixels = malloc(sz); if (!pixels) { weston_log("%s: failed to malloc %zu B\n", __func__, sz); return; } ret = weston_surface_copy_content(surface, pixels, sz, 0, 0, width, height); if (ret < 0) { weston_log("shooting surface %p failed\n", surface); goto out; } unpremultiply_and_swap_a8b8g8r8_to_PAMrgba(pixels, sz); fp = file_create_dated(NULL, prefix, suffix, fname, sizeof(fname)); if (!fp) { const char *msg; switch (errno) { case ETIME: msg = "failure in datetime formatting"; break; default: msg = strerror(errno); } weston_log("Cannot open '%s*%s' for writing: %s\n", prefix, suffix, msg); goto out; } ret = write_PAM_image_rgba(fp, width, height, pixels, sz, desc); if (fclose(fp) != 0 || ret < 0) weston_log("writing surface %p screenshot failed.\n", surface); else weston_log("successfully shot surface %p into '%s'\n", surface, fname); out: free(pixels); }