Пример #1
0
int main(int argc, char **argv)
{
    get_server_references();

    surface = wl_compositor_create_surface(compositor);

    if (surface == NULL) {
        fprintf(stderr, "Can't create surface\n");
        exit(1);
    } else {
        fprintf(stderr, "Created surface\n");
    }

    shell_surface = wl_shell_get_shell_surface(shell, surface);
    wl_shell_surface_set_toplevel(shell_surface);

//    create_opaque_region();
    init_egl();
    create_window();
    init_gl();

    while (1) {
        draw();
        if (eglSwapBuffers(egl_display, egl_surface)) {
            fprintf(stderr, "Swapped buffers\n");
       } else {
        fprintf(stderr, "Swapped buffers failed\n");
    }
    }

    wl_display_disconnect(display);
    printf("disconnected from display\n");

    exit(0);
}
Пример #2
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);
	window->shell_surface = wl_shell_get_shell_surface(display->shell,
							   window->surface);

	if (window->shell_surface)
		wl_shell_surface_add_listener(window->shell_surface,
					      &shell_surface_listener, window);

	wl_shell_surface_set_title(window->shell_surface, "simple-shm");

	wl_shell_surface_set_toplevel(window->shell_surface);

	return window;
}
Пример #3
0
static void
create_window (GstWaylandSink * sink, struct display *display, int width,
    int height)
{
  struct window *window;

  if (sink->window)
    return;

  g_mutex_lock (&sink->wayland_lock);

  window = malloc (sizeof *window);
  window->display = display;
  window->width = width;
  window->height = height;
  window->redraw_pending = FALSE;

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

  window->shell_surface = wl_shell_get_shell_surface (display->shell,
      window->surface);

  g_return_if_fail (window->shell_surface);

  wl_shell_surface_add_listener (window->shell_surface,
      &shell_surface_listener, window);

  wl_shell_surface_set_toplevel (window->shell_surface);
  wl_shell_surface_set_fullscreen (window->shell_surface,
      WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE, 0, NULL);

  sink->window = window;

  g_mutex_unlock (&sink->wayland_lock);
}
Пример #4
0
static struct window *
create_window(struct display *display, int width, int height)
{
	struct window *window;
	
	window = malloc(sizeof *window);

	window->buffer = create_shm_buffer(display,
					   width, height,
					   WL_SHM_FORMAT_XRGB8888,
					   &window->shm_data);

	if (!window->buffer) {
		free(window);
		return NULL;
	}

	window->callback = NULL;
	window->display = display;
	window->width = width;
	window->height = height;
	window->surface = wl_compositor_create_surface(display->compositor);
	window->shell_surface = wl_shell_get_shell_surface(display->shell,
							   window->surface);

	if (window->shell_surface)
		wl_shell_surface_add_listener(window->shell_surface,
					      &shell_surface_listener, window);

	wl_shell_surface_set_toplevel(window->shell_surface);

	return window;
}
Пример #5
0
wlfWindow* wlf_CreateDesktopWindow(wlfContext* wlfc, char* name, int width, int height, BOOL decorations)
{
	wlfWindow* window;

	window = (wlfWindow*) calloc(1, sizeof(wlfWindow));

	if (window)
	{
		window->width = width;
		window->height = height;
		window->fullscreen = FALSE;
		window->buffers[0].busy = FALSE;
		window->buffers[1].busy = FALSE;
		window->callback = NULL;
		window->display = wlfc->display;

		window->surface = wl_compositor_create_surface(window->display->compositor);
		window->shell_surface = wl_shell_get_shell_surface(window->display->shell, window->surface);
		wl_shell_surface_add_listener(window->shell_surface, &wl_shell_surface_listener, window);
		wl_shell_surface_set_toplevel(window->shell_surface);

		wlf_ResizeDesktopWindow(wlfc, window, width, height);

		wl_surface_damage(window->surface, 0, 0, window->width, window->height);
	}

	wlf_SetWindowText(wlfc, window, name);

	return window;
}
Пример #6
0
static void
create_surface(struct window *window)
{
	struct display *display = window->display;
	EGLBoolean ret;
	
	window->surface = wl_compositor_create_surface(display->compositor);
	window->shell_surface = wl_shell_get_shell_surface(display->shell,
							   window->surface);

	wl_shell_surface_add_listener(window->shell_surface,
				      &shell_surface_listener, window);

	window->native =
		wl_egl_window_create(window->surface,
				     window->window_size.width,
				     window->window_size.height);
	window->egl_surface =
		eglCreateWindowSurface(display->egl.dpy,
				       display->egl.conf,
				       window->native, NULL);

	wl_shell_surface_set_title(window->shell_surface, "simple-egl");

	ret = eglMakeCurrent(window->display->egl.dpy, window->egl_surface,
			     window->egl_surface, window->display->egl.ctx);
	assert(ret == EGL_TRUE);

	if (!window->frame_sync)
		eglSwapInterval(display->egl.dpy, 0);

	set_fullscreen(window, window->fullscreen);
}
static gboolean
create_surface (GstGLWindowWaylandEGL * window_egl)
{
  window_egl->window.surface =
      wl_compositor_create_surface (window_egl->display.compositor);
  window_egl->window.shell_surface =
      wl_shell_get_shell_surface (window_egl->display.shell,
      window_egl->window.surface);

  wl_shell_surface_add_listener (window_egl->window.shell_surface,
      &shell_surface_listener, window_egl);

  if (window_egl->window.window_width <= 0)
    window_egl->window.window_width = 320;
  if (window_egl->window.window_height <= 0)
    window_egl->window.window_height = 240;

  window_egl->window.native =
      wl_egl_window_create (window_egl->window.surface,
      window_egl->window.window_width, window_egl->window.window_height);

  wl_shell_surface_set_title (window_egl->window.shell_surface,
      "OpenGL Renderer");

  wl_shell_surface_set_toplevel (window_egl->window.shell_surface);

  return TRUE;
}
Пример #8
0
GstWlWindow *
gst_wl_window_new_toplevel (GstWlDisplay * display, const GstVideoInfo * info)
{
  GstWlWindow *window;
  gint width;

  window = gst_wl_window_new_internal (display);

  /* 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);
    wl_shell_surface_set_toplevel (window->shell_surface);
  } else {
    GST_ERROR ("Unable to get wl_shell_surface");

    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;
}
Пример #9
0
    void create_surface(struct display *display)
    {
      EGLBoolean ret;

      display->surface = wl_compositor_create_surface(display->compositor);
      display->shell_surface = wl_shell_get_shell_surface(display->shell,
                     display->surface);

      wl_shell_surface_add_listener(display->shell_surface,
                  &shell_surface_listener, display);

      display->native = wl_egl_window_create(display->surface, 1, 1);

      display->egl_surface =
        eglCreateWindowSurface((EGLDisplay) display->egl.dpy, display->egl.conf, (EGLNativeWindowType) display->native, NULL);

      wl_shell_surface_set_title(display->shell_surface, "projection");

      ret = eglMakeCurrent(display->egl.dpy, display->egl_surface,
               display->egl_surface, display->egl.ctx);
      assert(ret == EGL_TRUE);

      struct wl_callback *callback;

      display->configured = 0;

      wl_shell_surface_set_fullscreen(display->shell_surface,
        WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, NULL);

      callback = wl_display_sync(display->display);
      wl_callback_add_listener(callback, &configure_callback_listener, display);
    }
Пример #10
0
void WaylandWindow::init()
{
//     mClient = WaylandClient::getInstance();
//     mSurface = AndroidRuntime::getWaylandClient()->surface();//wl_compositor_create_surface(mClient->getCompositor());
    mSurface = wl_compositor_create_surface(WaylandClient::getInstance().getCompositor());
//     mShellSurface = AndroidRuntime::getWaylandClient()->shellSurface();// wl_shell_get_shell_surface(mClient->getShell(), mSurface);
    mShellSurface = wl_shell_get_shell_surface(WaylandClient::getInstance().getShell(), mSurface);

    if (mShellSurface) {
        wl_shell_surface_add_listener(mShellSurface, &mShellSurfaceListener, this);
        wl_shell_surface_set_toplevel(mShellSurface);
    } else {
       ALOGW("wl_shell_get_shell_surface FAILED \n");
       return;
    }

    wl_surface_set_user_data(mSurface, this);
    wl_shell_surface_set_title(mShellSurface, "android");
    wl_surface_commit(mSurface);
    mNative = wl_egl_window_create(mSurface, mWidth, mHeight);
    if (mNative == NULL) {
        ALOGW("wl_egl_window_create FAILED \n");
        return;
    } else {
        ALOGW("wl_egl_window_create succeded, resulting in %p \n", mNative);
    }
}
Пример #11
0
GstWlWindow *
gst_wl_window_new_toplevel (GstWlDisplay * display, GstVideoInfo * video_info)
{
  GstWlWindow *window;

  window = gst_wl_window_new_internal (display,
      wl_compositor_create_surface (display->compositor));

  gst_wl_window_set_video_info (window, video_info);
  gst_wl_window_set_render_rectangle (window, 0, 0, window->video_width,
      window->video_height);

  window->shell_surface = wl_shell_get_shell_surface (display->shell,
      window->surface);

  if (window->shell_surface) {
    wl_shell_surface_add_listener (window->shell_surface,
        &shell_surface_listener, window);
    wl_shell_surface_set_toplevel (window->shell_surface);
  } else {
    GST_ERROR ("Unable to get wl_shell_surface");

    g_object_unref (window);
    return NULL;
  }

  return window;
}
Пример #12
0
static GLFWbool createSurface(_GLFWwindow* window,
                              const _GLFWwndconfig* wndconfig)
{
    window->wl.surface = wl_compositor_create_surface(_glfw.wl.compositor);
    if (!window->wl.surface)
        return GLFW_FALSE;

    wl_surface_set_user_data(window->wl.surface, window);

    window->wl.native = wl_egl_window_create(window->wl.surface,
                                             wndconfig->width,
                                             wndconfig->height);
    if (!window->wl.native)
        return GLFW_FALSE;

    window->wl.shell_surface = wl_shell_get_shell_surface(_glfw.wl.shell,
                                                          window->wl.surface);
    if (!window->wl.shell_surface)
        return GLFW_FALSE;

    wl_shell_surface_add_listener(window->wl.shell_surface,
                                  &shellSurfaceListener,
                                  window);

    window->wl.width = wndconfig->width;
    window->wl.height = wndconfig->height;

    return GLFW_TRUE;
}
Пример #13
0
struct wl_shell_surface *hello_create_surface(void)
{
    struct wl_surface *surface;
    struct wl_shell_surface *shell_surface;

    surface = wl_compositor_create_surface(compositor);

    if (surface == NULL)
        return NULL;

    shell_surface = wl_shell_get_shell_surface(shell, surface);

    if (shell_surface == NULL) {
        wl_surface_destroy(surface);
        return NULL;
    }

    wl_shell_surface_add_listener(shell_surface,
        &shell_surface_listener, 0);
    wl_shell_surface_set_toplevel(shell_surface);
    wl_shell_surface_set_user_data(shell_surface, surface);
    wl_surface_set_user_data(surface, NULL);

    return shell_surface;
}
Пример #14
0
void WaylandCore::createWindow( int width, int height, const char* title )
{
  if( mDisplay == NULL || mCompositor == NULL ) {
    return;
  }
  mWidth = width;
  mHeight = height;

  static wl_shell_surface_listener shell_surf_listeners = {
    shell_surface_handler_ping,
    shell_surface_handler_configure,
    shell_surface_handler_popup_done,
  };

  wl_surface* surface = wl_compositor_create_surface( mCompositor );
  wl_shell_surface* shell_surface = wl_shell_get_shell_surface( mShell, surface );
  wl_shell_surface_set_toplevel( shell_surface );
  wl_shell_surface_set_title( shell_surface, title );

  wl_shell_surface_add_listener( shell_surface, &shell_surf_listeners, this );

  mShellSurface = shell_surface;
  mSurface.surface = surface;
  
  mEglWindow = wl_egl_window_create( surface, mWidth, mHeight );
  mSurface.eglSurface = eglCreateWindowSurface( mEglDisplay, mEglConfig, mEglWindow, NULL );
  
  if( !eglMakeCurrent( mEglDisplay, mSurface.eglSurface, mSurface.eglSurface, mEglContext ) ) {
    fprintf( stderr, "MakeCurrent failed.\n" );
  }
}
Пример #15
0
struct window *window_setup(struct registry *registry, uint32_t width, uint32_t height, bool shell_surface) {
	struct window *window = malloc(sizeof(struct window));
	memset(window, 0, sizeof(struct window));
	window->width = width;
	window->height = height;
	window->registry = registry;

	window->surface = wl_compositor_create_surface(registry->compositor);
	if (shell_surface) {
		window->shell_surface = wl_shell_get_shell_surface(registry->shell, window->surface);
		wl_shell_surface_add_listener(window->shell_surface, &surface_listener, window);
		wl_shell_surface_set_toplevel(window->shell_surface);
	}
	if (registry->pointer) {
		wl_pointer_add_listener(registry->pointer, &pointer_listener, window);
	}

	window->cursor.cursor_theme = wl_cursor_theme_load("default", 32, registry->shm); // TODO: let you customize this
	window->cursor.cursor = wl_cursor_theme_get_cursor(window->cursor.cursor_theme, "left_ptr");
	window->cursor.surface = wl_compositor_create_surface(registry->compositor);

	struct wl_cursor_image *image = window->cursor.cursor->images[0];
	struct wl_buffer *cursor_buf = wl_cursor_image_get_buffer(image);
	wl_surface_attach(window->cursor.surface, cursor_buf, 0, 0);
	wl_surface_damage(window->cursor.surface, 0, 0, image->width, image->height);
	wl_surface_commit(window->cursor.surface);

	return window;
}
Пример #16
0
static GLFWbool createShellSurface(_GLFWwindow* window)
{
    window->wl.shellSurface = wl_shell_get_shell_surface(_glfw.wl.shell,
                                                         window->wl.surface);
    if (!window->wl.shellSurface)
        return GLFW_FALSE;

    wl_shell_surface_add_listener(window->wl.shellSurface,
                                  &shellSurfaceListener,
                                  window);

    if (window->wl.title)
        wl_shell_surface_set_title(window->wl.shellSurface, window->wl.title);

    if (window->monitor)
    {
        wl_shell_surface_set_fullscreen(
            window->wl.shellSurface,
            WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
            0,
            window->monitor->wl.output);
    }
    else if (window->wl.maximized)
    {
        wl_shell_surface_set_maximized(window->wl.shellSurface, NULL);
    }
    else
    {
        wl_shell_surface_set_toplevel(window->wl.shellSurface);
    }

    wl_surface_commit(window->wl.surface);

    return GLFW_TRUE;
}
Пример #17
0
static CoglBool
_cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
                                EGLConfig egl_config,
                                CoglError **error)
{
  CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
  CoglOnscreenWayland *wayland_onscreen;
  CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
  CoglContext *context = framebuffer->context;
  CoglRenderer *renderer = context->display->renderer;
  CoglRendererEGL *egl_renderer = renderer->winsys;
  CoglRendererWayland *wayland_renderer = egl_renderer->platform;

  wayland_onscreen = g_slice_new0 (CoglOnscreenWayland);
  egl_onscreen->platform = wayland_onscreen;

  _cogl_list_init (&wayland_onscreen->frame_callbacks);

  if (onscreen->foreign_surface)
    wayland_onscreen->wayland_surface = onscreen->foreign_surface;
  else
    wayland_onscreen->wayland_surface =
      wl_compositor_create_surface (wayland_renderer->wayland_compositor);

  if (!wayland_onscreen->wayland_surface)
    {
      _cogl_set_error (error, COGL_WINSYS_ERROR,
                   COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                   "Error while creating wayland surface for CoglOnscreen");
      return FALSE;
    }

  wayland_onscreen->wayland_egl_native_window =
    wl_egl_window_create (wayland_onscreen->wayland_surface,
                          cogl_framebuffer_get_width (framebuffer),
                          cogl_framebuffer_get_height (framebuffer));
  if (!wayland_onscreen->wayland_egl_native_window)
    {
      _cogl_set_error (error, COGL_WINSYS_ERROR,
                   COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                   "Error while creating wayland egl native window "
                   "for CoglOnscreen");
      return FALSE;
    }

  egl_onscreen->egl_surface =
    eglCreateWindowSurface (egl_renderer->edpy,
                            egl_config,
                            (EGLNativeWindowType)
                            wayland_onscreen->wayland_egl_native_window,
                            NULL);

  if (!onscreen->foreign_surface)
    wayland_onscreen->wayland_shell_surface =
      wl_shell_get_shell_surface (wayland_renderer->wayland_shell,
                                  wayland_onscreen->wayland_surface);

  return TRUE;
}
Пример #18
0
int main(int argc, char **argv) {

    display = wl_display_connect(NULL);
    if (display == NULL) {
        fprintf(stderr, "Can't connect to display\n");
        exit(1);
    }
    printf("connected to display\n");

    struct wl_registry *registry = wl_display_get_registry(display);
    wl_registry_add_listener(registry, &registry_listener, NULL);

    wl_display_dispatch(display);
    wl_display_roundtrip(display);

    if (compositor == NULL) {
        fprintf(stderr, "Can't find compositor\n");
        exit(1);
    } else {
        fprintf(stderr, "Found compositor\n");
    }

    surface = wl_compositor_create_surface(compositor);
    if (surface == NULL) {
        fprintf(stderr, "Can't create surface\n");
        exit(1);
    } else {
        fprintf(stderr, "Created surface\n");
    }

    shell_surface = wl_shell_get_shell_surface(shell, surface);
    if (shell_surface == NULL) {
        fprintf(stderr, "Can't create shell surface\n");
        exit(1);
    } else {
        fprintf(stderr, "Created shell surface\n");
    }
    wl_shell_surface_set_toplevel(shell_surface);

    wl_shell_surface_add_listener(shell_surface,
                                  &shell_surface_listener, NULL);


    create_window();
    paint_pixels();

    while (wl_display_dispatch(display) != -1) {
        ;
    }

    wl_display_disconnect(display);
    printf("disconnected from display\n");

    exit(0);
}
static gboolean
gst_vaapi_window_wayland_create (GstVaapiWindow * window,
                                 guint * width, guint * height)
{
    GstVaapiWindowWaylandPrivate *const priv =
        GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (window);
    GstVaapiDisplayWaylandPrivate *const priv_display =
        GST_VAAPI_DISPLAY_WAYLAND_GET_PRIVATE (GST_VAAPI_OBJECT_DISPLAY (window));

    GST_DEBUG ("create window, size %ux%u", *width, *height);

    g_return_val_if_fail (priv_display->compositor != NULL, FALSE);
    g_return_val_if_fail (priv_display->shell != NULL, FALSE);

    GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
    priv->event_queue = wl_display_create_queue (priv_display->wl_display);
    GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
    if (!priv->event_queue)
        return FALSE;

    GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
    priv->surface = wl_compositor_create_surface (priv_display->compositor);
    GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
    if (!priv->surface)
        return FALSE;
    wl_proxy_set_queue ((struct wl_proxy *) priv->surface, priv->event_queue);

    GST_VAAPI_OBJECT_LOCK_DISPLAY (window);
    priv->shell_surface =
        wl_shell_get_shell_surface (priv_display->shell, priv->surface);
    GST_VAAPI_OBJECT_UNLOCK_DISPLAY (window);
    if (!priv->shell_surface)
        return FALSE;
    wl_proxy_set_queue ((struct wl_proxy *) priv->shell_surface,
                        priv->event_queue);

    wl_shell_surface_add_listener (priv->shell_surface,
                                   &shell_surface_listener, priv);
    wl_shell_surface_set_toplevel (priv->shell_surface);

    priv->poll = gst_poll_new (TRUE);
    gst_poll_fd_init (&priv->pollfd);

    if (priv->fullscreen_on_show)
        gst_vaapi_window_wayland_set_fullscreen (window, TRUE);

    priv->surface_format = GST_VIDEO_FORMAT_ENCODED;
    priv->use_vpp = GST_VAAPI_DISPLAY_HAS_VPP (GST_VAAPI_OBJECT_DISPLAY (window));
    priv->is_shown = TRUE;

    return TRUE;
}
Пример #20
0
static struct touch *
touch_create(int width, int height)
{
	struct touch *touch;

	touch = malloc(sizeof *touch);
	if (touch == NULL) {
		fprintf(stderr, "out of memory\n");
		exit(1);
	}
	touch->display = wl_display_connect(NULL);
	assert(touch->display);

	touch->has_argb = 0;
	touch->registry = wl_display_get_registry(touch->display);
	wl_registry_add_listener(touch->registry, &registry_listener, touch);
	wl_display_dispatch(touch->display);
	wl_display_roundtrip(touch->display);

	if (!touch->has_argb) {
		fprintf(stderr, "WL_SHM_FORMAT_ARGB32 not available\n");
		exit(1);
	}

	touch->width = width;
	touch->height = height;
	touch->surface = wl_compositor_create_surface(touch->compositor);
	touch->shell_surface = wl_shell_get_shell_surface(touch->shell,
							  touch->surface);
	create_shm_buffer(touch);

	if (touch->shell_surface) {
		wl_shell_surface_add_listener(touch->shell_surface,
					      &shell_surface_listener, touch);
		wl_shell_surface_set_toplevel(touch->shell_surface);
	}

	wl_surface_set_user_data(touch->surface, touch);
	wl_shell_surface_set_title(touch->shell_surface, "simple-touch");

	memset(touch->data, 64, width * height * 4);
	wl_surface_attach(touch->surface, touch->buffer, 0, 0);
	wl_surface_damage(touch->surface, 0, 0, width, height);
	wl_surface_commit(touch->surface);

	return touch;
}
Пример #21
0
static bool gfx_ctx_wl_set_video_mode(void *data,
      unsigned width, unsigned height,
      bool fullscreen)
{
   EGLint egl_attribs[16];
   EGLint *attr = NULL;
   gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;

   egl_install_sighandlers();

   attr = egl_fill_attribs(wl, egl_attribs);

   wl->width = width ? width : DEFAULT_WINDOWED_WIDTH;
   wl->height = height ? height : DEFAULT_WINDOWED_HEIGHT;

   wl->surface = wl_compositor_create_surface(wl->compositor);
   wl->win = wl_egl_window_create(wl->surface, wl->width, wl->height);
   wl->shell_surf = wl_shell_get_shell_surface(wl->shell, wl->surface);

   wl_shell_surface_add_listener(wl->shell_surf, &shell_surface_listener, NULL);
   wl_shell_surface_set_toplevel(wl->shell_surf);
   wl_shell_surface_set_class(wl->shell_surf, "RetroArch");
   wl_shell_surface_set_title(wl->shell_surf, "RetroArch");

   if (!egl_create_context(wl, (attr != egl_attribs) ? egl_attribs : NULL))
   {
      egl_report_error();
      goto error;
   }

   if (!egl_create_surface(wl, (EGLNativeWindowType)wl->win))
      goto error;

   egl_set_swap_interval(wl, wl->egl.interval);

   if (fullscreen)
      wl_shell_surface_set_fullscreen(wl->shell_surf, WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, NULL);

   flush_wayland_fd(wl);
   return true;

error:
   gfx_ctx_wl_destroy(data);
   return false;
}
Пример #22
0
static struct cursor_surface *
cursor_viewer_show_cursor(struct cursor_viewer *viewer, const char *name)
{
    struct wl_cursor_image *cursor_image;
    struct wl_buffer *cursor_buffer = NULL;

    struct cursor_surface *cursor = calloc(1, sizeof (struct cursor_surface));
    if (!cursor)
        die("Cannot allocate memory for cursor_surface\n");

    cursor->name = name;
    cursor->surface = wl_compositor_create_surface(viewer->compositor);
    cursor->shsurf = wl_shell_get_shell_surface(viewer->shell, cursor->surface);

    wl_shell_surface_add_listener(cursor->shsurf, &shsurf_listener, viewer);
    wl_shell_surface_set_toplevel(cursor->shsurf);
    wl_shell_surface_set_title(cursor->shsurf, name);
    wl_surface_set_user_data(cursor->surface, viewer);

    cursor->cursor = wl_cursor_theme_get_cursor(viewer->cursor_theme, name);
    if (!cursor->cursor || cursor->cursor->image_count < 1) {
        printf("No such cursor: %s\n", name);
        cursor_surface_destroy(cursor);
        return NULL;
    }

    cursor_image = cursor->cursor->images[0];
    cursor_buffer = wl_cursor_image_get_buffer(cursor_image);

    printf("%s: %s: size=%dx%d image_count=%u\n",
        __func__, cursor->name,
        cursor_image->width, cursor_image->height,
        cursor->cursor->image_count);

    if (cursor->cursor->image_count > 1) {
        cursor->frame = wl_surface_frame(cursor->surface);
        wl_callback_add_listener(cursor->frame, &frame_listener, cursor);
    }

    wl_surface_attach(cursor->surface, cursor_buffer, 0, 0);
    wl_surface_damage(cursor->surface, 0, 0, cursor_image->width, cursor_image->height);
    wl_surface_commit(cursor->surface);

    return cursor;
}
Пример #23
0
bool
NativeStateWayland::create_window(WindowProperties const& properties)
{
    struct my_output *output = 0;
    if (!display_->outputs.empty()) output = display_->outputs.at(0);
    window_ = new struct my_window();
    window_->properties = properties;
    window_->surface = wl_compositor_create_surface(display_->compositor);
    if (window_->properties.fullscreen && output) {
        window_->native = wl_egl_window_create(window_->surface,
                                               output->width, output->height);
        window_->properties.width = output->width;
        window_->properties.height = output->height;
    } else {
        window_->native = wl_egl_window_create(window_->surface,
                                               properties.width, properties.height);
    }

    window_->opaque_reqion = wl_compositor_create_region(display_->compositor);
    wl_region_add(window_->opaque_reqion, 0, 0,
                  window_->properties.width,
                  window_->properties.height);
    wl_surface_set_opaque_region(window_->surface, window_->opaque_reqion);

    window_->shell_surface = wl_shell_get_shell_surface(display_->shell,
                                                        window_->surface);

    if (window_->shell_surface) {
        wl_shell_surface_add_listener(window_->shell_surface,
                                      &shell_surface_listener_, this);
    }

    wl_shell_surface_set_title(window_->shell_surface, "glmark2");

    if (window_->properties.fullscreen) {
        wl_shell_surface_set_fullscreen(window_->shell_surface,
                                        WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER,
                                        output->refresh, output->output);
    } else {
        wl_shell_surface_set_toplevel(window_->shell_surface);
    }

    return true;
}
Пример #24
0
void *cWaylandInterface::CreateWindow(void)
{
	GLWin.window_size.width = 640;
	GLWin.window_size.height = 480;
	GLWin.fullscreen = true;

	GLWin.wl_surface = wl_compositor_create_surface(GLWin.wl_compositor);
	GLWin.wl_shell_surface = wl_shell_get_shell_surface(GLWin.wl_shell,
							   GLWin.wl_surface);

	wl_shell_surface_add_listener(GLWin.wl_shell_surface,
				      &shell_surface_listener, 0);

	GLWin.wl_egl_native = wl_egl_window_create(GLWin.wl_surface,
						   GLWin.window_size.width,
						   GLWin.window_size.height);

	return GLWin.wl_egl_native;
}
Пример #25
0
ShellSurface::ShellSurface(const Shell& shell, const Surface& surface)
	: shell_(shell)
	, surface_(surface)
	, wl_shell_surface_(
		wl_shell_get_shell_surface(shell, surface))
{
	ASSERT(wl_shell_surface_ != NULL);

	wl_shell_surface_set_user_data(*this, this);
	
	static const wl_shell_surface_listener listener = {
		ping, configure, popupDone};

	wl_shell_surface_add_listener(*this, &listener, this);

	wl_shell_surface_set_toplevel(*this);

	shell.display().roundtrip();
}
Пример #26
0
BOOL wl_post_connect(freerdp* instance)
{
	struct window* window;
	struct wl_context* context;

	context = (struct wl_context*) instance->context;

	window = malloc(sizeof(*window));
	window->width = instance->settings->DesktopWidth;
	window->height = instance->settings->DesktopHeight;
	window->buffers[0].busy = 0;
	window->buffers[1].busy = 0;
	window->callback = NULL;
	window->display = context->display;
	window->surface = wl_compositor_create_surface(window->display->compositor);
	window->shell_surface = wl_shell_get_shell_surface(window->display->shell, window->surface);

	wl_shell_surface_add_listener(window->shell_surface, &wl_shell_surface_listener, NULL);
	wl_shell_surface_set_title(window->shell_surface, "FreeRDP");
	wl_shell_surface_set_toplevel(window->shell_surface);
	wl_surface_damage(window->surface, 0, 0, window->width, window->height);

	 /* GC/GDI logic here */
	rdpGdi* gdi;

	gdi_init(instance, CLRCONV_ALPHA | CLRCONV_INVERT | CLRBUF_32BPP, NULL);
	gdi = instance->context->gdi;

	 /* fill buffer with first image here */
	window->data = malloc (gdi->width * gdi->height *4);
	memcpy(window->data, (void*) gdi->primary_buffer, gdi->width * gdi->height * 4);
	instance->update->BeginPaint = wl_begin_paint;
	instance->update->EndPaint = wl_end_paint;

	 /* put Wayland data in the context here */
	context->window = window;

	freerdp_channels_post_connect(instance->context->channels, instance);

	window_redraw(window, NULL, 0);

	return TRUE;
}
Пример #27
0
static void create_window (struct window *window, int32_t width, int32_t height) {
	eglBindAPI (EGL_OPENGL_API);
	EGLint attributes[] = {
		EGL_RED_SIZE, 8,
		EGL_GREEN_SIZE, 8,
		EGL_BLUE_SIZE, 8,
	EGL_NONE};
	EGLConfig config;
	EGLint num_config;
	eglChooseConfig (egl_display, attributes, &config, 1, &num_config);
	window->egl_context = eglCreateContext (egl_display, config, EGL_NO_CONTEXT, NULL);
	
	window->surface = wl_compositor_create_surface (compositor);
	window->shell_surface = wl_shell_get_shell_surface (shell, window->surface);
	wl_shell_surface_add_listener (window->shell_surface, &shell_surface_listener, window);
	wl_shell_surface_set_toplevel (window->shell_surface);
	window->egl_window = wl_egl_window_create (window->surface, width, height);
	window->egl_surface = eglCreateWindowSurface (egl_display, config, window->egl_window, NULL);
	eglMakeCurrent (egl_display, window->egl_surface, window->egl_surface, window->egl_context);
}
Пример #28
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;
}
EGLNativeWindowType createSubWindow(FBNativeWindowType p_window,
                                    EGLNativeDisplayType display,
                                    int x, int y,int width, int height) {

    /* krnlyng */
    printf("creating sub window\n"); 
#ifndef X11
    if(get_server_references(display) < 0) return NULL;

    surface = wl_compositor_create_surface(compositor);
    if(surface == NULL)
    {
        fprintf(stderr, "Cannot create wl surface\n");
        return NULL;
    }

    shell_surface = wl_shell_get_shell_surface(shell, surface);
    wl_shell_surface_set_toplevel(shell_surface);

    create_opaque_region(width, height);

    EGLNativeWindowType win = wl_egl_window_create(surface, width, height);
    if(win == EGL_NO_SURFACE || win == NULL)
    {
        fprintf(stderr, "wl_egl_window_create failed\n");
    }
    printf("created sub window\n");

    return win;
#else
    XSetWindowAttributes wa;
    wa.event_mask = StructureNotifyMask;
    Window win = XCreateWindow(display,p_window,x,y, width,height,0,CopyFromParent,CopyFromParent,CopyFromParent,CWEventMask,&wa);
    XMapWindow(display,win);
    XEvent e;
    XIfEvent(display, &e, WaitForMapNotify, (char *)win);
    return win;
#endif
}
static gboolean
gst_vaapi_window_wayland_create(
    GstVaapiWindow *window,
    guint          *width,
    guint          *height
)
{
    GstVaapiWindowWaylandPrivate * const priv =
        GST_VAAPI_WINDOW_WAYLAND(window)->priv;
    GstVaapiDisplayWaylandPrivate * const priv_display =
        GST_VAAPI_OBJECT_DISPLAY_WAYLAND(window)->priv;

    GST_DEBUG("create window, size %ux%u", *width, *height);

    g_return_val_if_fail(priv_display->compositor != NULL, FALSE);
    g_return_val_if_fail(priv_display->shell != NULL, FALSE);

    priv->surface = wl_compositor_create_surface(priv_display->compositor);
    if (!priv->surface)
        return FALSE;

    priv->shell_surface =
        wl_shell_get_shell_surface(priv_display->shell, priv->surface);
    if (!priv->shell_surface)
        return FALSE;

    wl_shell_surface_add_listener(priv->shell_surface,
                                  &shell_surface_listener, priv);
    wl_shell_surface_set_toplevel(priv->shell_surface);
    wl_shell_surface_set_fullscreen(
        priv->shell_surface,
        WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE,
        0,
        NULL
    );

    priv->redraw_pending = FALSE;
    return TRUE;
}