void ShellSurface::resize(struct wl_client *client,
                  struct wl_resource *shell_surface_resource,
                  struct wl_resource *input_device_super,
                  uint32_t time,
                  uint32_t edges)
{
    Q_UNUSED(shell_surface_resource);
    Q_UNUSED(client);
    Q_UNUSED(time);
    Q_UNUSED(edges);
    ShellSurface *self = static_cast<ShellSurface *>(shell_surface_resource->data);
    InputDevice *input_device = static_cast<InputDevice *>(input_device_super->data);
    if (self->m_moveGrabber || self->m_resizeGrabber) {
        qDebug() << "invalid state2";
        return;
    }
    self->m_resizeGrabber = new ShellSurfaceResizeGrabber(self);
    wl_pointer *pointer = input_device->pointerDevice();
    self->m_resizeGrabber->base()->x = pointer->x;
    self->m_resizeGrabber->base()->y = pointer->y;
    self->m_resizeGrabber->resize_edges = wl_shell_surface_resize(edges);
    self->m_resizeGrabber->width = self->surface()->size().width();
    self->m_resizeGrabber->height = self->surface()->size().height();

    wl_pointer_start_grab(pointer, self->m_resizeGrabber->base());
}
Beispiel #2
0
static void
data_device_start_drag(struct wl_client *client, struct wl_resource *resource,
		       struct wl_resource *source_resource,
		       struct wl_resource *origin_resource,
		       struct wl_resource *icon_resource, uint32_t serial)
{
	struct wl_seat *seat = resource->data;

	/* FIXME: Check that client has implicit grab on the origin
	 * surface that matches the given time. */

	/* FIXME: Check that the data source type array isn't empty. */

	seat->drag_grab.interface = &drag_grab_interface;

	seat->drag_client = client;
	seat->drag_data_source = NULL;

	if (source_resource) {
		seat->drag_data_source = source_resource->data;
		seat->drag_data_source_listener.notify =
			destroy_data_device_source;
		wl_signal_add(&source_resource->destroy_signal,
			      &seat->drag_data_source_listener);
	}

	if (icon_resource) {
		seat->drag_surface = icon_resource->data;
		seat->drag_icon_listener.notify = destroy_data_device_icon;
		wl_signal_add(&icon_resource->destroy_signal,
			      &seat->drag_icon_listener);
		wl_signal_emit(&seat->drag_icon_signal, icon_resource);
	}

	wl_pointer_set_focus(seat->pointer, NULL,
			     wl_fixed_from_int(0), wl_fixed_from_int(0));
	wl_pointer_start_grab(seat->pointer, &seat->drag_grab);
}
void ShellSurface::move(struct wl_client *client,
                struct wl_resource *shell_surface_resource,
                struct wl_resource *input_device_super,
                uint32_t time)
{
    Q_UNUSED(client);
    Q_UNUSED(time);
    ShellSurface *self = static_cast<ShellSurface *>(shell_surface_resource->data);
    InputDevice *input_device = static_cast<InputDevice *>(input_device_super->data);
    if (self->m_resizeGrabber || self->m_moveGrabber) {
        qDebug() << "invalid state";
        return;
    }

    self->m_moveGrabber = new ShellSurfaceMoveGrabber(self);
    wl_pointer *pointer = input_device->pointerDevice();
    self->m_moveGrabber->base()->x = pointer->x;
    self->m_moveGrabber->base()->y = pointer->y;
    self->m_moveGrabber->offset_x = wl_fixed_to_int(pointer->x) - self->surface()->pos().x();
    self->m_moveGrabber->offset_y = wl_fixed_to_int(pointer->y) - self->surface()->pos().y();

    wl_pointer_start_grab(pointer, self->m_moveGrabber->base());
}