void gst_wl_window_render (GstWlWindow * window, GstWlBuffer * buffer, const GstVideoInfo * info) { if (G_UNLIKELY (info)) { window->video_width = gst_util_uint64_scale_int_round (info->width, info->par_n, info->par_d); window->video_height = info->height; wl_subsurface_set_sync (window->video_subsurface); gst_wl_window_resize_video_surface (window, FALSE); gst_wl_window_set_opaque (window, info); } if (G_LIKELY (buffer)) gst_wl_buffer_attach (buffer, window->video_surface_wrapper); else wl_surface_attach (window->video_surface_wrapper, NULL, 0, 0); wl_surface_damage (window->video_surface_wrapper, 0, 0, window->video_rectangle.w, window->video_rectangle.h); wl_surface_commit (window->video_surface_wrapper); if (G_UNLIKELY (info)) { /* commit also the parent (area_surface) in order to change * the position of the video_subsurface */ wl_surface_damage (window->area_surface_wrapper, 0, 0, window->render_rectangle.w, window->render_rectangle.h); wl_surface_commit (window->area_surface_wrapper); wl_subsurface_set_desync (window->video_subsurface); } wl_display_flush (window->display->display); }
void render_frame(struct swaynag *swaynag) { if (!swaynag->run_display) { return; } cairo_surface_t *recorder = cairo_recording_surface_create( CAIRO_CONTENT_COLOR_ALPHA, NULL); cairo_t *cairo = cairo_create(recorder); cairo_save(cairo); cairo_set_operator(cairo, CAIRO_OPERATOR_CLEAR); cairo_paint(cairo); cairo_restore(cairo); uint32_t height = render_to_cairo(cairo, swaynag); if (height != swaynag->height) { zwlr_layer_surface_v1_set_size(swaynag->layer_surface, 0, height); zwlr_layer_surface_v1_set_exclusive_zone(swaynag->layer_surface, height); wl_surface_commit(swaynag->surface); wl_display_roundtrip(swaynag->display); } else { swaynag->current_buffer = get_next_buffer(swaynag->shm, swaynag->buffers, swaynag->width * swaynag->scale, swaynag->height * swaynag->scale); if (!swaynag->current_buffer) { sway_log(SWAY_DEBUG, "Failed to get buffer. Skipping frame."); goto cleanup; } cairo_t *shm = swaynag->current_buffer->cairo; cairo_save(shm); cairo_set_operator(shm, CAIRO_OPERATOR_CLEAR); cairo_paint(shm); cairo_restore(shm); cairo_set_source_surface(shm, recorder, 0.0, 0.0); cairo_paint(shm); wl_surface_set_buffer_scale(swaynag->surface, swaynag->scale); wl_surface_attach(swaynag->surface, swaynag->current_buffer->buffer, 0, 0); wl_surface_damage(swaynag->surface, 0, 0, swaynag->width, swaynag->height); wl_surface_commit(swaynag->surface); wl_display_roundtrip(swaynag->display); } cleanup: cairo_surface_destroy(recorder); cairo_destroy(cairo); }
static gboolean gst_mfx_window_wayland_resize (GstMfxWindow * window, guint width, guint height) { GstMfxWindowWaylandPrivate *const priv = GST_MFX_WINDOW_WAYLAND_GET_PRIVATE (window); GstMfxDisplayWaylandPrivate *const priv_display = GST_MFX_DISPLAY_WAYLAND_GET_PRIVATE (GST_MFX_WINDOW_DISPLAY (window)); GST_DEBUG ("resize window, new size %ux%u", width, height); GST_MFX_DISPLAY_LOCK (GST_MFX_WINDOW_DISPLAY (window)); #ifdef USE_WESTON_4_0 if (priv->wp_viewport) wp_viewport_set_destination (priv->wp_viewport, width, height); #else if (priv->viewport) wl_viewport_set_destination (priv->viewport, width, height); #endif wl_surface_damage (priv->surface, 0, 0, width, height); wl_surface_commit (priv->surface); if (priv->opaque_region) wl_region_destroy (priv->opaque_region); priv->opaque_region = wl_compositor_create_region (priv_display->compositor); wl_region_add (priv->opaque_region, 0, 0, width, height); GST_MFX_DISPLAY_UNLOCK (GST_MFX_WINDOW_DISPLAY (window)); return TRUE; }
static void pointer_handle_enter(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t sx, wl_fixed_t sy) { struct display *display = data; struct wl_buffer *buffer; struct wl_cursor *cursor = display->default_cursor; struct wl_cursor_image *image; if (display->window->fullscreen) wl_pointer_set_cursor(pointer, serial, NULL, 0, 0); else if (cursor) { image = display->default_cursor->images[0]; buffer = wl_cursor_image_get_buffer(image); wl_pointer_set_cursor(pointer, serial, display->cursor_surface, image->hotspot_x, image->hotspot_y); wl_surface_attach(display->cursor_surface, buffer, 0, 0); wl_surface_damage(display->cursor_surface, 0, 0, image->width, image->height); wl_surface_commit(display->cursor_surface); } }
void gst_wl_window_set_render_rectangle (GstWlWindow * window, gint x, gint y, gint w, gint h) { g_return_if_fail (window != NULL); window->render_rectangle.x = x; window->render_rectangle.y = y; window->render_rectangle.w = w; window->render_rectangle.h = h; /* position the area inside the parent - needs a parent commit to apply */ if (window->area_subsurface) wl_subsurface_set_position (window->area_subsurface, x, y); /* change the size of the area */ if (window->area_viewport) wp_viewport_set_destination (window->area_viewport, w, h); gst_wl_window_update_borders (window); if (window->video_width != 0) { wl_subsurface_set_sync (window->video_subsurface); gst_wl_window_resize_video_surface (window, TRUE); } wl_surface_damage (window->area_surface_wrapper, 0, 0, w, h); wl_surface_commit (window->area_surface_wrapper); if (window->video_width != 0) wl_subsurface_set_desync (window->video_subsurface); }
/* 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 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); } }
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 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; }
static void gst_wl_window_resize_video_surface (GstWlWindow * window, gboolean commit) { GstVideoRectangle src, res; /* center the video_subsurface inside area_subsurface */ src.w = window->video_width; src.h = window->video_height; gst_video_sink_center_rect (src, window->render_rectangle, &res, TRUE); wl_subsurface_set_position (window->video_subsurface, res.x, res.y); wl_viewport_set_destination (window->video_viewport, res.w, res.h); if (commit) { wl_surface_damage (window->video_surface, 0, 0, res.w, res.h); wl_surface_commit (window->video_surface); } if (gst_wl_window_is_toplevel (window)) { struct wl_region *region; region = wl_compositor_create_region (window->display->compositor); wl_region_add(region, 0, 0, window->render_rectangle.w, window->render_rectangle.h); wl_surface_set_input_region (window->area_surface, region); wl_region_destroy (region); } /* this is saved for use in wl_surface_damage */ window->surface_width = res.w; window->surface_height = res.h; }
static void setCursor(const char* name) { struct wl_buffer* buffer; struct wl_cursor* cursor; struct wl_cursor_image* image; struct wl_surface* surface = _glfw.wl.cursorSurface; cursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, name); if (!cursor) { _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Standard cursor not found"); return; } image = cursor->images[0]; if (!image) return; buffer = wl_cursor_image_get_buffer(image); if (!buffer) return; wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerSerial, surface, image->hotspot_x, image->hotspot_y); wl_surface_attach(surface, buffer, 0, 0); wl_surface_damage(surface, 0, 0, image->width, image->height); wl_surface_commit(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(); } 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; }
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; }
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; }
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 _evas_swapper_buffer_put(Wl_Swapper *ws, Wl_Buffer *wb, Eina_Rectangle *rects, unsigned int count) { Eina_Rectangle *rect; LOGFN(__FILE__, __LINE__, __FUNCTION__); /* check for valid swapper */ if (!ws) return; /* make sure swapper has a surface */ if (!ws->surface) return; /* check for valid buffer */ if (!wb) return; /* make sure buffer has mapped data */ if ((!wb->data) || (!wb->buffer)) { /* call function to mmap buffer data */ /* if (!_evas_swapper_buffer_new(ws, wb)) */ return; } rect = eina_rectangle_new(0, 0, 0, 0); if ((rects) && (count > 0)) { unsigned int i = 0; for (i = 0; i < count; i++) eina_rectangle_union(rect, &rects[i]); } else { Eina_Rectangle r; r.x = 0; r.y = 0; r.w = wb->w; r.h = wb->h; eina_rectangle_union(rect, &r); } /* surface attach */ if (ws->buffer_sent != wb) { wl_surface_attach(ws->surface, wb->buffer, ws->dx, ws->dy); ws->dx = 0; ws->dy = 0; ws->buffer_sent = wb; } wl_surface_damage(ws->surface, rect->x, rect->y, rect->w, rect->h); /* surface commit */ wl_surface_commit(ws->surface); eina_rectangle_free(rect); }
static void create_window() { buffer = create_buffer(); wl_surface_attach(surface, buffer, 0, 0); //wl_surface_damage(surface, 0, 0, WIDTH, HEIGHT); wl_surface_commit(surface); }
void hello_bind_buffer(struct wl_buffer *buffer, struct wl_shell_surface *shell_surface) { struct wl_surface *surface; surface = wl_shell_surface_get_user_data(shell_surface); wl_surface_attach(surface, buffer, 0, 0); wl_surface_commit(surface); }
int WaylandNativeWindow::postBuffer(ANativeWindowBuffer* buffer) { TRACE(""); WaylandNativeWindowBuffer *wnb = NULL; lock(); std::list<WaylandNativeWindowBuffer *>::iterator it = post_registered.begin(); for (; it != post_registered.end(); it++) { if ((*it)->other == buffer) { wnb = (*it); break; } } unlock(); if (!wnb) { wnb = new WaylandNativeWindowBuffer(buffer); wnb->common.incRef(&wnb->common); buffer->common.incRef(&buffer->common); } int ret = 0; lock(); wnb->busy = 1; ret = readQueue(false); unlock(); if (ret < 0) { return ret; } lock(); 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); post_registered.push_back(wnb); } TRACE("%p DAMAGE AREA: %dx%d", wnb, wnb->width, wnb->height); 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); wl_display_flush(m_display); posted.push_back(wnb); unlock(); return NO_ERROR; }
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; }
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; }
static void Display(vout_display_t *vd, picture_t *pic) { vout_display_sys_t *sys = vd->sys; struct wl_display *display = sys->embed->display.wl; struct wl_surface *surface = sys->embed->handle.wl; wl_surface_commit(surface); wl_display_roundtrip_queue(display, sys->eventq); (void) pic; }
static void clutter_wayland_handle_pointer_enter (void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y) { ClutterInputDeviceWayland *device = data; ClutterStageCogl *stage_cogl; ClutterEvent *event; ClutterBackend *backend; ClutterBackendWayland *backend_wayland; stage_cogl = wl_surface_get_user_data (surface); device->pointer_focus = stage_cogl; _clutter_input_device_set_stage (CLUTTER_INPUT_DEVICE (device), stage_cogl->wrapper); event = clutter_event_new (CLUTTER_ENTER); event->crossing.stage = stage_cogl->wrapper; event->crossing.time = 0; /* ?! */ event->crossing.x = wl_fixed_to_double(x); event->crossing.y = wl_fixed_to_double(y); event->crossing.source = CLUTTER_ACTOR (stage_cogl->wrapper); event->crossing.device = CLUTTER_INPUT_DEVICE (device); device->x = event->crossing.x; device->y = event->crossing.y; _clutter_event_push (event, FALSE); /* Set the cursor to the cursor loaded at backend initialisation */ backend = clutter_get_default_backend (); backend_wayland = CLUTTER_BACKEND_WAYLAND (backend); wl_pointer_set_cursor (pointer, serial, backend_wayland->cursor_surface, backend_wayland->cursor_x, backend_wayland->cursor_y); wl_surface_attach (backend_wayland->cursor_surface, backend_wayland->cursor_buffer, 0, 0); wl_surface_damage (backend_wayland->cursor_surface, 0, 0, 32, /* XXX: FFS */ 32); wl_surface_commit (backend_wayland->cursor_surface); }
// Makes the surface considered as XRGB instead of ARGB. static void setOpaqueRegion(_GLFWwindow* window) { struct wl_region* region; region = wl_compositor_create_region(_glfw.wl.compositor); if (!region) return; wl_region_add(region, 0, 0, window->wl.width, window->wl.height); wl_surface_set_opaque_region(window->wl.surface, region); wl_surface_commit(window->wl.surface); wl_region_destroy(region); }
static void _eventd_nd_cursor_set_image(EventdNdBackendContext *self, int i) { struct wl_buffer *buffer; struct wl_cursor_image *image; image = self->cursor.cursor->images[i]; self->cursor.image = image; buffer = wl_cursor_image_get_buffer(self->cursor.image); wl_surface_attach(self->cursor.surface, buffer, 0, 0); wl_surface_damage(self->cursor.surface, 0, 0, self->cursor.image->width, self->cursor.image->height); wl_surface_commit(self->cursor.surface); }
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 = wl_surface_frame(mSurface); wl_callback_add_listener(mFrameCallback,&QWaylandWindow::callbackListener,this); mWaitingForFrameSync = true; } wl_surface_damage(mSurface, rect.x(), rect.y(), rect.width(), rect.height()); wl_surface_commit(mSurface); }
void XdevLWindowWayland::setSize(const XdevLWindowSize& size) { XdevLWindowImpl::setSize(size); wl_egl_window_resize(m_egl.m_eglWindow, size.width, size.height, 0, 0); glClear(GL_COLOR_BUFFER_BIT); eglSwapBuffers(m_egl.m_eglDisplay, m_egl.m_eglSurface); wl_region* region = wl_compositor_create_region(m_compositor); wl_region_add(region, 0, 0, size.width, size.height); wl_surface_set_opaque_region(m_surface, region); wl_region_destroy(region); wl_surface_commit(m_surface); }
static void touch_paint(struct touch *touch, int32_t x, int32_t y, int32_t id) { uint32_t *p, c; static const uint32_t colors[] = { 0xffff0000, 0xffffff00, 0xff0000ff, 0xffff00ff, 0xff00ff00, 0xff00ffff, }; if (id < (int32_t) ARRAY_LENGTH(colors)) c = colors[id]; else c = 0xffffffff; if (x < 2 || x >= touch->width - 2 || y < 2 || y >= touch->height - 2) return; p = (uint32_t *) touch->data + (x - 2) + (y - 2) * touch->width; p[2] = c; p += touch->width; p[1] = c; p[2] = c; p[3] = c; p += touch->width; p[0] = c; p[1] = c; p[2] = c; p[3] = c; p[4] = c; p += touch->width; p[1] = c; p[2] = c; p[3] = c; p += touch->width; p[2] = c; wl_surface_attach(touch->surface, touch->buffer, 0, 0); wl_surface_damage(touch->surface, x - 2, y - 2, 5, 5); /* todo: We could queue up more damage before committing, if there * are more input events to handle. */ wl_surface_commit(touch->surface); }
static void pointer_enter(void *data, struct wl_pointer *wl_pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t surface_x, wl_fixed_t surface_y) { struct pointer_data *pointer_data; pointer_data = wl_pointer_get_user_data(wl_pointer); pointer_data->target_surface = surface; wl_surface_attach(pointer_data->surface, pointer_data->buffer, 0, 0); wl_surface_commit(pointer_data->surface); wl_pointer_set_cursor(wl_pointer, serial, pointer_data->surface, pointer_data->hot_spot_x, pointer_data->hot_spot_y); }
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); }