mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
wayland: add wayl_win_subsurface_new() and wayl_win_subsurface_destroy()
These are utility functions to create a Wayland subsurface associated with the window.
This commit is contained in:
parent
8658ab4bed
commit
bb4d9a5fd3
2 changed files with 60 additions and 1 deletions
47
wayland.c
47
wayland.c
|
|
@ -1570,3 +1570,50 @@ wayl_roundtrip(struct wayland *wayl)
|
|||
wl_display_dispatch_pending(wayl->display);
|
||||
wayl_flush(wayl);
|
||||
}
|
||||
|
||||
bool
|
||||
wayl_win_subsurface_new_with_custom_parent(
|
||||
struct wl_window *win, struct wl_surface *parent,
|
||||
struct wl_surf_subsurf *surf)
|
||||
{
|
||||
struct wayland *wayl = win->term->wl;
|
||||
|
||||
surf->surf = NULL;
|
||||
surf->sub = NULL;
|
||||
|
||||
struct wl_surface *main = wl_compositor_create_surface(wayl->compositor);
|
||||
if (main == NULL)
|
||||
return false;
|
||||
|
||||
struct wl_subsurface *sub = wl_subcompositor_get_subsurface(
|
||||
wayl->sub_compositor, main, parent);
|
||||
|
||||
if (sub == NULL) {
|
||||
wl_surface_destroy(main);
|
||||
return false;
|
||||
}
|
||||
|
||||
wl_surface_set_user_data(main, win);
|
||||
wl_subsurface_set_sync(sub);
|
||||
|
||||
surf->surf = main;
|
||||
surf->sub = sub;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
wayl_win_subsurface_new(struct wl_window *win, struct wl_surf_subsurf *surf)
|
||||
{
|
||||
return wayl_win_subsurface_new_with_custom_parent(win, win->surface, surf);
|
||||
}
|
||||
|
||||
void
|
||||
wayl_win_subsurface_destroy(struct wl_surf_subsurf *surf)
|
||||
{
|
||||
if (surf == NULL)
|
||||
return;
|
||||
if (surf->sub != NULL)
|
||||
wl_subsurface_destroy(surf->sub);
|
||||
if (surf->surf != NULL)
|
||||
wl_surface_destroy(surf->surf);
|
||||
}
|
||||
|
|
|
|||
14
wayland.h
14
wayland.h
|
|
@ -350,6 +350,11 @@ struct monitor {
|
|||
bool use_output_release;
|
||||
};
|
||||
|
||||
struct wl_surf_subsurf {
|
||||
struct wl_surface *surf;
|
||||
struct wl_subsurface *sub;
|
||||
};
|
||||
|
||||
struct wl_url {
|
||||
const struct url *url;
|
||||
struct wl_surface *surf;
|
||||
|
|
@ -453,10 +458,17 @@ struct wayland {
|
|||
struct wayland *wayl_init(const struct config *conf, struct fdm *fdm);
|
||||
void wayl_destroy(struct wayland *wayl);
|
||||
|
||||
bool wayl_reload_xcursor_theme(struct seat *seat, int new_scale);
|
||||
|
||||
void wayl_flush(struct wayland *wayl);
|
||||
void wayl_roundtrip(struct wayland *wayl);
|
||||
|
||||
struct wl_window *wayl_win_init(struct terminal *term);
|
||||
void wayl_win_destroy(struct wl_window *win);
|
||||
|
||||
bool wayl_reload_xcursor_theme(struct seat *seat, int new_scale);
|
||||
bool wayl_win_subsurface_new(
|
||||
struct wl_window *win, struct wl_surf_subsurf *surf);
|
||||
bool wayl_win_subsurface_new_with_custom_parent(
|
||||
struct wl_window *win, struct wl_surface *parent,
|
||||
struct wl_surf_subsurf *surf);
|
||||
void wayl_win_subsurface_destroy(struct wl_surf_subsurf *surf);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue