static void
redraw(void *data, struct wl_callback *callback, uint32_t time)
{
	struct window *window = data;
	struct buffer *buffer;

	buffer = window_next_buffer(window);
	if (!buffer) {
		fprintf(stderr,
			!callback ? "Failed to create the first buffer.\n" :
			"Both buffers busy at redraw(). Server bug?\n");
		abort();
	}

	/* XXX: would be nice to draw something that changes here... */

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

	if (callback)
		wl_callback_destroy(callback);

	window->callback = wl_surface_frame(window->surface);
	wl_callback_add_listener(window->callback, &frame_listener, window);
	wl_surface_commit(window->surface);
	buffer->busy = 1;
}
/* must be called with the render lock */
static void
render_last_buffer (GstWaylandSink * sink)
{
  GstWlMeta *meta;
  struct wl_surface *surface;
  struct wl_callback *callback;

  meta = gst_buffer_get_wl_meta (sink->last_buffer);
  surface = gst_wl_window_get_wl_surface (sink->window);

  g_atomic_int_set (&sink->redraw_pending, TRUE);
  callback = wl_surface_frame (surface);
  wl_callback_add_listener (callback, &frame_callback_listener, sink);

  /* Here we essentially add a reference to the buffer. This represents
   * the fact that the compositor is using the buffer and it should
   * not return back to the pool and be reused until the compositor
   * releases it. The release is handled internally in the pool */
  gst_wayland_compositor_acquire_buffer (meta->pool, sink->last_buffer);

  wl_surface_attach (surface, meta->wbuffer, 0, 0);
  wl_surface_damage (surface, 0, 0, sink->window->surface_width,
      sink->window->surface_height);

  wl_surface_commit (surface);
  wl_display_flush (sink->display->display);
}
void QWaylandShmBackingStore::done(void *data, wl_callback *callback, uint32_t time)
{
    Q_UNUSED(time);
    QWaylandShmBackingStore *self =
            static_cast<QWaylandShmBackingStore *>(data);
    if (callback != self->mFrameCallback) // others, like QWaylandWindow, may trigger callbacks too
        return;
    QWaylandShmWindow *window = self->waylandWindow();
    wl_callback_destroy(self->mFrameCallback);
    self->mFrameCallback = 0;

    if (self->mFrontBuffer != window->attached()) {
        delete window->attached();
    }

    if (window->attached() != self->mFrontBuffer)
        window->attachOffset(self->mFrontBuffer);

    if (self->mFrontBufferIsDirty && !self->mPainting) {
        self->mFrontBufferIsDirty = false;
        self->mFrameCallback = wl_surface_frame(window->wl_surface());
        wl_callback_add_listener(self->mFrameCallback,&self->frameCallbackListener,self);
        window->damage(QRect(QPoint(0,0),self->mFrontBuffer->size()));
    }
}
static void
_cogl_winsys_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
                                                const int *rectangles,
                                                int n_rectangles)
{
  CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
  CoglOnscreenWayland *wayland_onscreen = egl_onscreen->platform;
  FrameCallbackData *frame_callback_data = g_slice_new (FrameCallbackData);

  flush_pending_resize (onscreen);

  /* Before calling the winsys function,
   * cogl_onscreen_swap_buffers_with_damage() will have pushed the
   * frame info object onto the end of the pending frames. We can grab
   * it out of the queue now because we don't care about the order and
   * we will just directly queue the event corresponding to the exact
   * frame that Wayland reports as completed. This will steal the
   * reference */
  frame_callback_data->frame_info =
    g_queue_pop_tail (&onscreen->pending_frame_infos);
  frame_callback_data->onscreen = onscreen;

  frame_callback_data->callback =
    wl_surface_frame (wayland_onscreen->wayland_surface);
  wl_callback_add_listener (frame_callback_data->callback,
                            &frame_listener,
                            frame_callback_data);

  _cogl_list_insert (&wayland_onscreen->frame_callbacks,
                     &frame_callback_data->link);

  parent_vtable->onscreen_swap_buffers_with_damage (onscreen,
                                                    rectangles,
                                                    n_rectangles);
}
Exemple #5
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);
    }
static void
redraw(void *data, struct wl_callback *callback, uint32_t time)
{
	struct window *window = data;
	struct buffer *buffer;

	buffer = window_next_buffer(window);
	if (!buffer) {
		fprintf(stderr,
			!callback ? "Failed to create the first buffer.\n" :
			"Both buffers busy at redraw(). Server bug?\n");
		abort();
	}

	paint_pixels(buffer->shm_data, 20, window->width, window->height, time);

	wl_surface_attach(window->surface, buffer->buffer, 0, 0);
	wl_surface_damage(window->surface,
			  20, 20, window->width - 40, window->height - 40);

	if (callback)
		wl_callback_destroy(callback);

	window->callback = wl_surface_frame(window->surface);
	wl_callback_add_listener(window->callback, &frame_listener, window);
	wl_surface_commit(window->surface);
	buffer->busy = 1;
}
Exemple #7
0
/* Swap the contents of a drawable to the screen */
static WSEGLError wseglSwapDrawable
    (WSEGLDrawableHandle _drawable, unsigned long data)
{
    struct wl_egl_window *drawable = (struct wl_egl_window *) _drawable;
    struct wl_callback *callback;

    if (drawable->numFlipBuffers)
    {
        PVR2DPresentFlip(drawable->display->context, drawable->flipChain, drawable->backBuffers[drawable->currentBackBuffer], 0);
    }
    else if (drawable->display->display)
    { 
        while (drawable->block_swap_buffers == 1)
          wl_display_iterate(drawable->display->display,
          WL_DISPLAY_READABLE);
        drawable->block_swap_buffers = 1;
        callback = wl_display_sync(drawable->display->display);
        wl_callback_add_listener(callback, &sync_listener, drawable);

        wl_buffer_damage(drawable->drmbuffers[drawable->currentBackBuffer], 0, 0,
         drawable->width, drawable->height);
        wl_surface_attach(drawable->surface,
         drawable->drmbuffers[drawable->currentBackBuffer], 0, 0);
        wl_surface_damage(drawable->surface, 0, 0, drawable->width,
         drawable->height);

    }
    else
    {
       PVR2DBLTINFO blit;

       memset(&blit, 0, sizeof(blit));
    
       blit.CopyCode = PVR2DROPcopy;
       blit.BlitFlags = PVR2D_BLIT_DISABLE_ALL;
       blit.pSrcMemInfo = drawable->backBuffers[drawable->currentBackBuffer];
       blit.SrcStride = drawable->strideBytes;
       blit.SrcX = 0;
       blit.SrcY = 0;
       blit.SizeX = drawable->width;
       blit.SizeY = drawable->height;
       blit.SrcFormat = wsegl2pvr2dformat(drawable->format);

       blit.pDstMemInfo = drawable->frontBufferPVRMEM;
       blit.DstStride = drawable->strideBytes; 
       blit.DstX = 0;
       blit.DstY = 0;
       blit.DSizeX = drawable->width;
       blit.DSizeY = drawable->height;
       blit.DstFormat = wsegl2pvr2dformat(drawable->format);
       PVR2DBlt(drawable->display->context, &blit); 
       PVR2DQueryBlitsComplete
          (drawable->display->context, drawable->frontBufferPVRMEM, 1);                      
    }
    
    drawable->currentBackBuffer   
      = (drawable->currentBackBuffer + 1) % WAYLANDWSEGL_MAX_BACK_BUFFERS;

    return WSEGL_SUCCESS;
}
Exemple #8
0
static void
triangle_frame_callback(void *data, struct wl_callback *callback,
			uint32_t time)
{
	struct triangle *tri = data;

	DBG("%stime %u\n", callback ? "" : "artificial ", time);
	assert(callback == tri->frame_cb);
	tri->time = time;

	if (callback)
		wl_callback_destroy(callback);

	eglMakeCurrent(tri->egl->dpy, tri->egl_surface,
				   tri->egl_surface, tri->egl->ctx);

	glViewport(0, 0, tri->width, tri->height);

	triangle_draw(&tri->gl, tri->time);

	tri->frame_cb = wl_surface_frame(tri->wl_surface);
	wl_callback_add_listener(tri->frame_cb, &triangle_frame_listener, tri);

	eglSwapBuffers(tri->egl->dpy, tri->egl_surface);
}
static void
set_fullscreen(struct window *window, int fullscreen)
{
	struct wl_callback *callback;

	window->fullscreen = fullscreen;
	window->configured = 0;

	if (fullscreen) {
		wl_shell_surface_set_fullscreen(window->shell_surface,
						WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
						0, NULL);
		callback = wl_display_sync(window->display->display);
		wl_callback_add_listener(callback,
					 &configure_callback_listener,
					 window);

	} else {
		wl_shell_surface_set_toplevel(window->shell_surface);
		handle_configure(window, window->shell_surface, 0,
				 window->window_size.width,
				 window->window_size.height);
		window->configured = 1;
	}
}
Exemple #10
0
static void
locked_pointer_frame_callback(void *data,
			      struct wl_callback *callback,
			      uint32_t time)
{
	struct resizor *resizor = data;
	struct wl_surface *surface;
	struct rectangle allocation;
	float x, y;

	if (resizor->pointer_locked) {
		widget_get_allocation(resizor->widget, &allocation);

		x = resizor->pointer_x + (allocation.width - allocation.x);
		y = resizor->pointer_y + (allocation.height - allocation.y);

		widget_set_locked_pointer_cursor_hint(resizor->widget, x, y);
	}

	wl_callback_destroy(callback);

	surface = window_get_wl_surface(resizor->window);
	callback = wl_surface_frame(surface);
	wl_callback_add_listener(callback,
				 &locked_pointer_frame_listener,
				 resizor);
}
Exemple #11
0
static void
dri2_release_buffers(struct dri2_egl_surface *dri2_surf)
{
   struct dri2_egl_display *dri2_dpy =
      dri2_egl_display(dri2_surf->base.Resource.Display);
   struct wl_callback *callback;
   int i;

   if (dri2_surf->third_buffer) {
      dri2_dpy->dri2->releaseBuffer(dri2_dpy->dri_screen,
                                    dri2_surf->third_buffer);
      dri2_surf->third_buffer = NULL;
   }

   for (i = 0; i < __DRI_BUFFER_COUNT; ++i) {
      if (dri2_surf->dri_buffers[i]) {
         switch (i) {
         case __DRI_BUFFER_FRONT_LEFT:
            if (dri2_surf->pending_buffer)
	      wl_display_roundtrip(dri2_dpy->wl_dpy);
            dri2_surf->pending_buffer = dri2_surf->dri_buffers[i];
            callback = wl_display_sync(dri2_dpy->wl_dpy);
	    wl_callback_add_listener(callback,
				     &release_buffer_listener, dri2_surf);
            break;
         default:
            dri2_dpy->dri2->releaseBuffer(dri2_dpy->dri_screen,
                                          dri2_surf->dri_buffers[i]);
            break;
         }
         dri2_surf->dri_buffers[i] = NULL;
      }
   }
}
Exemple #12
0
void setup_callback_listener()
{
	struct wl_callback *callback;

	callback = wl_display_sync(GLWin.wl_display);
	wl_callback_add_listener(callback, &configure_callback_listener, 0);
}
Exemple #13
0
static void
frame_callback(void *data, struct wl_callback *callback, uint32_t time)
{
	struct resizor *resizor = data;

	assert(!callback || callback == resizor->frame_callback);

	if (resizor->frame_callback) {
		wl_callback_destroy(resizor->frame_callback);
		resizor->frame_callback = NULL;
	}

	if (window_is_maximized(resizor->window))
		return;

	spring_update(&resizor->width);
	spring_update(&resizor->height);

	widget_schedule_resize(resizor->widget,
			       resizor->width.current + 0.5,
			       resizor->height.current + 0.5);

	if (!spring_done(&resizor->width) || !spring_done(&resizor->height)) {
		resizor->frame_callback =
			wl_surface_frame(
				window_get_wl_surface(resizor->window));
		wl_callback_add_listener(resizor->frame_callback, &listener,
					 resizor);
	}
}
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 #15
0
static void wl_callback_done(void* data, struct wl_callback* callback, uint32_t time)
{
	wlfWindow* window = data;
	wlfBuffer* buffer;
	struct wl_shm_pool* shm_pool;
	void* shm_data;
	void* free_data;
	int fd;
	int fdt;

	if (!window->buffers[0].busy)
		buffer = &window->buffers[0];
	else if (!window->buffers[1].busy)
		buffer = &window->buffers[1];
	else
		return;

	if (!buffer->buffer) {
		fd = shm_open("/wlfreerdp_shm", O_CREAT | O_RDWR, 0666);
		fdt = ftruncate(fd, window->width * window->height * 4);
		if (fdt != 0)
		{
			WLog_ERR(TAG, "window_redraw: could not allocate memory");
			close(fd);
			return;
		}

		shm_data = mmap(NULL, window->width * window->height * 4, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
		if (shm_data == MAP_FAILED)
		{
			WLog_ERR(TAG, "window_redraw: failed to memory map buffer");
			close(fd);
			return;
		}

		shm_pool = wl_shm_create_pool(window->display->shm, fd, window->width * window->height * 4);
		buffer->buffer = wl_shm_pool_create_buffer(shm_pool, 0, window->width, window->height, window->width* 4, WL_SHM_FORMAT_XRGB8888);
		wl_buffer_add_listener(buffer->buffer, &wl_buffer_listener, buffer);
		wl_shm_pool_destroy(shm_pool);
		shm_unlink("/wlfreerdp_shm");
		close(fd);

		free_data = buffer->shm_data;
		buffer->shm_data = shm_data;
		munmap(free_data, window->width * window->height * 4);
	}

	 /* this is the real surface data */
	memcpy(buffer->shm_data, (void*) window->data, window->width * window->height * 4);
	wl_surface_attach(window->surface, buffer->buffer, 0, 0);
	wl_surface_damage(window->surface, 0, 0, window->width, window->height);

	if (callback) wl_callback_destroy(callback);
	window->callback = wl_surface_frame(window->surface);
	wl_callback_add_listener(window->callback, &wl_callback_listener, window);
	wl_surface_commit(window->surface);

	buffer->busy = TRUE;
}
Exemple #16
0
static void
redraw(void *data, struct wl_callback *callback, uint32_t time)
{
	struct window *window = data;
	static const GLfloat verts[3][2] = {
		{ -0.5, -0.5 },
		{  0.5, -0.5 },
		{  0,    0.5 }
	};
	static const GLfloat colors[3][3] = {
		{ 1, 0, 0 },
		{ 0, 1, 0 },
		{ 0, 0, 1 }
	};
	GLfloat angle;
	GLfloat rotation[4][4] = {
		{ 1, 0, 0, 0 },
		{ 0, 1, 0, 0 },
		{ 0, 0, 1, 0 },
		{ 0, 0, 0, 1 }
	};
	static const int32_t speed_div = 5;
	static uint32_t start_time = 0;

	if (start_time == 0)
		start_time = time;

	angle = ((time-start_time) / speed_div) % 360 * M_PI / 180.0;
	rotation[0][0] =  cos(angle);
	rotation[0][2] =  sin(angle);
	rotation[2][0] = -sin(angle);
	rotation[2][2] =  cos(angle);

	glUniformMatrix4fv(window->gl.rotation_uniform, 1, GL_FALSE,
			   (GLfloat *) rotation);

	glClearColor(0.0, 0.0, 0.0, 0.5);
	glClear(GL_COLOR_BUFFER_BIT);

	glVertexAttribPointer(window->gl.pos, 2, GL_FLOAT, GL_FALSE, 0, verts);
	glVertexAttribPointer(window->gl.col, 3, GL_FLOAT, GL_FALSE, 0, colors);
	glEnableVertexAttribArray(window->gl.pos);
	glEnableVertexAttribArray(window->gl.col);

	glDrawArrays(GL_TRIANGLES, 0, 3);

	glDisableVertexAttribArray(window->gl.pos);
	glDisableVertexAttribArray(window->gl.col);

	glFlush();

	eglSwapBuffers(window->display->egl.dpy, window->egl_surface);
	if (callback)
		wl_callback_destroy(callback);

	window->callback = wl_surface_frame(window->surface);
	wl_callback_add_listener(window->callback, &frame_listener, window);
}
void WaylandNativeWindow::finishSwap()
{
    int ret = 0;
    lock();

    WaylandNativeWindowBuffer *wnb = queue.front();
    if (!wnb) {
        wnb = m_lastBuffer;
    } else {
        queue.pop_front();
    }
    assert(wnb);
    m_lastBuffer = wnb;
    wnb->busy = 1;

    ret = readQueue(false);
    if (this->frame_callback) {
        do {
            ret = readQueue(true);
        } while (this->frame_callback && ret != -1);
    }
    if (ret < 0) {
        HYBRIS_TRACE_END("wayland-platform", "queueBuffer_wait_for_frame_callback", "-%p", wnb);
        return;
    }

    if (wnb->wlbuffer == NULL)
    {
        wnb->wlbuffer_from_native_handle(m_android_wlegl, m_display, wl_queue);
        TRACE("%p add listener with %p inside", wnb, wnb->wlbuffer);
        wl_buffer_add_listener(wnb->wlbuffer, &wl_buffer_listener, this);
        wl_proxy_set_queue((struct wl_proxy *) wnb->wlbuffer, this->wl_queue);
    }

    if (m_swap_interval > 0) {
        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);
    }

    wl_surface_attach(m_window->surface, wnb->wlbuffer, 0, 0);
    wl_surface_damage(m_window->surface, 0, 0, wnb->width, wnb->height);
    wl_surface_commit(m_window->surface);
    // Some compositors, namely Weston, queue buffer release events instead
    // of sending them immediately.  If a frame event is used, this should
    // not be a problem.  Without a frame event, we need to send a sync
    // request to ensure that they get flushed.
    wl_callback_destroy(wl_display_sync(m_display));
    wl_display_flush(m_display);
    fronted.push_back(wnb);

    m_window->attached_width = wnb->width;
    m_window->attached_height = wnb->height;

    m_damage_rects = NULL;
    m_damage_n_rects = 0;
    unlock();
}
Exemple #18
0
static void
wait_for_roundtrip(GdkWaylandDisplay *display)
{
  struct wl_callback *callback;

  display->init_ref_count++;
  callback = wl_display_sync(display->wl_display);
  wl_callback_add_listener(callback, &init_sync_listener, display);
}
Exemple #19
0
int window_render(struct window *window) {
	window->frame_cb = wl_surface_frame(window->surface);
	wl_callback_add_listener(window->frame_cb, &listener, window);

	wl_surface_damage(window->surface, 0, 0, window->buffer->width, window->buffer->height);
	wl_surface_attach(window->surface, window->buffer->buffer, 0, 0);
	wl_surface_commit(window->surface);

	return 1;
}
Exemple #20
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;
}
Exemple #21
0
void Surface::setupFrameCallback()
{
    Q_D(Surface);

    if (!d->isInitialized())
        return;

    wl_callback *callback = d->frame();
    wl_callback_add_listener(callback, &d->callbackListener, d);
    d->frameCallbackInstalled = true;
}
struct wl_callback *
frame_callback_set(struct wl_surface *surface, int *done)
{
	struct wl_callback *callback;

	*done = 0;
	callback = wl_surface_frame(surface);
	wl_callback_add_listener(callback, &frame_listener, done);

	return callback;
}
void QWaylandXCompositeEGLWindow::createEglSurface()
{
    QSize size(geometry().size());
    if (size.isEmpty()) {
        // QGLWidget wants a context for a window without geometry
        size = QSize(1,1);
    }

    delete m_buffer;
    //XFreePixmap deletes the glxPixmap as well
    if (m_xWindow) {
        XDestroyWindow(m_glxIntegration->xDisplay(), m_xWindow);
    }

    VisualID visualId = QXlibEglIntegration::getCompatibleVisualId(m_glxIntegration->xDisplay(), m_glxIntegration->eglDisplay(), m_config);

    XVisualInfo visualInfoTemplate;
    memset(&visualInfoTemplate, 0, sizeof(XVisualInfo));
    visualInfoTemplate.visualid = visualId;

    int matchingCount = 0;
    XVisualInfo *visualInfo = XGetVisualInfo(m_glxIntegration->xDisplay(), VisualIDMask, &visualInfoTemplate, &matchingCount);

    Colormap cmap = XCreateColormap(m_glxIntegration->xDisplay(),m_glxIntegration->rootWindow(),visualInfo->visual,AllocNone);

    XSetWindowAttributes a;
    a.colormap = cmap;
    m_xWindow = XCreateWindow(m_glxIntegration->xDisplay(), m_glxIntegration->rootWindow(),0, 0, size.width(), size.height(),
                             0, visualInfo->depth, InputOutput, visualInfo->visual,
                             CWColormap, &a);

    XCompositeRedirectWindow(m_glxIntegration->xDisplay(), m_xWindow, CompositeRedirectManual);
    XMapWindow(m_glxIntegration->xDisplay(), m_xWindow);

    m_surface = eglCreateWindowSurface(m_glxIntegration->eglDisplay(), m_config, m_xWindow,0);
    if (m_surface == EGL_NO_SURFACE) {
        qFatal("Could not make eglsurface");
    }

    XSync(m_glxIntegration->xDisplay(),False);
    m_buffer = new QWaylandXCompositeBuffer(m_glxIntegration->waylandXComposite(),
                                           (uint32_t)m_xWindow,
                                           size);
    attach(m_buffer, 0, 0);

    m_waitingForSync = true;
    struct wl_callback *callback = wl_display_sync(m_glxIntegration->waylandDisplay()->wl_display());
    wl_callback_add_listener(callback,&m_callback_listener,&m_waitingForSync);

    m_glxIntegration->waylandDisplay()->flushRequests();
    while (m_waitingForSync)
        m_glxIntegration->waylandDisplay()->blockingReadEvents();
}
Exemple #24
0
static void
_gdk_wayland_display_async_roundtrip (GdkWaylandDisplay *display_wayland)
{
  struct wl_callback *callback;

  callback = wl_display_sync (display_wayland->wl_display);
  wl_callback_add_listener (callback,
                            &async_roundtrip_listener,
                            display_wayland);
  display_wayland->async_roundtrips =
    g_list_append (display_wayland->async_roundtrips, callback);
}
void QWaylandWindow::damage(const QRect &rect)
{
    //We have to do sync stuff before calling damage, or we might
    //get a frame callback before we get the timestamp
    if (!mWaitingForFrameSync) {
        mFrameCallback = frame();
        wl_callback_add_listener(mFrameCallback,&QWaylandWindow::callbackListener,this);
        mWaitingForFrameSync = true;
    }
    if (mBuffer) {
        damage(rect.x(), rect.y(), rect.width(), rect.height());
    }
}
Exemple #26
0
static void
_eventd_nd_cursor_frame_callback(void *data, struct wl_callback *callback, uint32_t time)
{
    EventdNdBackendContext *self = data;
    int i;

    if ( self->cursor.frame_cb != NULL )
        wl_callback_destroy(self->cursor.frame_cb);
    self->cursor.frame_cb = wl_surface_frame(self->cursor.surface);
    wl_callback_add_listener(self->cursor.frame_cb, &_eventd_nd_cursor_frame_wl_callback_listener, self);

    i = wl_cursor_frame(self->cursor.cursor, time);
    _eventd_nd_cursor_set_image(self, i);
}
int wayland_roundtrip(struct wl_egl_display *display)
{
    struct wl_callback *callback;
    int done = 0, ret = 0;
    wl_display_dispatch_queue_pending(display->display, display->queue);

    callback = wl_display_sync(display->display);
    wl_callback_add_listener(callback, &roundtrip_listener, &done);
    wl_proxy_set_queue((struct wl_proxy *)callback, display->queue);
    while (ret == 0 && !done)
        ret = wl_display_dispatch_queue(display->display, display->queue);

    return ret;
}
Exemple #28
0
/* Test that when receiving the first of two synchronization
 * callback events, destroying the second one doesn't cause any
 * errors even if the delete_id event is handled out of order. */
static int
client_test_multiple_queues(void)
{
	struct wl_event_queue *queue;
	struct wl_callback *callback1;
	struct multiple_queues_state state;
	int ret = 0;

	state.display = wl_display_connect(SOCKET_NAME);
	client_assert(state.display);

	/* Make the current thread the display thread. This is because
	 * wl_display_dispatch_queue() will only read the display fd if
	 * the main display thread has been set. */
	wl_display_dispatch_pending(state.display);

	queue = wl_display_create_queue(state.display);
	client_assert(queue);

	state.done = false;
	callback1 = wl_display_sync(state.display);
	wl_callback_add_listener(callback1, &sync_listener, &state);
	wl_proxy_set_queue((struct wl_proxy *) callback1, queue);

	state.callback2 = wl_display_sync(state.display);
	wl_callback_add_listener(state.callback2, &sync_listener, NULL);
	wl_proxy_set_queue((struct wl_proxy *) state.callback2, queue);

	wl_display_flush(state.display);

	while (!state.done && !ret)
		ret = wl_display_dispatch_queue(state.display, queue);

	wl_display_disconnect(state.display);

	return ret == -1 ? -1 : 0;
}
    int
WaylandNativeWindow::wayland_roundtrip(WaylandNativeWindow *display)
{
    struct wl_callback *callback;
    int done = 0, ret = 0;
    wl_display_dispatch_queue_pending(display->m_display, display->wl_queue);

    callback = wl_display_sync(display->m_display);
    wl_callback_add_listener(callback, &sync_listener, &done);
    wl_proxy_set_queue((struct wl_proxy *) callback, display->wl_queue);
    while (ret == 0 && !done)
        ret = wl_display_dispatch_queue(display->m_display, display->wl_queue);

    return ret;
}
	void XdevLWindowWayland::onPaint() {
		wl_callback_destroy(m_frameCallback);
		XdevLWindowPosition position = getPosition();
		XdevLWindowSize size = getSize();
		wl_surface_damage(m_surface, position.x, position.y, size.width, size.height);

		paint_pixels();

		m_frameCallback = wl_surface_frame(m_surface);
		wl_surface_attach(m_surface, m_buffer, 0, 0);


		wl_callback_add_listener(m_frameCallback, &frame_listener, this);

		wl_surface_commit(m_surface);
	}