Пример #1
0
ClaylandSeat *
clayland_seat_new (struct wl_display *display)
{
  ClaylandSeat *seat = g_new0 (ClaylandSeat, 1);

  wl_signal_init (&seat->destroy_signal);

  seat->selection_data_source = NULL;
  wl_list_init (&seat->base_resource_list);
  wl_signal_init (&seat->selection_signal);
  wl_list_init (&seat->drag_resource_list);
  wl_signal_init (&seat->drag_icon_signal);

  clayland_pointer_init (&seat->pointer);

  clayland_keyboard_init (&seat->keyboard, display);

  seat->display = display;

  seat->current_stage = 0;

  seat->sprite = NULL;
  seat->sprite_destroy_listener.notify = pointer_handle_sprite_destroy;
  seat->hotspot_x = 16;
  seat->hotspot_y = 16;

  wl_display_add_global (display, &wl_seat_interface, seat, bind_seat);

  return seat;
}
Пример #2
0
struct tag * tag_new(unsigned index, const char * name)
{
    struct tag * tag;

    if (!(tag = malloc(sizeof *tag)))
        goto error0;

    if (!(tag->name = strdup(name)))
        goto error1;

    tag->mask = TAG_MASK(index);
    tag->screen = NULL;
    tag->global = wl_global_create(velox.display, &velox_tag_interface, 1,
                                   tag, &bind_tag);

    if (!tag->global)
        goto error2;

    tag->config.group.name = strdup(tag->name);
    tag->config.group.type = CONFIG_NODE_TYPE_GROUP;
    wl_list_init(&tag->config.group.group);
    wl_list_insert(&tag_group.group, &tag->config.group.link);

    tag->config.name.name = "name";
    tag->config.name.type = CONFIG_NODE_TYPE_PROPERTY;
    tag->config.name.property.set = &set_name;
    wl_list_insert(&tag->config.group.group, &tag->config.name.link);

    tag->config.activate.name = "activate";
    tag->config.activate.type = CONFIG_NODE_TYPE_ACTION;
    tag->config.activate.action.run = &activate;
    wl_list_insert(&tag->config.group.group, &tag->config.activate.link);

    tag->config.toggle.name = "toggle";
    tag->config.toggle.type = CONFIG_NODE_TYPE_ACTION;
    tag->config.toggle.action.run = &toggle;
    wl_list_insert(&tag->config.group.group, &tag->config.toggle.link);

    tag->config.apply.name = "apply";
    tag->config.apply.type = CONFIG_NODE_TYPE_ACTION;
    tag->config.apply.action.run = &apply;
    wl_list_insert(&tag->config.group.group, &tag->config.apply.link);

    wl_list_init(&tag->resources);

    return tag;

  error2:
    free(tag->name);
  error1:
    free(tag);
  error0:
    return NULL;
}
Пример #3
0
Eina_Bool
e_mod_comp_wl_output_init(void)
{
   Ecore_X_Window *roots;
   int num = 0, rw, rh;

   LOGFN(__FILE__, __LINE__, __FUNCTION__);

   roots = ecore_x_window_root_list(&num);
   if ((!roots) || (num <= 0))
     {
        EINA_LOG_ERR("Could not get root window list\n");
        return EINA_FALSE;
     }
   ecore_x_window_size_get(roots[0], &rw, &rh);
   free(roots);

   if (!(_wl_output = malloc(sizeof(Wayland_Output))))
     {
        EINA_LOG_ERR("Could not allocate space for output\n");
        return EINA_FALSE;
     }

   memset(_wl_output, 0, sizeof(*_wl_output));

   _wl_output->mode.flags =
     (WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED);
   _wl_output->mode.w = rw;
   _wl_output->mode.h = rh;
   _wl_output->mode.refresh = 60;

   _wl_output->x = 0;
   _wl_output->y = 0;
   _wl_output->w = rw;
   _wl_output->h = rh;
   _wl_output->flags = WL_OUTPUT_FLIPPED;

   wl_list_init(&_wl_output->link);
   wl_list_init(&_wl_output->frame_callbacks);

   if (!wl_display_add_global(_wl_disp, &wl_output_interface, _wl_output,
                              _e_mod_comp_wl_output_bind))
     {
        EINA_LOG_ERR("Failed to add output to wayland\n");
        free(_wl_output);
        return EINA_FALSE;
     }

   return EINA_TRUE;
}
Пример #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;
}
static int
headless_compositor_create_output(struct headless_compositor *c,
				  struct headless_parameters *param)
{
	struct headless_output *output;
	struct wl_event_loop *loop;

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

	output->mode.flags =
		WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
	output->mode.width = param->width;
	output->mode.height = param->height;
	output->mode.refresh = 60000;
	wl_list_init(&output->base.mode_list);
	wl_list_insert(&output->base.mode_list, &output->mode.link);

	output->base.current_mode = &output->mode;
	weston_output_init(&output->base, &c->base, 0, 0, param->width,
			   param->height, param->transform, 1);

	output->base.make = "weston";
	output->base.model = "headless";

	loop = wl_display_get_event_loop(c->base.wl_display);
	output->finish_frame_timer =
		wl_event_loop_add_timer(loop, finish_frame_handler, output);

	output->base.start_repaint_loop = headless_output_start_repaint_loop;
	output->base.repaint = headless_output_repaint;
	output->base.destroy = headless_output_destroy;
	output->base.assign_planes = NULL;
	output->base.set_backlight = NULL;
	output->base.set_dpms = NULL;
	output->base.switch_mode = NULL;

	if (c->use_pixman) {
		output->image_buf = malloc(param->width * param->height * 4);
		if (!output->image_buf)
			return -1;

		output->image = pixman_image_create_bits(PIXMAN_x8r8g8b8,
							 param->width,
							 param->height,
							 output->image_buf,
							 param->width * 4);

		if (pixman_renderer_output_create(&output->base) < 0)
			return -1;

		pixman_renderer_output_set_buffer(&output->base,
						  output->image);
	}

	wl_list_insert(c->base.output_list.prev, &output->base.link);

	return 0;
}
Пример #6
0
static void
wl_event_queue_init(struct wl_event_queue *queue, struct wl_display *display)
{
	wl_list_init(&queue->event_list);
	pthread_cond_init(&queue->cond, NULL);
	queue->display = display;
}
Пример #7
0
static void
weston_zoom_frame_z(struct weston_animation *animation,
		struct weston_output *output, uint32_t msecs)
{
	if (animation->frame_counter <= 1)
		output->zoom.spring_z.timestamp = msecs;

	weston_spring_update(&output->zoom.spring_z, msecs);

	if (output->zoom.spring_z.current > output->zoom.max_level)
		output->zoom.spring_z.current = output->zoom.max_level;
	else if (output->zoom.spring_z.current < 0.0)
		output->zoom.spring_z.current = 0.0;

	if (weston_spring_done(&output->zoom.spring_z)) {
		if (output->zoom.active && output->zoom.level <= 0.0) {
			output->zoom.active = 0;
			output->disable_planes--;
			wl_list_remove(&output->zoom.motion_listener.link);
		}
		output->zoom.spring_z.current = output->zoom.level;
		wl_list_remove(&animation->link);
		wl_list_init(&animation->link);
	}

	output->dirty = 1;
	weston_output_damage(output);
}
Пример #8
0
struct weston_desktop_seat *
weston_desktop_seat_from_seat(struct weston_seat *wseat)
{
	struct wl_listener *listener;
	struct weston_desktop_seat *seat;

	listener = wl_signal_get(&wseat->destroy_signal,
				 weston_desktop_seat_destroy);
	if (listener != NULL)
		return wl_container_of(listener, seat, seat_destroy_listener);

	seat = zalloc(sizeof(struct weston_desktop_seat));
	if (seat == NULL)
		return NULL;

	seat->seat = wseat;

	seat->seat_destroy_listener.notify = weston_desktop_seat_destroy;
	wl_signal_add(&wseat->destroy_signal, &seat->seat_destroy_listener);

	seat->popup_grab.keyboard.interface =
		&weston_desktop_seat_keyboard_popup_grab_interface;
	seat->popup_grab.pointer.interface =
		&weston_desktop_seat_pointer_popup_grab_interface;
	seat->popup_grab.touch.interface =
		&weston_desktop_seat_touch_popup_grab_interface;
	wl_list_init(&seat->popup_grab.surfaces);

	return seat;
}
Пример #9
0
static void
weston_zoom_frame_xy(struct weston_animation *animation,
		struct weston_output *output, uint32_t msecs)
{
	struct weston_seat *seat = weston_zoom_pick_seat(output->compositor);
	wl_fixed_t x, y;

	if (animation->frame_counter <= 1)
		output->zoom.spring_xy.timestamp = msecs;

	weston_spring_update(&output->zoom.spring_xy, msecs);

	x = output->zoom.from.x - ((output->zoom.from.x - output->zoom.to.x) *
						output->zoom.spring_xy.current);
	y = output->zoom.from.y - ((output->zoom.from.y - output->zoom.to.y) *
						output->zoom.spring_xy.current);

	output->zoom.current.x = x;
	output->zoom.current.y = y;

	if (weston_spring_done(&output->zoom.spring_xy)) {
		output->zoom.spring_xy.current = output->zoom.spring_xy.target;
		output->zoom.current.x = seat->pointer->x;
		output->zoom.current.y = seat->pointer->y;
		wl_list_remove(&animation->link);
		wl_list_init(&animation->link);
	}

	output->dirty = 1;
	weston_output_damage(output);
}
Пример #10
0
Compositor::Compositor()
    : m_display(wl_display_create())
    , m_time(0)
{
    wl_list_init(&m_outputResources);

    if (wl_display_add_socket(m_display, 0)) {
        fprintf(stderr, "Fatal: Failed to open server socket\n");
        exit(EXIT_FAILURE);
    }

    wl_display_add_global(m_display, &wl_compositor_interface, this, bindCompositor);

    m_data_device_manager.reset(new DataDeviceManager(this, m_display));

    wl_display_init_shm(m_display);

    m_seat.reset(new Seat(this, m_display));
    m_pointer = m_seat->pointer();
    m_keyboard = m_seat->keyboard();

    wl_display_add_global(m_display, &wl_output_interface, this, bindOutput);
    wl_display_add_global(m_display, &wl_shell_interface, this, bindShell);

    m_loop = wl_display_get_event_loop(m_display);
    m_fd = wl_event_loop_get_fd(m_loop);
}
Пример #11
0
static void
cogland_compositor_create_surface (struct wl_client *wayland_client,
                                   struct wl_resource *wayland_compositor_resource,
                                   uint32_t id)
{
  CoglandCompositor *compositor =
    wl_resource_get_user_data (wayland_compositor_resource);
  CoglandSurface *surface = g_slice_new0 (CoglandSurface);

  surface->compositor = compositor;

  wl_signal_init (&surface->destroy_signal);

  surface->resource = wl_client_add_object (wayland_client,
                                            &wl_surface_interface,
                                            &cogland_surface_interface,
                                            id,
                                            surface);
  wl_resource_set_destructor (surface->resource,
                              cogland_surface_resource_destroy_cb);

  surface->pending.buffer_destroy_listener.notify =
    surface_handle_pending_buffer_destroy;
  wl_list_init (&surface->pending.frame_callback_list);
  region_init (&surface->pending.damage);

  compositor->surfaces = g_list_prepend (compositor->surfaces,
                                         surface);
}
Пример #12
0
void Animation::stop()
{
    if (isRunning()) {
        wl_list_remove(&m_animation.ani.link);
        wl_list_init(&m_animation.ani.link);
    }
}
Пример #13
0
static void
create_data_source(struct wl_client *client,
		   struct wl_resource *resource, uint32_t id)
{
	struct wl_data_source *source;

	source = malloc(sizeof *source);
	if (source == NULL) {
		wl_resource_post_no_memory(resource);
		return;
	}

	source->resource.destroy = destroy_data_source;
	source->resource.object.id = id;
	source->resource.object.interface = &wl_data_source_interface;
	source->resource.object.implementation =
		(void (**)(void)) &data_source_interface;
	source->resource.data = source;
	wl_list_init(&source->resource.destroy_listener_list);

	source->offer_interface = &data_offer_interface;
	source->cancel = data_source_cancel;

	wl_array_init(&source->mime_types);
	wl_client_add_resource(client, &source->resource);
}
Пример #14
0
static struct wl_event_source *
add_source(struct wl_event_loop *loop,
	   struct wl_event_source *source, uint32_t mask, void *data)
{
	struct epoll_event ep;

	if (source->fd < 0) {
		free(source);
		return NULL;
	}

	source->loop = loop;
	source->data = data;
	wl_list_init(&source->link);

	memset(&ep, 0, sizeof ep);
	if (mask & WL_EVENT_READABLE)
		ep.events |= EPOLLIN;
	if (mask & WL_EVENT_WRITABLE)
		ep.events |= EPOLLOUT;
	ep.data.ptr = source;

	if (epoll_ctl(loop->epoll_fd, EPOLL_CTL_ADD, source->fd, &ep) < 0) {
		close(source->fd);
		free(source);
		return NULL;
	}

	return source;
}
Пример #15
0
bool data_device_initialize(struct data_device * data_device)
{
    data_device->selection_destroy_listener.notify = &handle_selection_destroy;
    wl_signal_init(&data_device->event_signal);
    wl_list_init(&data_device->resources);

    return true;
}
Пример #16
0
static struct interface *
create_interface(struct location loc, const char *name, int version)
{
	struct interface *interface;

	interface = xzalloc(sizeof *interface);
	interface->loc = loc;
	interface->name = xstrdup(name);
	interface->uppercase_name = uppercase_dup(name);
	interface->version = version;
	interface->since = 1;
	wl_list_init(&interface->request_list);
	wl_list_init(&interface->event_list);
	wl_list_init(&interface->enumeration_list);

	return interface;
}
Пример #17
0
void Touch::focusDestroyed(wl_listener *listener, void *data)
{
    Q_UNUSED(data)
    Touch *touch = reinterpret_cast<Listener *>(listener)->parent;
    wl_list_remove(&touch->m_focusDestroyListener.listener.link);
    wl_list_init(&touch->m_focusDestroyListener.listener.link);

    touch->m_focus = 0;
    touch->m_focusResource = 0;
}
Пример #18
0
WL_EXPORT void
weston_output_init_zoom(struct weston_output *output)
{
	output->zoom.active = 0;
	output->zoom.increment = 0.07;
	output->zoom.max_level = 0.95;
	output->zoom.level = 0.0;
	output->zoom.trans_x = 0.0;
	output->zoom.trans_y = 0.0;
	weston_spring_init(&output->zoom.spring_z, 250.0, 0.0, 0.0);
	output->zoom.spring_z.friction = 1000;
	output->zoom.animation_z.frame = weston_zoom_frame_z;
	wl_list_init(&output->zoom.animation_z.link);
	weston_spring_init(&output->zoom.spring_xy, 250.0, 0.0, 0.0);
	output->zoom.spring_xy.friction = 1000;
	output->zoom.animation_xy.frame = weston_zoom_frame_xy;
	wl_list_init(&output->zoom.animation_xy.link);
	output->zoom.motion_listener.notify = motion;
}
Пример #19
0
Animation::Animation()
         : m_curve(nullptr)
{
    m_animation.parent = this;
    wl_list_init(&m_animation.ani.link);
    m_animation.ani.frame = [](struct weston_animation *base, struct weston_output *output, uint32_t msecs) {
        AnimWrapper *animation = container_of(base, AnimWrapper, ani);
        animation->parent->update(output, msecs);
    };
}
Пример #20
0
void Touch::setFocus(Surface *surface)
{
    wl_list_remove(&m_focusDestroyListener.listener.link);
    wl_list_init(&m_focusDestroyListener.listener.link);
    if (surface)
        wl_signal_add(&surface->resource()->handle->destroy_signal, &m_focusDestroyListener.listener);

    m_focus = surface;
    m_focusResource = surface ? resourceMap().value(surface->resource()->client()) : 0;
}
Пример #21
0
static void
wl_event_loop_process_destroy_list(struct wl_event_loop *loop)
{
	struct wl_event_source *source, *next;

	wl_list_for_each_safe(source, next, &loop->destroy_list, link)
		free(source);

	wl_list_init(&loop->destroy_list);
}
Пример #22
0
Touch::Touch(Compositor *compositor)
    : wl_touch()
    , m_compositor(compositor)
    , m_focus()
    , m_focusResource()
{
    m_focusDestroyListener.parent = this;
    m_focusDestroyListener.listener.notify = focusDestroyed;
    wl_list_init(&m_focusDestroyListener.listener.link);
}
Пример #23
0
Wayland_Surface *
e_mod_comp_wl_surface_create(int32_t x, int32_t y, int32_t w, int32_t h)
{
   Wayland_Surface *ws;

   LOGFN(__FILE__, __LINE__, __FUNCTION__);

   if (!(ws = calloc(1, sizeof(Wayland_Surface)))) return NULL;

   wl_list_init(&ws->link);
   wl_list_init(&ws->buffer_link);

   glGenTextures(1, &ws->texture);
   glBindTexture(GL_TEXTURE_2D, ws->texture);

   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

   ws->surface.resource.client = NULL;

   ws->x = x;
   ws->y = y;
   ws->w = w;
   ws->h = h;
   ws->buffer = NULL;

   ws->win = e_win_new(e_container_current_get(e_manager_current_get()));
   e_win_borderless_set(ws->win, EINA_TRUE);
   e_win_move_resize(ws->win, x, y, w, h);

   pixman_region32_init(&ws->damage);
   pixman_region32_init(&ws->opaque);

   wl_list_init(&ws->frame_callbacks);

   ws->buffer_destroy_listener.notify =
     _e_mod_comp_wl_surface_buffer_destroy_handle;

   /* ws->transform = NULL; */

   return ws;
}
Пример #24
0
/** Connect to Wayland display on an already open fd
 *
 * \param fd The fd to use for the connection
 * \return A \ref wl_display object or \c NULL on failure
 *
 * The wl_display takes ownership of the fd and will close it when the
 * display is destroyed.  The fd will also be closed in case of
 * failure.
 *
 * \memberof wl_display
 */
WL_EXPORT struct wl_display *
wl_display_connect_to_fd(int fd)
{
	struct wl_display *display;
	const char *debug;

	debug = getenv("WAYLAND_DEBUG");
	if (debug && (strstr(debug, "client") || strstr(debug, "1")))
		debug_client = 1;

	display = malloc(sizeof *display);
	if (display == NULL) {
		close(fd);
		return NULL;
	}

	memset(display, 0, sizeof *display);

	display->fd = fd;
	wl_map_init(&display->objects, WL_MAP_CLIENT_SIDE);
	wl_event_queue_init(&display->default_queue, display);
	wl_event_queue_init(&display->display_queue, display);
	wl_list_init(&display->event_queue_list);
	pthread_mutex_init(&display->mutex, NULL);
	pthread_cond_init(&display->reader_cond, NULL);
	display->reader_count = 0;

	wl_map_insert_new(&display->objects, 0, NULL);

	display->proxy.object.interface = &wl_display_interface;
	display->proxy.object.id = wl_map_insert_new(&display->objects, 0, display);
	display->proxy.display = display;
	display->proxy.object.implementation = (void(**)(void)) &display_listener;
	display->proxy.user_data = display;
	display->proxy.queue = &display->default_queue;
	display->proxy.flags = 0;
	display->proxy.refcount = 1;

	display->connection = wl_connection_create(display->fd);
	if (display->connection == NULL)
		goto err_connection;

	printf("<< %s:%u\n", __func__, __LINE__);
	return display;

 err_connection:
	pthread_mutex_destroy(&display->mutex);
	pthread_cond_destroy(&display->reader_cond);
	wl_map_release(&display->objects);
	close(display->fd);
	free(display);

	return NULL;
}
Пример #25
0
struct client *
client_create(int x, int y, int width, int height)
{
	struct client *client;
	struct surface *surface;

	wl_log_set_handler_client(log_handler);

	/* connect to display */
	client = xzalloc(sizeof *client);
	client->wl_display = wl_display_connect(NULL);
	assert(client->wl_display);
	wl_list_init(&client->global_list);

	/* setup registry so we can bind to interfaces */
	client->wl_registry = wl_display_get_registry(client->wl_display);
	wl_registry_add_listener(client->wl_registry, &registry_listener, client);

	/* trigger global listener */
	wl_display_dispatch(client->wl_display);
	wl_display_roundtrip(client->wl_display);

	/* must have WL_SHM_FORMAT_ARGB32 */
	assert(client->has_argb);

	/* must have wl_test interface */
	assert(client->test);

	/* must have an output */
	assert(client->output);

	/* initialize the client surface */
	surface = xzalloc(sizeof *surface);
	surface->wl_surface =
		wl_compositor_create_surface(client->wl_compositor);
	assert(surface->wl_surface);

	wl_surface_add_listener(surface->wl_surface, &surface_listener,
				surface);

	client->surface = surface;
	wl_surface_set_user_data(surface->wl_surface, surface);

	surface->width = width;
	surface->height = height;
	surface->wl_buffer = create_shm_buffer(client, width, height,
					       &surface->data);

	memset(surface->data, 64, width * height * 4);

	move_client(client, x, y);

	return client;
}
Пример #26
0
BaseAnimation::BaseAnimation()
         : m_speed(-1.)
         , m_curve(nullptr)
{
    m_animation.parent = this;
    wl_list_init(&m_animation.ani.link);
    m_animation.ani.frame = [](weston_animation *base, weston_output *output, uint32_t msecs) {
        AnimWrapper *animation = wl_container_of(base, (AnimWrapper *)nullptr, ani);
        animation->parent->tick(output, msecs);
    };
}
Пример #27
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);
}
Пример #28
0
int main(void)
{
	struct wl_list list;
	wl_list_init(&list);

	struct item *i1 = malloc(sizeof *i1);
	wl_list_insert(&list, &i1->link);
	i1->number = 8;

	assert(list.next == &i1->link);
	return 0;
}
Пример #29
0
WL_EXPORT struct wl_event_loop *
wl_event_loop_create(void)
{
	struct wl_event_loop *loop;

	loop = malloc(sizeof *loop);
	if (loop == NULL)
		return NULL;

	loop->epoll_fd = wl_os_epoll_create_cloexec();
	if (loop->epoll_fd < 0) {
		free(loop);
		return NULL;
	}
	wl_list_init(&loop->check_list);
	wl_list_init(&loop->idle_list);
	wl_list_init(&loop->destroy_list);

	wl_signal_init(&loop->destroy_signal);

	return loop;
}
Пример #30
0
static struct message *
create_message(struct location loc, const char *name)
{
	struct message *message;

	message = xzalloc(sizeof *message);
	message->loc = loc;
	message->name = xstrdup(name);
	message->uppercase_name = uppercase_dup(name);
	wl_list_init(&message->arg_list);

	return message;
}