static void sync_callback(void *data, struct wl_callback *callback, uint32_t serial) { struct multiple_queues_state *state = data; state->done = true; wl_callback_destroy(callback); wl_display_dispatch_pending(state->display); wl_callback_destroy(state->callback2); }
UwacReturnCode UwacDestroyWindow(UwacWindow** pwindow) { UwacWindow* w; assert(pwindow); w = *pwindow; UwacWindowDestroyBuffers(w); if (w->frame_callback) wl_callback_destroy(w->frame_callback); if (w->xdg_surface) xdg_surface_destroy(w->xdg_surface); #if BUILD_IVI if (w->ivi_surface) ivi_surface_destroy(w->ivi_surface); #endif if (w->opaque_region) wl_region_destroy(w->opaque_region); if (w->input_region) wl_region_destroy(w->opaque_region); wl_surface_destroy(w->surface); wl_list_remove(&w->link); free(w); *pwindow = NULL; return UWAC_SUCCESS; }
static void frame_listener_func(void *data, struct wl_callback *callback, uint32_t time) { if (callback) { wl_callback_destroy(callback); } }
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; }
static void frame_redraw_callback (void *data, struct wl_callback *callback, uint32_t time) { struct window *window = (struct window *) data; window->redraw_pending = FALSE; wl_callback_destroy (callback); }
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 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 leak_closure(void) { struct wl_callback *cb; struct pollfd pfd; struct client *c = client_connect(); cb = wl_display_sync(c->wl_display); assert(cb); assert(wl_display_flush(c->wl_display) > 0); /* we don't need it, it is referenced */ wl_callback_destroy(cb); pfd.fd = wl_display_get_fd(c->wl_display); pfd.events = POLLIN; test_set_timeout(2); assert(poll(&pfd, 1, -1) == 1); /* read events, but do not dispatch them */ assert(wl_display_prepare_read(c->wl_display) == 0); assert(wl_display_read_events(c->wl_display) == 0); /* * now we have wl_callback.done and wl_display.delete_id queued; * if we now release the queue (in wl_display_disconnect()) * we should not leak memory */ client_disconnect(c); }
QWaylandWindow::~QWaylandWindow() { delete mWindowDecoration; if (isInitialized()) { delete mShellSurface; destroy(); } if (mFrameCallback) wl_callback_destroy(mFrameCallback); QList<QWaylandInputDevice *> inputDevices = mDisplay->inputDevices(); for (int i = 0; i < inputDevices.size(); ++i) inputDevices.at(i)->handleWindowDestroyed(this); const QWindow *parent = window(); foreach (QWindow *w, QGuiApplication::topLevelWindows()) { if (w->transientParent() == parent) QWindowSystemInterface::handleCloseEvent(w); } if (mMouseGrab == this) { mMouseGrab = 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 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; }
static void wayland_frame_callback(void *data, struct wl_callback *callback, uint32_t time) { WaylandNativeWindow *surface = static_cast<WaylandNativeWindow *>(data); surface->frame(); wl_callback_destroy(callback); }
static void roundtrip_callback(void *data, struct wl_callback *callback, uint32_t serial) { int *done = (int *)data; *done = 1; wl_callback_destroy(callback); }
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); }
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; }
static void sync_callback(void *data, struct wl_callback *callback, uint32_t time) { struct wl_egl_window *window = data; window->block_swap_buffers = 0; /* false */ wl_callback_destroy(callback); }
static void sync_callback(void *data, struct wl_callback *callback, uint32_t serial) { int *done = data; *done = 1; wl_callback_destroy(callback); }
void WaylandNativeWindow::sync_callback(void *data, struct wl_callback *callback, uint32_t serial) { int *done = static_cast<int *>(data); *done = 1; wl_callback_destroy(callback); }
static void init_sync_callback(void *data, struct wl_callback *callback, uint32_t serial) { GdkWaylandDisplay *display = data; display->init_ref_count--; wl_callback_destroy(callback); }
static void buffer_create_sync_callback(void *data, struct wl_callback *callback, uint32_t serial) { struct wl_callback **created_callback = static_cast<struct wl_callback **>(data); *created_callback = NULL; wl_callback_destroy(callback); }
static void wayland_frame_callback(void *data, struct wl_callback *callback, uint32_t time) { struct dri2_egl_surface *dri2_surf = data; dri2_surf->block_swap_buffers = EGL_FALSE; wl_callback_destroy(callback); }
static void free_frame_callback_data (FrameCallbackData *callback_data) { cogl_object_unref (callback_data->frame_info); wl_callback_destroy (callback_data->callback); _cogl_list_remove (&callback_data->link); g_slice_free (FrameCallbackData, callback_data); }
static void frame_done(void *data, struct wl_callback *callback, uint32_t time) { struct weston_output *output = data; wl_callback_destroy(callback); weston_output_finish_frame(output, time); }
static void frame_callback(void *data, struct wl_callback *callback, uint32_t time) { struct ModeInfo *mi = data; window_schedule_redraw(mi->window); wl_callback_destroy(callback); }
static void wayland_frame_callback(void *data, struct wl_callback *callback, uint32_t time) { //wsegl_info("wayland-wsegl: wayland_frame_callback"); struct wl_egl_window *drawable = (struct wl_egl_window *)data; drawable->display->frame_callback = NULL; wl_callback_destroy(callback); }
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(); }
static void wayland_frame_callback(void *data, struct wl_callback *callback, uint32_t time) { struct wayland_surface *surface = data; surface->block_swap_buffers = FALSE; wl_callback_destroy(callback); }
static void frame_callback_handler(void *data, struct wl_callback *callback, uint32_t time) { int *done = data; *done = 1; wl_callback_destroy(callback); }
void QWaylandXCompositeEGLWindow::done(void *data, struct wl_callback *callback, uint32_t time) { Q_UNUSED(time); bool *waitingForSync = static_cast<bool *>(data); *waitingForSync=false; wl_callback_destroy(callback); }