示例#1
0
文件: simple-egl.c 项目: N8Fear/adwc
static void
display_handle_global(struct wl_display *display, uint32_t id,
		      const char *interface, uint32_t version, void *data)
{
	struct display *d = data;

	if (strcmp(interface, "wl_compositor") == 0) {
		d->compositor =
			wl_display_bind(display, id, &wl_compositor_interface);
	} else if (strcmp(interface, "wl_shell") == 0) {
		d->shell = wl_display_bind(display, id, &wl_shell_interface);
	}
}
void
_clutter_device_manager_wayland_add_input_group (ClutterDeviceManager *manager,
                                                 uint32_t id)
{
  ClutterBackend *backend = _clutter_device_manager_get_backend (manager);
  ClutterBackendWayland *backend_wayland = CLUTTER_BACKEND_WAYLAND (backend);
  ClutterInputDeviceWayland *device;

  device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_WAYLAND,
                         "id", id,
                         "device-type", CLUTTER_POINTER_DEVICE,
                         "name", "wayland device",
                         "enabled", TRUE,
                         NULL);

  device->input_device =
    wl_display_bind (backend_wayland->wayland_display, id,
                     &wl_input_device_interface);
  wl_input_device_add_listener (device->input_device,
                                &_clutter_input_device_wayland_listener,
                                device);
  wl_input_device_set_user_data (device->input_device, device);

  device->xkb = _clutter_xkb_desc_new (NULL,
                                       option_xkb_layout,
                                       option_xkb_variant,
                                       option_xkb_options);
  if (!device->xkb)
    CLUTTER_NOTE (BACKEND, "Failed to compile keymap");

  _clutter_device_manager_add_device (manager, CLUTTER_INPUT_DEVICE (device));
}
示例#3
0
void 
_ecore_wl_input_add(Ecore_Wl_Display *ewd, unsigned int id)
{
   Ecore_Wl_Input *input;

   LOGFN(__FILE__, __LINE__, __FUNCTION__);

   if (!(input = malloc(sizeof(Ecore_Wl_Input)))) return;

   memset(input, 0, sizeof(Ecore_Wl_Input));

   input->display = ewd;
   input->pointer_focus = NULL;
   input->keyboard_focus = NULL;

   input->input_device = 
     wl_display_bind(ewd->wl.display, id, &wl_input_device_interface);
   wl_list_insert(ewd->inputs.prev, &input->link);
   wl_input_device_add_listener(input->input_device, 
                                &_ecore_wl_input_listener, input);
   wl_input_device_set_user_data(input->input_device, input);

   input->data_device = 
     wl_data_device_manager_get_data_device(ewd->wl.data_device_manager, 
                                            input->input_device);
   wl_data_device_add_listener(input->data_device, 
                               &_ecore_wl_data_listener, input);
   ewd->input = input;
}
示例#4
0
static void
display_handle_global_cb (struct wl_display *display,
                          uint32_t id,
                          const char *interface,
                          uint32_t version,
                          void *data)
{
  CoglRendererEGL *egl_renderer = (CoglRendererEGL *)data;
  CoglRendererWayland *wayland_renderer = egl_renderer->platform;

  if (strcmp (interface, "wl_compositor") == 0)
    wayland_renderer->wayland_compositor =
      wl_display_bind (display, id, &wl_compositor_interface);
  else if (strcmp(interface, "wl_shell") == 0)
    wayland_renderer->wayland_shell =
      wl_display_bind (display, id, &wl_shell_interface);
}
示例#5
0
static void
global_handler(struct wl_display *display, uint32_t id,
	       const char *interface, uint32_t version, void *data)
{
	struct wscreensaver *screensaver = data;

	if (!strcmp(interface, "screensaver")) {
		screensaver->interface =
			wl_display_bind(display, id, &screensaver_interface);
	}
}
示例#6
0
static void
gdk_display_handle_global(struct wl_display *display, uint32_t id,
			  const char *interface, uint32_t version, void *data)
{
  GdkDisplayWayland *display_wayland = data;
  GdkDisplay *gdk_display = GDK_DISPLAY_OBJECT (data);
  struct wl_input_device *input;

  if (strcmp(interface, "wl_compositor") == 0) {
    display_wayland->compositor =
      wl_display_bind(display, id, &wl_compositor_interface);
  } else if (strcmp(interface, "wl_shm") == 0) {
    display_wayland->shm = wl_display_bind(display, id, &wl_shm_interface);
  } else if (strcmp(interface, "wl_shell") == 0) {
    display_wayland->shell = wl_display_bind(display, id, &wl_shell_interface);
  } else if (strcmp(interface, "wl_output") == 0) {
    display_wayland->output =
      wl_display_bind(display, id, &wl_output_interface);
    wl_output_add_listener(display_wayland->output,
			   &output_listener, display_wayland);
  } else if (strcmp(interface, "wl_input_device") == 0) {
    input = wl_display_bind(display, id, &wl_input_device_interface);
    _gdk_wayland_device_manager_add_device (gdk_display->device_manager,
					    input);
  } else if (strcmp(interface, "wl_data_device_manager") == 0) {
      display_wayland->data_device_manager =
        wl_display_bind(display, id,
                        &wl_data_device_manager_interface);
  }
}
示例#7
0
文件: editor.c 项目: Blei/weston
static void
global_handler(struct wl_display *display, uint32_t id,
	       const char *interface, uint32_t version, void *data)
{
	struct editor *editor = data;

	if (!strcmp(interface, "text_model_factory")) {
		editor->text_model_factory = wl_display_bind(display, id,
							     &text_model_factory_interface);
	} else if (!strcmp(interface, "wl_seat")) {
		fprintf(stderr, "wl_seat added\n");
	}
}
示例#8
0
static boolean
wayland_drm_display_init_screen(struct native_display *ndpy)
{
   struct wayland_drm_display *drmdpy = wayland_drm_display(ndpy);
   uint32_t id;

   id = wl_display_get_global(drmdpy->base.dpy, "wl_drm", 1);
   if (id == 0)
      wl_display_roundtrip(drmdpy->base.dpy);
   id = wl_display_get_global(drmdpy->base.dpy, "wl_drm", 1);
   if (id == 0)
      return FALSE;

   drmdpy->wl_drm = wl_display_bind(drmdpy->base.dpy, id, &wl_drm_interface);
   if (!drmdpy->wl_drm)
      return FALSE;

   wl_drm_add_listener(drmdpy->wl_drm, &drm_listener, drmdpy);
   wl_display_roundtrip(drmdpy->base.dpy);
   if (drmdpy->fd == -1)
      return FALSE;

   wl_display_roundtrip(drmdpy->base.dpy);
   if (!drmdpy->authenticated)
      return FALSE;

   if (drmdpy->base.formats == 0)
      wl_display_roundtrip(drmdpy->base.dpy);
   if (drmdpy->base.formats == 0)
      return FALSE;

   drmdpy->base.base.screen =
      drmdpy->event_handler->new_drm_screen(&drmdpy->base.base,
                                            NULL, drmdpy->fd);
   if (!drmdpy->base.base.screen) {
      _eglLog(_EGL_WARNING, "failed to create DRM screen");
      return FALSE;
   }

   return TRUE;
}
示例#9
0
/* Initialize a native display for use with WSEGL */
static WSEGLError wseglInitializeDisplay
    (NativeDisplayType nativeDisplay, WSEGLDisplayHandle *display,
     const WSEGLCaps **caps, WSEGLConfig **configs)
{
    struct wl_egl_display *egldisplay = wl_egl_display_create((struct wl_display *) nativeDisplay);

    if (wseglFetchContext(egldisplay) != 1)
    {
       wl_egl_display_destroy(egldisplay);
       return WSEGL_OUT_OF_MEMORY;
    }

    /* If it is a framebuffer */
    if (egldisplay->display == NULL)
    {
       int fd;
       WSEGLPixelFormat format;
       
       /* Open the framebuffer and fetch its properties */
       fd = open("/dev/fb0", O_RDWR, 0);
       if (fd < 0) {
          perror("/dev/fb0");
          wseglReleaseContext(egldisplay);
          wl_egl_display_destroy(egldisplay);
          return WSEGL_CANNOT_INITIALISE;
       }
       if (ioctl(fd, FBIOGET_VSCREENINFO, &egldisplay->var) < 0) {
          perror("FBIOGET_VSCREENINFO");
          wseglReleaseContext(egldisplay);
          wl_egl_display_destroy(egldisplay);
          close(fd);
          return WSEGL_CANNOT_INITIALISE; 
       }
       if (ioctl(fd, FBIOGET_FSCREENINFO, &egldisplay->fix) < 0) {
          perror("FBIOGET_FSCREENINFO");
          wseglReleaseContext(egldisplay);
          wl_egl_display_destroy(egldisplay);
          close(fd);
          return WSEGL_CANNOT_INITIALISE; 
       }
       format = getwseglPixelFormat(egldisplay);

       egldisplay->wseglDisplayConfigs[0].ePixelFormat = format;
       egldisplay->wseglDisplayConfigs[1].ePixelFormat = format;
    }
    else
    {
      uint32_t id;
      id = wl_display_get_global(egldisplay->display, "wl_drm", 1);
      if (id == 0)
        wl_display_roundtrip(egldisplay->display);
      id = wl_display_get_global(egldisplay->display, "wl_drm", 1);
      if (id == 0)
        return WSEGL_CANNOT_INITIALISE; 

      egldisplay->drm = wl_display_bind(egldisplay->display, id, &wl_drm_interface);
      if (!egldisplay->drm)
         return WSEGL_CANNOT_INITIALISE;
      wl_drm_add_listener(egldisplay->drm, &drm_listener, egldisplay);
      wl_display_roundtrip(egldisplay->display);

    }

    *display = (WSEGLDisplayHandle)egldisplay;
    *caps = wseglDisplayCaps;
    *configs = egldisplay->wseglDisplayConfigs;
    return WSEGL_SUCCESS;
}
示例#10
0
EGLBoolean
dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
{
   struct dri2_egl_display *dri2_dpy;
   const __DRIconfig *config;
   uint32_t id, types;
   int i;
   static const unsigned int argb_masks[4] =
      { 0xff0000, 0xff00, 0xff, 0xff000000 };
   static const unsigned int rgb_masks[4] = { 0xff0000, 0xff00, 0xff, 0 };

   drv->API.CreateWindowSurface = dri2_create_window_surface;
   drv->API.CreatePixmapSurface = dri2_create_pixmap_surface;
   drv->API.DestroySurface = dri2_destroy_surface;
   drv->API.SwapBuffers = dri2_swap_buffers;
   drv->API.CreateImageKHR = dri2_wayland_create_image_khr;
   drv->API.Terminate = dri2_terminate;

   dri2_dpy = malloc(sizeof *dri2_dpy);
   if (!dri2_dpy)
      return _eglError(EGL_BAD_ALLOC, "eglInitialize");

   memset(dri2_dpy, 0, sizeof *dri2_dpy);

   disp->DriverData = (void *) dri2_dpy;
   if (disp->PlatformDisplay == NULL) {
      dri2_dpy->wl_dpy = wl_display_connect(NULL);
      if (dri2_dpy->wl_dpy == NULL)
         goto cleanup_dpy;
      dri2_dpy->own_device = 1;
   } else {
      dri2_dpy->wl_dpy = disp->PlatformDisplay;
   }

   id = wl_display_get_global(dri2_dpy->wl_dpy, "wl_drm", 1);
   if (id == 0)
      wl_display_roundtrip(dri2_dpy->wl_dpy);
   id = wl_display_get_global(dri2_dpy->wl_dpy, "wl_drm", 1);
   if (id == 0)
      goto cleanup_dpy;
   dri2_dpy->wl_drm = wl_display_bind(dri2_dpy->wl_dpy, id, &wl_drm_interface);
   if (!dri2_dpy->wl_drm)
      goto cleanup_dpy;
   wl_drm_add_listener(dri2_dpy->wl_drm, &drm_listener, dri2_dpy);
   wl_display_roundtrip(dri2_dpy->wl_dpy);
   if (dri2_dpy->fd == -1)
      goto cleanup_drm;

   wl_display_roundtrip(dri2_dpy->wl_dpy);
   if (!dri2_dpy->authenticated)
      goto cleanup_fd;

   dri2_dpy->driver_name = dri2_get_driver_for_fd(dri2_dpy->fd);
   if (dri2_dpy->driver_name == NULL) {
      _eglError(EGL_BAD_ALLOC, "DRI2: failed to get driver name");
      goto cleanup_fd;
   }

   if (!dri2_load_driver(disp))
      goto cleanup_driver_name;

   dri2_dpy->dri2_loader_extension.base.name = __DRI_DRI2_LOADER;
   dri2_dpy->dri2_loader_extension.base.version = 3;
   dri2_dpy->dri2_loader_extension.getBuffers = dri2_get_buffers;
   dri2_dpy->dri2_loader_extension.flushFrontBuffer = dri2_flush_front_buffer;
   dri2_dpy->dri2_loader_extension.getBuffersWithFormat =
      dri2_get_buffers_with_format;
      
   dri2_dpy->extensions[0] = &dri2_dpy->dri2_loader_extension.base;
   dri2_dpy->extensions[1] = &image_lookup_extension.base;
   dri2_dpy->extensions[2] = &use_invalidate.base;
   dri2_dpy->extensions[3] = NULL;

   if (!dri2_create_screen(disp))
      goto cleanup_driver;

   types = EGL_WINDOW_BIT | EGL_PIXMAP_BIT;
   if (dri2_dpy->formats & HAS_PREMUL_ARGB32)
      types |= EGL_VG_ALPHA_FORMAT_PRE_BIT;

   for (i = 0; dri2_dpy->driver_configs[i]; i++) {
      config = dri2_dpy->driver_configs[i];
      if (dri2_dpy->formats & HAS_XRGB32)
	 dri2_add_config(disp, config, i + 1, 0, types, NULL, rgb_masks);
      if (dri2_dpy->formats & (HAS_ARGB32 | HAS_PREMUL_ARGB32))
	 dri2_add_config(disp, config, i + 1, 0, types, NULL, argb_masks);
   }

   disp->Extensions.KHR_image_pixmap = EGL_TRUE;

   disp->Extensions.WL_bind_wayland_display = EGL_TRUE;
   dri2_dpy->authenticate = dri2_wayland_authenticate;

   /* we're supporting EGL 1.4 */
   disp->VersionMajor = 1;
   disp->VersionMinor = 4;

   return EGL_TRUE;

 cleanup_driver:
   dlclose(dri2_dpy->driver);
 cleanup_driver_name:
   free(dri2_dpy->driver_name);
 cleanup_fd:
   close(dri2_dpy->fd);
 cleanup_drm:
   free(dri2_dpy->device_name);
   wl_drm_destroy(dri2_dpy->wl_drm);
 cleanup_dpy:
   free(dri2_dpy);
   
   return EGL_FALSE;
}