예제 #1
0
static void
data_device_end_drag_grab(struct wl_seat *seat)
{
	struct wl_resource *surface_resource;
	struct wl_surface_interface *implementation;

	if (seat->drag_surface) {
		surface_resource = &seat->drag_surface->resource;
		implementation = (struct wl_surface_interface *)
			surface_resource->object.implementation;

		implementation->attach(surface_resource->client,
				       surface_resource, NULL, 0, 0);
		wl_list_remove(&seat->drag_icon_listener.link);
	}

	drag_grab_focus(&seat->drag_grab, NULL,
	                wl_fixed_from_int(0), wl_fixed_from_int(0));

	wl_pointer_end_grab(seat->pointer);

	seat->drag_data_source = NULL;
	seat->drag_surface = NULL;
	seat->drag_client = NULL;
}
TYPED_TEST_P(InputEventQueueWestonTest, ButtonEvent)
{
  typedef InputEventsWestonTest Base;
  int x = Base::SurfaceWidth / 2;
  int y = Base::SurfaceHeight / 2;
  const unsigned int WaylandLeftButton = 272;
  
  Base::xbmcWayland->MovePointerTo(Base::surface->GetWlSurface(),
                                   wl_fixed_from_int(x),
                                   wl_fixed_from_int(y));
  Base::xbmcWayland->SendButtonTo(Base::surface->GetWlSurface(),
                                  WaylandLeftButton,
                                  WL_POINTER_BUTTON_STATE_PRESSED);
  Base::WaitForSynchronize();
  
  /* Throw away motion event */
  Base::listener.FetchLastEvent();

  XBMC_Event event(Base::listener.FetchLastEvent());

  EXPECT_EQ(XBMC_MOUSEBUTTONDOWN, event.type);
  EXPECT_EQ(1, event.button.button);
  EXPECT_EQ(x, event.button.x);
  EXPECT_EQ(y, event.button.y);
}
예제 #3
0
static void
check_focus(struct wayland_input *input, wl_fixed_t x, wl_fixed_t y)
{
	struct wayland_compositor *c = input->compositor;
	int width, height, inside;

	width = input->output->mode.width;
	height = input->output->mode.height;

	inside = c->border.left <= wl_fixed_to_int(x) &&
		wl_fixed_to_int(x) < width + c->border.left &&
		c->border.top <= wl_fixed_to_int(y) &&
		wl_fixed_to_int(y) < height + c->border.top;

	if (!input->focus && inside) {
		notify_pointer_focus(&input->base, &input->output->base,
				     x - wl_fixed_from_int(c->border.left),
				     y = wl_fixed_from_int(c->border.top));
		wl_pointer_set_cursor(input->pointer,
				      input->enter_serial, NULL, 0, 0);
	} else if (input->focus && !inside) {
		notify_pointer_focus(&input->base, NULL, 0, 0);
		/* FIXME: Should set default cursor here. */
	}

	input->focus = inside;
}
TYPED_TEST_P(InputEventQueueWestonTest, AxisEvent)
{
  typedef InputEventsWestonTest Base;
  int x = Base::SurfaceWidth / 2;
  int y = Base::SurfaceHeight / 2;
  
  Base::xbmcWayland->MovePointerTo(Base::surface->GetWlSurface(),
                                   wl_fixed_from_int(x),
                                   wl_fixed_from_int(y));
  Base::xbmcWayland->SendAxisTo(Base::surface->GetWlSurface(),
                                WL_POINTER_AXIS_VERTICAL_SCROLL,
                                wl_fixed_from_int(10));
  Base::WaitForSynchronize();
  
  /* Throw away motion event */
  Base::listener.FetchLastEvent();

  /* Should get button up and down */
  XBMC_Event event(Base::listener.FetchLastEvent());

  EXPECT_EQ(XBMC_MOUSEBUTTONDOWN, event.type);
  EXPECT_EQ(5, event.button.button);
  EXPECT_EQ(x, event.button.x);
  EXPECT_EQ(y, event.button.y);
  
  event = Base::listener.FetchLastEvent();

  EXPECT_EQ(XBMC_MOUSEBUTTONUP, event.type);
  EXPECT_EQ(5, event.button.button);
  EXPECT_EQ(x, event.button.x);
  EXPECT_EQ(y, event.button.y);
}
예제 #5
0
static void
send_state(int fd, struct display* display)
{
	char buf[64];
	int len;
	int visible = display->surface->output != NULL;
	wl_fixed_t x = wl_fixed_from_int(-1);
	wl_fixed_t y = wl_fixed_from_int(-1);

	if (display->input->pointer_focus != NULL) {
		assert(display->input->pointer_focus == display->surface);
		x = wl_fixed_from_double(display->input->x);
		y = wl_fixed_from_double(display->input->y);
	}

	if (visible) {
		/* FIXME: this fails on multi-display setup */
		/* assert(display->surface->output == display->output); */
	}

	wl_display_flush(display->display);

	len = snprintf(buf, sizeof buf, "%d %d %d\n", x, y, visible);
	assert(write(fd, buf, len) == len);

	wl_display_roundtrip(display->display);
}
예제 #6
0
static void
zoom_area_center_from_pointer(struct weston_output *output,
				wl_fixed_t *x, wl_fixed_t *y)
{
	float level = output->zoom.spring_z.current;
	wl_fixed_t offset_x = wl_fixed_from_int(output->x);
	wl_fixed_t offset_y = wl_fixed_from_int(output->y);
	wl_fixed_t w = wl_fixed_from_int(output->width);
	wl_fixed_t h = wl_fixed_from_int(output->height);

	*x -= ((((*x - offset_x) / (float) w) - 0.5) * (w * (1.0 - level)));
	*y -= ((((*y - offset_y) / (float) h) - 0.5) * (h * (1.0 - level)));
}
예제 #7
0
파일: zoom.c 프로젝트: Holusion/weston
static void
zoom_area_center_from_point(struct weston_output *output,
			    wl_fixed_t *x, wl_fixed_t *y)
{
	float level = output->zoom.spring_z.current;
	wl_fixed_t offset_x = wl_fixed_from_int(output->x);
	wl_fixed_t offset_y = wl_fixed_from_int(output->y);
	wl_fixed_t w = wl_fixed_from_int(output->width);
	wl_fixed_t h = wl_fixed_from_int(output->height);

	*x = (*x - offset_x) * level + w / 2;
	*y = (*y - offset_y) * level + h / 2;
}
TYPED_TEST_P(InputEventQueueWestonTest, MotionEvent)
{
  typedef InputEventsWestonTest Base;
  int x = Base::SurfaceWidth / 2;
  int y = Base::SurfaceHeight / 2;
  Base::xbmcWayland->MovePointerTo(Base::surface->GetWlSurface(),
                                   wl_fixed_from_int(x),
                                   wl_fixed_from_int(y));
  Base::WaitForSynchronize();
  XBMC_Event event(Base::listener.FetchLastEvent());

  EXPECT_EQ(XBMC_MOUSEMOTION, event.type);
  EXPECT_EQ(x, event.motion.xrel);
  EXPECT_EQ(y, event.motion.yrel);
}
예제 #9
0
static void
input_handle_motion(void *data, struct wl_pointer *pointer,
		    uint32_t time, wl_fixed_t x, wl_fixed_t y)
{
	struct wayland_input *input = data;
	struct wayland_compositor *c = input->compositor;

	check_focus(input, x, y);
	if (input->focus)
		notify_motion(&input->base, time,
			      x - wl_fixed_from_int(c->border.left) -
			      input->base.pointer->x,
			      y - wl_fixed_from_int(c->border.top) -
			      input->base.pointer->y);
}
예제 #10
0
static void
data_device_end_drag_grab(struct wl_seat *seat)
{
	if (seat->drag_surface) {
		seat->drag_surface = NULL;
		wl_signal_emit(&seat->drag_icon_signal, NULL);
		wl_list_remove(&seat->drag_icon_listener.link);
	}

	drag_grab_focus(&seat->drag_grab, NULL,
	                wl_fixed_from_int(0), wl_fixed_from_int(0));

	wl_pointer_end_grab(seat->pointer);

	seat->drag_data_source = NULL;
	seat->drag_client = NULL;
}
예제 #11
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;
}
예제 #12
0
파일: evdev.c 프로젝트: anderco/weston
static inline void
evdev_process_relative(struct evdev_device *device,
		       struct input_event *e, uint32_t time)
{
	switch (e->code) {
	case REL_X:
		device->rel.dx += wl_fixed_from_int(e->value);
		device->pending_events |= EVDEV_RELATIVE_MOTION;
		break;
	case REL_Y:
		device->rel.dy += wl_fixed_from_int(e->value);
		device->pending_events |= EVDEV_RELATIVE_MOTION;
		break;
	case REL_WHEEL:
		switch (e->value) {
		case -1:
			/* Scroll down */
		case 1:
			/* Scroll up */
			notify_axis(device->seat,
				    time,
				    WL_POINTER_AXIS_VERTICAL_SCROLL,
				    -1 * e->value * DEFAULT_AXIS_STEP_DISTANCE);
			break;
		default:
			break;
		}
		break;
	case REL_HWHEEL:
		switch (e->value) {
		case -1:
			/* Scroll left */
		case 1:
			/* Scroll right */
			notify_axis(device->seat,
				    time,
				    WL_POINTER_AXIS_HORIZONTAL_SCROLL,
				    e->value * DEFAULT_AXIS_STEP_DISTANCE);
			break;
		default:
			break;

		}
	}
}
예제 #13
0
void ShellSeat::popup_grab_focus(struct weston_pointer_grab *grab)
{
    struct weston_pointer *pointer = grab->pointer;
    ShellSeat *shseat = static_cast<PopupGrab *>(container_of(grab, PopupGrab, grab))->seat;

    wl_fixed_t sx, sy;
    struct weston_surface *surface = weston_compositor_pick_surface(pointer->seat->compositor,
                                                                    pointer->x, pointer->y,
                                                                    &sx, &sy);

    if (surface && surface->resource->client == shseat->m_popupGrab.client) {
        weston_pointer_set_focus(pointer, surface, sx, sy);
        grab->pointer->focus = surface;
    } else {
        weston_pointer_set_focus(pointer, NULL, wl_fixed_from_int(0), wl_fixed_from_int(0));
        grab->pointer->focus = NULL;
    }
}
예제 #14
0
void Pointer::setFocus(Surface *surface, const QPoint &pos)
{
    if (m_focusResource && m_focus != surface) {
        uint32_t serial = m_compositor->nextSerial();
        send_leave(m_focusResource->handle, serial, m_focus->resource()->handle);
    }

    Resource *resource = surface ? resourceMap().value(surface->resource()->client()) : 0;

    if (resource && (m_focus != surface || resource != m_focusResource)) {
        uint32_t serial = m_compositor->nextSerial();
        send_enter(resource->handle, serial, surface->resource()->handle,
                   wl_fixed_from_int(pos.x()), wl_fixed_from_int(pos.y()));
    }

    m_focusResource = resource;
    m_focus = surface;
}
예제 #15
0
void
Wayland_display_add_input(SDL_VideoData *d, uint32_t id)
{
    struct SDL_WaylandInput *input;
    SDL_WaylandDataDevice *data_device = NULL;

    input = SDL_calloc(1, sizeof *input);
    if (input == NULL)
        return;

    input->display = d;
    input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface, 1);
    input->sx_w = wl_fixed_from_int(0);
    input->sy_w = wl_fixed_from_int(0);
    d->input = input;
    
    if (d->data_device_manager != NULL) {
        data_device = SDL_calloc(1, sizeof *data_device);
        if (data_device == NULL) {
            return;
        }

        data_device->data_device = wl_data_device_manager_get_data_device(
            d->data_device_manager, input->seat
        );
        data_device->video_data = d;

        if (data_device->data_device == NULL) {
            SDL_free(data_device);
        } else {
            wl_data_device_set_user_data(data_device->data_device, data_device);
            wl_data_device_add_listener(data_device->data_device,
                                        &data_device_listener, data_device);
            input->data_device = data_device;
        }
    }

    wl_seat_add_listener(input->seat, &seat_listener, input);
    wl_seat_set_user_data(input->seat, input);

    WAYLAND_wl_display_flush(d->display);
}
예제 #16
0
/*!
 * Sends a mouse wheel event with the given \a orientation and \a delta to the view that currently holds mouse focus.
 */
void QWaylandPointer::sendMouseWheelEvent(Qt::Orientation orientation, int delta)
{
    Q_D(QWaylandPointer);
    if (!d->focusResource)
        return;

    uint32_t time = d->compositor()->currentTimeMsecs();
    uint32_t axis = orientation == Qt::Horizontal ? WL_POINTER_AXIS_HORIZONTAL_SCROLL
                                                  : WL_POINTER_AXIS_VERTICAL_SCROLL;
    d->send_axis(d->focusResource, time, axis, wl_fixed_from_int(-delta / 12));
}
예제 #17
0
void
Wayland_display_add_input(SDL_VideoData *d, uint32_t id)
{
    struct SDL_WaylandInput *input;

    input = SDL_calloc(1, sizeof *input);
    if (input == NULL)
        return;

    input->display = d;
    input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface, 1);
    input->sx_w = wl_fixed_from_int(0);
    input->sy_w = wl_fixed_from_int(0);
    d->input = input;

    wl_seat_add_listener(input->seat, &seat_listener, input);
    wl_seat_set_user_data(input->seat, input);

    WAYLAND_wl_display_flush(d->display);
}
예제 #18
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);
}
예제 #19
0
static void
surface_to_from_global(void *data)
{
	struct weston_compositor *compositor = data;
	struct weston_surface *surface;
	struct weston_view *view;
	float x, y;
	wl_fixed_t fx, fy;
	int32_t ix, iy;

	surface = weston_surface_create(compositor);
	assert(surface);
	view = weston_view_create(surface);
	assert(view);
	surface->width = 50;
	surface->height = 50;
	weston_view_set_position(view, 5, 10);
	weston_view_update_transform(view);

	weston_view_to_global_float(view, 33, 22, &x, &y);
	assert(x == 38 && y == 32);

	weston_view_to_global_float(view, -8, -2, &x, &y);
	assert(x == -3 && y == 8);

	weston_view_to_global_fixed(view, wl_fixed_from_int(12),
				       wl_fixed_from_int(5), &fx, &fy);
	assert(fx == wl_fixed_from_int(17) && fy == wl_fixed_from_int(15));

	weston_view_from_global_float(view, 38, 32, &x, &y);
	assert(x == 33 && y == 22);

	weston_view_from_global_float(view, 42, 5, &x, &y);
	assert(x == 37 && y == -5);

	weston_view_from_global_fixed(view, wl_fixed_from_int(21),
					 wl_fixed_from_int(100), &fx, &fy);
	assert(fx == wl_fixed_from_int(16) && fy == wl_fixed_from_int(90));

	weston_view_from_global(view, 0, 0, &ix, &iy);
	assert(ix == -5 && iy == -10);

	weston_view_from_global(view, 5, 10, &ix, &iy);
	assert(ix == 0 && iy == 0);

	wl_display_terminate(compositor->wl_display);
}
예제 #20
0
static void
surface_to_from_global(void *data)
{
	struct weston_compositor *compositor = data;
	struct weston_surface *surface;
	float x, y;
	wl_fixed_t fx, fy;
	int32_t ix, iy;

	surface = weston_surface_create(compositor);
	weston_surface_configure(surface, 5, 10, 50, 50);
	weston_surface_update_transform(surface);

	weston_surface_to_global_float(surface, 33, 22, &x, &y);
	assert(x == 38 && y == 32);

	weston_surface_to_global_float(surface, -8, -2, &x, &y);
	assert(x == -3 && y == 8);

	weston_surface_to_global_fixed(surface, wl_fixed_from_int(12),
				       wl_fixed_from_int(5), &fx, &fy);
	assert(fx == wl_fixed_from_int(17) && fy == wl_fixed_from_int(15));

	weston_surface_from_global_float(surface, 38, 32, &x, &y);
	assert(x == 33 && y == 22);

	weston_surface_from_global_float(surface, 42, 5, &x, &y);
	assert(x == 37 && y == -5);

	weston_surface_from_global_fixed(surface, wl_fixed_from_int(21),
					 wl_fixed_from_int(100), &fx, &fy);
	assert(fx == wl_fixed_from_int(16) && fy == wl_fixed_from_int(90));

	weston_surface_from_global(surface, 0, 0, &ix, &iy);
	assert(ix == -5 && iy == -10);

	weston_surface_from_global(surface, 5, 10, &ix, &iy);
	assert(ix == 0 && iy == 0);

	wl_display_terminate(compositor->wl_display);
}
예제 #21
0
파일: evdev.c 프로젝트: anarsoul/weston
static void
evdev_flush_motion(struct evdev_device *device, uint32_t time)
{
	struct weston_seat *master = device->seat;

	if (!device->pending_events)
		return;

	if (device->pending_events & EVDEV_RELATIVE_MOTION) {
		notify_motion(master, time,
			      master->seat.pointer->x + device->rel.dx,
			      master->seat.pointer->y + device->rel.dy);
		device->pending_events &= ~EVDEV_RELATIVE_MOTION;
		device->rel.dx = 0;
		device->rel.dy = 0;
	}
	if (device->pending_events & EVDEV_ABSOLUTE_MT_DOWN) {
		notify_touch(master, time,
			     device->mt.slot,
			     wl_fixed_from_int(device->mt.x[device->mt.slot]),
			     wl_fixed_from_int(device->mt.y[device->mt.slot]),
			     WL_TOUCH_DOWN);
		device->pending_events &= ~EVDEV_ABSOLUTE_MT_DOWN;
		device->pending_events &= ~EVDEV_ABSOLUTE_MT_MOTION;
	}
	if (device->pending_events & EVDEV_ABSOLUTE_MT_MOTION) {
		notify_touch(master, time,
			     device->mt.slot,
			     wl_fixed_from_int(device->mt.x[device->mt.slot]),
			     wl_fixed_from_int(device->mt.y[device->mt.slot]),
			     WL_TOUCH_MOTION);
		device->pending_events &= ~EVDEV_ABSOLUTE_MT_DOWN;
		device->pending_events &= ~EVDEV_ABSOLUTE_MT_MOTION;
	}
	if (device->pending_events & EVDEV_ABSOLUTE_MT_UP) {
		notify_touch(master, time, device->mt.slot, 0, 0,
			     WL_TOUCH_UP);
		device->pending_events &= ~EVDEV_ABSOLUTE_MT_UP;
	}
	if (device->pending_events & EVDEV_ABSOLUTE_MOTION) {
		transform_absolute(device);
		notify_motion(master, time,
			      wl_fixed_from_int(device->abs.x),
			      wl_fixed_from_int(device->abs.y));
		device->pending_events &= ~EVDEV_ABSOLUTE_MOTION;
	}
}
예제 #22
0
void Pointer::sendMotion(const QPoint &pos)
{
    if (m_focusResource)
        send_motion(m_focusResource->handle, m_compositor->time(),
                    wl_fixed_from_int(pos.x()), wl_fixed_from_int(pos.y()));
}
예제 #23
0
static void
redraw(void *data, struct wl_callback *callback, uint32_t time)
{
	struct window *window = data;
	struct buffer *buffer;
	int off_x, off_y, bwidth, bheight, bborder, bpitch, bradius;
	uint32_t *buffer_data;
	float bx, by;

	buffer = window_next_buffer(window);
	if (!buffer) {
		fprintf(stderr,
			!callback ? "Failed to create the first buffer.\n" :
			"Both buffers busy at redraw(). Server bug?\n");
		abort();
	}

	/* Rotate the damage, but keep the even/odd parity so the
	 * dimensions of the buffers don't change */
	if (window->flags & WINDOW_FLAG_ROTATING_TRANSFORM)
		window->transform = (window->transform + 2) % 8;

	switch (window->transform) {
	default:
	case WL_OUTPUT_TRANSFORM_NORMAL:
	case WL_OUTPUT_TRANSFORM_180:
	case WL_OUTPUT_TRANSFORM_FLIPPED:
	case WL_OUTPUT_TRANSFORM_FLIPPED_180:
		bwidth = window->width * window->scale;
		bheight = window->height * window->scale;
		break;
	case WL_OUTPUT_TRANSFORM_90:
	case WL_OUTPUT_TRANSFORM_270:
	case WL_OUTPUT_TRANSFORM_FLIPPED_90:
	case WL_OUTPUT_TRANSFORM_FLIPPED_270:
		bwidth = window->height * window->scale;
		bheight = window->width * window->scale;
		break;
	}

	bpitch = bwidth;

	bborder = window->border * window->scale;
	bradius = window->ball.radius * window->scale;

	buffer_data = buffer->shm_data;
	if (window->viewport) {
		/* Fill the whole thing with red to detect viewport errors */
		paint_box(buffer->shm_data, bpitch, 0, 0, bwidth, bheight,
			  0xffff0000);

		/* The buffer is the same size.  However, we crop it
		 * and scale it up by a factor of 2 */
		bborder /= 2;
		bradius /= 2;
		bwidth /= 2;
		bheight /= 2;

		/* Offset the drawing region */
		off_x = (window->width / 3) * window->scale;
		off_y = (window->height / 5) * window->scale;
		switch (window->transform) {
		default:
		case WL_OUTPUT_TRANSFORM_NORMAL:
			buffer_data += off_y * bpitch + off_x;
			break;
		case WL_OUTPUT_TRANSFORM_90:
			buffer_data += off_x * bpitch + (bwidth - off_y);
			break;
		case WL_OUTPUT_TRANSFORM_180:
			buffer_data += (bheight - off_y) * bpitch +
				       (bwidth - off_x);
			break;
		case WL_OUTPUT_TRANSFORM_270:
			buffer_data += (bheight - off_x) * bpitch + off_y;
			break;
		case WL_OUTPUT_TRANSFORM_FLIPPED:
			buffer_data += off_y * bpitch + (bwidth - off_x);
			break;
		case WL_OUTPUT_TRANSFORM_FLIPPED_90:
			buffer_data += (bheight - off_x) * bpitch +
				       (bwidth - off_y);
			break;
		case WL_OUTPUT_TRANSFORM_FLIPPED_180:
			buffer_data += (bheight - off_y) * bpitch + off_x;
			break;
		case WL_OUTPUT_TRANSFORM_FLIPPED_270:
			buffer_data += off_x * bpitch + off_y;
			break;
		}
		wl_viewport_set_source(window->viewport,
				       wl_fixed_from_int(window->width / 3),
				       wl_fixed_from_int(window->height / 5),
				       wl_fixed_from_int(window->width / 2),
				       wl_fixed_from_int(window->height / 2));
	}

	/* Paint the border */
	paint_box(buffer_data, bpitch, 0, 0, bwidth, bborder, 0xffffffff);
	paint_box(buffer_data, bpitch, 0, 0, bborder, bheight, 0xffffffff);
	paint_box(buffer_data, bpitch,
		  bwidth - bborder, 0, bborder, bheight, 0xffffffff);
	paint_box(buffer_data, bpitch,
		  0, bheight - bborder, bwidth, bborder, 0xffffffff);

	/* fill with translucent */
	paint_box(buffer_data, bpitch, bborder, bborder,
		  bwidth - 2 * bborder, bheight - 2 * bborder, 0x80000000);

	/* Damage where the ball was */
	wl_surface_damage(window->surface,
			  window->ball.x - window->ball.radius,
			  window->ball.y - window->ball.radius,
			  window->ball.radius * 2 + 1,
			  window->ball.radius * 2 + 1);

	window_advance_game(window, time);

	window_get_transformed_ball(window, &bx, &by);

	/* Paint the ball */
	paint_circle(buffer_data, bpitch, bx, by, bradius, 0xff00ff00);

	if (print_debug) {
		printf("Ball now located at (%f, %f)\n",
		       window->ball.x, window->ball.y);

		printf("Circle painted at (%f, %f), radius %d\n", bx, by,
		       bradius);

		printf("Buffer damage rectangle: (%d, %d) @ %dx%d\n",
		       (int)(bx - bradius), (int)(by - bradius),
		       bradius * 2 + 1, bradius * 2 + 1);
	}

	/* Damage where the ball is now */
	wl_surface_damage(window->surface,
			  window->ball.x - window->ball.radius,
			  window->ball.y - window->ball.radius,
			  window->ball.radius * 2 + 1,
			  window->ball.radius * 2 + 1);

	wl_surface_attach(window->surface, buffer->buffer, 0, 0);

	if (window->display->compositor_version >= 2 &&
	    (window->transform != WL_OUTPUT_TRANSFORM_NORMAL ||
	     window->flags & WINDOW_FLAG_ROTATING_TRANSFORM))
		wl_surface_set_buffer_transform(window->surface,
						window->transform);

	if (window->viewport)
		wl_viewport_set_destination(window->viewport,
					    window->width,
					    window->height);

	if (window->scale != 1)
		wl_surface_set_buffer_scale(window->surface,
					    window->scale);

	if (callback)
		wl_callback_destroy(callback);

	window->callback = wl_surface_frame(window->surface);
	wl_callback_add_listener(window->callback, &frame_listener, window);
	wl_surface_commit(window->surface);
	buffer->busy = 1;
}
예제 #24
0
파일: shm.c 프로젝트: videolan/vlc
static int Control(vout_display_t *vd, int query, va_list ap)
{
    vout_display_sys_t *sys = vd->sys;

    switch (query)
    {
        case VOUT_DISPLAY_RESET_PICTURES:
        {
            const vout_display_cfg_t *cfg = va_arg(ap, const vout_display_cfg_t *);
            video_format_t *fmt = va_arg(ap, video_format_t *);
            vout_display_place_t place;
            video_format_t src;
            assert(sys->viewport == NULL);

            vout_display_PlacePicture(&place, &vd->source, cfg);
            video_format_ApplyRotation(&src, &vd->source);

            fmt->i_width  = src.i_width * place.width
                                        / src.i_visible_width;
            fmt->i_height = src.i_height * place.height
                                         / src.i_visible_height;
            fmt->i_visible_width  = place.width;
            fmt->i_visible_height = place.height;
            fmt->i_x_offset = src.i_x_offset * place.width
                                             / src.i_visible_width;
            fmt->i_y_offset = src.i_y_offset * place.height
                                             / src.i_visible_height;
            break;
        }

        case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE:
        case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED:
        case VOUT_DISPLAY_CHANGE_ZOOM:
        case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT:
        case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
        {
            const vout_display_cfg_t *cfg = va_arg(ap, const vout_display_cfg_t *);
            sys->display_width = cfg->display.width;
            sys->display_height = cfg->display.height;

            if (sys->viewport != NULL)
            {
                video_format_t fmt;
                vout_display_place_t place;

                video_format_ApplyRotation(&fmt, &vd->source);
                vout_display_PlacePicture(&place, &vd->source, cfg);

                wp_viewport_set_source(sys->viewport,
                                wl_fixed_from_int(fmt.i_x_offset),
                                wl_fixed_from_int(fmt.i_y_offset),
                                wl_fixed_from_int(fmt.i_visible_width),
                                wl_fixed_from_int(fmt.i_visible_height));
                wp_viewport_set_destination(sys->viewport,
                                            place.width, place.height);
            }
            else
                return VLC_EGENERIC;
            break;
        }
        default:
             msg_Err(vd, "unknown request %d", query);
             return VLC_EGENERIC;
    }
    return VLC_SUCCESS;
}
예제 #25
0
파일: shell.cpp 프로젝트: amon-ra/nuclear
void ShellGrab::setCursor(Cursor cursor)
{
    Shell::instance()->setGrabCursor(cursor);
    weston_pointer_set_focus(pointer(), Shell::instance()->m_grabView, wl_fixed_from_int(0), wl_fixed_from_int(0));
}