mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
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).
This commit is contained in:
parent
c5d533ec71
commit
ba46a039ac
5 changed files with 149 additions and 139 deletions
2
quirks.c
2
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);
|
||||
}
|
||||
|
|
|
|||
100
render.c
100
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
|
||||
|
|
|
|||
18
terminal.c
18
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;
|
||||
|
|
|
|||
125
wayland.c
125
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;
|
||||
|
|
|
|||
43
wayland.h
43
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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue