mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-29 06:46:35 -04:00
Disable scrolling code for FreeBSD
This is do to the fact that `fallocate(FALLOC_FL_PUNCH_HOLE)` is not available under FreeBSD
This commit is contained in:
parent
de7c8467f0
commit
fc8e51a4dc
1 changed files with 16 additions and 0 deletions
16
shm.c
16
shm.c
|
|
@ -53,7 +53,9 @@ static off_t max_pool_size = 512 * 1024 * 1024;
|
||||||
static tll(struct buffer) buffers;
|
static tll(struct buffer) buffers;
|
||||||
|
|
||||||
static bool can_punch_hole = false;
|
static bool can_punch_hole = false;
|
||||||
|
#ifdef __linux__
|
||||||
static bool can_punch_hole_initialized = false;
|
static bool can_punch_hole_initialized = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
#undef MEASURE_SHM_ALLOCS
|
#undef MEASURE_SHM_ALLOCS
|
||||||
#if defined(MEASURE_SHM_ALLOCS)
|
#if defined(MEASURE_SHM_ALLOCS)
|
||||||
|
|
@ -278,6 +280,7 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie,
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
if (!can_punch_hole_initialized) {
|
if (!can_punch_hole_initialized) {
|
||||||
can_punch_hole_initialized = true;
|
can_punch_hole_initialized = true;
|
||||||
can_punch_hole = fallocate(
|
can_punch_hole = fallocate(
|
||||||
|
|
@ -289,6 +292,9 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie,
|
||||||
"supported (%s): expect lower performance", strerror(errno));
|
"supported (%s): expect lower performance", strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#elif __FreeBSD__
|
||||||
|
can_punch_hole = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (scrollable && !can_punch_hole) {
|
if (scrollable && !can_punch_hole) {
|
||||||
initial_offset = 0;
|
initial_offset = 0;
|
||||||
|
|
@ -384,6 +390,7 @@ shm_can_scroll(const struct buffer *buf)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
static bool
|
static bool
|
||||||
wrap_buffer(struct wl_shm *shm, struct buffer *buf, off_t new_offset)
|
wrap_buffer(struct wl_shm *shm, struct buffer *buf, off_t new_offset)
|
||||||
{
|
{
|
||||||
|
|
@ -418,7 +425,9 @@ wrap_buffer(struct wl_shm *shm, struct buffer *buf, off_t new_offset)
|
||||||
buffer_destroy_dont_close(buf);
|
buffer_destroy_dont_close(buf);
|
||||||
return instantiate_offset(shm, buf, new_offset);
|
return instantiate_offset(shm, buf, new_offset);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
static bool
|
static bool
|
||||||
shm_scroll_forward(struct wl_shm *shm, struct buffer *buf, int rows,
|
shm_scroll_forward(struct wl_shm *shm, struct buffer *buf, int rows,
|
||||||
int top_margin, int top_keep_rows,
|
int top_margin, int top_keep_rows,
|
||||||
|
|
@ -522,7 +531,9 @@ err:
|
||||||
abort();
|
abort();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
static bool
|
static bool
|
||||||
shm_scroll_reverse(struct wl_shm *shm, struct buffer *buf, int rows,
|
shm_scroll_reverse(struct wl_shm *shm, struct buffer *buf, int rows,
|
||||||
int top_margin, int top_keep_rows,
|
int top_margin, int top_keep_rows,
|
||||||
|
|
@ -616,12 +627,16 @@ err:
|
||||||
abort();
|
abort();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool
|
bool
|
||||||
shm_scroll(struct wl_shm *shm, struct buffer *buf, int rows,
|
shm_scroll(struct wl_shm *shm, struct buffer *buf, int rows,
|
||||||
int top_margin, int top_keep_rows,
|
int top_margin, int top_keep_rows,
|
||||||
int bottom_margin, int bottom_keep_rows)
|
int bottom_margin, int bottom_keep_rows)
|
||||||
{
|
{
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
return false;
|
||||||
|
#elif __linux__
|
||||||
if (!shm_can_scroll(buf))
|
if (!shm_can_scroll(buf))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
@ -629,6 +644,7 @@ shm_scroll(struct wl_shm *shm, struct buffer *buf, int rows,
|
||||||
return rows > 0
|
return rows > 0
|
||||||
? shm_scroll_forward(shm, buf, rows, top_margin, top_keep_rows, bottom_margin, bottom_keep_rows)
|
? shm_scroll_forward(shm, buf, rows, top_margin, top_keep_rows, bottom_margin, bottom_keep_rows)
|
||||||
: shm_scroll_reverse(shm, buf, -rows, top_margin, top_keep_rows, bottom_margin, bottom_keep_rows);
|
: shm_scroll_reverse(shm, buf, -rows, top_margin, top_keep_rows, bottom_margin, bottom_keep_rows);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue