You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

55 lines
1.9 KiB

  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stddef.h>
  4. #include <sys/types.h>
  5. #include <pixman.h>
  6. #include <wayland-client.h>
  7. struct buffer {
  8. unsigned long cookie;
  9. int width;
  10. int height;
  11. int stride;
  12. bool busy;
  13. size_t size; /* Buffer size */
  14. void *mmapped; /* Raw data (TODO: rename) */
  15. struct wl_buffer *wl_buf;
  16. pixman_image_t **pix;
  17. size_t pix_instances;
  18. /* Internal */
  19. int fd; /* memfd */
  20. struct wl_shm_pool *pool;
  21. void *real_mmapped; /* Address returned from mmap */
  22. size_t mmap_size; /* Size of mmap (>= size) */
  23. off_t offset; /* Offset into memfd where data begins */
  24. bool scrollable;
  25. bool purge; /* True if this buffer should be destroyed */
  26. };
  27. struct buffer *shm_get_buffer(
  28. struct wl_shm *shm, int width, int height, unsigned long cookie, bool scrollable, size_t pix_instances);
  29. void shm_fini(void);
  30. void shm_set_max_pool_size(off_t max_pool_size);
  31. bool shm_can_scroll(const struct buffer *buf);
  32. bool shm_scroll(struct wl_shm *shm, struct buffer *buf, int rows,
  33. int top_margin, int top_keep_rows,
  34. int bottom_margin, int bottom_keep_rows);
  35. void shm_purge(struct wl_shm *shm, unsigned long cookie);
  36. struct terminal;
  37. static inline unsigned long shm_cookie_grid(const struct terminal *term) { return (unsigned long)((uintptr_t)term + 0); }
  38. static inline unsigned long shm_cookie_search(const struct terminal *term) { return (unsigned long)((uintptr_t)term + 1); }
  39. static inline unsigned long shm_cookie_scrollback_indicator(const struct terminal *term) { return (unsigned long)(uintptr_t)term + 2; }
  40. static inline unsigned long shm_cookie_render_timer(const struct terminal *term) { return (unsigned long)(uintptr_t)term + 3; }
  41. static inline unsigned long shm_cookie_csd(const struct terminal *term, int n) { return (unsigned long)((uintptr_t)term + 4 + (n)); }