Exemplo n.º 1
0
Arquivo: zoom.c Projeto: bpeel/weston
WL_EXPORT void
weston_output_update_zoom(struct weston_output *output, uint32_t type)
{
	struct weston_seat *seat = weston_zoom_pick_seat(output->compositor);
	wl_fixed_t x = seat->pointer->x;
	wl_fixed_t y = seat->pointer->y;

	zoom_area_center_from_pointer(output, &x, &y);

	if (type == ZOOM_FOCUS_POINTER) {
		if (wl_list_empty(&output->zoom.animation_xy.link)) {
			output->zoom.current.x = seat->pointer->x;
			output->zoom.current.y = seat->pointer->y;
		} else {
			output->zoom.to.x = x;
			output->zoom.to.y = y;
		}
	}

	if (type == ZOOM_FOCUS_TEXT) {
		if (wl_list_empty(&output->zoom.animation_xy.link)) {
			output->zoom.current.x = output->zoom.text_cursor.x;
			output->zoom.current.y = output->zoom.text_cursor.y;
		} else {
			output->zoom.to.x = output->zoom.text_cursor.x;
			output->zoom.to.y = output->zoom.text_cursor.y;
		}
	}

	weston_zoom_transition(output, type, x, y);
	weston_output_update_zoom_transform(output);
}
Exemplo n.º 2
0
static int
dispatch_queue(struct wl_display *display, struct wl_event_queue *queue)
{
	int count;

	if (display->last_error)
		goto err;

	count = 0;
	while (!wl_list_empty(&display->display_queue.event_list)) {
		dispatch_event(display, &display->display_queue);
		if (display->last_error)
			goto err;
		count++;
	}

	while (!wl_list_empty(&queue->event_list)) {
		dispatch_event(display, queue);
		if (display->last_error)
			goto err;
		count++;
	}

	return count;

err:
	errno = display->last_error;

	return -1;
}
Exemplo n.º 3
0
WL_EXPORT void
wlb_keyboard_key(struct wlb_keyboard *keyboard, uint32_t time,
		 uint32_t key, enum wl_keyboard_key_state state)
{
	struct wl_resource *resource;
	uint32_t serial, *k, *end;

	keyboard_ensure_focus(keyboard);

	end = keyboard->keys.data + keyboard->keys.size;
	for (k = keyboard->keys.data; k < end; k++) {
		if (*k == key) {
			/* Ignore server-generated repeats. */
			if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
				return;
			*k = *--end;
		}
	}
	keyboard->keys.size = (void *) end - keyboard->keys.data;
	if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
		k = wl_array_add(&keyboard->keys, sizeof *k);
		*k = key;
	}

	if (!keyboard->focus || wl_list_empty(&keyboard->resource_list))
		return;
	
	serial = wl_display_next_serial(keyboard->seat->compositor->display);
	wl_resource_for_each(resource, &keyboard->resource_list)
		wl_keyboard_send_key(resource, serial, time, key, state);
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
0
Arquivo: zoom.c Projeto: bpeel/weston
static void
weston_zoom_transition(struct weston_output *output, uint32_t type,
						wl_fixed_t x, wl_fixed_t y)
{
	if (output->zoom.type != type) {
		/* Set from/to points and start animation */
		output->zoom.spring_xy.current = 0.0;
		output->zoom.spring_xy.previous = 0.0;
		output->zoom.spring_xy.target = 1.0;

		if (wl_list_empty(&output->zoom.animation_xy.link)) {
			output->zoom.animation_xy.frame_counter = 0;
			wl_list_insert(output->animation_list.prev,
				&output->zoom.animation_xy.link);

			output->zoom.from.x = (type == ZOOM_FOCUS_TEXT) ?
						x : output->zoom.text_cursor.x;
			output->zoom.from.y = (type == ZOOM_FOCUS_TEXT) ?
						y : output->zoom.text_cursor.y;
		} else {
			output->zoom.from.x = output->zoom.current.x;
			output->zoom.from.y = output->zoom.current.y;
		}

		output->zoom.to.x = (type == ZOOM_FOCUS_POINTER) ?
						x : output->zoom.text_cursor.x;
		output->zoom.to.y = (type == ZOOM_FOCUS_POINTER) ?
						y : output->zoom.text_cursor.y;
		output->zoom.current.x = output->zoom.from.x;
		output->zoom.current.y = output->zoom.from.y;

		output->zoom.type = type;
	}

	if (output->zoom.level != output->zoom.spring_z.current) {
		output->zoom.spring_z.target = output->zoom.level;
		if (wl_list_empty(&output->zoom.animation_z.link)) {
			output->zoom.animation_z.frame_counter = 0;
			wl_list_insert(output->animation_list.prev,
				&output->zoom.animation_z.link);
		}
	}

	output->dirty = 1;
	weston_output_damage(output);
}
Exemplo n.º 6
0
static int
queue_event(struct wl_display *display, int len)
{
	uint32_t p[2], id;
	int opcode, size;
	struct wl_proxy *proxy;
	struct wl_closure *closure;
	const struct wl_message *message;
	struct wl_event_queue *queue;

	wl_connection_copy(display->connection, p, sizeof p);
	id = p[0];
	opcode = p[1] & 0xffff;
	size = p[1] >> 16;
	if (len < size)
		return 0;

	proxy = wl_map_lookup(&display->objects, id);
	if (proxy == WL_ZOMBIE_OBJECT) {
		wl_connection_consume(display->connection, size);
		return size;
	} else if (proxy == NULL) {
		wl_connection_consume(display->connection, size);
		return size;
	}

	message = &proxy->object.interface->events[opcode];
	closure = wl_connection_demarshal(display->connection, size,
					  &display->objects, message);
	if (!closure)
		return -1;

	if (create_proxies(proxy, closure) < 0) {
		wl_closure_destroy(closure);
		return -1;
	}

	if (wl_closure_lookup_objects(closure, &display->objects) != 0) {
		wl_closure_destroy(closure);
		return -1;
	}

	increase_closure_args_refcount(closure);
	proxy->refcount++;
	closure->proxy = proxy;

	if (proxy == &display->proxy)
		queue = &display->display_queue;
	else
		queue = proxy->queue;

	if (wl_list_empty(&queue->event_list))
		pthread_cond_signal(&queue->cond);
	wl_list_insert(queue->event_list.prev, &closure->link);

	return size;
}
Exemplo n.º 7
0
struct weston_desktop_surface *
weston_desktop_seat_popup_grab_get_topmost_surface(struct weston_desktop_seat *seat)
{
	if (wl_list_empty(&seat->popup_grab.surfaces))
		return NULL;

	struct wl_list *grab_link = seat->popup_grab.surfaces.next;

	return weston_desktop_surface_from_grab_link(grab_link);
}
Exemplo n.º 8
0
WL_EXPORT void
wl_list_insert_list(struct wl_list *list, struct wl_list *other)
{
	if (wl_list_empty(other))
		return;

	other->next->prev = list;
	other->prev->next = list->next;
	list->next->prev = other->prev;
	list->next = other->next;
}
Exemplo n.º 9
0
void
weston_desktop_seat_popup_grab_remove_surface(struct weston_desktop_seat *seat,
					      struct wl_list *link)
{
	assert(seat->popup_grab.client != NULL);

	wl_list_remove(link);
	wl_list_init(link);
	if (wl_list_empty(&seat->popup_grab.surfaces))
		weston_desktop_seat_popup_grab_end(seat);
}
Exemplo n.º 10
0
WL_EXPORT void
wl_event_loop_dispatch_idle(struct wl_event_loop *loop)
{
	struct wl_event_source_idle *source;

	while (!wl_list_empty(&loop->idle_list)) {
		source = container_of(loop->idle_list.next,
				      struct wl_event_source_idle, base.link);
		source->func(source->base.data);
		wl_event_source_remove(&source->base);
	}
}
Exemplo n.º 11
0
void
meta_wayland_compositor_paint_finished (MetaWaylandCompositor *compositor)
{
  while (!wl_list_empty (&compositor->frame_callbacks))
    {
      MetaWaylandFrameCallback *callback =
        wl_container_of (compositor->frame_callbacks.next, callback, link);

      wl_callback_send_done (callback->resource, get_time ());
      wl_resource_destroy (callback->resource);
    }
}
Exemplo n.º 12
0
static void
wl_event_queue_release(struct wl_event_queue *queue)
{
	struct wl_closure *closure;

	while (!wl_list_empty(&queue->event_list)) {
		closure = container_of(queue->event_list.next,
				       struct wl_closure, link);
		wl_list_remove(&closure->link);
		wl_closure_destroy(closure);
	}
	pthread_cond_destroy(&queue->cond);
}
Exemplo n.º 13
0
static void
notify_output_destroy(struct wl_listener *listener, void *data)
{
	struct evdev_device *device =
		container_of(listener,
			     struct evdev_device, output_destroy_listener);
	struct weston_compositor *c = device->seat->compositor;
	struct weston_output *output;

	if (!device->output_name && !wl_list_empty(&c->output_list)) {
		output = container_of(c->output_list.next,
				      struct weston_output, link);
		evdev_device_set_output(device, output);
	} else {
Exemplo n.º 14
0
static void
weston_zoom_transition(struct weston_output *output, wl_fixed_t x, wl_fixed_t y)
{
	if (output->zoom.level != output->zoom.spring_z.current) {
		output->zoom.spring_z.target = output->zoom.level;
		if (wl_list_empty(&output->zoom.animation_z.link)) {
			output->zoom.animation_z.frame_counter = 0;
			wl_list_insert(output->animation_list.prev,
				&output->zoom.animation_z.link);
		}
	}

	output->dirty = 1;
	weston_output_damage(output);
}
Exemplo n.º 15
0
Arquivo: zoom.c Projeto: bpeel/weston
static void
weston_output_update_zoom_transform(struct weston_output *output)
{
	uint32_t type = output->zoom.type;
	float global_x, global_y;
	wl_fixed_t x = output->zoom.current.x;
	wl_fixed_t y = output->zoom.current.y;
	float trans_min, trans_max;
	float ratio, level;

	level = output->zoom.spring_z.current;
	ratio = 1 / level;

	if (!output->zoom.active || level > output->zoom.max_level ||
	    level == 0.0f)
		return;

	if (type == ZOOM_FOCUS_POINTER &&
			wl_list_empty(&output->zoom.animation_xy.link))
		zoom_area_center_from_pointer(output, &x, &y);

	global_x = wl_fixed_to_double(x);
	global_y = wl_fixed_to_double(y);

	output->zoom.trans_x =
		((((global_x - output->x) / output->width) *
		(level * 2)) - level) * ratio;
	output->zoom.trans_y =
		((((global_y - output->y) / output->height) *
		(level * 2)) - level) * ratio;

	weston_zoom_apply_output_transform(output, &output->zoom.trans_x,
						   &output->zoom.trans_y);

	trans_max = level * 2 - level;
	trans_min = -trans_max;

	/* Clip zoom area to output */
	if (output->zoom.trans_x > trans_max)
		output->zoom.trans_x = trans_max;
	else if (output->zoom.trans_x < trans_min)
		output->zoom.trans_x = trans_min;
	if (output->zoom.trans_y > trans_max)
		output->zoom.trans_y = trans_max;
	else if (output->zoom.trans_y < trans_min)
		output->zoom.trans_y = trans_min;
}
Exemplo n.º 16
0
Arquivo: cogland.c Projeto: 3v1n0/cogl
static CoglBool
paint_cb (void *user_data)
{
  CoglandCompositor *compositor = user_data;
  GList *l;

  for (l = compositor->outputs; l; l = l->next)
    {
      CoglandOutput *output = l->data;
      CoglFramebuffer *fb = output->onscreen;
      GList *l2;

      cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);

      cogl_primitive_draw (compositor->triangle,
                           fb, compositor->triangle_pipeline);

      for (l2 = compositor->surfaces; l2; l2 = l2->next)
        {
          CoglandSurface *surface = l2->data;

          if (surface->texture)
            {
              CoglTexture2D *texture = surface->texture;
              CoglPipeline *pipeline =
                cogl_pipeline_new (compositor->cogl_context);
              cogl_pipeline_set_layer_texture (pipeline, 0, texture);
              cogl_framebuffer_draw_rectangle (fb, pipeline, -1, 1, 1, -1);
              cogl_object_unref (pipeline);
            }
        }
      cogl_onscreen_swap_buffers (COGL_ONSCREEN (fb));
    }

  while (!wl_list_empty (&compositor->frame_callbacks))
    {
      CoglandFrameCallback *callback =
        wl_container_of (compositor->frame_callbacks.next, callback, link);

      wl_callback_send_done (callback->resource, get_time ());
      wl_resource_destroy (callback->resource);
    }

  compositor->redraw_idle = 0;

  return G_SOURCE_REMOVE;
}
Exemplo n.º 17
0
WL_EXPORT void
wlb_keyboard_modifiers(struct wlb_keyboard *keyboard, uint32_t mods_depressed,
		       uint32_t mods_latched, uint32_t mods_locked,
		       uint32_t group)
{
	struct wl_resource *resource;
	uint32_t serial;

	keyboard_ensure_focus(keyboard);

	if (!keyboard->focus || wl_list_empty(&keyboard->resource_list))
		return;
	
	serial = wl_display_next_serial(keyboard->seat->compositor->display);
	wl_resource_for_each(resource, &keyboard->resource_list)
		wl_keyboard_send_modifiers(resource, serial, mods_depressed,
					   mods_latched, mods_locked, group);
}
Exemplo n.º 18
0
void
evdev_device_destroy(struct evdev_device *device)
{
	struct evdev_dispatch *dispatch;

	dispatch = device->dispatch;
	if (dispatch)
		dispatch->interface->destroy(dispatch);

	if (device->source)
		wl_event_source_remove(device->source);
	if (!wl_list_empty(&device->link))
		wl_list_remove(&device->link);
	if (device->mtdev)
		mtdev_close_delete(device->mtdev);
	close(device->fd);
	free(device->devname);
	free(device->devnode);
	free(device);
}
Exemplo n.º 19
0
WL_EXPORT int
wl_display_prepare_read_queue(struct wl_display *display,
			      struct wl_event_queue *queue)
{
	int ret;

	pthread_mutex_lock(&display->mutex);

	if (!wl_list_empty(&queue->event_list)) {
		errno = EAGAIN;
		ret = -1;
	} else {
		display->reader_count++;
		ret = 0;
	}

	pthread_mutex_unlock(&display->mutex);

	return ret;
}
Exemplo n.º 20
0
WL_EXPORT void
weston_output_update_zoom(struct weston_output *output)
{
	struct weston_seat *seat = weston_zoom_pick_seat(output->compositor);
	wl_fixed_t x = seat->pointer->x;
	wl_fixed_t y = seat->pointer->y;

	zoom_area_center_from_pointer(output, &x, &y);

	if (wl_list_empty(&output->zoom.animation_xy.link)) {
		output->zoom.current.x = seat->pointer->x;
		output->zoom.current.y = seat->pointer->y;
	} else {
		output->zoom.to.x = x;
		output->zoom.to.y = y;
	}

	weston_zoom_transition(output, x, y);
	weston_output_update_zoom_transform(output);
}
Exemplo n.º 21
0
static void
output_destroy(struct output *o)
{
	struct vidmode *v;

	wl_list_remove(&o->link);
	free(o->make);
	free(o->model);

	while (!wl_list_empty(&o->mode_list)) {
		v = wl_container_of(o->mode_list.next, v, link);
		wl_list_remove(&v->link);
		free(v);
	}

	if (o->proxy)
		wl_output_destroy(o->proxy);

	free(o);
}
Exemplo n.º 22
0
static int
dispatch_queue(struct wl_display *display, struct wl_event_queue *queue)
{
	int count;

	if (display->last_error)
		goto err;

	for (count = 0; !wl_list_empty(&queue->event_list); count++) {
		dispatch_event(display, queue);
		if (display->last_error)
			goto err;
	}

	return count;

err:
	errno = display->last_error;

	return -1;
}
Exemplo n.º 23
0
static struct wayland_shm_buffer *
wayland_output_get_shm_buffer(struct wayland_output *output)
{
	struct wayland_compositor *c =
		(struct wayland_compositor *) output->base.compositor;
	struct wl_shm *shm = c->parent.shm;
	struct wayland_shm_buffer *sb;

	struct wl_shm_pool *pool;
	int width, height, stride;
	int32_t fx, fy;
	int fd;
	unsigned char *data;

	if (!wl_list_empty(&output->shm.free_buffers)) {
		sb = container_of(output->shm.free_buffers.next,
				  struct wayland_shm_buffer, free_link);
		wl_list_remove(&sb->free_link);
		wl_list_init(&sb->free_link);

		return sb;
	}
Exemplo n.º 24
0
static struct ss_shm_buffer *
shared_output_get_shm_buffer(struct shared_output *so)
{
	struct ss_shm_buffer *sb, *bnext;
	struct wl_shm_pool *pool;
	int width, height, stride;
	int fd;
	unsigned char *data;

	width = so->output->width;
	height = so->output->height;
	stride = width * 4;

	/* If the size of the output changed, we free the old buffers and
	 * make new ones. */
	if (so->shm.width != width ||
	    so->shm.height != height) {

		/* Destroy free buffers */
		wl_list_for_each_safe(sb, bnext, &so->shm.free_buffers, free_link)
			ss_shm_buffer_destroy(sb);

		/* Orphan in-use buffers so they get destroyed */
		wl_list_for_each(sb, &so->shm.buffers, link)
			sb->output = NULL;

		so->shm.width = width;
		so->shm.height = height;
	}

	if (!wl_list_empty(&so->shm.free_buffers)) {
		sb = container_of(so->shm.free_buffers.next,
				  struct ss_shm_buffer, free_link);
		wl_list_remove(&sb->free_link);
		wl_list_init(&sb->free_link);

		return sb;
	}
Exemplo n.º 25
0
bool Animation::isRunning() const
{
    return !wl_list_empty(&m_animation.ani.link);
}