aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md12
-rw-r--r--backend/drm/drm.c33
-rw-r--r--backend/wayland/backend.c10
-rw-r--r--backend/wayland/output.c101
-rw-r--r--include/backend/wayland.h17
-rw-r--r--include/wlr/interfaces/wlr_output.h5
-rw-r--r--include/wlr/types/wlr_layer_shell.h8
-rw-r--r--include/wlr/types/wlr_output_damage.h1
-rw-r--r--include/wlr/xwayland.h1
-rw-r--r--meson.build9
-rw-r--r--meson_options.txt2
-rw-r--r--rootston/desktop.c31
-rw-r--r--rootston/output.c3
-rw-r--r--types/wlr_layer_shell.c22
-rw-r--r--types/wlr_output.c99
-rw-r--r--types/wlr_output_damage.c9
-rw-r--r--xwayland/xwm.c7
17 files changed, 190 insertions, 180 deletions
diff --git a/README.md b/README.md
index 8ab2422e..08844313 100644
--- a/README.md
+++ b/README.md
@@ -59,15 +59,15 @@ Install dependencies:
If you choose to enable X11 support:
-* xkb
-* xkb-composite
-* xkb-xfixes
-* xkb-image
-* xkb-render
+* xcb
+* xcb-composite
+* xcb-xfixes
+* xcb-image
+* xcb-render
* x11-xcb
* xcb-errors (optional, for improved error reporting)
* x11-icccm (optional, for improved Xwayland introspection)
-* xkb-xcb (optional, for improved keyboard handling on the X11 backend)
+* xcb-xkb (optional, for improved keyboard handling on the X11 backend)
Run these commands:
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index 7ace90dc..e8ed7316 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -538,8 +538,8 @@ static void drm_connector_transform(struct wlr_output *output,
}
static bool drm_connector_set_cursor(struct wlr_output *output,
- const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height,
- int32_t hotspot_x, int32_t hotspot_y, bool update_pixels) {
+ struct wlr_texture *texture, int32_t hotspot_x, int32_t hotspot_y,
+ bool update_texture) {
struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output;
struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend;
struct wlr_drm_renderer *renderer = &drm->renderer;
@@ -568,11 +568,6 @@ static bool drm_connector_set_cursor(struct wlr_output *output,
ret = drmGetCap(drm->fd, DRM_CAP_CURSOR_HEIGHT, &h);
h = ret ? 64 : h;
- if (width > w || height > h) {
- wlr_log(L_INFO, "Cursor too large (max %dx%d)", (int)w, (int)h);
- return false;
- }
-
if (!init_drm_surface(&plane->surf, renderer, w, h,
GBM_FORMAT_ARGB8888, 0)) {
wlr_log(L_ERROR, "Cannot allocate cursor resources");
@@ -613,14 +608,22 @@ static bool drm_connector_set_cursor(struct wlr_output *output,
wlr_output_update_needs_swap(output);
}
- if (!update_pixels) {
+ if (!update_texture) {
// Don't update cursor image
return true;
}
- plane->cursor_enabled = buf != NULL;
+ plane->cursor_enabled = false;
+ if (texture != NULL) {
+ int width, height;
+ wlr_texture_get_size(texture, &width, &height);
+
+ if (width > (int)plane->surf.width || height > (int)plane->surf.height) {
+ wlr_log(L_ERROR, "Cursor too large (max %dx%d)",
+ (int)plane->surf.width, (int)plane->surf.height);
+ return false;
+ }
- if (buf != NULL) {
uint32_t bo_width = gbm_bo_get_width(plane->cursor_bo);
uint32_t bo_height = gbm_bo_get_height(plane->cursor_bo);
@@ -636,13 +639,6 @@ static bool drm_connector_set_cursor(struct wlr_output *output,
struct wlr_renderer *rend = plane->surf.renderer->wlr_rend;
- struct wlr_texture *texture = wlr_texture_from_pixels(rend,
- WL_SHM_FORMAT_ARGB8888, stride, width, height, buf);
- if (texture == NULL) {
- wlr_log(L_ERROR, "Unable to create texture");
- return false;
- }
-
wlr_renderer_begin(rend, plane->surf.width, plane->surf.height);
wlr_renderer_clear(rend, (float[]){ 0.0, 0.0, 0.0, 0.0 });
wlr_render_texture(rend, texture, plane->matrix, 0, 0, 1.0f);
@@ -653,8 +649,9 @@ static bool drm_connector_set_cursor(struct wlr_output *output,
swap_drm_surface_buffers(&plane->surf, NULL);
- wlr_texture_destroy(texture);
gbm_bo_unmap(plane->cursor_bo, bo_data);
+
+ plane->cursor_enabled = true;
}
if (!drm->session->active) {
diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c
index 15d8feab..dc50cf23 100644
--- a/backend/wayland/backend.c
+++ b/backend/wayland/backend.c
@@ -164,8 +164,16 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
goto error_registry;
}
+ static EGLint config_attribs[] = {
+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
+ EGL_RED_SIZE, 1,
+ EGL_GREEN_SIZE, 1,
+ EGL_BLUE_SIZE, 1,
+ EGL_ALPHA_SIZE, 1,
+ EGL_NONE,
+ };
if (!wlr_egl_init(&backend->egl, EGL_PLATFORM_WAYLAND_EXT,
- backend->remote_display, NULL, WL_SHM_FORMAT_ARGB8888)) {
+ backend->remote_display, config_attribs, WL_SHM_FORMAT_ARGB8888)) {
wlr_log(L_ERROR, "Could not initialize EGL");
goto error_egl;
}
diff --git a/backend/wayland/output.c b/backend/wayland/output.c
index 209b060f..c498fc4e 100644
--- a/backend/wayland/output.c
+++ b/backend/wayland/output.c
@@ -9,6 +9,7 @@
#include <wayland-client.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/render/wlr_renderer.h>
+#include <wlr/types/wlr_matrix.h>
#include <wlr/util/log.h>
#include "backend/wayland.h"
#include "util/signal.h"
@@ -72,8 +73,8 @@ static void output_transform(struct wlr_output *_output,
}
static bool output_set_cursor(struct wlr_output *_output,
- const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height,
- int32_t hotspot_x, int32_t hotspot_y, bool update_pixels) {
+ struct wlr_texture *texture, int32_t hotspot_x, int32_t hotspot_y,
+ bool update_texture) {
struct wlr_wl_output *output =
(struct wlr_wl_output *)_output;
struct wlr_wl_backend *backend = output->backend;
@@ -82,76 +83,47 @@ static bool output_set_cursor(struct wlr_output *_output,
output->cursor.hotspot_x = hotspot_x;
output->cursor.hotspot_y = hotspot_y;
- if (!update_pixels) {
+ if (!update_texture) {
// Update hotspot without changing cursor image
update_wl_output_cursor(output);
return true;
}
- if (!buf) {
- // Hide cursor
- if (output->cursor.surface) {
- wl_surface_destroy(output->cursor.surface);
- munmap(output->cursor.data, output->cursor.buf_size);
- output->cursor.surface = NULL;
- output->cursor.buf_size = 0;
- }
- update_wl_output_cursor(output);
- return true;
- }
- if (!backend->shm || !backend->pointer) {
- wlr_log(L_INFO, "cannot set cursor: no wl_shm or wl_pointer");
- return false;
- }
-
- if (!output->cursor.surface) {
+ if (output->cursor.surface == NULL) {
output->cursor.surface =
- wl_compositor_create_surface(output->backend->compositor);
+ wl_compositor_create_surface(backend->compositor);
}
+ struct wl_surface *surface = output->cursor.surface;
- uint32_t size = stride * height;
- if (output->cursor.buf_size != size) {
- if (output->cursor.buffer) {
- wl_buffer_destroy(output->cursor.buffer);
- }
+ if (texture != NULL) {
+ int width, height;
+ wlr_texture_get_size(texture, &width, &height);
- if (size > output->cursor.buf_size) {
- if (output->cursor.pool) {
- wl_shm_pool_destroy(output->cursor.pool);
- output->cursor.pool = NULL;
- munmap(output->cursor.data, output->cursor.buf_size);
- }
+ if (output->cursor.egl_window == NULL) {
+ output->cursor.egl_window =
+ wl_egl_window_create(surface, width, height);
}
+ wl_egl_window_resize(output->cursor.egl_window, width, height, 0, 0);
- if (!output->cursor.pool) {
- int fd = os_create_anonymous_file(size);
- if (fd < 0) {
- wlr_log_errno(L_INFO,
- "creating anonymous file for cursor buffer failed");
- return false;
- }
-
- output->cursor.data = mmap(NULL, size, PROT_READ | PROT_WRITE,
- MAP_SHARED, fd, 0);
- if (output->cursor.data == MAP_FAILED) {
- close(fd);
- wlr_log_errno(L_INFO, "mmap failed");
- return false;
- }
-
- output->cursor.pool = wl_shm_create_pool(backend->shm, fd, size);
- close(fd);
- }
+ EGLSurface egl_surface =
+ wlr_egl_create_surface(&backend->egl, output->cursor.egl_window);
- output->cursor.buffer = wl_shm_pool_create_buffer(output->cursor.pool,
- 0, width, height, stride, WL_SHM_FORMAT_ARGB8888);
- output->cursor.buf_size = size;
- }
+ wlr_egl_make_current(&backend->egl, egl_surface, NULL);
- memcpy(output->cursor.data, buf, size);
- wl_surface_attach(output->cursor.surface, output->cursor.buffer, 0, 0);
- wl_surface_damage(output->cursor.surface, 0, 0, width, height);
- wl_surface_commit(output->cursor.surface);
+ float matrix[9];
+ wlr_matrix_projection(matrix, width, height, WL_OUTPUT_TRANSFORM_NORMAL);
+
+ wlr_renderer_begin(backend->renderer, width, height);
+ wlr_renderer_clear(backend->renderer, (float[]){ 0.0, 0.0, 0.0, 0.0 });
+ wlr_render_texture(backend->renderer, texture, matrix, 0, 0, 1.0);
+ wlr_renderer_end(backend->renderer);
+
+ wlr_egl_swap_buffers(&backend->egl, egl_surface, NULL);
+ wlr_egl_destroy_surface(&backend->egl, egl_surface);
+ } else {
+ wl_surface_attach(surface, NULL, 0, 0);
+ wl_surface_commit(surface);
+ }
update_wl_output_cursor(output);
return true;
@@ -166,16 +138,9 @@ static void output_destroy(struct wlr_output *wlr_output) {
wl_list_remove(&output->link);
- if (output->cursor.buf_size != 0) {
- assert(output->cursor.data);
- assert(output->cursor.buffer);
- assert(output->cursor.pool);
-
- wl_buffer_destroy(output->cursor.buffer);
- munmap(output->cursor.data, output->cursor.buf_size);
- wl_shm_pool_destroy(output->cursor.pool);
+ if (output->cursor.egl_window != NULL) {
+ wl_egl_window_destroy(output->cursor.egl_window);
}
-
if (output->cursor.surface) {
wl_surface_destroy(output->cursor.surface);
}
diff --git a/include/backend/wayland.h b/include/backend/wayland.h
index 38c7ee32..fec328ba 100644
--- a/include/backend/wayland.h
+++ b/include/backend/wayland.h
@@ -40,25 +40,22 @@ struct wlr_wl_output {
struct wlr_output wlr_output;
struct wlr_wl_backend *backend;
+ struct wl_list link;
+
struct wl_surface *surface;
+ struct wl_callback *frame_callback;
struct zxdg_surface_v6 *xdg_surface;
struct zxdg_toplevel_v6 *xdg_toplevel;
struct wl_egl_window *egl_window;
- struct wl_callback *frame_callback;
+ EGLSurface egl_surface;
+
+ uint32_t enter_serial;
struct {
- struct wl_shm_pool *pool;
- void *buffer; // actually a (client-side) struct wl_buffer *
- uint32_t buf_size;
- uint8_t *data;
struct wl_surface *surface;
+ struct wl_egl_window *egl_window;
int32_t hotspot_x, hotspot_y;
} cursor;
-
- uint32_t enter_serial;
-
- void *egl_surface;
- struct wl_list link;
};
struct wlr_wl_input_device {
diff --git a/include/wlr/interfaces/wlr_output.h b/include/wlr/interfaces/wlr_output.h
index c9ddf615..d8c54067 100644
--- a/include/wlr/interfaces/wlr_output.h
+++ b/include/wlr/interfaces/wlr_output.h
@@ -13,9 +13,8 @@ struct wlr_output_impl {
int32_t height, int32_t refresh);
void (*transform)(struct wlr_output *output,
enum wl_output_transform transform);
- bool (*set_cursor)(struct wlr_output *output, const uint8_t *buf,
- int32_t stride, uint32_t width, uint32_t height,
- int32_t hotspot_x, int32_t hotspot_y, bool update_pixels);
+ bool (*set_cursor)(struct wlr_output *output, struct wlr_texture *texture,
+ int32_t hotspot_x, int32_t hotspot_y, bool update_texture);
bool (*move_cursor)(struct wlr_output *output, int x, int y);
void (*destroy)(struct wlr_output *output);
bool (*make_current)(struct wlr_output *output, int *buffer_age);
diff --git a/include/wlr/types/wlr_layer_shell.h b/include/wlr/types/wlr_layer_shell.h
index 22352906..1477989d 100644
--- a/include/wlr/types/wlr_layer_shell.h
+++ b/include/wlr/types/wlr_layer_shell.h
@@ -113,4 +113,12 @@ struct wlr_layer_surface *wlr_layer_surface_from_wlr_surface(
void wlr_layer_surface_for_each_surface(struct wlr_layer_surface *surface,
wlr_surface_iterator_func_t iterator, void *user_data);
+/**
+ * Find a surface within this layer-surface tree at the given surface-local
+ * coordinates. Returns the surface and coordinates in the leaf surface
+ * coordinate system or NULL if no surface is found at that location.
+ */
+struct wlr_surface *wlr_layer_surface_surface_at(
+ struct wlr_layer_surface *surface, double sx, double sy,
+ double *sub_x, double *sub_y);
#endif
diff --git a/include/wlr/types/wlr_output_damage.h b/include/wlr/types/wlr_output_damage.h
index beba2f6c..a4333c1a 100644
--- a/include/wlr/types/wlr_output_damage.h
+++ b/include/wlr/types/wlr_output_damage.h
@@ -23,6 +23,7 @@
*/
struct wlr_output_damage {
struct wlr_output *output;
+ int max_rects; // max number of damaged rectangles
pixman_region32_t current; // in output-local coordinates
diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h
index d0f37834..3507e547 100644
--- a/include/wlr/xwayland.h
+++ b/include/wlr/xwayland.h
@@ -109,6 +109,7 @@ struct wlr_xwayland_surface {
char *class;
char *instance;
pid_t pid;
+ bool has_utf8_title;
struct wl_list children; // wlr_xwayland_surface::parent_link
struct wlr_xwayland_surface *parent;
diff --git a/meson.build b/meson.build
index 19d334e3..362de9f6 100644
--- a/meson.build
+++ b/meson.build
@@ -201,8 +201,13 @@ summary = [
message('\n'.join(summary))
-subdir('rootston')
-subdir('examples')
+if get_option('enable-rootston')
+ subdir('rootston')
+endif
+
+if get_option('enable-examples')
+ subdir('examples')
+endif
pkgconfig = import('pkgconfig')
pkgconfig.generate(
diff --git a/meson_options.txt b/meson_options.txt
index de29e401..e474b8aa 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -4,3 +4,5 @@ option('enable-elogind', type: 'combo', choices: ['auto', 'true', 'false'], valu
option('enable-xcb_errors', type: 'combo', choices: ['auto', 'true', 'false'], value: 'auto', description: 'Use xcb-errors util library')
option('enable-xwayland', type: 'boolean', value: true, description: 'Enable support X11 applications')
option('enable-x11_backend', type: 'boolean', value: true, description: 'Enable X11 backend')
+option('enable-rootston', type: 'boolean', value: true, description: 'Build the rootston example compositor')
+option('enable-examples', type: 'boolean', value: true, description: 'Build example applications')
diff --git a/rootston/desktop.c b/rootston/desktop.c
index 7be1c64a..178a975a 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -641,30 +641,17 @@ static struct wlr_surface *layer_surface_at(struct roots_output *output,
struct wl_list *layer, double ox, double oy, double *sx, double *sy) {
struct roots_layer_surface *roots_surface;
wl_list_for_each_reverse(roots_surface, layer, link) {
- struct wlr_surface *wlr_surface;
- double _sx, _sy;
- struct wlr_xdg_popup *popup;
- wl_list_for_each(popup, &roots_surface->layer_surface->popups, link) {
- wlr_surface = popup->base->surface;
- _sx = ox - roots_surface->geo.x - popup->geometry.x;
- _sy = oy - roots_surface->geo.y - popup->geometry.y;
- if (wlr_surface_point_accepts_input(wlr_surface, _sx, _sy)) {
- *sx = _sx;
- *sy = _sy;
- return wlr_surface;
- }
- // TODO: popups can have popups
- }
- // TODO: Test subsurfaces
- wlr_surface = roots_surface->layer_surface->surface;
- _sx = ox - roots_surface->geo.x;
- _sy = oy - roots_surface->geo.y;
- if (wlr_surface_point_accepts_input(wlr_surface, _sx, _sy)) {
- *sx = _sx;
- *sy = _sy;
- return wlr_surface;
+ double _sx = ox - roots_surface->geo.x;
+ double _sy = oy - roots_surface->geo.y;
+
+ struct wlr_surface *sub = wlr_layer_surface_surface_at(
+ roots_surface->layer_surface, _sx, _sy, sx, sy);
+
+ if (sub) {
+ return sub;
}
}
+
return NULL;
}
diff --git a/rootston/output.c b/rootston/output.c
index d4c6d5a2..e07cd935 100644
--- a/rootston/output.c
+++ b/rootston/output.c
@@ -174,9 +174,8 @@ static void scissor_output(struct roots_output *output, pixman_box32_t *rect) {
};
int ow, oh;
- wlr_output_transformed_resolution(output->wlr_output, &ow, &oh);
+ wlr_output_transformed_resolution(wlr_output, &ow, &oh);
- // Scissor is in renderer coordinates, ie. upside down
enum wl_output_transform transform =
wlr_output_transform_invert(wlr_output->transform);
wlr_box_transform(&box, transform, ow, oh, &box);
diff --git a/types/wlr_layer_shell.c b/types/wlr_layer_shell.c
index fd7bc659..0fae048c 100644
--- a/types/wlr_layer_shell.c
+++ b/types/wlr_layer_shell.c
@@ -531,3 +531,25 @@ void wlr_layer_surface_for_each_surface(struct wlr_layer_surface *surface,
wlr_surface_iterator_func_t iterator, void *user_data) {
layer_surface_for_each_surface(surface, 0, 0, iterator, user_data);
}
+
+struct wlr_surface *wlr_layer_surface_surface_at(
+ struct wlr_layer_surface *surface, double sx, double sy,
+ double *sub_x, double *sub_y) {
+ struct wlr_xdg_popup *popup_state;
+ wl_list_for_each(popup_state, &surface->popups, link) {
+ struct wlr_xdg_surface *popup = popup_state->base;
+
+ double popup_sx = popup_state->geometry.x - popup->geometry.x;
+ double popup_sy = popup_state->geometry.y - popup->geometry.y;
+
+ struct wlr_surface *sub = wlr_xdg_surface_surface_at(popup,
+ sx - popup_sx,
+ sy - popup_sy,
+ sub_x, sub_y);
+ if (sub != NULL) {
+ return sub;
+ }
+ }
+
+ return wlr_surface_surface_at(surface->surface, sx, sy, sub_x, sub_y);
+}
diff --git a/types/wlr_output.c b/types/wlr_output.c
index d45e91a4..0973fbc7 100644
--- a/types/wlr_output.c
+++ b/types/wlr_output.c
@@ -245,6 +245,9 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
const struct wlr_output_impl *impl, struct wl_display *display) {
assert(impl->make_current && impl->swap_buffers && impl->transform);
+ if (impl->set_cursor || impl->move_cursor) {
+ assert(impl->set_cursor && impl->move_cursor);
+ }
output->backend = backend;
output->impl = impl;
output->display = display;
@@ -691,6 +694,28 @@ static void output_cursor_update_visible(struct wlr_output_cursor *cursor) {
cursor->visible = visible;
}
+static bool output_cursor_attempt_hardware(struct wlr_output_cursor *cursor) {
+ struct wlr_texture *texture = cursor->texture;
+ if (cursor->surface != NULL) {
+ texture = cursor->surface->texture;
+ }
+
+ struct wlr_output_cursor *hwcur = cursor->output->hardware_cursor;
+ if (cursor->output->impl->set_cursor && (hwcur == NULL || hwcur == cursor)) {
+ if (hwcur != cursor) {
+ assert(cursor->output->impl->move_cursor);
+ cursor->output->impl->move_cursor(cursor->output,
+ (int)cursor->x, (int)cursor->y);
+ }
+ if (cursor->output->impl->set_cursor(cursor->output, texture,
+ cursor->hotspot_x, cursor->hotspot_y, true)) {
+ cursor->output->hardware_cursor = cursor;
+ return true;
+ }
+ }
+ return false;
+}
+
bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
const uint8_t *pixels, int32_t stride, uint32_t width, uint32_t height,
int32_t hotspot_x, int32_t hotspot_y) {
@@ -706,33 +731,26 @@ bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
cursor->hotspot_y = hotspot_y;
output_cursor_update_visible(cursor);
- struct wlr_output_cursor *hwcur = cursor->output->hardware_cursor;
- if (cursor->output->impl->set_cursor && (hwcur == NULL || hwcur == cursor)) {
- if (cursor->output->impl->move_cursor && hwcur != cursor) {
- cursor->output->impl->move_cursor(cursor->output,
- (int)cursor->x, (int)cursor->y);
- }
- int ok = cursor->output->impl->set_cursor(cursor->output, pixels,
- stride, width, height, hotspot_x, hotspot_y, true);
- if (ok) {
- cursor->output->hardware_cursor = cursor;
- return true;
+ wlr_texture_destroy(cursor->texture);
+ cursor->texture = NULL;
+
+ cursor->enabled = false;
+ if (pixels != NULL) {
+ cursor->texture = wlr_texture_from_pixels(renderer,
+ WL_SHM_FORMAT_ARGB8888, stride, width, height, pixels);
+ if (cursor->texture == NULL) {
+ return false;
}
+ cursor->enabled = true;
}
- wlr_log(L_DEBUG, "Falling back to software cursor");
- output_cursor_damage_whole(cursor);
-
- cursor->enabled = pixels != NULL;
- if (!cursor->enabled) {
+ if (output_cursor_attempt_hardware(cursor)) {
return true;
}
- wlr_texture_destroy(cursor->texture);
-
- cursor->texture = wlr_texture_from_pixels(renderer, WL_SHM_FORMAT_ARGB8888,
- stride, width, height, pixels);
- return cursor->texture != NULL;
+ wlr_log(L_DEBUG, "Falling back to software cursor");
+ output_cursor_damage_whole(cursor);
+ return true;
}
static void output_cursor_commit(struct wlr_output_cursor *cursor) {
@@ -745,15 +763,15 @@ static void output_cursor_commit(struct wlr_output_cursor *cursor) {
cursor->width = cursor->surface->current->width * cursor->output->scale;
cursor->height = cursor->surface->current->height * cursor->output->scale;
- if (cursor->output->hardware_cursor != cursor) {
- output_cursor_damage_whole(cursor);
- } else {
- // TODO: upload pixels
-
+ if (output_cursor_attempt_hardware(cursor)) {
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
wlr_surface_send_frame_done(cursor->surface, &now);
+ return;
}
+
+ // Fallback to software cursor
+ output_cursor_damage_whole(cursor);
}
static void output_cursor_handle_commit(struct wl_listener *listener,
@@ -789,11 +807,9 @@ void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
cursor->hotspot_y = hotspot_y;
if (cursor->output->hardware_cursor != cursor) {
output_cursor_damage_whole(cursor);
- }
-
- if (cursor->output->hardware_cursor == cursor &&
- cursor->output->impl->set_cursor) {
- cursor->output->impl->set_cursor(cursor->output, NULL, 0, 0, 0,
+ } else {
+ assert(cursor->output->impl->set_cursor);
+ cursor->output->impl->set_cursor(cursor->output, NULL,
hotspot_x, hotspot_y, false);
}
return;
@@ -801,15 +817,6 @@ void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
output_cursor_reset(cursor);
- // Disable hardware cursor for surfaces
- // TODO: support hardware cursors
- if (cursor->output->hardware_cursor == cursor &&
- cursor->output->impl->set_cursor) {
- cursor->output->impl->set_cursor(cursor->output, NULL, 0, 0, 0, 0, 0,
- true);
- cursor->output->hardware_cursor = NULL;
- }
-
cursor->surface = surface;
cursor->hotspot_x = hotspot_x;
cursor->hotspot_y = hotspot_y;
@@ -826,7 +833,10 @@ void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
cursor->width = 0;
cursor->height = 0;
- // TODO: if hardware cursor, disable cursor
+ if (cursor->output->hardware_cursor == cursor) {
+ assert(cursor->output->impl->set_cursor);
+ cursor->output->impl->set_cursor(cursor->output, NULL, 0, 0, true);
+ }
}
}
@@ -857,9 +867,7 @@ bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
return true;
}
- if (!cursor->output->impl->move_cursor) {
- return false;
- }
+ assert(cursor->output->impl->move_cursor);
return cursor->output->impl->move_cursor(cursor->output, (int)x, (int)y);
}
@@ -889,8 +897,7 @@ void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor) {
if (cursor->output->hardware_cursor == cursor) {
// If this cursor was the hardware cursor, disable it
if (cursor->output->impl->set_cursor) {
- cursor->output->impl->set_cursor(cursor->output, NULL, 0, 0, 0, 0,
- 0, true);
+ cursor->output->impl->set_cursor(cursor->output, NULL, 0, 0, true);
}
cursor->output->hardware_cursor = NULL;
}
diff --git a/types/wlr_output_damage.c b/types/wlr_output_damage.c
index b3636c37..bf3a671d 100644
--- a/types/wlr_output_damage.c
+++ b/types/wlr_output_damage.c
@@ -58,6 +58,7 @@ struct wlr_output_damage *wlr_output_damage_create(struct wlr_output *output) {
}
output_damage->output = output;
+ output_damage->max_rects = 20;
wl_signal_init(&output_damage->events.frame);
wl_signal_init(&output_damage->events.destroy);
@@ -125,6 +126,14 @@ bool wlr_output_damage_make_current(struct wlr_output_damage *output_damage,
int j = (idx + i) % WLR_OUTPUT_DAMAGE_PREVIOUS_LEN;
pixman_region32_union(damage, damage, &output_damage->previous[j]);
}
+
+ // Check the number of rectangles
+ int n_rects = pixman_region32_n_rects(damage);
+ if (n_rects > output_damage->max_rects) {
+ pixman_box32_t *extents = pixman_region32_extents(damage);
+ pixman_region32_union_rect(damage, damage, extents->x1, extents->y1,
+ extents->x2 - extents->x1, extents->y2 - extents->y1);
+ }
}
*needs_swap = output->needs_swap || pixman_region32_not_empty(damage);
diff --git a/xwayland/xwm.c b/xwayland/xwm.c
index b97a1753..7c9cd304 100644
--- a/xwayland/xwm.c
+++ b/xwayland/xwm.c
@@ -353,8 +353,10 @@ static void read_surface_title(struct wlr_xwm *xwm,
return;
}
- // TODO: if reply->type == XCB_ATOM_STRING, uses latin1 encoding
- // if reply->type == xwm->atoms[UTF8_STRING], uses utf8 encoding
+ bool is_utf8 = reply->type == xwm->atoms[UTF8_STRING];
+ if (!is_utf8 && xsurface->has_utf8_title) {
+ return;
+ }
size_t len = xcb_get_property_value_length(reply);
char *title = xcb_get_property_value(reply);
@@ -365,6 +367,7 @@ static void read_surface_title(struct wlr_xwm *xwm,
} else {
xsurface->title = NULL;
}
+ xsurface->has_utf8_title = is_utf8;
wlr_log(L_DEBUG, "XCB_ATOM_WM_NAME: %s", xsurface->title);
wlr_signal_emit_safe(&xsurface->events.set_title, xsurface);