wl_window: Use wl_surf for main surface

This commit is contained in:
Alexander Orzechowski 2022-12-04 19:31:16 -05:00
parent 7a78fdf771
commit 8d99aae1d1
4 changed files with 37 additions and 35 deletions

View file

@ -902,21 +902,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->main.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->main.surf, 0, bmargin, term->width, term->margins.bottom);
/* Left */
wl_surface_damage_buffer(
term->window->surface,
term->window->main.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->main.surf,
rmargin, term->margins.top + start_line * term->cell_height,
term->margins.right, line_count * term->cell_height);
}
@ -1019,7 +1019,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->main.surf, term->margins.left, dst_y,
term->width - term->margins.left - term->margins.right, height);
/*
@ -1091,7 +1091,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->main.surf, term->margins.left, dst_y,
term->width - term->margins.left - term->margins.right, height);
/*
@ -1140,7 +1140,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->main.surf, x, y, width, height);
}
static void
@ -1467,7 +1467,7 @@ render_ime_preedit_for_seat(struct terminal *term, struct seat *seat,
free(real_cells);
wl_surface_damage_buffer(
term->window->surface,
term->window->main.surf,
term->margins.left,
term->margins.top + row_idx * term->cell_height,
term->width - term->margins.left - term->margins.right,
@ -2685,6 +2685,8 @@ dirty_cursor(struct terminal *term)
static void
grid_render(struct terminal *term)
{
xassert(term->window->main.sub == NULL);
if (term->shutdown.in_progress)
return;
@ -2878,7 +2880,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->main.surf, x, y, width, height);
pixman_region32_union_rect(
&buf->dirty, &buf->dirty, 0, y, buf->width, height);
}
@ -2906,7 +2908,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->main.surf, x, y, width, height);
pixman_region32_union_rect(&buf->dirty, &buf->dirty, 0, y, buf->width, height);
}
@ -2973,17 +2975,17 @@ 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->main.surf);
wl_callback_add_listener(term->window->frame_callback, &frame_listener, term);
wl_surface_set_buffer_scale(term->window->surface, term->scale);
wl_surface_set_buffer_scale(term->window->main.surf, term->scale);
if (term->wl->presentation != NULL && term->conf->presentation_timings) {
struct timespec commit_time;
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->main.surf);
if (feedback == NULL) {
LOG_WARN("failed to create presentation feedback");
@ -3007,14 +3009,14 @@ 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->main.surf, 0, 0, INT32_MAX, INT32_MAX);
}
xassert(buf->width % term->scale == 0);
xassert(buf->height % term->scale == 0);
wl_surface_attach(term->window->surface, buf->wl_buf, 0, 0);
wl_surface_commit(term->window->surface);
wl_surface_attach(term->window->main.surf, buf->wl_buf, 0, 0);
wl_surface_commit(term->window->main.surf);
}
static void

View file

@ -3512,7 +3512,7 @@ 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->main.surf))
return TERM_SURF_GRID;
else if (surface == term->window->csd.surface[CSD_SURF_TITLE].surf)
return TERM_SURF_TITLE;

View file

@ -838,7 +838,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->main.surf);
}
if (wasnt_configured)
@ -1194,7 +1194,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->main.surf);
}
if (seat->mouse_focus != NULL) {
@ -1204,7 +1204,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->main.surf);
}
seat_destroy(seat);
@ -1479,8 +1479,8 @@ 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->main.surf = wl_compositor_create_surface(wayl->compositor);
if (win->main.surf == NULL) {
LOG_ERR("failed to create wayland surface");
goto out;
}
@ -1491,14 +1491,14 @@ wayl_win_init(struct terminal *term, const char *token)
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->main.surf, region);
wl_region_destroy(region);
}
}
wl_surface_add_listener(win->surface, &surface_listener, win);
wl_surface_add_listener(win->main.surf, &surface_listener, win);
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->main.surf);
xdg_surface_add_listener(win->xdg_surface, &xdg_surface_listener, win);
win->xdg_toplevel = xdg_surface_get_toplevel(win->xdg_surface);
@ -1531,12 +1531,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->main.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->main.surf);
#endif
if (!wayl_win_subsurface_new(win, &win->overlay, false)) {
@ -1619,8 +1619,8 @@ wayl_win_destroy(struct wl_window *win)
wayl_roundtrip(win->term->wl);
/* Main window */
wl_surface_attach(win->surface, NULL, 0, 0);
wl_surface_commit(win->surface);
wl_surface_attach(win->main.surf, NULL, 0, 0);
wl_surface_commit(win->main.surf);
wayl_roundtrip(win->term->wl);
tll_free(win->on_outputs);
@ -1659,8 +1659,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->main.surf != NULL)
wl_surface_destroy(win->main.surf);
wayl_roundtrip(win->term->wl);
@ -1794,7 +1794,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->main.surf);
}
#endif /* HAVE_XDG_ACTIVATION */
@ -1881,7 +1881,7 @@ wayl_win_subsurface_new(struct wl_window *win, struct wl_surf *surf,
bool allow_pointer_input)
{
return wayl_win_subsurface_new_with_custom_parent(
win, win->surface, surf, allow_pointer_input);
win, win->main.surf, surf, allow_pointer_input);
}
void
@ -1960,7 +1960,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->main.surf);
xdg_activation_token_v1_add_listener(token, &activation_token_listener, ctx);
xdg_activation_token_v1_commit(token);
return true;

View file

@ -320,7 +320,6 @@ struct xdg_activation_token_context {
struct wayland;
struct wl_window {
struct terminal *term;
struct wl_surface *surface;
struct xdg_surface *xdg_surface;
struct xdg_toplevel *xdg_toplevel;
#if defined(HAVE_XDG_ACTIVATION)
@ -344,6 +343,7 @@ struct wl_window {
bool minimize:1;
} wm_capabilities;
struct wl_surf main;
struct wl_surf search;
struct wl_surf scrollback_indicator;
struct wl_surf render_timer;