Example #1
0
static struct window *
create_window(struct display *display, int width, int height)
{
	struct window *window;

	window = calloc(1, sizeof *window);
	if (!window)
		return NULL;

	window->callback = NULL;
	window->display = display;
	window->width = width;
	window->height = height;
	window->surface = wl_compositor_create_surface(display->compositor);

	if (display->shell) {
		window->xdg_surface =
			xdg_shell_get_xdg_surface(display->shell,
						  window->surface);

		assert(window->xdg_surface);

		xdg_surface_add_listener(window->xdg_surface,
					 &xdg_surface_listener, window);

		xdg_surface_set_title(window->xdg_surface, "simple-shm");

	} else if (display->fshell) {
		zwp_fullscreen_shell_v1_present_surface(display->fshell,
							window->surface,
							ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_DEFAULT,
							NULL);
	} else if (display->ivi_application ) {
		uint32_t id_ivisurf = IVI_SURFACE_ID + (uint32_t)getpid();
		window->ivi_surface =
			ivi_application_surface_create(display->ivi_application,
						       id_ivisurf, window->surface);
		if (window->ivi_surface == NULL) {
			fprintf(stderr, "Failed to create ivi_client_surface\n");
			abort();
		}

		ivi_surface_add_listener(window->ivi_surface,
					 &ivi_surface_listener, window);

	} else {
		assert(0);
	}

	return window;
}
static struct window *
create_window(struct display *display, int width, int height)
{
	struct window *window;
	int i;
	int ret;

	window = zalloc(sizeof *window);
	if (!window)
		return NULL;

	window->callback = NULL;
	window->display = display;
	window->width = width;
	window->height = height;
	window->surface = wl_compositor_create_surface(display->compositor);

	if (display->shell) {
		window->xdg_surface =
			xdg_shell_get_xdg_surface(display->shell,
						  window->surface);

		assert(window->xdg_surface);

		xdg_surface_add_listener(window->xdg_surface,
					 &xdg_surface_listener, window);

		xdg_surface_set_title(window->xdg_surface, "simple-dmabuf");
	} else if (display->fshell) {
		zwp_fullscreen_shell_v1_present_surface(display->fshell,
							window->surface,
							ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_DEFAULT,
							NULL);
	} else {
		assert(0);
	}

	for (i = 0; i < 2; ++i) {
		ret = create_dmabuf_buffer(display, &window->buffers[i],
		                               width, height);

		if (ret < 0)
			return NULL;
	}

	return window;
}
Example #3
0
GstWlWindow *
gst_wl_window_new_toplevel (GstWlDisplay * display, const GstVideoInfo * info,
    gboolean fullscreen, GMutex * render_lock)
{
  GstWlWindow *window;
  gint width;

  window = gst_wl_window_new_internal (display, render_lock);

  if (display->shell) {
    /* go toplevel */
    window->shell_surface = wl_shell_get_shell_surface (display->shell,
        window->area_surface);

    if (window->shell_surface) {
      wl_shell_surface_add_listener (window->shell_surface,
          &shell_surface_listener, window);
      gst_wl_window_ensure_fullscreen (window, fullscreen);
    } else {
      GST_ERROR ("Unable to get wl_shell_surface");
      g_object_unref (window);
      return NULL;
    }
  } else if (display->fullscreen_shell) {
    zwp_fullscreen_shell_v1_present_surface (display->fullscreen_shell,
        window->area_surface, ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_ZOOM,
        NULL);
  } else {
    GST_ERROR ("Unable to use wl_shell or zwp_fullscreen_shell.");
    g_object_unref (window);
    return NULL;
  }

  /* set the initial size to be the same as the reported video size */
  width =
      gst_util_uint64_scale_int_round (info->width, info->par_n, info->par_d);
  gst_wl_window_set_render_rectangle (window, 0, 0, width, info->height);

  return window;
}
Example #4
0
static struct window *
create_window(struct display *display, int width, int height,
	      enum wl_output_transform transform, int scale,
	      enum window_flags flags)
{
	struct window *window;

	if (display->compositor_version < 2 &&
	    (transform != WL_OUTPUT_TRANSFORM_NORMAL ||
	     flags & WINDOW_FLAG_ROTATING_TRANSFORM)) {
		fprintf(stderr, "wl_surface.buffer_transform unsupported in "
				"wl_surface version %d\n",
			display->compositor_version);
		exit(1);
	}

	if (display->compositor_version < 3 &&
	    (! (flags & WINDOW_FLAG_USE_VIEWPORT)) && scale != 1) {
		fprintf(stderr, "wl_surface.buffer_scale unsupported in "
				"wl_surface version %d\n",
			display->compositor_version);
		exit(1);
	}

	if (display->scaler == NULL && (flags & WINDOW_FLAG_USE_VIEWPORT)) {
		fprintf(stderr, "Compositor does not support wl_viewport");
		exit(1);
	}

	if (display->compositor_version <
	    WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION &&
	    (flags & WINDOW_FLAG_USE_DAMAGE_BUFFER)) {
		fprintf(stderr, "wl_surface.damage_buffer unsupported in "
				"wl_surface version %d\n",
			display->compositor_version);
		exit(1);
	}

	window = zalloc(sizeof *window);
	if (!window)
		return NULL;

	window->callback = NULL;
	window->display = display;
	window->width = width;
	window->height = height;
	window->border = 10;
	window->flags = flags;
	window->transform = transform;
	window->scale = scale;

	window_init_game(window);

	window->surface = wl_compositor_create_surface(display->compositor);

	if (window->flags & WINDOW_FLAG_USE_VIEWPORT)
		window->viewport = wl_scaler_get_viewport(display->scaler,
							  window->surface);

	if (display->shell) {
		window->xdg_surface =
			xdg_shell_get_xdg_surface(display->shell,
						  window->surface);

		assert(window->xdg_surface);

		xdg_surface_add_listener(window->xdg_surface,
					 &xdg_surface_listener, window);

		xdg_surface_set_title(window->xdg_surface, "simple-damage");
	} else if (display->fshell) {
		zwp_fullscreen_shell_v1_present_surface(display->fshell,
							window->surface,
							ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_DEFAULT,
							NULL);
	} else {
		assert(0);
	}

	/* Initialise damage to full surface, so the padding gets painted */
	if (window->flags & WINDOW_FLAG_USE_DAMAGE_BUFFER) {
		wl_surface_damage_buffer(window->surface, 0, 0,
					 INT32_MAX, INT32_MAX);
	} else {
		wl_surface_damage(window->surface, 0, 0, INT32_MAX, INT32_MAX);
	}
	return window;
}