예제 #1
0
파일: shell.cpp 프로젝트: amon-ra/nuclear
void ShellGrab::start(weston_seat *seat)
{
    ShellSeat::shellSeat(seat)->endPopupGrab();

    m_pointer = seat->pointer;
    weston_pointer_start_grab(m_pointer, &m_grab.base);
}
예제 #2
0
파일: seat.c 프로젝트: dtoartist/weston
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;
}
예제 #3
0
WL_EXPORT int
weston_pointer_start_drag(struct weston_pointer *pointer,
		       struct weston_data_source *source,
		       struct weston_surface *icon,
		       struct wl_client *client)
{
	struct weston_pointer_drag *drag;

	drag = zalloc(sizeof *drag);
	if (drag == NULL)
		return -1;

	drag->grab.interface = &pointer_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 = pointer_drag_surface_configure;
		icon->configure_private = drag;
	} else {
		drag->base.icon = NULL;
	}

	if (source) {
		drag->base.data_source_listener.notify = destroy_pointer_data_device_source;
		wl_signal_add(&source->destroy_signal,
			      &drag->base.data_source_listener);
	}

	weston_pointer_set_focus(pointer, NULL,
				 wl_fixed_from_int(0), wl_fixed_from_int(0));
	weston_pointer_start_grab(pointer, &drag->grab);

	return 0;
}
예제 #4
0
bool ShellSeat::addPopupGrab(ShellSurface *surface, uint32_t serial)
{
    if (serial == m_seat->pointer->grab_serial) {
        if (m_popupGrab.surfaces.empty()) {
            m_popupGrab.client = surface->client();
            m_popupGrab.grab.interface = &popup_grab_interface;
            /* We must make sure here that this popup was opened after
            * a mouse press, and not just by moving around with other
            * popups already open. */
            if (m_seat->pointer->button_count > 0) {
                m_popupGrab.initial_up = 0;
            }

            weston_pointer_start_grab(m_seat->pointer, &m_popupGrab.grab);
        }
        m_popupGrab.surfaces.push_back(surface);

        return true;
    }

    m_popupGrab.client = nullptr;
    return false;
}