예제 #1
0
파일: extensions.c 프로젝트: hhw/sway
void register_extensions(void) {
    wl_global_create(wlc_get_wl_display(), &desktop_shell_interface, 3, NULL, desktop_shell_bind);
    desktop_shell.backgrounds = create_list();
    desktop_shell.panels = create_list();
    desktop_shell.lock_surfaces = create_list();
    desktop_shell.is_locked = false;
    wl_global_create(wlc_get_wl_display(), &lock_interface, 1, NULL, swaylock_bind);
}
예제 #2
0
파일: shell.c 프로젝트: dapus/swc
bool swc_shell_initialize()
{
    shell.global = wl_global_create(swc.display, &wl_shell_interface, 1,
                                    NULL, &bind_shell);

    return shell.global;
}
예제 #3
0
Global::Global(Compositor *c, const wl_interface *i, uint32_t v)
{
    m_global = wl_global_create(c->m_display, i, v, this,
                                [](wl_client *client, void *data, uint32_t version, uint32_t id) {
                                    static_cast<Global *>(data)->bind(client, version, id);
                                });
}
예제 #4
0
bool data_device_manager_initialize(void)
{
    data_device_manager.global
        = wl_global_create(swc.display, &wl_data_device_manager_interface, 1,
                           NULL, &bind_data_device_manager);

    return data_device_manager.global != NULL;
}
예제 #5
0
void
meta_wayland_pointer_gestures_init (MetaWaylandCompositor *compositor)
{
  wl_global_create (compositor->wayland_display,
                    &zwp_pointer_gestures_v1_interface,
                    META_ZWP_POINTER_GESTURES_V1_VERSION,
                    NULL, bind_pointer_gestures);
}
예제 #6
0
WL_EXPORT int
wl_display_init_shm(struct wl_display *display)
{
	if (!wl_global_create(display, &wl_shm_interface, 1, NULL, bind_shm))
		return -1;

	return 0;
}
예제 #7
0
int
wl_display_init_gdl(struct wl_display *display)
{
	if (!wl_global_create(display, &wl_gdl_interface, 1, NULL, bind_gdl))
		return -1;

	return 0;
}
예제 #8
0
void compositor::initialize(wl_display* display) {
    static compositor comp{display};

    wl_global* const g = wl_global_create(display, &wl_compositor_interface,
                                          1, &comp, handle_bind);
    assert(g);

    wl_display_init_shm(display);
}
예제 #9
0
void
meta_wayland_data_device_manager_init (MetaWaylandCompositor *compositor)
{
  if (wl_global_create (compositor->wayland_display,
			&wl_data_device_manager_interface,
			META_WL_DATA_DEVICE_MANAGER_VERSION,
			NULL, bind_manager) == NULL)
    g_error ("Could not create data_device");
}
예제 #10
0
void
meta_wayland_wl_shell_init (MetaWaylandCompositor *compositor)
{
  if (wl_global_create (compositor->wayland_display,
                        &wl_shell_interface,
                        META_WL_SHELL_VERSION,
                        compositor, bind_wl_shell) == NULL)
    g_error ("Failed to register a global wl-shell object");
}
예제 #11
0
/** Advertise linux_dmabuf support
 *
 * Calling this initializes the zwp_linux_dmabuf protocol support, so that
 * the interface will be advertised to clients. Essentially it creates a
 * global. Do not call this function multiple times in the compositor's
 * lifetime. There is no way to deinit explicitly, globals will be reaped
 * when the wl_display gets destroyed.
 *
 * \param compositor The compositor to init for.
 * \return Zero on success, -1 on failure.
 */
WL_EXPORT int
linux_dmabuf_setup(struct weston_compositor *compositor)
{
	if (!wl_global_create(compositor->wl_display,
			      &zwp_linux_dmabuf_v1_interface, 1,
			      compositor, bind_linux_dmabuf))
		return -1;

	return 0;
}
예제 #12
0
WL_EXPORT int
wl_data_device_manager_init(struct wl_display *display)
{
	if (wl_global_create(display,
			     &wl_data_device_manager_interface, 1,
			     NULL, bind_manager) == NULL)
		return -1;

	return 0;
}
예제 #13
0
void
meta_wayland_init_viewporter (MetaWaylandCompositor *compositor)
{
  if (wl_global_create (compositor->wayland_display,
                        &wp_viewporter_interface,
                        META_WP_VIEWPORTER_VERSION,
                        compositor,
                        wp_viewporter_bind) == NULL)
    g_error ("Failed to register a global wl-viewporter object");
}
예제 #14
0
파일: meta-wayland.c 프로젝트: wolfv/mutter
void
meta_wayland_init (void)
{
  MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
  GSource *wayland_event_source;

  if (!wl_global_create (compositor->wayland_display,
			 &wl_compositor_interface,
			 META_WL_COMPOSITOR_VERSION,
			 compositor, compositor_bind))
    g_error ("Failed to register the global wl_compositor");

  wayland_event_source = wayland_event_source_new (compositor->wayland_display);

  /* XXX: Here we are setting the wayland event source to have a
   * slightly lower priority than the X event source, because we are
   * much more likely to get confused being told about surface changes
   * relating to X clients when we don't know what's happened to them
   * according to the X protocol.
   *
   * At some point we could perhaps try and get the X protocol proxied
   * over the wayland protocol so that we don't have to worry about
   * synchronizing the two command streams. */
  g_source_set_priority (wayland_event_source, GDK_PRIORITY_EVENTS + 1);
  g_source_attach (wayland_event_source, NULL);

  wl_display_init_shm (compositor->wayland_display);

  meta_wayland_outputs_init (compositor);
  meta_wayland_data_device_manager_init (compositor);
  meta_wayland_shell_init (compositor);
  meta_wayland_seat_init (compositor);

  /* FIXME: find the first free name instead */
  compositor->display_name = wl_display_add_socket_auto (compositor->wayland_display);
  if (compositor->display_name == NULL)
    g_error ("Failed to create socket");

  /* XXX: It's important that we only try and start xwayland after we
   * have initialized EGL because EGL implements the "wl_drm"
   * interface which xwayland requires to determine what drm device
   * name it should use.
   *
   * By waiting until we've shown the stage above we ensure that the
   * underlying GL resources for the surface have also been allocated
   * and so EGL must be initialized by this point.
   */

  if (!meta_xwayland_start (&compositor->xwayland_manager, compositor->wayland_display))
    g_error ("Failed to start X Wayland");

  set_gnome_env ("DISPLAY", meta_wayland_get_xwayland_display_name (compositor));
  set_gnome_env ("WAYLAND_DISPLAY", meta_wayland_get_wayland_display_name (compositor));
}
예제 #15
0
파일: panel_manager.c 프로젝트: ibab/swc
bool panel_manager_initialize()
{
    panel_manager.global = wl_global_create(swc.display,
                                            &swc_panel_manager_interface, 1,
                                            NULL, &bind_panel_manager);

    if (!panel_manager.global)
        return false;

    return true;
}
예제 #16
0
파일: tag.c 프로젝트: Kinokoio/velox
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;
}
예제 #17
0
server_wlegl *
server_wlegl_create(struct wl_display *display)
{
	struct server_wlegl *wlegl;

	wlegl = new server_wlegl;

	wlegl->display = display;
	wlegl->global = wl_global_create(display, &android_wlegl_interface, 2,
					      wlegl, server_wlegl_bind);

	return wlegl;
}
예제 #18
0
static MetaWaylandOutput *
meta_wayland_output_new (MetaWaylandCompositor *compositor,
                         MetaMonitorInfo *monitor_info)
{
  MetaWaylandOutput *wayland_output;

  wayland_output = g_object_new (META_TYPE_WAYLAND_OUTPUT, NULL);
  wayland_output->global = wl_global_create (compositor->wayland_display,
                                             &wl_output_interface,
                                             META_WL_OUTPUT_VERSION,
                                             wayland_output, bind_output);
  wayland_output_set_monitor_info (wayland_output, monitor_info);

  return wayland_output;
}
예제 #19
0
static GHashTable *
meta_wayland_compositor_update_outputs (MetaWaylandCompositor *compositor,
                                        MetaMonitorManager    *monitors)
{
  MetaOutput *outputs;
  unsigned int i, n_outputs;
  GHashTable *new_table;

  outputs = meta_monitor_manager_get_outputs (monitors, &n_outputs);
  new_table = g_hash_table_new_full (NULL, NULL, NULL, wayland_output_destroy_notify);

  for (i = 0; i < n_outputs; i++)
    {
      MetaOutput *output = &outputs[i];
      MetaWaylandOutput *wayland_output;

      /* wayland does not expose disabled outputs */
      if (output->crtc == NULL)
        {
          g_hash_table_remove (compositor->outputs, GSIZE_TO_POINTER (output->winsys_id));
          continue;
        }

      wayland_output = g_hash_table_lookup (compositor->outputs, GSIZE_TO_POINTER (output->winsys_id));

      if (wayland_output)
        {
          g_hash_table_steal (compositor->outputs, GSIZE_TO_POINTER (output->winsys_id));
        }
      else
        {
          wayland_output = g_slice_new0 (MetaWaylandOutput);
          wayland_output->global = wl_global_create (compositor->wayland_display,
                                                     &wl_output_interface,
						     META_WL_OUTPUT_VERSION,
                                                     wayland_output, bind_output);
        }

      wayland_output_update_for_output (wayland_output, output);
      g_hash_table_insert (new_table, GSIZE_TO_POINTER (output->winsys_id), wayland_output);
    }

  g_hash_table_destroy (compositor->outputs);
  return new_table;
}
예제 #20
0
RestrictedGlobal::RestrictedGlobal(Compositor *c, const wl_interface *i, uint32_t v)
                : m_authorizer(c->authorizer())
                , m_interface(i)
{
    m_global = wl_global_create(c->m_display, i, v, this,
                                [](wl_client *client, void *data, uint32_t version, uint32_t id) {
                                    RestrictedGlobal *_this = static_cast<RestrictedGlobal *>(data);
                                    if (_this->m_authorizer->isClientTrusted(_this->m_interface->name, client)) {
                                        _this->bind(client, version, id);
                                    } else {
                                        wl_resource *resource = wl_resource_create(client, _this->m_interface, version, id);
                                        wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
                                                               "permission to bind the global interface '%s' denied", _this->m_interface->name);
                                        wl_resource_destroy(resource);
                                    }
                                });
    m_authorizer->addRestrictedInterface(i->name);
}
예제 #21
0
파일: wayland-drm.c 프로젝트: UIKit0/mesa-1
struct wl_drm *
wayland_drm_init(struct wl_display *display, char *device_name,
                 struct wayland_drm_callbacks *callbacks, void *user_data,
                 uint32_t flags)
{
	struct wl_drm *drm;

	drm = malloc(sizeof *drm);

	drm->display = display;
	drm->device_name = strdup(device_name);
	drm->callbacks = callbacks;
	drm->user_data = user_data;
        drm->flags = flags;

	wl_global_create(display, &wl_drm_interface, 2, drm, bind_drm);

	return drm;
}
예제 #22
0
WL_EXPORT int
controller_module_init(struct weston_compositor *compositor,
		       int *argc, char *argv[],
		       const struct ivi_layout_interface *iface,
		       size_t iface_version)
{
	struct wl_event_loop *loop;
	struct test_launcher *launcher;
	const char *path;

	/* strict check, since this is an internal test module */
	if (iface_version != sizeof(*iface)) {
		weston_log("fatal: controller interface mismatch\n");
		return -1;
	}

	path = getenv("WESTON_BUILD_DIR");
	if (!path) {
		weston_log("test setup failure: WESTON_BUILD_DIR not set\n");
		return -1;
	}

	launcher = zalloc(sizeof *launcher);
	if (!launcher)
		return -1;

	launcher->compositor = compositor;
	launcher->layout_interface = iface;
	snprintf(launcher->exe, sizeof launcher->exe,
		 "%s/ivi-layout.ivi", path);

	if (wl_global_create(compositor->wl_display,
			     &weston_test_runner_interface, 1,
			     launcher, bind_runner) == NULL)
		return -1;

	loop = wl_display_get_event_loop(compositor->wl_display);
	wl_event_loop_add_idle(loop, idle_launch_client, launcher);

	return 0;
}
예제 #23
0
파일: zoom.c 프로젝트: bpeel/weston
void
text_cursor_position_notifier_create(struct weston_compositor *ec)
{
	struct text_cursor_position *text_cursor_position;

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

	text_cursor_position->ec = ec;

	text_cursor_position->global =
		wl_global_create(ec->wl_display,
				 &text_cursor_position_interface, 1,
				 text_cursor_position,
				 bind_text_cursor_position);

	text_cursor_position->destroy_listener.notify =
		text_cursor_position_notifier_destroy;
	wl_signal_add(&ec->destroy_signal, &text_cursor_position->destroy_listener);
}
예제 #24
0
파일: shm.c 프로젝트: C0DEHERO/swc
bool swc_shm_initialize()
{
    if (!(swc.shm->context = wld_pixman_create_context()))
        goto error0;

    if (!(swc.shm->renderer = wld_create_renderer(swc.shm->context)))
        goto error1;

    shm.global = wl_global_create(swc.display, &wl_shm_interface, 1,
                                  NULL, &bind_shm);

    if (!shm.global)
        goto error2;

    return true;

  error2:
    wld_destroy_renderer(swc.shm->renderer);
  error1:
    wld_destroy_context(swc.shm->context);
  error0:
    return false;
}
예제 #25
0
파일: drm.c 프로젝트: daurnimator/arcan
static struct wl_drm* wayland_drm_init(struct wl_display *display,
	char *device_name, struct wayland_drm_callbacks *callbacks, void *user_data,
	uint32_t flags)
{
	struct wl_drm *drm;

	drm = malloc(sizeof *drm);
	if (!drm)
		return NULL;

	drm->display = display;
	drm->device_name = getenv("ARCAN_RENDER_NODE");
	drm->callbacks = NULL;
	drm->user_data = user_data;
	drm->flags = flags;

	drm->buffer_interface.destroy = drm_buffer_destroy;

	drm->wl_drm_global =
		wl_global_create(display, &wl_drm_interface, 2, drm, bind_drm);

	return drm;
}
예제 #26
0
//Subcompositor
Subcompositor::Subcompositor(Compositor& comp) : compositor_(&comp)
{
    wlGlobal_ = wl_global_create(&comp.wlDisplay(), &wl_subcompositor_interface, 1, 
			this, bindSubcompositor);
}
예제 #27
0
파일: drm.c 프로젝트: ibab/swc
bool swc_drm_initialize()
{
    struct stat master, render;

    if (!find_primary_drm_device(drm.path, sizeof drm.path))
    {
        ERROR("Could not find DRM device\n");
        goto error0;
    }

    drm.taken_ids = 0;
    swc.drm->fd = launch_open_device(drm.path, O_RDWR | O_CLOEXEC);

    if (swc.drm->fd == -1)
    {
        ERROR("Could not open DRM device at %s\n", drm.path);
        goto error0;
    }

    if (fstat(swc.drm->fd, &master) != 0)
    {
        ERROR("Could not fstat DRM FD: %s\n", strerror(errno));
        goto error1;
    }

    if (snprintf(drm.path, sizeof drm.path, "/dev/dri/renderD%d",
                 minor(master.st_rdev) + 0x80) >= sizeof drm.path)
    {
        ERROR("Render node path is too long");
        goto error1;
    }

    if (stat(drm.path, &render) != 0)
    {
        ERROR("Could not stat render node for primary DRM device: %s\n",
              strerror(errno));
        goto error1;
    }

    if (master.st_mode != render.st_mode
        || minor(master.st_rdev) + 0x80 != minor(render.st_rdev))
    {
        ERROR("Render node does not have expected mode or minor number\n");
        goto error1;
    }

    if (!(swc.drm->context = wld_drm_create_context(swc.drm->fd)))
    {
        ERROR("Could not create WLD DRM context\n");
        goto error1;
    }

    if (!(swc.drm->renderer = wld_create_renderer(swc.drm->context)))
    {
        ERROR("Could not create WLD DRM renderer\n");
        goto error2;
    }

    drm.event_source = wl_event_loop_add_fd
        (swc.event_loop, swc.drm->fd, WL_EVENT_READABLE, &handle_data, NULL);

    if (!drm.event_source)
    {
        ERROR("Could not create DRM event source\n");
        goto error3;
    }

    if (!wld_drm_is_dumb(swc.drm->context))
    {
        drm.global = wl_global_create(swc.display, &wl_drm_interface, 2,
                                      NULL, &bind_drm);

        if (!drm.global)
        {
            ERROR("Could not create wl_drm global\n");
            goto error4;
        }
    }

    return true;

  error4:
    wl_event_source_remove(drm.event_source);
  error3:
    wld_destroy_renderer(swc.drm->renderer);
  error2:
    wld_destroy_context(swc.drm->context);
  error1:
    close(swc.drm->fd);
  error0:
    return false;
}