summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorManuel Stoeckl <code@mstoeckl.com>2023-03-12 16:48:58 -0400
committerSimon Ser <contact@emersion.fr>2023-03-22 10:56:42 +0100
commit1d3e62c67f07a180fca02a6df1cf9648f2b50349 (patch)
tree598dd26d5a62ade9ee705073cad83c8d71b7617f /include
parentac3b49b6571ceda3f8db11a98bfe320106996280 (diff)
Stop pooling background surface buffers
The wl_buffers for the background surface only need to be updated when the output dimensions change. Using the fixed pool of two buffers to cache these buffers does not help, since if a new buffer is needed, it will have a different size than whatever buffers were cached. Furthermore, because the pool has fixed size, it is possible to run out of buffers if configure events arrive faster than pool buffers are marked not busy, which can lead to protocol errors when the background surface is committed after acknowledging a new size, but without attaching a buffer that matches that size.
Diffstat (limited to 'include')
-rw-r--r--include/pool-buffer.h4
-rw-r--r--include/swaylock.h7
2 files changed, 7 insertions, 4 deletions
diff --git a/include/pool-buffer.h b/include/pool-buffer.h
index 0ebf787..38e8218 100644
--- a/include/pool-buffer.h
+++ b/include/pool-buffer.h
@@ -15,8 +15,10 @@ struct pool_buffer {
bool busy;
};
+struct pool_buffer *create_buffer(struct wl_shm *shm, struct pool_buffer *buf,
+ int32_t width, int32_t height, uint32_t format);
struct pool_buffer *get_next_buffer(struct wl_shm *shm,
- struct pool_buffer pool[static 2], uint32_t width, uint32_t height);
+ struct pool_buffer pool[static 2], uint32_t width, uint32_t height);
void destroy_buffer(struct pool_buffer *buffer);
#endif
diff --git a/include/swaylock.h b/include/swaylock.h
index 9de8ab6..bb71c8c 100644
--- a/include/swaylock.h
+++ b/include/swaylock.h
@@ -98,11 +98,10 @@ struct swaylock_surface {
struct swaylock_state *state;
struct wl_output *output;
uint32_t output_global_name;
- struct wl_surface *surface;
- struct wl_surface *child; // surface made into subsurface
+ struct wl_surface *surface; // surface for background
+ struct wl_surface *child; // indicator surface made into subsurface
struct wl_subsurface *subsurface;
struct ext_session_lock_surface_v1 *ext_session_lock_surface_v1;
- struct pool_buffer buffers[2];
struct pool_buffer indicator_buffers[2];
bool frame_pending, dirty;
uint32_t width, height;
@@ -110,6 +109,8 @@ struct swaylock_surface {
enum wl_output_subpixel subpixel;
char *output_name;
struct wl_list link;
+ // Dimensions of last wl_buffer committed to background surface
+ int last_buffer_width, last_buffer_height;
};
// There is exactly one swaylock_image for each -i argument