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) { if (apply_damage) {
/* Top */ /* Top */
wl_surface_damage_buffer( 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 */ /* Bottom */
wl_surface_damage_buffer( 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 */ /* Left */
wl_surface_damage_buffer( wl_surface_damage_buffer(
term->window->surface, term->window->main.surf,
0, term->margins.top + start_line * term->cell_height, 0, term->margins.top + start_line * term->cell_height,
term->margins.left, line_count * term->cell_height); term->margins.left, line_count * term->cell_height);
/* Right */ /* Right */
wl_surface_damage_buffer( wl_surface_damage_buffer(
term->window->surface, term->window->main.surf,
rmargin, term->margins.top + start_line * term->cell_height, rmargin, term->margins.top + start_line * term->cell_height,
term->margins.right, line_count * 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 #endif
wl_surface_damage_buffer( 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); term->width - term->margins.left - term->margins.right, height);
/* /*
@ -1091,7 +1091,7 @@ grid_render_scroll_reverse(struct terminal *term, struct buffer *buf,
#endif #endif
wl_surface_damage_buffer( 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); 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, x, y,
width, height); 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 static void
@ -1467,7 +1467,7 @@ render_ime_preedit_for_seat(struct terminal *term, struct seat *seat,
free(real_cells); free(real_cells);
wl_surface_damage_buffer( wl_surface_damage_buffer(
term->window->surface, term->window->main.surf,
term->margins.left, term->margins.left,
term->margins.top + row_idx * term->cell_height, term->margins.top + row_idx * term->cell_height,
term->width - term->margins.left - term->margins.right, term->width - term->margins.left - term->margins.right,
@ -2685,6 +2685,8 @@ dirty_cursor(struct terminal *term)
static void static void
grid_render(struct terminal *term) grid_render(struct terminal *term)
{ {
xassert(term->window->main.sub == NULL);
if (term->shutdown.in_progress) if (term->shutdown.in_progress)
return; return;
@ -2878,7 +2880,7 @@ grid_render(struct terminal *term)
int height = (r - first_dirty_row) * term->cell_height; int height = (r - first_dirty_row) * term->cell_height;
wl_surface_damage_buffer( wl_surface_damage_buffer(
term->window->surface, x, y, width, height); term->window->main.surf, x, y, width, height);
pixman_region32_union_rect( pixman_region32_union_rect(
&buf->dirty, &buf->dirty, 0, y, buf->width, height); &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 width = term->width - term->margins.left - term->margins.right;
int height = (term->rows - first_dirty_row) * term->cell_height; 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); 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->grid->view >= 0 && term->grid->view < term->grid->num_rows);
xassert(term->window->frame_callback == NULL); 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_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) { if (term->wl->presentation != NULL && term->conf->presentation_timings) {
struct timespec commit_time; struct timespec commit_time;
clock_gettime(term->wl->presentation_clock_id, &commit_time); clock_gettime(term->wl->presentation_clock_id, &commit_time);
struct wp_presentation_feedback *feedback = wp_presentation_feedback( struct wp_presentation_feedback *feedback = wp_presentation_feedback(
term->wl->presentation, term->window->surface); term->wl->presentation, term->window->main.surf);
if (feedback == NULL) { if (feedback == NULL) {
LOG_WARN("failed to create presentation feedback"); LOG_WARN("failed to create presentation feedback");
@ -3007,14 +3009,14 @@ grid_render(struct terminal *term)
if (term->conf->tweak.damage_whole_window) { if (term->conf->tweak.damage_whole_window) {
wl_surface_damage_buffer( 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->width % term->scale == 0);
xassert(buf->height % term->scale == 0); xassert(buf->height % term->scale == 0);
wl_surface_attach(term->window->surface, buf->wl_buf, 0, 0); wl_surface_attach(term->window->main.surf, buf->wl_buf, 0, 0);
wl_surface_commit(term->window->surface); wl_surface_commit(term->window->main.surf);
} }
static void static void

View file

@ -3512,7 +3512,7 @@ term_single_shift(struct terminal *term, enum charset_designator idx)
enum term_surface enum term_surface
term_surface_kind(const struct terminal *term, const struct wl_surface *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; 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].surf)
return TERM_SURF_TITLE; 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 * anytime soon. Some compositors require a commit in
* combination with an ack - make them happy. * combination with an ack - make them happy.
*/ */
wl_surface_commit(win->surface); wl_surface_commit(win->main.surf);
} }
if (wasnt_configured) if (wasnt_configured)
@ -1194,7 +1194,7 @@ handle_global_remove(void *data, struct wl_registry *registry, uint32_t name)
if (seat->wl_keyboard != NULL) if (seat->wl_keyboard != NULL)
keyboard_listener.leave( 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) { 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) if (seat->wl_pointer != NULL)
pointer_listener.leave( 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); seat_destroy(seat);
@ -1479,8 +1479,8 @@ wayl_win_init(struct terminal *term, const char *token)
win->wm_capabilities.maximize = true; win->wm_capabilities.maximize = true;
win->wm_capabilities.minimize = true; win->wm_capabilities.minimize = true;
win->surface = wl_compositor_create_surface(wayl->compositor); win->main.surf = wl_compositor_create_surface(wayl->compositor);
if (win->surface == NULL) { if (win->main.surf == NULL) {
LOG_ERR("failed to create wayland surface"); LOG_ERR("failed to create wayland surface");
goto out; goto out;
} }
@ -1491,14 +1491,14 @@ wayl_win_init(struct terminal *term, const char *token)
if (region != NULL) { if (region != NULL) {
wl_region_add(region, 0, 0, INT32_MAX, INT32_MAX); 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_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); xdg_surface_add_listener(win->xdg_surface, &xdg_surface_listener, win);
win->xdg_toplevel = xdg_surface_get_toplevel(win->xdg_surface); 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"); 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) #if defined(HAVE_XDG_ACTIVATION)
/* Complete XDG startup notification */ /* Complete XDG startup notification */
if (token) if (token)
xdg_activation_v1_activate(wayl->xdg_activation, token, win->surface); xdg_activation_v1_activate(wayl->xdg_activation, token, win->main.surf);
#endif #endif
if (!wayl_win_subsurface_new(win, &win->overlay, false)) { 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); wayl_roundtrip(win->term->wl);
/* Main window */ /* Main window */
wl_surface_attach(win->surface, NULL, 0, 0); wl_surface_attach(win->main.surf, NULL, 0, 0);
wl_surface_commit(win->surface); wl_surface_commit(win->main.surf);
wayl_roundtrip(win->term->wl); wayl_roundtrip(win->term->wl);
tll_free(win->on_outputs); tll_free(win->on_outputs);
@ -1659,8 +1659,8 @@ wayl_win_destroy(struct wl_window *win)
xdg_toplevel_destroy(win->xdg_toplevel); xdg_toplevel_destroy(win->xdg_toplevel);
if (win->xdg_surface != NULL) if (win->xdg_surface != NULL)
xdg_surface_destroy(win->xdg_surface); xdg_surface_destroy(win->xdg_surface);
if (win->surface != NULL) if (win->main.surf != NULL)
wl_surface_destroy(win->surface); wl_surface_destroy(win->main.surf);
wayl_roundtrip(win->term->wl); 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; struct wayland *wayl = win->term->wl;
win->urgency_token_is_pending = false; 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 */ #endif /* HAVE_XDG_ACTIVATION */
@ -1881,7 +1881,7 @@ wayl_win_subsurface_new(struct wl_window *win, struct wl_surf *surf,
bool allow_pointer_input) bool allow_pointer_input)
{ {
return wayl_win_subsurface_new_with_custom_parent( return wayl_win_subsurface_new_with_custom_parent(
win, win->surface, surf, allow_pointer_input); win, win->main.surf, surf, allow_pointer_input);
} }
void void
@ -1960,7 +1960,7 @@ wayl_get_activation_token(
if (seat != NULL && serial != 0) if (seat != NULL && serial != 0)
xdg_activation_token_v1_set_serial(token, serial, seat->wl_seat); 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_add_listener(token, &activation_token_listener, ctx);
xdg_activation_token_v1_commit(token); xdg_activation_token_v1_commit(token);
return true; return true;

View file

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