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; }
WL_EXPORT int weston_touch_start_drag(struct weston_touch *touch, struct weston_data_source *source, struct weston_surface *icon, struct wl_client *client) { struct weston_touch_drag *drag; drag = zalloc(sizeof *drag); if (drag == NULL) return -1; drag->grab.interface = &touch_drag_grab_interface; drag->base.client = client; drag->base.data_source = source; if (icon) { drag->base.icon = weston_view_create(icon); if (drag->base.icon == NULL) { free(drag); return -1; } drag->base.icon_destroy_listener.notify = handle_drag_icon_destroy; wl_signal_add(&icon->destroy_signal, &drag->base.icon_destroy_listener); icon->configure = touch_drag_surface_configure; icon->configure_private = drag; } else { drag->base.icon = NULL; } if (source) { drag->base.data_source_listener.notify = destroy_touch_data_device_source; wl_signal_add(&source->destroy_signal, &drag->base.data_source_listener); } weston_touch_start_grab(touch, &drag->grab); drag_grab_touch_focus(drag); return 0; }