Exemple #1
0
ServerWaylandBuffer::~ServerWaylandBuffer()
{
    if (m_buf)
        wl_buffer_destroy(m_buf);

    m_gralloc->unregisterBuffer(m_gralloc, handle);
    native_handle_close(handle);
    native_handle_delete(const_cast<native_handle_t *>(handle));
    wl_array_release(&ints);
    wl_array_release(&fds);
}
Exemple #2
0
static void
destroy_wlegl_handle(struct wl_resource *resource)
{
	struct wlegl_handle *handle = wl_resource_get_user_data(resource);
	int *fd;

	wl_array_for_each(fd, &handle->fds)
		close(fd);

	wl_array_release(&handle->ints);
	wl_array_release(&handle->fds);

	free(handle);
}
Exemple #3
0
static void
selection_offer_keyboard_focus(void *data,
			       struct wl_selection_offer *selection_offer,
			       struct wl_input_device *input_device)
{
	struct selection_offer *offer = data;
	struct input *input;
	char **p, **end;

	if (input_device == NULL) {
		printf("selection offer retracted %p\n", selection_offer);
		input = offer->input;
		input->offer = NULL;
		wl_selection_offer_destroy(selection_offer);
		wl_array_release(&offer->types);
		free(offer);
		return;
	}

	input = wl_input_device_get_user_data(input_device);
	printf("new selection offer %p:", selection_offer);

	offer->input = input;
	input->offer = offer;
	end = offer->types.data + offer->types.size;
	for (p = offer->types.data; p < end; p++)
		printf(" %s", *p);

	printf("\n");
}
void WaylandNativeWindowBuffer::wlbuffer_from_native_handle(struct android_wlegl *android_wlegl,
                                                            struct wl_display *display, struct wl_event_queue *queue)
{
    struct wl_array ints;
    int *ints_data;
    struct android_wlegl_handle *wlegl_handle;

    wl_array_init(&ints);
    ints_data = (int*) wl_array_add(&ints, handle->numInts*sizeof(int));
    memcpy(ints_data, handle->data + handle->numFds, handle->numInts*sizeof(int));

    wlegl_handle = android_wlegl_create_handle(android_wlegl, handle->numFds, &ints);

    wl_array_release(&ints);

    for (int i = 0; i < handle->numFds; i++) {
        android_wlegl_handle_add_fd(wlegl_handle, handle->data[i]);
    }

    wlbuffer = android_wlegl_create_buffer(android_wlegl,
            width, height, stride,
            format, usage, wlegl_handle);

    android_wlegl_handle_destroy(wlegl_handle);

    creation_callback = wl_display_sync(display);
    wl_callback_add_listener(creation_callback, &buffer_create_sync_listener, &creation_callback);
    wl_proxy_set_queue((struct wl_proxy *)creation_callback, queue);
}
Exemple #5
0
static void
weston_wm_send_incr_chunk(struct weston_wm *wm)
{
	int length;

	weston_log("property deleted\n");

	wm->selection_property_set = 0;
	if (wm->flush_property_on_delete) {
		weston_log("setting new property, %zu bytes\n",
			wm->source_data.size);
		wm->flush_property_on_delete = 0;
		length = weston_wm_flush_source_data(wm);

		if (wm->data_source_fd >= 0) {
			wm->property_source =
				wl_event_loop_add_fd(wm->server->loop,
						     wm->data_source_fd,
						     WL_EVENT_READABLE,
						     weston_wm_read_data_source,
						     wm);
		} else if (length > 0) {
			/* Transfer is all done, but queue a flush for
			 * the delete of the last chunk so we can set
			 * the 0 sized propert to signal the end of
			 * the transfer. */
			wm->flush_property_on_delete = 1;
			wl_array_release(&wm->source_data);
		} else {
			wm->selection_request.requestor = XCB_NONE;
		}
	}
}
Exemple #6
0
static void
clipboard_source_unref(struct clipboard_source *source)
{
	char **s;

	source->refcount--;
	if (source->refcount > 0)
		return;

	if (source->event_source)
		wl_event_source_remove(source->event_source);
	wl_signal_emit(&source->base.resource.destroy_signal,
		       &source->base.resource);
	s = source->base.mime_types.data;
	free(*s);
	wl_array_release(&source->base.mime_types);
	wl_array_release(&source->contents);
	free(source);
}
Exemple #7
0
int WaylandNativeWindow::queueBuffer(BaseNativeWindowBuffer* buffer, int fenceFd){
    WaylandNativeWindowBuffer *backbuf = (WaylandNativeWindowBuffer *) buffer;
    int ret = 0;
    lock();
    backbuf->busy = 2;
    unlock();
    while (this->frame_callback && ret != -1)
     	ret = wl_display_dispatch_queue(m_display, this->wl_queue);
    
    if (ret < 0)
	return ret;

    lock();
    this->frame_callback = wl_surface_frame(m_window->surface);
    wl_callback_add_listener(this->frame_callback, &frame_listener, this);
    wl_proxy_set_queue((struct wl_proxy *) this->frame_callback, this->wl_queue);

    if (backbuf->wlbuffer == NULL)	
    {
	    struct wl_array ints;
	    int *ints_data;
	    struct android_wlegl_handle *wlegl_handle;
	    buffer_handle_t handle;
		
	    handle = backbuf->handle;

	    wl_array_init(&ints);
	    ints_data = (int*) wl_array_add(&ints, handle->numInts*sizeof(int));
	    memcpy(ints_data, handle->data + handle->numFds, handle->numInts*sizeof(int));
	    wlegl_handle = android_wlegl_create_handle(m_android_wlegl, handle->numFds, &ints);
	    wl_array_release(&ints);
	    for (int i = 0; i < handle->numFds; i++) {
		android_wlegl_handle_add_fd(wlegl_handle, handle->data[i]);
	    }

	    backbuf->wlbuffer = android_wlegl_create_buffer(m_android_wlegl,
			backbuf->width, backbuf->height, backbuf->stride,
			backbuf->format, backbuf->usage, wlegl_handle);

	    android_wlegl_handle_destroy(wlegl_handle);
	    backbuf->common.incRef(&backbuf->common);

	    TRACE("Add listener for %p with %p inside", backbuf, backbuf->wlbuffer);
	    wl_buffer_add_listener(backbuf->wlbuffer, &wl_buffer_listener, this);
	    wl_proxy_set_queue((struct wl_proxy *) backbuf->wlbuffer,
				this->wl_queue);
    }
    wl_surface_attach(m_window->surface, backbuf->wlbuffer, 0, 0); 
    wl_surface_damage(m_window->surface, 0, 0, backbuf->width, backbuf->height);
    wl_surface_commit(m_window->surface);
    fronted.push_back(backbuf);   
 
    unlock();
    return NO_ERROR;
}
static void
destroy_data_source (struct wl_resource *resource)
{
  MetaWaylandDataSource *source = wl_resource_get_user_data (resource);
  char **p;

  wl_array_for_each (p, &source->mime_types) free (*p);

  wl_array_release (&source->mime_types);

  g_slice_free (MetaWaylandDataSource, source);
}
Exemple #9
0
static void
input_method_activate(void *data,
		      struct wl_input_method *input_method,
		      struct wl_input_method_context *context)
{
	struct virtual_keyboard *keyboard = data;
	struct wl_array modifiers_map;
	const struct layout *layout;

	keyboard->keyboard->state = keyboardstate_default;

	if (keyboard->context)
		wl_input_method_context_destroy(keyboard->context);

	if (keyboard->preedit_string)
		free(keyboard->preedit_string);

	keyboard->preedit_string = strdup("");
	keyboard->content_hint = 0;
	keyboard->content_purpose = 0;
	free(keyboard->preferred_language);
	keyboard->preferred_language = NULL;
	free(keyboard->surrounding_text);
	keyboard->surrounding_text = NULL;

	keyboard->serial = 0;

	keyboard->context = context;
	wl_input_method_context_add_listener(context,
					     &input_method_context_listener,
					     keyboard);

	wl_array_init(&modifiers_map);
	keysym_modifiers_add(&modifiers_map, "Shift");
	keysym_modifiers_add(&modifiers_map, "Control");
	keysym_modifiers_add(&modifiers_map, "Mod1");
	wl_input_method_context_modifiers_map(context, &modifiers_map);
	keyboard->keysym.shift_mask = keysym_modifiers_get_mask(&modifiers_map, "Shift");
	wl_array_release(&modifiers_map);

	layout = get_current_layout(keyboard);

	window_schedule_resize(keyboard->keyboard->window,
			       layout->columns * key_width,
			       layout->rows * key_height);

	wl_input_method_context_language(context, keyboard->serial, layout->language);
	wl_input_method_context_text_direction(context, keyboard->serial, layout->text_direction);

	widget_schedule_redraw(keyboard->keyboard->widget);
}
Exemple #10
0
static void
destroy_data_source(struct wl_resource *resource)
{
	struct wl_data_source *source =
		container_of(resource, struct wl_data_source, resource);
	char **p;

	wl_array_for_each(p, &source->mime_types)
		free(*p);

	wl_array_release(&source->mime_types);

	source->resource.object.id = 0;
}
Exemple #11
0
void KeyboardInterface::Private::sendEnter(SurfaceInterface *surface, quint32 serial)
{
    wl_array keys;
    wl_array_init(&keys);
    const auto states = seat->pressedKeys();
    for (auto it = states.begin(); it != states.end(); ++it) {
        uint32_t *k = reinterpret_cast<uint32_t*>(wl_array_add(&keys, sizeof(uint32_t)));
        *k = *it;
    }
    wl_keyboard_send_enter(resource, serial, surface->resource(), &keys);
    wl_array_release(&keys);

    sendModifiers();
}
Exemple #12
0
static void
destroy_data_source(struct wl_resource *resource)
{
	struct wl_data_source *source =
		container_of(resource, struct wl_data_source, resource);
	char **p, **end;

	end = source->mime_types.data + source->mime_types.size;
	for (p = source->mime_types.data; p < end; p++)
		free(*p);

	wl_array_release(&source->mime_types);

	source->resource.object.id = 0;
}
Exemple #13
0
static struct clipboard_source *
clipboard_source_create(struct clipboard *clipboard,
			const char *mime_type, uint32_t serial, int fd)
{
	struct wl_display *display = clipboard->seat->compositor->wl_display;
	struct wl_event_loop *loop = wl_display_get_event_loop(display);
	struct clipboard_source *source;
	char **s;

	source = zalloc(sizeof *source);
	if (source == NULL)
		return NULL;

	wl_array_init(&source->contents);
	wl_array_init(&source->base.mime_types);
	source->base.resource = NULL;
	source->base.accept = clipboard_source_accept;
	source->base.send = clipboard_source_send;
	source->base.cancel = clipboard_source_cancel;
	wl_signal_init(&source->base.destroy_signal);
	source->refcount = 1;
	source->clipboard = clipboard;
	source->serial = serial;
	source->fd = fd;

	s = wl_array_add(&source->base.mime_types, sizeof *s);
	if (s == NULL)
		goto err_add;
	*s = strdup(mime_type);
	if (*s == NULL)
		goto err_strdup;
	source->event_source =
		wl_event_loop_add_fd(loop, fd, WL_EVENT_READABLE,
				     clipboard_source_data, source);
	if (source->event_source == NULL)
		goto err_source;

	return source;

 err_source:
	free(*s);
 err_strdup:
	wl_array_release(&source->base.mime_types);
 err_add:
	free(source);

	return NULL;
}
Exemple #14
0
static void
destroy_data_source(struct wl_resource *resource)
{
	struct weston_data_source *source =
		wl_resource_get_user_data(resource);
	char **p;

	wl_signal_emit(&source->destroy_signal, source);

	wl_array_for_each(p, &source->mime_types)
		free(*p);

	wl_array_release(&source->mime_types);

	free(source);
}
Exemple #15
0
static void
server_wlegl_get_server_buffer_handle(wl_client *client, wl_resource *res, uint32_t id, int32_t width, int32_t height, int32_t format, int32_t usage)
{
	if (width == 0 || height == 0) {
		wl_resource_post_error(res, 0, "invalid buffer size: %u,%u\n", width, height);
		return;
	}

	server_wlegl *wlegl = server_wlegl_from(res);

	wl_resource *resource = wl_resource_create(client, &android_wlegl_server_buffer_handle_interface, wl_resource_get_version(res), id);

	buffer_handle_t _handle;
	int _stride;

	usage |= GRALLOC_USAGE_HW_COMPOSER;

	int r = hybris_gralloc_allocate(width, height, format, usage, &_handle, (uint32_t*)&_stride);
        if (r) {
            HYBRIS_ERROR_LOG(SERVER_WLEGL, "failed to allocate buffer\n");
        }
	server_wlegl_buffer *buffer = server_wlegl_buffer_create_server(client, width, height, _stride, format, usage, _handle, wlegl);

	struct wl_array ints;
	int *ints_data;
	wl_array_init(&ints);
	ints_data = (int*) wl_array_add(&ints, _handle->numInts * sizeof(int));
	memcpy(ints_data, _handle->data + _handle->numFds, _handle->numInts * sizeof(int));

	android_wlegl_server_buffer_handle_send_buffer_ints(resource, &ints);
	wl_array_release(&ints);

	for (int i = 0; i < _handle->numFds; i++) {
		android_wlegl_server_buffer_handle_send_buffer_fd(resource, _handle->data[i]);
	}

	android_wlegl_server_buffer_handle_send_buffer(resource, buffer->resource, format, _stride);
	wl_resource_destroy(resource);
}
static void
xdg_surface_role_configure (MetaWaylandSurfaceRoleShellSurface *shell_surface_role,
                            int                                 new_width,
                            int                                 new_height,
                            MetaWaylandSerial                  *sent_serial)
{
  MetaWaylandXdgSurface *xdg_surface =
    META_WAYLAND_XDG_SURFACE (shell_surface_role);
  MetaWaylandSurfaceRole *surface_role =
    META_WAYLAND_SURFACE_ROLE (shell_surface_role);
  MetaWaylandSurface *surface =
    meta_wayland_surface_role_get_surface (surface_role);
  struct wl_client *client = wl_resource_get_client (xdg_surface->resource);
  struct wl_display *display = wl_client_get_display (client);
  uint32_t serial = wl_display_next_serial (display);
  struct wl_array states;

  if (!xdg_surface->resource)
    return;

  wl_array_init (&states);
  fill_states (&states, surface->window);

  xdg_surface_send_configure (xdg_surface->resource,
                              new_width, new_height,
                              &states,
                              serial);

  wl_array_release (&states);

  if (sent_serial)
    {
      sent_serial->set = TRUE;
      sent_serial->value = serial;
    }
}
void WaylandNativeWindowBuffer::wlbuffer_from_native_handle(struct android_wlegl *android_wlegl)
{
    struct wl_array ints;
    int *ints_data;
    struct android_wlegl_handle *wlegl_handle;

    wl_array_init(&ints);
    ints_data = (int*) wl_array_add(&ints, handle->numInts*sizeof(int));
    memcpy(ints_data, handle->data + handle->numFds, handle->numInts*sizeof(int));

    wlegl_handle = android_wlegl_create_handle(android_wlegl, handle->numFds, &ints);

    wl_array_release(&ints);

    for (int i = 0; i < handle->numFds; i++) {
        android_wlegl_handle_add_fd(wlegl_handle, handle->data[i]);
    }

    wlbuffer = android_wlegl_create_buffer(android_wlegl,
            width, height, stride,
            format, usage, wlegl_handle);

    android_wlegl_handle_destroy(wlegl_handle);
}
Exemple #18
0
TouchExtensionGlobal::~TouchExtensionGlobal()
{
    wl_array_release(&m_rawdata_array);
}
Exemple #19
0
static int
weston_wm_read_data_source(int fd, uint32_t mask, void *data)
{
	struct weston_wm *wm = data;
	int len, current, available;
	void *p;

	current = wm->source_data.size;
	if (wm->source_data.size < incr_chunk_size)
		p = wl_array_add(&wm->source_data, incr_chunk_size);
	else
		p = (char *) wm->source_data.data + wm->source_data.size;
	available = wm->source_data.alloc - current;

	len = read(fd, p, available);
	if (len == -1) {
		weston_log("read error from data source: %m\n");
		weston_wm_send_selection_notify(wm, XCB_ATOM_NONE);
		wl_event_source_remove(wm->property_source);
		close(fd);
		wl_array_release(&wm->source_data);
	}

	weston_log("read %d (available %d, mask 0x%x) bytes: \"%.*s\"\n",
		len, available, mask, len, (char *) p);

	wm->source_data.size = current + len;
	if (wm->source_data.size >= incr_chunk_size) {
		if (!wm->incr) {
			weston_log("got %zu bytes, starting incr\n",
				wm->source_data.size);
			wm->incr = 1;
			xcb_change_property(wm->conn,
					    XCB_PROP_MODE_REPLACE,
					    wm->selection_request.requestor,
					    wm->selection_request.property,
					    wm->atom.incr,
					    32, /* format */
					    1, &incr_chunk_size);
			wm->selection_property_set = 1;
			wm->flush_property_on_delete = 1;
			wl_event_source_remove(wm->property_source);
			weston_wm_send_selection_notify(wm, wm->selection_request.property);
		} else if (wm->selection_property_set) {
			weston_log("got %zu bytes, waiting for "
				"property delete\n", wm->source_data.size);

			wm->flush_property_on_delete = 1;
			wl_event_source_remove(wm->property_source);
		} else {
			weston_log("got %zu bytes, "
				"property deleted, seting new property\n",
				wm->source_data.size);
			weston_wm_flush_source_data(wm);
		}
	} else if (len == 0 && !wm->incr) {
		weston_log("non-incr transfer complete\n");
		/* Non-incr transfer all done. */
		weston_wm_flush_source_data(wm);
		weston_wm_send_selection_notify(wm, wm->selection_request.property);
		xcb_flush(wm->conn);
		wl_event_source_remove(wm->property_source);
		close(fd);
		wl_array_release(&wm->source_data);
		wm->selection_request.requestor = XCB_NONE;
	} else if (len == 0 && wm->incr) {
		weston_log("incr transfer complete\n");

		wm->flush_property_on_delete = 1;
		if (wm->selection_property_set) {
			weston_log("got %zu bytes, waiting for "
				"property delete\n", wm->source_data.size);
		} else {
			weston_log("got %zu bytes, "
				"property deleted, seting new property\n",
				wm->source_data.size);
			weston_wm_flush_source_data(wm);
		}
		xcb_flush(wm->conn);
		wl_event_source_remove(wm->property_source);
		close(wm->data_source_fd);
		wm->data_source_fd = -1;
		close(fd);
	} else {
		weston_log("nothing happened, buffered the bytes\n");
	}

	return 1;
}
 ~QWaylandBrcmBuffer()
 {
     wl_array_release(&m_array);
 }
Exemple #21
0
void 
_ecore_wl_input_del(Ecore_Wl_Input *input)
{
   if (!input) return;

   _pointer_update_stop(input);

   if (input->cursor_name) eina_stringshare_del(input->cursor_name);
   input->cursor_name = NULL;

   if (input->touch_focus)
     {
        input->touch_focus = NULL;
     }

   if (input->pointer_focus)
     {
        Ecore_Wl_Window *win = NULL;

        if ((win = input->pointer_focus))
          win->pointer_device = NULL;

        input->pointer_focus = NULL;
     }

   if (input->keyboard_focus)
     {
        Ecore_Wl_Window *win = NULL;

        if ((win = input->keyboard_focus))
          win->keyboard_device = NULL;

        input->keyboard_focus = NULL;
     }

   if (input->data_types.data)
     {
        char **t;

        wl_array_for_each(t, &input->data_types)
          free(*t);
        wl_array_release(&input->data_types);
     }

   if (input->data_source) wl_data_source_destroy(input->data_source);
   input->data_source = NULL;

   if (input->drag_source) _ecore_wl_dnd_del(input->drag_source);
   input->drag_source = NULL;

   if (input->selection_source) _ecore_wl_dnd_del(input->selection_source);
   input->selection_source = NULL;

   if (input->data_device) wl_data_device_destroy(input->data_device);

   if (input->xkb.state)
     xkb_state_unref(input->xkb.state);
   if (input->xkb.keymap)
     xkb_map_unref(input->xkb.keymap);

   if (input->cursor_surface)
     wl_surface_destroy(input->cursor_surface);

   _ecore_wl_disp->inputs = eina_inlist_remove
      (_ecore_wl_disp->inputs, EINA_INLIST_GET(input));
   if (input->seat) wl_seat_destroy(input->seat);

   if (input->repeat.tmr) ecore_timer_del(input->repeat.tmr);
   input->repeat.tmr = NULL;

   free(input);
}
Exemple #22
0
WL_EXPORT void
wl_map_release(struct wl_map *map)
{
	wl_array_release(&map->client_entries);
	wl_array_release(&map->server_entries);
}