From c1f374cc8dab121388669cee6df3e2d1c483d77f Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 22 Jun 2023 14:21:51 +0200 Subject: term: convert ‘scale’ to a float MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- render.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'render.c') diff --git a/render.c b/render.c index 1858467d..f5438e42 100644 --- a/render.c +++ b/render.c @@ -1830,8 +1830,8 @@ get_csd_data(const struct terminal *term, enum csd_surface surf_idx) static void csd_commit(struct terminal *term, struct wl_surface *surf, struct buffer *buf) { - xassert(buf->width % term->scale == 0); - xassert(buf->height % term->scale == 0); + xassert(buf->width % (int)term->scale == 0); + xassert(buf->height % (int)term->scale == 0); wl_surface_attach(surf, buf->wl_buf, 0, 0); wl_surface_damage_buffer(surf, 0, 0, buf->width, buf->height); @@ -1926,8 +1926,8 @@ render_osd(struct terminal *term, pixman_image_unref(src); pixman_image_set_clip_region32(buf->pix[0], NULL); - xassert(buf->width % term->scale == 0); - xassert(buf->height % term->scale == 0); + xassert(buf->width % (int)term->scale == 0); + xassert(buf->height % (int)term->scale == 0); quirk_weston_subsurface_desync_on(sub_surf); wl_surface_attach(surf, buf->wl_buf, 0, 0); @@ -1955,8 +1955,8 @@ render_csd_title(struct terminal *term, const struct csd_data *info, if (info->width == 0 || info->height == 0) return; - xassert(info->width % term->scale == 0); - xassert(info->height % term->scale == 0); + xassert(info->width % (int)term->scale == 0); + xassert(info->height % (int)term->scale == 0); uint32_t bg = term->conf->csd.color.title_set ? term->conf->csd.color.title @@ -2000,8 +2000,8 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx, if (info->width == 0 || info->height == 0) return; - xassert(info->width % term->scale == 0); - xassert(info->height % term->scale == 0); + xassert(info->width % (int)term->scale == 0); + xassert(info->height % (int)term->scale == 0); { pixman_color_t color = color_hex_to_pixman_with_alpha(0, 0); @@ -2289,8 +2289,8 @@ render_csd_button(struct terminal *term, enum csd_surface surf_idx, if (info->width == 0 || info->height == 0) return; - xassert(info->width % term->scale == 0); - xassert(info->height % term->scale == 0); + xassert(info->width % (int)term->scale == 0); + xassert(info->height % (int)term->scale == 0); uint32_t _color; uint16_t alpha = 0xffff; @@ -3067,8 +3067,8 @@ grid_render(struct terminal *term) term->window->surface, 0, 0, INT32_MAX, INT32_MAX); } - xassert(buf->width % term->scale == 0); - xassert(buf->height % term->scale == 0); + xassert(buf->width % (int)term->scale == 0); + xassert(buf->height % (int)term->scale == 0); wl_surface_attach(term->window->surface, buf->wl_buf, 0, 0); wl_surface_commit(term->window->surface); -- cgit v1.3 From 44743b5635aeee2d9cbb2bae33d5dcbc374be8da Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 22 Jun 2023 14:27:16 +0200 Subject: render: draw_unfocused_block(): round scale, instead of truncating --- render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'render.c') diff --git a/render.c b/render.c index f5438e42..e62e000d 100644 --- a/render.c +++ b/render.c @@ -311,7 +311,7 @@ static void draw_unfocused_block(const struct terminal *term, pixman_image_t *pix, const pixman_color_t *color, int x, int y, int cell_cols) { - const int scale = term->scale; + const int scale = round(term->scale); const int width = min(min(scale, term->cell_width), term->cell_height); pixman_image_fill_rectangles( -- cgit v1.3 From b65612479135da9bf888fcd037c86519940e17b4 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 22 Jun 2023 14:27:37 +0200 Subject: render: csd_border: round scaled border width, instead of truncating --- render.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'render.c') diff --git a/render.c b/render.c index e62e000d..f87ef093 100644 --- a/render.c +++ b/render.c @@ -2012,9 +2012,9 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx, * The “visible” border. */ - int scale = term->scale; - int bwidth = term->conf->csd.border_width * scale; - int vwidth = term->conf->csd.border_width_visible * scale; /* Visible size */ + float scale = term->scale; + int bwidth = round(term->conf->csd.border_width * scale); + int vwidth = round(term->conf->csd.border_width_visible * scale); /* Visible size */ xassert(bwidth >= vwidth); @@ -2067,7 +2067,6 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx, uint16_t alpha = _color >> 24 | (_color >> 24 << 8); pixman_color_t color = color_hex_to_pixman_with_alpha(_color, alpha); - pixman_image_fill_rectangles( PIXMAN_OP_SRC, buf->pix[0], &color, 1, &(pixman_rectangle16_t){x, y, w, h}); -- cgit v1.3 From cf280e6655da63dd6d2c2e146ec1ff8e71235779 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 22 Jun 2023 14:35:02 +0200 Subject: render: render_timer(): round scaling factor --- render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'render.c') diff --git a/render.c b/render.c index f87ef093..51f4f1e8 100644 --- a/render.c +++ b/render.c @@ -2568,7 +2568,7 @@ render_render_timer(struct terminal *term, struct timespec render_time) char32_t text[256]; mbstoc32(text, usecs_str, ALEN(text)); - const int scale = term->scale; + const int scale = round(term->scale); const int cell_count = c32len(text); const int margin = 3 * scale; const int width = -- cgit v1.3 From 30c8d3e652db1cff7138e5e916cdaf2c9b6026a5 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 22 Jun 2023 14:35:19 +0200 Subject: render: search_box(): round scaling factor --- render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'render.c') diff --git a/render.c b/render.c index 51f4f1e8..34648d53 100644 --- a/render.c +++ b/render.c @@ -3132,7 +3132,7 @@ render_search_box(struct terminal *term) const size_t wanted_visible_cells = max(20, total_cells); xassert(term->scale >= 1); - const int scale = term->scale; + const int scale = round(term->scale); const size_t margin = 3 * scale; -- cgit v1.3 From d8f64d1047415d1446dad893167d1a756ffa9a95 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 22 Jun 2023 14:35:29 +0200 Subject: render: urls(): round scaling factor --- render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'render.c') diff --git a/render.c b/render.c index 34648d53..80025d5e 100644 --- a/render.c +++ b/render.c @@ -3422,7 +3422,7 @@ render_urls(struct terminal *term) struct wl_window *win = term->window; xassert(tll_length(win->urls) > 0); - const int scale = term->scale; + const int scale = round(term->scale); const int x_margin = 2 * scale; const int y_margin = 1 * scale; -- cgit v1.3 From 2bb7b28837aac939dad61b7ca58a0dcef08399e9 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 22 Jun 2023 14:37:31 +0200 Subject: render: xcursor_update(): convert local ‘scale’ variable to float MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'render.c') diff --git a/render.c b/render.c index 80025d5e..25249218 100644 --- a/render.c +++ b/render.c @@ -4276,7 +4276,7 @@ render_xcursor_update(struct seat *seat) xassert(seat->pointer.cursor != NULL); - const int scale = seat->pointer.scale; + const float scale = seat->pointer.scale; struct wl_cursor_image *image = seat->pointer.cursor->images[0]; wl_surface_attach( -- cgit v1.3 From 4bd62b10058c626cecb5eb15c9c44aee58bf547a Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 22 Jun 2023 15:01:59 +0200 Subject: render: maybe_resize(): convert local variable ‘scale’ to float MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- render.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'render.c') diff --git a/render.c b/render.c index 25249218..3c2e6f18 100644 --- a/render.c +++ b/render.c @@ -3868,13 +3868,13 @@ maybe_resize(struct terminal *term, int width, int height, bool force) if (term->cell_width == 0 && term->cell_height == 0) return false; - int scale = -1; + float scale = -1; tll_foreach(term->window->on_outputs, it) { if (it->item->scale > scale) scale = it->item->scale; } - if (scale < 0) { + if (scale < 0.) { /* Haven't 'entered' an output yet? */ scale = term->scale; } @@ -3922,13 +3922,18 @@ maybe_resize(struct terminal *term, int width, int height, bool force) * Ensure we can scale to logical size, and back to * pixels without truncating. */ - if (width % scale) - width += scale - width % scale; - if (height % scale) - height += scale - height % scale; + if (wayl_fractional_scaling(term->wl)) { + xassert((int)round(scale) == (int)scale); - xassert(width % scale == 0); - xassert(height % scale == 0); + int iscale = scale; + if (width % iscale) + width += iscale - width % iscale; + if (height % iscale) + height += iscale - height % iscale; + + xassert(width % iscale == 0); + xassert(height % iscale == 0); + } break; } } -- cgit v1.3 From 0a5073f5703e89cfa4219d5b532cb134f9def6d5 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 26 Jun 2023 15:51:04 +0200 Subject: wayland: add wayl_surface_scale(), and wayl_win_scale() These functions scale a surface+buffer. For now, only using the legacy scaling method (wl_surface_set_buffer_scale()). --- render.c | 47 +++++++++++++---------------------------------- wayland.c | 44 ++++++++++++++++++++++++++++++++++---------- wayland.h | 7 +++++-- 3 files changed, 52 insertions(+), 46 deletions(-) (limited to 'render.c') diff --git a/render.c b/render.c index 3c2e6f18..5663c45a 100644 --- a/render.c +++ b/render.c @@ -1691,8 +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->surf, term->scale); wl_subsurface_set_position(overlay->sub, 0, 0); - wl_surface_set_buffer_scale(overlay->surf, term->scale); wl_surface_attach(overlay->surf, buf->wl_buf, 0, 0); wl_surface_damage_buffer( @@ -1830,12 +1830,9 @@ get_csd_data(const struct terminal *term, enum csd_surface surf_idx) static void csd_commit(struct terminal *term, struct wl_surface *surf, struct buffer *buf) { - xassert(buf->width % (int)term->scale == 0); - xassert(buf->height % (int)term->scale == 0); - + wayl_surface_scale(term->wl, surf, term->scale); wl_surface_attach(surf, buf->wl_buf, 0, 0); wl_surface_damage_buffer(surf, 0, 0, buf->width, buf->height); - wl_surface_set_buffer_scale(surf, term->scale); wl_surface_commit(surf); } @@ -1926,13 +1923,10 @@ render_osd(struct terminal *term, pixman_image_unref(src); pixman_image_set_clip_region32(buf->pix[0], NULL); - xassert(buf->width % (int)term->scale == 0); - xassert(buf->height % (int)term->scale == 0); - quirk_weston_subsurface_desync_on(sub_surf); + wayl_surface_scale(term->wl, surf, term->scale); wl_surface_attach(surf, buf->wl_buf, 0, 0); wl_surface_damage_buffer(surf, 0, 0, buf->width, buf->height); - wl_surface_set_buffer_scale(surf, term->scale); struct wl_region *region = wl_compositor_create_region(term->wl->compositor); if (region != NULL) { @@ -1955,9 +1949,6 @@ render_csd_title(struct terminal *term, const struct csd_data *info, if (info->width == 0 || info->height == 0) return; - xassert(info->width % (int)term->scale == 0); - xassert(info->height % (int)term->scale == 0); - uint32_t bg = term->conf->csd.color.title_set ? term->conf->csd.color.title : 0xffu << 24 | term->conf->colors.fg; @@ -2000,9 +1991,6 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx, if (info->width == 0 || info->height == 0) return; - xassert(info->width % (int)term->scale == 0); - xassert(info->height % (int)term->scale == 0); - { pixman_color_t color = color_hex_to_pixman_with_alpha(0, 0); render_csd_part(term, surf, buf, info->width, info->height, &color); @@ -2288,9 +2276,6 @@ render_csd_button(struct terminal *term, enum csd_surface surf_idx, if (info->width == 0 || info->height == 0) return; - xassert(info->width % (int)term->scale == 0); - xassert(info->height % (int)term->scale == 0); - uint32_t _color; uint16_t alpha = 0xffff; bool is_active = false; @@ -3032,7 +3017,7 @@ grid_render(struct terminal *term) term->window->frame_callback = wl_surface_frame(term->window->surface); wl_callback_add_listener(term->window->frame_callback, &frame_listener, term); - wl_surface_set_buffer_scale(term->window->surface, term->scale); + wayl_win_scale(term->window); if (term->wl->presentation != NULL && term->conf->presentation_timings) { struct timespec commit_time; @@ -3066,9 +3051,6 @@ grid_render(struct terminal *term) term->window->surface, 0, 0, INT32_MAX, INT32_MAX); } - xassert(buf->width % (int)term->scale == 0); - xassert(buf->height % (int)term->scale == 0); - wl_surface_attach(term->window->surface, buf->wl_buf, 0, 0); wl_surface_commit(term->window->surface); } @@ -3132,17 +3114,17 @@ render_search_box(struct terminal *term) const size_t wanted_visible_cells = max(20, total_cells); xassert(term->scale >= 1); - const int scale = round(term->scale); + const int rounded_scale = round(term->scale); - const size_t margin = 3 * scale; + const size_t margin = 3 * rounded_scale; const size_t width = term->width - 2 * margin; const size_t visible_width = min( term->width - 2 * margin, - (2 * margin + wanted_visible_cells * term->cell_width + scale - 1) / scale * scale); + (2 * margin + wanted_visible_cells * term->cell_width + rounded_scale - 1) / rounded_scale * rounded_scale); const size_t height = min( term->height - 2 * margin, - (2 * margin + 1 * term->cell_height + scale - 1) / scale * scale); + (2 * margin + 1 * term->cell_height + rounded_scale - 1) / rounded_scale * rounded_scale); const size_t visible_cells = (visible_width - 2 * margin) / term->cell_width; size_t glyph_offset = term->render.search_glyph_offset; @@ -3389,15 +3371,12 @@ render_search_box(struct terminal *term) /* TODO: this is only necessary on a window resize */ wl_subsurface_set_position( term->window->search.sub, - margin / scale, - max(0, (int32_t)term->height - height - margin) / scale); - - xassert(buf->width % scale == 0); - xassert(buf->height % scale == 0); + margin / term->scale, + max(0, (int32_t)term->height - height - margin) / term->scale); + wayl_surface_scale(term->wl, term->window->search.surf, term->scale); wl_surface_attach(term->window->search.surf, buf->wl_buf, 0, 0); wl_surface_damage_buffer(term->window->search.surf, 0, 0, width, height); - wl_surface_set_buffer_scale(term->window->search.surf, scale); struct wl_region *region = wl_compositor_create_region(term->wl->compositor); if (region != NULL) { @@ -4284,6 +4263,8 @@ render_xcursor_update(struct seat *seat) const float scale = seat->pointer.scale; struct wl_cursor_image *image = seat->pointer.cursor->images[0]; + wayl_surface_scale(seat->wayl, seat->pointer.surface, scale); + wl_surface_attach( seat->pointer.surface, wl_cursor_image_get_buffer(image), 0, 0); @@ -4295,8 +4276,6 @@ render_xcursor_update(struct seat *seat) wl_surface_damage_buffer( seat->pointer.surface, 0, 0, INT32_MAX, INT32_MAX); - wl_surface_set_buffer_scale(seat->pointer.surface, scale); - xassert(seat->pointer.xcursor_callback == NULL); seat->pointer.xcursor_callback = wl_surface_frame(seat->pointer.surface); wl_callback_add_listener(seat->pointer.xcursor_callback, &xcursor_listener, seat); diff --git a/wayland.c b/wayland.c index e01a3a50..5aa10966 100644 --- a/wayland.c +++ b/wayland.c @@ -1850,6 +1850,40 @@ wayl_roundtrip(struct wayland *wayl) wayl_flush(wayl); } + +bool +wayl_fractional_scaling(const struct wayland *wayl) +{ +#if defined(HAVE_FRACTIONAL_SCALE) + return wayl->fractional_scale_manager != NULL; +#else + return false; +#endif +} + +void +wayl_surface_scale(const struct wayland *wayl, struct wl_surface *surf, + float scale) +{ + LOG_WARN("scaling by a factor of %.2f (legacy)", scale); + + if (wayl_fractional_scaling(wayl)) { + BUG("not yet implemented"); + } else { + wl_surface_set_buffer_scale(surf, (int)scale); + } +} + +void +wayl_win_scale(struct wl_window *win) +{ + const struct terminal *term = win->term; + const struct wayland *wayl = term->wl; + const float scale = term->scale; + + wayl_surface_scale(wayl, win->surface, scale); +} + void wayl_win_alpha_changed(struct wl_window *win) { @@ -2048,13 +2082,3 @@ wayl_get_activation_token( return true; } #endif - -bool -wayl_fractional_scaling(const struct wayland *wayl) -{ -#if defined(HAVE_FRACTIONAL_SCALE) - return wayl->fractional_scale_manager != NULL; -#else - return false; -#endif -} diff --git a/wayland.h b/wayland.h index 756da8d2..06150328 100644 --- a/wayland.h +++ b/wayland.h @@ -447,9 +447,14 @@ bool wayl_reload_xcursor_theme(struct seat *seat, float new_scale); void wayl_flush(struct wayland *wayl); void wayl_roundtrip(struct wayland *wayl); +bool wayl_fractional_scaling(const struct wayland *wayl); +void wayl_surface_scale( + const struct wayland *wayl, struct wl_surface *surf, 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_alpha_changed(struct wl_window *win); bool wayl_win_set_urgent(struct wl_window *win); @@ -469,5 +474,3 @@ bool wayl_get_activation_token( struct wayland *wayl, struct seat *seat, uint32_t serial, struct wl_window *win, activation_token_cb_t cb, void *cb_data); #endif - -bool wayl_fractional_scaling(const struct wayland *wayl); -- cgit v1.3 From ba46a039aca734bb284c22ba5d5bddf5407e3848 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 26 Jun 2023 16:10:40 +0200 Subject: wayland: refactor: wrap wl_surface pointers in a wayl_surface struct And add a viewport object to accompany the surface (to be used when scaling the surface). Also rename the wl_surf_subsurf struct to wayl_sub_surface, and add a wayl_surface object to it, rather than a plain wl_surface pointer (to also get the viewport pointer). --- quirks.c | 2 +- render.c | 100 ++++++++++++++++++++++++------------------------- terminal.c | 18 ++++----- wayland.c | 125 ++++++++++++++++++++++++++++++++----------------------------- wayland.h | 43 +++++++++++---------- 5 files changed, 149 insertions(+), 139 deletions(-) (limited to 'render.c') diff --git a/quirks.c b/quirks.c index bf9bc7fb..9769f1ff 100644 --- a/quirks.c +++ b/quirks.c @@ -89,5 +89,5 @@ quirk_sway_subsurface_unmap(struct terminal *term) if (!is_sway()) return; - wl_surface_damage_buffer(term->window->surface, 0, 0, INT32_MAX, INT32_MAX); + wl_surface_damage_buffer(term->window->surface.surf, 0, 0, INT32_MAX, INT32_MAX); } diff --git a/render.c b/render.c index 5663c45a..5ebd69eb 100644 --- a/render.c +++ b/render.c @@ -905,21 +905,21 @@ render_margin(struct terminal *term, struct buffer *buf, if (apply_damage) { /* Top */ wl_surface_damage_buffer( - term->window->surface, 0, 0, term->width, term->margins.top); + term->window->surface.surf, 0, 0, term->width, term->margins.top); /* Bottom */ wl_surface_damage_buffer( - term->window->surface, 0, bmargin, term->width, term->margins.bottom); + term->window->surface.surf, 0, bmargin, term->width, term->margins.bottom); /* Left */ wl_surface_damage_buffer( - term->window->surface, + term->window->surface.surf, 0, term->margins.top + start_line * term->cell_height, term->margins.left, line_count * term->cell_height); /* Right */ wl_surface_damage_buffer( - term->window->surface, + term->window->surface.surf, rmargin, term->margins.top + start_line * term->cell_height, term->margins.right, line_count * term->cell_height); } @@ -1027,7 +1027,7 @@ grid_render_scroll(struct terminal *term, struct buffer *buf, #endif wl_surface_damage_buffer( - term->window->surface, term->margins.left, dst_y, + term->window->surface.surf, term->margins.left, dst_y, term->width - term->margins.left - term->margins.right, height); /* @@ -1104,7 +1104,7 @@ grid_render_scroll_reverse(struct terminal *term, struct buffer *buf, #endif wl_surface_damage_buffer( - term->window->surface, term->margins.left, dst_y, + term->window->surface.surf, term->margins.left, dst_y, term->width - term->margins.left - term->margins.right, height); /* @@ -1153,7 +1153,7 @@ render_sixel_chunk(struct terminal *term, pixman_image_t *pix, const struct sixe x, y, width, height); - wl_surface_damage_buffer(term->window->surface, x, y, width, height); + wl_surface_damage_buffer(term->window->surface.surf, x, y, width, height); } static void @@ -1480,7 +1480,7 @@ render_ime_preedit_for_seat(struct terminal *term, struct seat *seat, free(real_cells); wl_surface_damage_buffer( - term->window->surface, + term->window->surface.surf, term->margins.left, term->margins.top + row_idx * term->cell_height, term->width - term->margins.left - term->margins.right, @@ -1502,7 +1502,7 @@ render_ime_preedit(struct terminal *term, struct buffer *buf) static void render_overlay(struct terminal *term) { - struct wl_surf_subsurf *overlay = &term->window->overlay; + struct wayl_sub_surface *overlay = &term->window->overlay; bool unicode_mode_active = false; /* Check if unicode mode is active on at least one seat focusing @@ -1523,8 +1523,8 @@ render_overlay(struct terminal *term) if (likely(style == OVERLAY_NONE)) { if (term->render.last_overlay_style != OVERLAY_NONE) { /* Unmap overlay sub-surface */ - wl_surface_attach(overlay->surf, NULL, 0, 0); - wl_surface_commit(overlay->surf); + wl_surface_attach(overlay->surface.surf, NULL, 0, 0); + wl_surface_commit(overlay->surface.surf); term->render.last_overlay_style = OVERLAY_NONE; term->render.last_overlay_buf = NULL; @@ -1691,17 +1691,17 @@ 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->surf, term->scale); + wayl_surface_scale(term->wl, overlay->surface.surf, term->scale); wl_subsurface_set_position(overlay->sub, 0, 0); - wl_surface_attach(overlay->surf, buf->wl_buf, 0, 0); + wl_surface_attach(overlay->surface.surf, buf->wl_buf, 0, 0); wl_surface_damage_buffer( - overlay->surf, + overlay->surface.surf, damage_bounds.x1, damage_bounds.y1, damage_bounds.x2 - damage_bounds.x1, damage_bounds.y2 - damage_bounds.y1); - wl_surface_commit(overlay->surf); + wl_surface_commit(overlay->surface.surf); quirk_weston_subsurface_desync_off(overlay->sub); buf->age = 0; @@ -1945,7 +1945,7 @@ render_csd_title(struct terminal *term, const struct csd_data *info, { xassert(term->window->csd_mode == CSD_YES); - struct wl_surf_subsurf *surf = &term->window->csd.surface[CSD_SURF_TITLE]; + struct wayl_sub_surface *surf = &term->window->csd.surface[CSD_SURF_TITLE]; if (info->width == 0 || info->height == 0) return; @@ -1971,11 +1971,11 @@ render_csd_title(struct terminal *term, const struct csd_data *info, const int margin = M != NULL ? M->advance.x : win->csd.font->max_advance.x; - render_osd(term, surf->surf, surf->sub, win->csd.font, + render_osd(term, surf->surface.surf, surf->sub, win->csd.font, buf, title_text, fg, bg, margin, (buf->height - win->csd.font->height) / 2); - csd_commit(term, surf->surf, buf); + csd_commit(term, surf->surface.surf, buf); free(_title_text); } @@ -1986,7 +1986,7 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx, xassert(term->window->csd_mode == CSD_YES); xassert(surf_idx >= CSD_SURF_LEFT && surf_idx <= CSD_SURF_BOTTOM); - struct wl_surface *surf = term->window->csd.surface[surf_idx].surf; + struct wl_surface *surf = term->window->csd.surface[surf_idx].surface.surf; if (info->width == 0 || info->height == 0) return; @@ -2271,7 +2271,7 @@ render_csd_button(struct terminal *term, enum csd_surface surf_idx, xassert(term->window->csd_mode == CSD_YES); xassert(surf_idx >= CSD_SURF_MINIMIZE && surf_idx <= CSD_SURF_CLOSE); - struct wl_surface *surf = term->window->csd.surface[surf_idx].surf; + struct wl_surface *surf = term->window->csd.surface[surf_idx].surface.surf; if (info->width == 0 || info->height == 0) return; @@ -2358,7 +2358,7 @@ render_csd(struct terminal *term) const int width = infos[i].width; const int height = infos[i].height; - struct wl_surface *surf = term->window->csd.surface[i].surf; + struct wl_surface *surf = term->window->csd.surface[i].surface.surf; struct wl_subsurface *sub = term->window->csd.surface[i].sub; xassert(surf != NULL); @@ -2397,7 +2397,7 @@ render_scrollback_position(struct terminal *term) struct wl_window *win = term->window; if (term->grid->view == term->grid->offset) { - if (win->scrollback_indicator.surf != NULL) { + if (win->scrollback_indicator.surface.surf != NULL) { wayl_win_subsurface_destroy(&win->scrollback_indicator); /* Work around Sway bug - unmapping a sub-surface does not damage @@ -2407,7 +2407,7 @@ render_scrollback_position(struct terminal *term) return; } - if (win->scrollback_indicator.surf == NULL) { + if (win->scrollback_indicator.surface.surf == NULL) { if (!wayl_win_subsurface_new( win, &win->scrollback_indicator, false)) { @@ -2416,7 +2416,7 @@ render_scrollback_position(struct terminal *term) } } - xassert(win->scrollback_indicator.surf != NULL); + xassert(win->scrollback_indicator.surface.surf != NULL); xassert(win->scrollback_indicator.sub != NULL); /* Find absolute row number of the scrollback start */ @@ -2514,8 +2514,8 @@ render_scrollback_position(struct terminal *term) const int y = (term->margins.top + surf_top) / scale * scale; if (y + height > term->height) { - wl_surface_attach(win->scrollback_indicator.surf, NULL, 0, 0); - wl_surface_commit(win->scrollback_indicator.surf); + wl_surface_attach(win->scrollback_indicator.surface.surf, NULL, 0, 0); + wl_surface_commit(win->scrollback_indicator.surface.surf); return; } @@ -2534,7 +2534,7 @@ render_scrollback_position(struct terminal *term) render_osd( term, - win->scrollback_indicator.surf, + win->scrollback_indicator.surface.surf, win->scrollback_indicator.sub, term->fonts[0], buf, text, fg, 0xffu << 24 | bg, @@ -2571,7 +2571,7 @@ render_render_timer(struct terminal *term, struct timespec render_time) render_osd( term, - win->render_timer.surf, + win->render_timer.surface.surf, win->render_timer.sub, term->fonts[0], buf, text, term->colors.table[0], 0xffu << 24 | term->colors.table[8 + 1], @@ -2919,7 +2919,7 @@ grid_render(struct terminal *term) int height = (r - first_dirty_row) * term->cell_height; wl_surface_damage_buffer( - term->window->surface, x, y, width, height); + term->window->surface.surf, x, y, width, height); pixman_region32_union_rect( &buf->dirty, &buf->dirty, 0, y, buf->width, height); } @@ -2947,7 +2947,7 @@ grid_render(struct terminal *term) int width = term->width - term->margins.left - term->margins.right; int height = (term->rows - first_dirty_row) * term->cell_height; - wl_surface_damage_buffer(term->window->surface, x, y, width, height); + wl_surface_damage_buffer(term->window->surface.surf, x, y, width, height); pixman_region32_union_rect(&buf->dirty, &buf->dirty, 0, y, buf->width, height); } @@ -3014,7 +3014,7 @@ grid_render(struct terminal *term) xassert(term->grid->view >= 0 && term->grid->view < term->grid->num_rows); xassert(term->window->frame_callback == NULL); - term->window->frame_callback = wl_surface_frame(term->window->surface); + 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); @@ -3024,7 +3024,7 @@ grid_render(struct terminal *term) clock_gettime(term->wl->presentation_clock_id, &commit_time); struct wp_presentation_feedback *feedback = wp_presentation_feedback( - term->wl->presentation, term->window->surface); + term->wl->presentation, term->window->surface.surf); if (feedback == NULL) { LOG_WARN("failed to create presentation feedback"); @@ -3048,11 +3048,11 @@ grid_render(struct terminal *term) if (term->conf->tweak.damage_whole_window) { wl_surface_damage_buffer( - term->window->surface, 0, 0, INT32_MAX, INT32_MAX); + term->window->surface.surf, 0, 0, INT32_MAX, INT32_MAX); } - wl_surface_attach(term->window->surface, buf->wl_buf, 0, 0); - wl_surface_commit(term->window->surface); + wl_surface_attach(term->window->surface.surf, buf->wl_buf, 0, 0); + wl_surface_commit(term->window->surface.surf); } static void @@ -3374,18 +3374,18 @@ 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.surf, term->scale); - wl_surface_attach(term->window->search.surf, buf->wl_buf, 0, 0); - wl_surface_damage_buffer(term->window->search.surf, 0, 0, width, height); + wayl_surface_scale(term->wl, term->window->search.surface.surf, 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); struct wl_region *region = wl_compositor_create_region(term->wl->compositor); if (region != NULL) { wl_region_add(region, width - visible_width, 0, visible_width, height); - wl_surface_set_opaque_region(term->window->search.surf, region); + wl_surface_set_opaque_region(term->window->search.surface.surf, region); wl_region_destroy(region); } - wl_surface_commit(term->window->search.surf); + wl_surface_commit(term->window->search.surface.surf); quirk_weston_subsurface_desync_off(term->window->search.sub); #if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED @@ -3466,7 +3466,7 @@ render_urls(struct terminal *term) continue; } - struct wl_surface *surf = it->item.surf.surf; + struct wl_surface *surf = it->item.surf.surface.surf; struct wl_subsurface *sub_surf = it->item.surf.sub; if (surf == NULL || sub_surf == NULL) @@ -3601,7 +3601,7 @@ render_urls(struct terminal *term) : term->colors.table[3]; for (size_t i = 0; i < render_count; i++) { - struct wl_surface *surf = info[i].url->surf.surf; + struct wl_surface *surf = info[i].url->surf.surface.surf; struct wl_subsurface *sub_surf = info[i].url->surf.sub; const char32_t *label = info[i].text; @@ -4253,8 +4253,8 @@ render_xcursor_update(struct seat *seat) if (seat->pointer.xcursor == XCURSOR_HIDDEN) { /* Hide cursor */ - wl_surface_attach(seat->pointer.surface, NULL, 0, 0); - wl_surface_commit(seat->pointer.surface); + wl_surface_attach(seat->pointer.surface.surf, NULL, 0, 0); + wl_surface_commit(seat->pointer.surface.surf); return; } @@ -4263,24 +4263,24 @@ render_xcursor_update(struct seat *seat) const float scale = seat->pointer.scale; struct wl_cursor_image *image = seat->pointer.cursor->images[0]; - wayl_surface_scale(seat->wayl, seat->pointer.surface, scale); + wayl_surface_scale(seat->wayl, seat->pointer.surface.surf, scale); wl_surface_attach( - seat->pointer.surface, wl_cursor_image_get_buffer(image), 0, 0); + seat->pointer.surface.surf, wl_cursor_image_get_buffer(image), 0, 0); wl_pointer_set_cursor( seat->wl_pointer, seat->pointer.serial, - seat->pointer.surface, + seat->pointer.surface.surf, image->hotspot_x / scale, image->hotspot_y / scale); wl_surface_damage_buffer( - seat->pointer.surface, 0, 0, INT32_MAX, INT32_MAX); + seat->pointer.surface.surf, 0, 0, INT32_MAX, INT32_MAX); xassert(seat->pointer.xcursor_callback == NULL); - seat->pointer.xcursor_callback = wl_surface_frame(seat->pointer.surface); + seat->pointer.xcursor_callback = wl_surface_frame(seat->pointer.surface.surf); wl_callback_add_listener(seat->pointer.xcursor_callback, &xcursor_listener, seat); - wl_surface_commit(seat->pointer.surface); + wl_surface_commit(seat->pointer.surface.surf); } static void diff --git a/terminal.c b/terminal.c index 43ba157b..825e1550 100644 --- a/terminal.c +++ b/terminal.c @@ -3589,23 +3589,23 @@ term_single_shift(struct terminal *term, enum charset_designator idx) enum term_surface term_surface_kind(const struct terminal *term, const struct wl_surface *surface) { - if (likely(surface == term->window->surface)) + if (likely(surface == term->window->surface.surf)) return TERM_SURF_GRID; - else if (surface == term->window->csd.surface[CSD_SURF_TITLE].surf) + else if (surface == term->window->csd.surface[CSD_SURF_TITLE].surface.surf) return TERM_SURF_TITLE; - else if (surface == term->window->csd.surface[CSD_SURF_LEFT].surf) + else if (surface == term->window->csd.surface[CSD_SURF_LEFT].surface.surf) return TERM_SURF_BORDER_LEFT; - else if (surface == term->window->csd.surface[CSD_SURF_RIGHT].surf) + else if (surface == term->window->csd.surface[CSD_SURF_RIGHT].surface.surf) return TERM_SURF_BORDER_RIGHT; - else if (surface == term->window->csd.surface[CSD_SURF_TOP].surf) + else if (surface == term->window->csd.surface[CSD_SURF_TOP].surface.surf) return TERM_SURF_BORDER_TOP; - else if (surface == term->window->csd.surface[CSD_SURF_BOTTOM].surf) + else if (surface == term->window->csd.surface[CSD_SURF_BOTTOM].surface.surf) return TERM_SURF_BORDER_BOTTOM; - else if (surface == term->window->csd.surface[CSD_SURF_MINIMIZE].surf) + else if (surface == term->window->csd.surface[CSD_SURF_MINIMIZE].surface.surf) return TERM_SURF_BUTTON_MINIMIZE; - else if (surface == term->window->csd.surface[CSD_SURF_MAXIMIZE].surf) + else if (surface == term->window->csd.surface[CSD_SURF_MAXIMIZE].surface.surf) return TERM_SURF_BUTTON_MAXIMIZE; - else if (surface == term->window->csd.surface[CSD_SURF_CLOSE].surf) + else if (surface == term->window->csd.surface[CSD_SURF_CLOSE].surface.surf) return TERM_SURF_BUTTON_CLOSE; else return TERM_SURF_NONE; diff --git a/wayland.c b/wayland.c index 9a3d11e8..3b6833c5 100644 --- a/wayland.c +++ b/wayland.c @@ -74,7 +74,7 @@ csd_instantiate(struct wl_window *win) for (size_t i = CSD_SURF_MINIMIZE; i < CSD_SURF_COUNT; i++) { bool ret = wayl_win_subsurface_new_with_custom_parent( - win, win->csd.surface[CSD_SURF_TITLE].surf, &win->csd.surface[i], + win, win->csd.surface[CSD_SURF_TITLE].surface.surf, &win->csd.surface[i], true); xassert(ret); } @@ -187,8 +187,12 @@ seat_destroy(struct seat *seat) if (seat->pointer.theme != NULL) wl_cursor_theme_destroy(seat->pointer.theme); - if (seat->pointer.surface != NULL) - wl_surface_destroy(seat->pointer.surface); + if (seat->pointer.surface.surf != NULL) + wl_surface_destroy(seat->pointer.surface.surf); +#if defined(HAVE_FRACTIONAL_SCALE) + if (seat->pointer.surface.viewport != NULL) + wp_viewport_destroy(seat->pointer.surface.viewport); +#endif if (seat->pointer.xcursor_callback != NULL) wl_callback_destroy(seat->pointer.xcursor_callback); @@ -288,10 +292,10 @@ seat_handle_capabilities(void *data, struct wl_seat *wl_seat, if (caps & WL_SEAT_CAPABILITY_POINTER) { if (seat->wl_pointer == NULL) { - xassert(seat->pointer.surface == NULL); - seat->pointer.surface = wl_compositor_create_surface(seat->wayl->compositor); + xassert(seat->pointer.surface.surf == NULL); + seat->pointer.surface.surf = wl_compositor_create_surface(seat->wayl->compositor); - if (seat->pointer.surface == NULL) { + if (seat->pointer.surface.surf == NULL) { LOG_ERR("%s: failed to create pointer surface", seat->name); return; } @@ -302,13 +306,13 @@ seat_handle_capabilities(void *data, struct wl_seat *wl_seat, } else { if (seat->wl_pointer != NULL) { wl_pointer_release(seat->wl_pointer); - wl_surface_destroy(seat->pointer.surface); + wl_surface_destroy(seat->pointer.surface.surf); if (seat->pointer.theme != NULL) wl_cursor_theme_destroy(seat->pointer.theme); seat->wl_pointer = NULL; - seat->pointer.surface = NULL; + seat->pointer.surface.surf = NULL; seat->pointer.theme = NULL; seat->pointer.cursor = NULL; } @@ -848,7 +852,7 @@ xdg_surface_configure(void *data, struct xdg_surface *xdg_surface, * anytime soon. Some compositors require a commit in * combination with an ack - make them happy. */ - wl_surface_commit(win->surface); + wl_surface_commit(win->surface.surf); } if (wasnt_configured) @@ -1225,7 +1229,7 @@ handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) if (seat->wl_keyboard != NULL) keyboard_listener.leave( - seat, seat->wl_keyboard, -1, seat->kbd_focus->window->surface); + seat, seat->wl_keyboard, -1, seat->kbd_focus->window->surface.surf); } if (seat->mouse_focus != NULL) { @@ -1235,7 +1239,7 @@ handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) if (seat->wl_pointer != NULL) pointer_listener.leave( - seat, seat->wl_pointer, -1, seat->mouse_focus->window->surface); + seat, seat->wl_pointer, -1, seat->mouse_focus->window->surface.surf); } seat_destroy(seat); @@ -1531,29 +1535,29 @@ wayl_win_init(struct terminal *term, const char *token) win->wm_capabilities.maximize = true; win->wm_capabilities.minimize = true; - win->surface = wl_compositor_create_surface(wayl->compositor); - if (win->surface == NULL) { + win->surface.surf = wl_compositor_create_surface(wayl->compositor); + if (win->surface.surf == NULL) { LOG_ERR("failed to create wayland surface"); goto out; } wayl_win_alpha_changed(win); - wl_surface_add_listener(win->surface, &surface_listener, win); + wl_surface_add_listener(win->surface.surf, &surface_listener, win); #if defined(HAVE_FRACTIONAL_SCALE) if (wayl->fractional_scale_manager != NULL && wayl->viewporter != NULL) { - win->viewport = wp_viewporter_get_viewport(wayl->viewporter, win->surface); + win->surface.viewport = wp_viewporter_get_viewport(wayl->viewporter, win->surface.surf); win->fractional_scale = wp_fractional_scale_manager_v1_get_fractional_scale( - wayl->fractional_scale_manager, win->surface); + wayl->fractional_scale_manager, win->surface.surf); wp_fractional_scale_v1_add_listener( win->fractional_scale, &fractional_scale_listener, win); } #endif - win->xdg_surface = xdg_wm_base_get_xdg_surface(wayl->shell, win->surface); + win->xdg_surface = xdg_wm_base_get_xdg_surface(wayl->shell, win->surface.surf); xdg_surface_add_listener(win->xdg_surface, &xdg_surface_listener, win); win->xdg_toplevel = xdg_surface_get_toplevel(win->xdg_surface); @@ -1586,12 +1590,12 @@ wayl_win_init(struct terminal *term, const char *token) LOG_WARN("no decoration manager available - using CSDs unconditionally"); } - wl_surface_commit(win->surface); + wl_surface_commit(win->surface.surf); #if defined(HAVE_XDG_ACTIVATION) /* Complete XDG startup notification */ if (token) - xdg_activation_v1_activate(wayl->xdg_activation, token, win->surface); + xdg_activation_v1_activate(wayl->xdg_activation, token, win->surface.surf); #endif if (!wayl_win_subsurface_new(win, &win->overlay, false)) { @@ -1641,33 +1645,33 @@ wayl_win_destroy(struct wl_window *win) * nor mouse focus). */ - if (win->render_timer.surf != NULL) { - wl_surface_attach(win->render_timer.surf, NULL, 0, 0); - wl_surface_commit(win->render_timer.surf); + if (win->render_timer.surface.surf != NULL) { + wl_surface_attach(win->render_timer.surface.surf, NULL, 0, 0); + wl_surface_commit(win->render_timer.surface.surf); } - if (win->scrollback_indicator.surf != NULL) { - wl_surface_attach(win->scrollback_indicator.surf, NULL, 0, 0); - wl_surface_commit(win->scrollback_indicator.surf); + if (win->scrollback_indicator.surface.surf != NULL) { + wl_surface_attach(win->scrollback_indicator.surface.surf, NULL, 0, 0); + wl_surface_commit(win->scrollback_indicator.surface.surf); } /* Scrollback search */ - if (win->search.surf != NULL) { - wl_surface_attach(win->search.surf, NULL, 0, 0); - wl_surface_commit(win->search.surf); + if (win->search.surface.surf != NULL) { + wl_surface_attach(win->search.surface.surf, NULL, 0, 0); + wl_surface_commit(win->search.surface.surf); } /* URLs */ tll_foreach(win->urls, it) { - wl_surface_attach(it->item.surf.surf, NULL, 0, 0); - wl_surface_commit(it->item.surf.surf); + wl_surface_attach(it->item.surf.surface.surf, NULL, 0, 0); + wl_surface_commit(it->item.surf.surface.surf); } /* CSD */ for (size_t i = 0; i < ALEN(win->csd.surface); i++) { - if (win->csd.surface[i].surf != NULL) { - wl_surface_attach(win->csd.surface[i].surf, NULL, 0, 0); - wl_surface_commit(win->csd.surface[i].surf); + if (win->csd.surface[i].surface.surf != NULL) { + wl_surface_attach(win->csd.surface[i].surface.surf, NULL, 0, 0); + wl_surface_commit(win->csd.surface[i].surface.surf); } } @@ -1675,8 +1679,8 @@ wayl_win_destroy(struct wl_window *win) /* Main window */ win->unmapped = true; - wl_surface_attach(win->surface, NULL, 0, 0); - wl_surface_commit(win->surface); + wl_surface_attach(win->surface.surf, NULL, 0, 0); + wl_surface_commit(win->surface.surf); wayl_roundtrip(win->term->wl); tll_free(win->on_outputs); @@ -1710,8 +1714,8 @@ wayl_win_destroy(struct wl_window *win) #if defined(HAVE_FRACTIONAL_SCALE) if (win->fractional_scale != NULL) wp_fractional_scale_v1_destroy(win->fractional_scale); - if (win->viewport != NULL) - wp_viewport_destroy(win->viewport); + if (win->surface.viewport != NULL) + wp_viewport_destroy(win->surface.viewport); #endif if (win->frame_callback != NULL) wl_callback_destroy(win->frame_callback); @@ -1721,8 +1725,8 @@ wayl_win_destroy(struct wl_window *win) xdg_toplevel_destroy(win->xdg_toplevel); if (win->xdg_surface != NULL) xdg_surface_destroy(win->xdg_surface); - if (win->surface != NULL) - wl_surface_destroy(win->surface); + if (win->surface.surf != NULL) + wl_surface_destroy(win->surface.surf); wayl_roundtrip(win->term->wl); @@ -1880,7 +1884,7 @@ wayl_win_scale(struct wl_window *win) const struct wayland *wayl = term->wl; const float scale = term->scale; - wayl_surface_scale(wayl, win->surface, scale); + wayl_surface_scale(wayl, win->surface.surf, scale); } void @@ -1894,11 +1898,11 @@ wayl_win_alpha_changed(struct wl_window *win) if (region != NULL) { wl_region_add(region, 0, 0, INT32_MAX, INT32_MAX); - wl_surface_set_opaque_region(win->surface, region); + wl_surface_set_opaque_region(win->surface.surf, region); wl_region_destroy(region); } } else - wl_surface_set_opaque_region(win->surface, NULL); + wl_surface_set_opaque_region(win->surface.surf, NULL); } #if defined(HAVE_XDG_ACTIVATION) @@ -1909,7 +1913,7 @@ activation_token_for_urgency_done(const char *token, void *data) struct wayland *wayl = win->term->wl; win->urgency_token_is_pending = false; - xdg_activation_v1_activate(wayl->xdg_activation, token, win->surface); + xdg_activation_v1_activate(wayl->xdg_activation, token, win->surface.surf); } #endif /* HAVE_XDG_ACTIVATION */ @@ -1954,11 +1958,11 @@ wayl_win_csd_borders_visible(const struct wl_window *win) bool wayl_win_subsurface_new_with_custom_parent( struct wl_window *win, struct wl_surface *parent, - struct wl_surf_subsurf *surf, bool allow_pointer_input) + struct wayl_sub_surface *surf, bool allow_pointer_input) { struct wayland *wayl = win->term->wl; - surf->surf = NULL; + surf->surface.surf = NULL; surf->sub = NULL; struct wl_surface *main_surface @@ -2002,39 +2006,42 @@ wayl_win_subsurface_new_with_custom_parent( wl_region_destroy(empty); } - surf->surf = main_surface; + surf->surface.surf = main_surface; surf->sub = sub; #if defined(HAVE_FRACTIONAL_SCALE) - surf->viewport = viewport; + surf->surface.viewport = viewport; #endif return true; } bool -wayl_win_subsurface_new(struct wl_window *win, struct wl_surf_subsurf *surf, +wayl_win_subsurface_new(struct wl_window *win, struct wayl_sub_surface *surf, bool allow_pointer_input) { return wayl_win_subsurface_new_with_custom_parent( - win, win->surface, surf, allow_pointer_input); + win, win->surface.surf, surf, allow_pointer_input); } void -wayl_win_subsurface_destroy(struct wl_surf_subsurf *surf) +wayl_win_subsurface_destroy(struct wayl_sub_surface *surf) { if (surf == NULL) return; #if defined(HAVE_FRACTIONAL_SCALE) - if (surf->viewport != NULL) - wp_viewport_destroy(surf->viewport); + if (surf->surface.viewport != NULL) { + wp_viewport_destroy(surf->surface.viewport); + surf->surface.viewport = NULL; + } #endif - if (surf->sub != NULL) + if (surf->sub != NULL) { wl_subsurface_destroy(surf->sub); - if (surf->surf != NULL) - wl_surface_destroy(surf->surf); - - surf->surf = NULL; - surf->sub = NULL; + surf->sub = NULL; + } + if (surf->surface.surf != NULL) { + wl_surface_destroy(surf->surface.surf); + surf->surface.surf = NULL; + } } #if defined(HAVE_XDG_ACTIVATION) @@ -2099,7 +2106,7 @@ wayl_get_activation_token( if (seat != NULL && serial != 0) xdg_activation_token_v1_set_serial(token, serial, seat->wl_seat); - xdg_activation_token_v1_set_surface(token, win->surface); + xdg_activation_token_v1_set_surface(token, win->surface.surf); xdg_activation_token_v1_add_listener(token, &activation_token_listener, ctx); xdg_activation_token_v1_commit(token); return true; diff --git a/wayland.h b/wayland.h index bb9bf77f..3ad05d33 100644 --- a/wayland.h +++ b/wayland.h @@ -45,6 +45,18 @@ enum data_offer_mime_type { DATA_OFFER_MIME_TEXT_UTF8_STRING, }; +struct wayl_surface { + struct wl_surface *surf; +#if defined(HAVE_FRACTIONAL_SCALE) + struct wp_viewport *viewport; +#endif +}; + +struct wayl_sub_surface { + struct wayl_surface surface; + struct wl_subsurface *sub; +}; + struct wl_window; struct wl_clipboard { struct wl_window *window; /* For DnD */ @@ -132,7 +144,7 @@ struct seat { struct { uint32_t serial; - struct wl_surface *surface; + struct wayl_surface surface; struct wl_cursor_theme *theme; struct wl_cursor *cursor; float scale; @@ -294,17 +306,9 @@ struct monitor { bool use_output_release; }; -struct wl_surf_subsurf { - struct wl_surface *surf; - struct wl_subsurface *sub; -#if defined(HAVE_FRACTIONAL_SCALE) - struct wp_viewport *viewport; -#endif -}; - struct wl_url { const struct url *url; - struct wl_surf_subsurf surf; + struct wayl_sub_surface surf; }; enum csd_mode {CSD_UNKNOWN, CSD_NO, CSD_YES}; @@ -328,7 +332,7 @@ struct xdg_activation_token_context { struct wayland; struct wl_window { struct terminal *term; - struct wl_surface *surface; + struct wayl_surface surface; struct xdg_surface *xdg_surface; struct xdg_toplevel *xdg_toplevel; #if defined(HAVE_XDG_ACTIVATION) @@ -336,7 +340,6 @@ struct wl_window { bool urgency_token_is_pending; #endif #if defined(HAVE_FRACTIONAL_SCALE) - struct wp_viewport *viewport; struct wp_fractional_scale_v1 *fractional_scale; #endif bool unmapped; @@ -348,7 +351,7 @@ struct wl_window { enum csd_mode csd_mode; struct { - struct wl_surf_subsurf surface[CSD_SURF_COUNT]; + struct wayl_sub_surface surface[CSD_SURF_COUNT]; struct fcft_font *font; int move_timeout_fd; uint32_t serial; @@ -359,10 +362,10 @@ struct wl_window { bool minimize:1; } wm_capabilities; - struct wl_surf_subsurf search; - struct wl_surf_subsurf scrollback_indicator; - struct wl_surf_subsurf render_timer; - struct wl_surf_subsurf overlay; + struct wayl_sub_surface search; + struct wayl_sub_surface scrollback_indicator; + struct wayl_sub_surface render_timer; + struct wayl_sub_surface overlay; struct wl_callback *frame_callback; @@ -465,12 +468,12 @@ bool wayl_win_csd_titlebar_visible(const struct wl_window *win); bool wayl_win_csd_borders_visible(const struct wl_window *win); bool wayl_win_subsurface_new( - struct wl_window *win, struct wl_surf_subsurf *surf, + struct wl_window *win, struct wayl_sub_surface *surf, bool allow_pointer_input); bool wayl_win_subsurface_new_with_custom_parent( struct wl_window *win, struct wl_surface *parent, - struct wl_surf_subsurf *surf, bool allow_pointer_input); -void wayl_win_subsurface_destroy(struct wl_surf_subsurf *surf); + struct wayl_sub_surface *surf, bool allow_pointer_input); +void wayl_win_subsurface_destroy(struct wayl_sub_surface *surf); #if defined(HAVE_XDG_ACTIVATION) bool wayl_get_activation_token( -- cgit v1.3 From 434fd6aa1f4a21ef6572a772ec891eeb2006a82c Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 26 Jun 2023 16:53:16 +0200 Subject: wayland: refactor: wayl_surface_scale(): pass wayl_surface pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of passing a raw wl_surface pointer, pass a wayl_surface pointer. This is needed later, when using fractional scaling to scale the surface (since then we need the surface’s viewport object). --- render.c | 61 ++++++++++++++++++++++++++++--------------------------------- wayland.c | 6 +++--- wayland.h | 2 +- 3 files changed, 32 insertions(+), 37 deletions(-) (limited to 'render.c') diff --git a/render.c b/render.c index 5ebd69eb..e78f1eeb 100644 --- a/render.c +++ b/render.c @@ -1691,7 +1691,7 @@ 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.surf, term->scale); + wayl_surface_scale(term->wl, &overlay->surface, term->scale); wl_subsurface_set_position(overlay->sub, 0, 0); wl_surface_attach(overlay->surface.surf, buf->wl_buf, 0, 0); @@ -1828,12 +1828,12 @@ get_csd_data(const struct terminal *term, enum csd_surface surf_idx) } static void -csd_commit(struct terminal *term, struct wl_surface *surf, struct buffer *buf) +csd_commit(struct terminal *term, struct wayl_surface *surf, struct buffer *buf) { wayl_surface_scale(term->wl, surf, term->scale); - wl_surface_attach(surf, buf->wl_buf, 0, 0); - wl_surface_damage_buffer(surf, 0, 0, buf->width, buf->height); - wl_surface_commit(surf); + 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); } static void @@ -1849,8 +1849,7 @@ render_csd_part(struct terminal *term, } static void -render_osd(struct terminal *term, - struct wl_surface *surf, struct wl_subsurface *sub_surf, +render_osd(struct terminal *term, const struct wayl_sub_surface *sub_surf, struct fcft_font *font, struct buffer *buf, const char32_t *text, uint32_t _fg, uint32_t _bg, unsigned x, unsigned y) @@ -1923,20 +1922,20 @@ render_osd(struct terminal *term, pixman_image_unref(src); pixman_image_set_clip_region32(buf->pix[0], NULL); - quirk_weston_subsurface_desync_on(sub_surf); - wayl_surface_scale(term->wl, surf, term->scale); - wl_surface_attach(surf, buf->wl_buf, 0, 0); - wl_surface_damage_buffer(surf, 0, 0, buf->width, buf->height); + quirk_weston_subsurface_desync_on(sub_surf->sub); + wayl_surface_scale(term->wl, &sub_surf->surface, 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); struct wl_region *region = wl_compositor_create_region(term->wl->compositor); if (region != NULL) { wl_region_add(region, 0, 0, buf->width, buf->height); - wl_surface_set_opaque_region(surf, region); + wl_surface_set_opaque_region(sub_surf->surface.surf, region); wl_region_destroy(region); } - wl_surface_commit(surf); - quirk_weston_subsurface_desync_off(sub_surf); + wl_surface_commit(sub_surf->surface.surf); + quirk_weston_subsurface_desync_off(sub_surf->sub); } static void @@ -1971,11 +1970,10 @@ render_csd_title(struct terminal *term, const struct csd_data *info, const int margin = M != NULL ? M->advance.x : win->csd.font->max_advance.x; - render_osd(term, surf->surface.surf, surf->sub, win->csd.font, - buf, title_text, fg, bg, margin, + render_osd(term, surf, win->csd.font, buf, title_text, fg, bg, margin, (buf->height - win->csd.font->height) / 2); - csd_commit(term, surf->surface.surf, buf); + csd_commit(term, &surf->surface, buf); free(_title_text); } @@ -1986,14 +1984,14 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx, xassert(term->window->csd_mode == CSD_YES); xassert(surf_idx >= CSD_SURF_LEFT && surf_idx <= CSD_SURF_BOTTOM); - struct wl_surface *surf = term->window->csd.surface[surf_idx].surface.surf; + struct wayl_surface *surf = &term->window->csd.surface[surf_idx].surface; if (info->width == 0 || info->height == 0) return; { pixman_color_t color = color_hex_to_pixman_with_alpha(0, 0); - render_csd_part(term, surf, buf, info->width, info->height, &color); + render_csd_part(term, surf->surf, buf, info->width, info->height, &color); } /* @@ -2271,7 +2269,7 @@ render_csd_button(struct terminal *term, enum csd_surface surf_idx, xassert(term->window->csd_mode == CSD_YES); xassert(surf_idx >= CSD_SURF_MINIMIZE && surf_idx <= CSD_SURF_CLOSE); - struct wl_surface *surf = term->window->csd.surface[surf_idx].surface.surf; + struct wayl_surface *surf = &term->window->csd.surface[surf_idx].surface; if (info->width == 0 || info->height == 0) return; @@ -2323,7 +2321,7 @@ render_csd_button(struct terminal *term, enum csd_surface surf_idx, _color = color_dim(term, _color); pixman_color_t color = color_hex_to_pixman_with_alpha(_color, alpha); - render_csd_part(term, surf, buf, info->width, info->height, &color); + render_csd_part(term, surf->surf, buf, info->width, info->height, &color); switch (surf_idx) { case CSD_SURF_MINIMIZE: render_csd_button_minimize(term, buf); break; @@ -2534,8 +2532,7 @@ render_scrollback_position(struct terminal *term) render_osd( term, - win->scrollback_indicator.surface.surf, - win->scrollback_indicator.sub, + &win->scrollback_indicator, term->fonts[0], buf, text, fg, 0xffu << 24 | bg, width - margin - c32len(text) * term->cell_width, margin); @@ -2571,8 +2568,7 @@ render_render_timer(struct terminal *term, struct timespec render_time) render_osd( term, - win->render_timer.surface.surf, - win->render_timer.sub, + &win->render_timer, term->fonts[0], buf, text, term->colors.table[0], 0xffu << 24 | term->colors.table[8 + 1], margin, margin); @@ -3374,7 +3370,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.surf, term->scale); + wayl_surface_scale(term->wl, &term->window->search.surface, 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); @@ -3601,23 +3597,22 @@ render_urls(struct terminal *term) : term->colors.table[3]; for (size_t i = 0; i < render_count; i++) { - struct wl_surface *surf = info[i].url->surf.surface.surf; - struct wl_subsurface *sub_surf = info[i].url->surf.sub; + const struct wayl_sub_surface *sub_surf = &info[i].url->surf; const char32_t *label = info[i].text; const int x = info[i].x; const int y = info[i].y; - xassert(surf != NULL); - xassert(sub_surf != NULL); + xassert(sub_surf->surface.surf != NULL); + xassert(sub_surf->sub != NULL); wl_subsurface_set_position( - sub_surf, + sub_surf->sub, (term->margins.left + x) / term->scale, (term->margins.top + y) / term->scale); render_osd( - term, surf, sub_surf, term->fonts[0], bufs[i], label, + term, sub_surf, term->fonts[0], bufs[i], label, fg, 0xffu << 24 | bg, x_margin, y_margin); free(info[i].text); @@ -4263,7 +4258,7 @@ render_xcursor_update(struct seat *seat) const float scale = seat->pointer.scale; struct wl_cursor_image *image = seat->pointer.cursor->images[0]; - wayl_surface_scale(seat->wayl, seat->pointer.surface.surf, scale); + wayl_surface_scale(seat->wayl, &seat->pointer.surface, scale); wl_surface_attach( seat->pointer.surface.surf, wl_cursor_image_get_buffer(image), 0, 0); diff --git a/wayland.c b/wayland.c index 3b6833c5..cd1a4c68 100644 --- a/wayland.c +++ b/wayland.c @@ -1865,7 +1865,7 @@ wayl_fractional_scaling(const struct wayland *wayl) } void -wayl_surface_scale(const struct wayland *wayl, struct wl_surface *surf, +wayl_surface_scale(const struct wayland *wayl, const struct wayl_surface *surf, float scale) { LOG_WARN("scaling by a factor of %.2f (legacy)", scale); @@ -1873,7 +1873,7 @@ wayl_surface_scale(const struct wayland *wayl, struct wl_surface *surf, if (wayl_fractional_scaling(wayl)) { BUG("not yet implemented"); } else { - wl_surface_set_buffer_scale(surf, (int)scale); + wl_surface_set_buffer_scale(surf->surf, (int)scale); } } @@ -1884,7 +1884,7 @@ wayl_win_scale(struct wl_window *win) const struct wayland *wayl = term->wl; const float scale = term->scale; - wayl_surface_scale(wayl, win->surface.surf, scale); + wayl_surface_scale(wayl, &win->surface, scale); } void diff --git a/wayland.h b/wayland.h index 3ad05d33..0506f82b 100644 --- a/wayland.h +++ b/wayland.h @@ -455,7 +455,7 @@ void wayl_roundtrip(struct wayland *wayl); bool wayl_fractional_scaling(const struct wayland *wayl); void wayl_surface_scale( - const struct wayland *wayl, struct wl_surface *surf, float scale); + const struct wayland *wayl, const struct wayl_surface *surf, float scale); struct wl_window *wayl_win_init(struct terminal *term, const char *token); void wayl_win_destroy(struct wl_window *win); -- cgit v1.3 From 5a60bbc119397c2993fc1895bae75c2c1e69fe1d Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 26 Jun 2023 17:05:16 +0200 Subject: wayland: refactor: add a buffer argument to wayl_*_scale() functions This will be needed later, when using fractional scaling + viewporter to scale. --- render.c | 28 +++++++++++++++++----------- wayland.c | 17 +++++++++++++---- wayland.h | 9 +++++++-- 3 files changed, 37 insertions(+), 17 deletions(-) (limited to 'render.c') diff --git a/render.c b/render.c index e78f1eeb..72d87bff 100644 --- a/render.c +++ b/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, diff --git a/wayland.c b/wayland.c index cd1a4c68..43f85066 100644 --- a/wayland.c +++ b/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 diff --git a/wayland.h b/wayland.h index 0506f82b..9736ea4d 100644 --- a/wayland.h +++ b/wayland.h @@ -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); -- cgit v1.3 From d71e588800fea0f7b7815cc5ce51ded752070b95 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 26 Jun 2023 21:06:47 +0200 Subject: wayland: refactor: surface_scale(): pass wl_window pointer, instead of wayland global --- render.c | 11 ++++++----- wayland.c | 11 +++++------ wayland.h | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'render.c') diff --git a/render.c b/render.c index 72d87bff..11b5223a 100644 --- a/render.c +++ b/render.c @@ -1692,7 +1692,7 @@ render_overlay(struct terminal *term) quirk_weston_subsurface_desync_on(overlay->sub); wayl_surface_scale( - term->wl, &overlay->surface, buf, term->scale); + term->window, &overlay->surface, buf, term->scale); wl_subsurface_set_position(overlay->sub, 0, 0); wl_surface_attach(overlay->surface.surf, buf->wl_buf, 0, 0); @@ -1831,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, buf, term->scale); + wayl_surface_scale(term->window, 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); @@ -1924,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, buf, term->scale); + wayl_surface_scale(term->window, &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); @@ -3371,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, buf, term->scale); + wayl_surface_scale(term->window, &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); @@ -4265,7 +4265,8 @@ render_xcursor_update(struct seat *seat) struct wl_buffer *buf = wl_cursor_image_get_buffer(image); wayl_surface_scale_explicit_width_height( - seat->wayl, &seat->pointer.surface, image->width, image->height, scale); + seat->mouse_focus->window, + &seat->pointer.surface, image->width, image->height, scale); wl_surface_attach(seat->pointer.surface.surf, buf, 0, 0); diff --git a/wayland.c b/wayland.c index ce0e879f..aa1b298c 100644 --- a/wayland.c +++ b/wayland.c @@ -1891,7 +1891,7 @@ wayl_fractional_scaling(const struct wayland *wayl) void wayl_surface_scale_explicit_width_height( - const struct wayland *wayl, const struct wayl_surface *surf, + const struct wl_window *win, const struct wayl_surface *surf, int width, int height, float scale) { @@ -1915,26 +1915,25 @@ wayl_surface_scale_explicit_width_height( xassert(width % iscale == 0); xassert(height % iscale == 0); - wl_surface_set_buffer_scale(surf->surf, (int)scale); + wl_surface_set_buffer_scale(surf->surf, iscale); } } void -wayl_surface_scale(const struct wayland *wayl, const struct wayl_surface *surf, +wayl_surface_scale(const struct wl_window *win, const struct wayl_surface *surf, const struct buffer *buf, float scale) { wayl_surface_scale_explicit_width_height( - wayl, surf, buf->width, buf->height, scale); + win, 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, buf, scale); + wayl_surface_scale(win, &win->surface, buf, scale); } void diff --git a/wayland.h b/wayland.h index 9736ea4d..7305ade7 100644 --- a/wayland.h +++ b/wayland.h @@ -456,10 +456,10 @@ 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, + const struct wl_window *win, 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, + const struct wl_window *win, const struct wayl_surface *surf, int width, int height, float scale); struct wl_window *wayl_win_init(struct terminal *term, const char *token); -- cgit v1.3