mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
wayland: refactor: add a buffer argument to wayl_*_scale() functions
This will be needed later, when using fractional scaling + viewporter to scale.
This commit is contained in:
parent
434fd6aa1f
commit
5a60bbc119
3 changed files with 37 additions and 17 deletions
28
render.c
28
render.c
|
|
@ -1691,7 +1691,8 @@ render_overlay(struct terminal *term)
|
|||
&(pixman_rectangle16_t){0, 0, term->width, term->height});
|
||||
|
||||
quirk_weston_subsurface_desync_on(overlay->sub);
|
||||
wayl_surface_scale(term->wl, &overlay->surface, term->scale);
|
||||
wayl_surface_scale(
|
||||
term->wl, &overlay->surface, buf, term->scale);
|
||||
wl_subsurface_set_position(overlay->sub, 0, 0);
|
||||
wl_surface_attach(overlay->surface.surf, buf->wl_buf, 0, 0);
|
||||
|
||||
|
|
@ -1830,7 +1831,7 @@ get_csd_data(const struct terminal *term, enum csd_surface surf_idx)
|
|||
static void
|
||||
csd_commit(struct terminal *term, struct wayl_surface *surf, struct buffer *buf)
|
||||
{
|
||||
wayl_surface_scale(term->wl, surf, term->scale);
|
||||
wayl_surface_scale(term->wl, surf, buf, term->scale);
|
||||
wl_surface_attach(surf->surf, buf->wl_buf, 0, 0);
|
||||
wl_surface_damage_buffer(surf->surf, 0, 0, buf->width, buf->height);
|
||||
wl_surface_commit(surf->surf);
|
||||
|
|
@ -1923,7 +1924,7 @@ render_osd(struct terminal *term, const struct wayl_sub_surface *sub_surf,
|
|||
pixman_image_set_clip_region32(buf->pix[0], NULL);
|
||||
|
||||
quirk_weston_subsurface_desync_on(sub_surf->sub);
|
||||
wayl_surface_scale(term->wl, &sub_surf->surface, term->scale);
|
||||
wayl_surface_scale(term->wl, &sub_surf->surface, buf, term->scale);
|
||||
wl_surface_attach(sub_surf->surface.surf, buf->wl_buf, 0, 0);
|
||||
wl_surface_damage_buffer(sub_surf->surface.surf, 0, 0, buf->width, buf->height);
|
||||
|
||||
|
|
@ -3013,7 +3014,7 @@ grid_render(struct terminal *term)
|
|||
term->window->frame_callback = wl_surface_frame(term->window->surface.surf);
|
||||
wl_callback_add_listener(term->window->frame_callback, &frame_listener, term);
|
||||
|
||||
wayl_win_scale(term->window);
|
||||
wayl_win_scale(term->window, buf);
|
||||
|
||||
if (term->wl->presentation != NULL && term->conf->presentation_timings) {
|
||||
struct timespec commit_time;
|
||||
|
|
@ -3370,7 +3371,7 @@ render_search_box(struct terminal *term)
|
|||
margin / term->scale,
|
||||
max(0, (int32_t)term->height - height - margin) / term->scale);
|
||||
|
||||
wayl_surface_scale(term->wl, &term->window->search.surface, term->scale);
|
||||
wayl_surface_scale(term->wl, &term->window->search.surface, buf, term->scale);
|
||||
wl_surface_attach(term->window->search.surface.surf, buf->wl_buf, 0, 0);
|
||||
wl_surface_damage_buffer(term->window->search.surface.surf, 0, 0, width, height);
|
||||
|
||||
|
|
@ -3843,9 +3844,13 @@ maybe_resize(struct terminal *term, int width, int height, bool force)
|
|||
return false;
|
||||
|
||||
float scale = -1;
|
||||
tll_foreach(term->window->on_outputs, it) {
|
||||
if (it->item->scale > scale)
|
||||
scale = it->item->scale;
|
||||
if (wayl_fractional_scaling(term->wl)) {
|
||||
scale = term->window->scale;
|
||||
} else {
|
||||
tll_foreach(term->window->on_outputs, it) {
|
||||
if (it->item->scale > scale)
|
||||
scale = it->item->scale;
|
||||
}
|
||||
}
|
||||
|
||||
if (scale < 0.) {
|
||||
|
|
@ -4257,11 +4262,12 @@ render_xcursor_update(struct seat *seat)
|
|||
|
||||
const float scale = seat->pointer.scale;
|
||||
struct wl_cursor_image *image = seat->pointer.cursor->images[0];
|
||||
struct wl_buffer *buf = wl_cursor_image_get_buffer(image);
|
||||
|
||||
wayl_surface_scale(seat->wayl, &seat->pointer.surface, scale);
|
||||
wayl_surface_scale_explicit_width_height(
|
||||
seat->wayl, &seat->pointer.surface, image->width, image->height, scale);
|
||||
|
||||
wl_surface_attach(
|
||||
seat->pointer.surface.surf, wl_cursor_image_get_buffer(image), 0, 0);
|
||||
wl_surface_attach(seat->pointer.surface.surf, buf, 0, 0);
|
||||
|
||||
wl_pointer_set_cursor(
|
||||
seat->wl_pointer, seat->pointer.serial,
|
||||
|
|
|
|||
17
wayland.c
17
wayland.c
|
|
@ -1865,8 +1865,9 @@ wayl_fractional_scaling(const struct wayland *wayl)
|
|||
}
|
||||
|
||||
void
|
||||
wayl_surface_scale(const struct wayland *wayl, const struct wayl_surface *surf,
|
||||
float scale)
|
||||
wayl_surface_scale_explicit_width_height(
|
||||
const struct wayland *wayl, const struct wayl_surface *surf,
|
||||
int width, int height, float scale)
|
||||
{
|
||||
LOG_WARN("scaling by a factor of %.2f (legacy)", scale);
|
||||
|
||||
|
|
@ -1878,13 +1879,21 @@ wayl_surface_scale(const struct wayland *wayl, const struct wayl_surface *surf,
|
|||
}
|
||||
|
||||
void
|
||||
wayl_win_scale(struct wl_window *win)
|
||||
wayl_surface_scale(const struct wayland *wayl, const struct wayl_surface *surf,
|
||||
const struct buffer *buf, float scale)
|
||||
{
|
||||
wayl_surface_scale_explicit_width_height(
|
||||
wayl, surf, buf->width, buf->height, scale);
|
||||
}
|
||||
|
||||
void
|
||||
wayl_win_scale(struct wl_window *win, const struct buffer *buf)
|
||||
{
|
||||
const struct terminal *term = win->term;
|
||||
const struct wayland *wayl = term->wl;
|
||||
const float scale = term->scale;
|
||||
|
||||
wayl_surface_scale(wayl, &win->surface, scale);
|
||||
wayl_surface_scale(wayl, &win->surface, buf, scale);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
/* Forward declarations */
|
||||
struct terminal;
|
||||
struct buffer;
|
||||
|
||||
/* Mime-types we support when dealing with data offers (e.g. copy-paste, or DnD) */
|
||||
enum data_offer_mime_type {
|
||||
|
|
@ -455,12 +456,16 @@ void wayl_roundtrip(struct wayland *wayl);
|
|||
|
||||
bool wayl_fractional_scaling(const struct wayland *wayl);
|
||||
void wayl_surface_scale(
|
||||
const struct wayland *wayl, const struct wayl_surface *surf, float scale);
|
||||
const struct wayland *wayl, const struct wayl_surface *surf,
|
||||
const struct buffer *buf, float scale);
|
||||
void wayl_surface_scale_explicit_width_height(
|
||||
const struct wayland *wayl, const struct wayl_surface *surf,
|
||||
int width, int height, float scale);
|
||||
|
||||
struct wl_window *wayl_win_init(struct terminal *term, const char *token);
|
||||
void wayl_win_destroy(struct wl_window *win);
|
||||
|
||||
void wayl_win_scale(struct wl_window *win);
|
||||
void wayl_win_scale(struct wl_window *win, const struct buffer *buf);
|
||||
void wayl_win_alpha_changed(struct wl_window *win);
|
||||
bool wayl_win_set_urgent(struct wl_window *win);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue