aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-11-26 13:18:44 +0100
committerSimon Ser <contact@emersion.fr>2020-12-13 12:16:28 +0100
commit441bac139fdfbbe576d3d87a91adeb906f9bd2a7 (patch)
tree47faaa69d47fbfbeec5a2b7d3e3c23a5085abd81
parent3923ff005ddc56729d0ed699dbdf47182f3f68c8 (diff)
backend/wayland: use wlr_swapchain for cursor surface
-rw-r--r--backend/wayland/output.c54
-rw-r--r--include/backend/wayland.h4
2 files changed, 40 insertions, 18 deletions
diff --git a/backend/wayland/output.c b/backend/wayland/output.c
index 540cc1f7..188c22b6 100644
--- a/backend/wayland/output.c
+++ b/backend/wayland/output.c
@@ -377,19 +377,30 @@ static bool output_set_cursor(struct wlr_output *wlr_output,
width = width * wlr_output->scale / scale;
height = height * wlr_output->scale / scale;
- output->cursor.width = width;
- output->cursor.height = height;
-
- if (output->cursor.egl_window == NULL) {
- output->cursor.egl_window =
- wl_egl_window_create(surface, width, height);
+ if (output->cursor.swapchain == NULL ||
+ output->cursor.swapchain->width != width ||
+ output->cursor.swapchain->height != height) {
+ wlr_swapchain_destroy(output->cursor.swapchain);
+ output->cursor.swapchain = wlr_swapchain_create(
+ output->backend->allocator, width, height,
+ output->backend->format);
+ if (output->cursor.swapchain == NULL) {
+ return false;
+ }
}
- wl_egl_window_resize(output->cursor.egl_window, width, height, 0, 0);
- EGLSurface egl_surface =
- wlr_egl_create_surface(&backend->egl, output->cursor.egl_window);
+ struct wlr_buffer *wlr_buffer =
+ wlr_swapchain_acquire(output->cursor.swapchain, NULL);
+ if (wlr_buffer == NULL) {
+ return false;
+ }
- wlr_egl_make_current(&backend->egl, egl_surface, NULL);
+ if (!wlr_egl_make_current(&output->backend->egl, EGL_NO_SURFACE, NULL)) {
+ return false;
+ }
+ if (!wlr_renderer_bind_buffer(output->backend->renderer, wlr_buffer)) {
+ return false;
+ }
struct wlr_box cursor_box = {
.width = width,
@@ -407,8 +418,23 @@ static bool output_set_cursor(struct wlr_output *wlr_output,
wlr_render_texture_with_matrix(backend->renderer, texture, matrix, 1.0);
wlr_renderer_end(backend->renderer);
- wlr_egl_swap_buffers(&backend->egl, egl_surface, NULL);
- wlr_egl_destroy_surface(&backend->egl, egl_surface);
+ wlr_renderer_bind_buffer(output->backend->renderer, NULL);
+ wlr_egl_unset_current(&output->backend->egl);
+
+ struct wlr_wl_buffer *buffer =
+ create_wl_buffer(output->backend, wlr_buffer);
+ if (buffer == NULL) {
+ return false;
+ }
+
+ wl_surface_attach(surface, buffer->wl_buffer, 0, 0);
+ wl_surface_damage_buffer(surface, 0, 0, INT32_MAX, INT32_MAX);
+ wl_surface_commit(surface);
+
+ wlr_buffer_unlock(wlr_buffer);
+
+ output->cursor.width = width;
+ output->cursor.height = height;
} else {
wl_surface_attach(surface, NULL, 0, 0);
wl_surface_commit(surface);
@@ -426,9 +452,7 @@ static void output_destroy(struct wlr_output *wlr_output) {
wl_list_remove(&output->link);
- if (output->cursor.egl_window != NULL) {
- wl_egl_window_destroy(output->cursor.egl_window);
- }
+ wlr_swapchain_destroy(output->cursor.swapchain);
if (output->cursor.surface) {
wl_surface_destroy(output->cursor.surface);
}
diff --git a/include/backend/wayland.h b/include/backend/wayland.h
index 8189c463..0ff52b51 100644
--- a/include/backend/wayland.h
+++ b/include/backend/wayland.h
@@ -4,9 +4,7 @@
#include <stdbool.h>
#include <wayland-client.h>
-#include <wayland-egl.h>
#include <wayland-server-core.h>
-#include <wayland-util.h>
#include <wlr/backend/wayland.h>
#include <wlr/render/egl.h>
@@ -79,7 +77,7 @@ struct wlr_wl_output {
struct {
struct wlr_wl_pointer *pointer;
struct wl_surface *surface;
- struct wl_egl_window *egl_window;
+ struct wlr_swapchain *swapchain;
int32_t hotspot_x, hotspot_y;
int32_t width, height;
} cursor;