diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2024-05-21 14:09:34 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2024-05-22 11:48:46 +0000 |
| commit | 3c96d0b68e3f3d270e885c4d7bb82ae8667ba385 (patch) | |
| tree | 4d770302510598a47822e773b100c3ee44223424 /wayland.c | |
| parent | issue-template: fix typo (diff) | |
render: use single-pixel buffers for overlays, when possible
The unicode-mode, and flash overlays are single color buffers. This
means we can use the single-pixel buffer protocol.
It's undefined whether the compositor will release the buffer or not;
to make things easier, simply destroy the buffer as soon as we've
committed it.
Note that since compositors don't necessarily release single-pixel
buffers, we can't plug them into our own buffer interface. This means
we can't use buffer pointers to check if we can re-use the previous
buffer (i.e. we can skip comitting a new buffer), or if we have to
create a new one.
It's _almost_ enough to just check if the last overlay style is the
same as the current one. Except that that doesn't take window resizes
into account...
Diffstat (limited to 'wayland.c')
| -rw-r--r-- | wayland.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -1320,6 +1320,16 @@ handle_global(void *data, struct wl_registry *registry, wayl->registry, name, &wp_cursor_shape_manager_v1_interface, required); } + else if (streq(interface, wp_single_pixel_buffer_manager_v1_interface.name)) { + const uint32_t required = 1; + if (!verify_iface_version(interface, version, required)) + return; + + wayl->single_pixel_manager = wl_registry_bind( + wayl->registry, name, + &wp_single_pixel_buffer_manager_v1_interface, required); + } + #if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED else if (streq(interface, zwp_text_input_manager_v3_interface.name)) { const uint32_t required = 1; @@ -1636,6 +1646,8 @@ wayl_destroy(struct wayland *wayl) zwp_text_input_manager_v3_destroy(wayl->text_input_manager); #endif + if (wayl->single_pixel_manager != NULL) + wp_single_pixel_buffer_manager_v1_destroy(wayl->single_pixel_manager); if (wayl->fractional_scale_manager != NULL) wp_fractional_scale_manager_v1_destroy(wayl->fractional_scale_manager); if (wayl->viewporter != NULL) @@ -2058,6 +2070,7 @@ surface_scale_explicit_width_height( } } + xassert(surf->viewport != NULL); wl_surface_set_buffer_scale(surf->surf, 1); wp_viewport_set_destination( surf->viewport, roundf(width / scale), roundf(height / scale)); @@ -2204,7 +2217,7 @@ wayl_win_subsurface_new_with_custom_parent( } struct wp_viewport *viewport = NULL; - if (wayl->fractional_scale_manager != NULL && wayl->viewporter != NULL) { + if (wayl->viewporter != NULL) { viewport = wp_viewporter_get_viewport(wayl->viewporter, main_surface); if (viewport == NULL) { LOG_ERR("failed to instantiate viewport for sub-surface"); |
