mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-27 06:46:44 -04:00
wl_surf: Add invalidated function callback
This commit is contained in:
parent
8d99aae1d1
commit
aa3d0060c2
3 changed files with 67 additions and 0 deletions
|
|
@ -135,6 +135,12 @@ if wayland_protocols.version().version_compare('>=1.21')
|
|||
wl_proto_xml += [wayland_protocols_datadir + '/staging/xdg-activation/xdg-activation-v1.xml']
|
||||
endif
|
||||
|
||||
# TODO: Update when this protocol is actually released
|
||||
if wayland_protocols.version().version_compare('>=1.21')
|
||||
add_project_arguments('-DHAVE_SURFACE_INVALIDATION', language: 'c')
|
||||
wl_proto_xml += [ wayland_protocols_datadir + '/staging/surface-invalidation/surface-invalidation-v1.xml']
|
||||
endif
|
||||
|
||||
foreach prot : wl_proto_xml
|
||||
wl_proto_headers += custom_target(
|
||||
prot.underscorify() + '-client-header',
|
||||
|
|
|
|||
50
wayland.c
50
wayland.c
|
|
@ -1124,6 +1124,17 @@ handle_global(void *data, struct wl_registry *registry,
|
|||
seat_add_text_input(&it->item);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SURFACE_INVALIDATION) && HAVE_SURFACE_INVALIDATION
|
||||
else if (strcmp(interface, wp_surface_invalidation_manager_v1_interface.name) == 0) {
|
||||
const uint32_t required = 1;
|
||||
if (!verify_iface_version(interface, version, required))
|
||||
return;
|
||||
|
||||
wayl->surface_invalidation_manager = wl_registry_bind(
|
||||
wayl->registry, name, &wp_surface_invalidation_manager_v1_interface, required);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1459,6 +1470,41 @@ wayl_destroy(struct wayland *wayl)
|
|||
free(wayl);
|
||||
}
|
||||
|
||||
#if defined (HAVE_SURFACE_INVALIDATION)
|
||||
static void surface_invalidation_handle_invalidated(
|
||||
void *data,
|
||||
struct wp_surface_invalidation_v1 *wp_surface_invalidation_v1,
|
||||
uint32_t serial)
|
||||
{
|
||||
struct wl_surf *surf = data;
|
||||
|
||||
if (surf->invalidated == NULL)
|
||||
return;
|
||||
|
||||
wp_surface_invalidation_v1_ack(wp_surface_invalidation_v1, serial);
|
||||
surf->invalidated(surf->term);
|
||||
}
|
||||
|
||||
static struct wp_surface_invalidation_v1_listener surface_invalidation_listener = {
|
||||
.invalidated = surface_invalidation_handle_invalidated,
|
||||
};
|
||||
#endif
|
||||
|
||||
static void
|
||||
init_wl_surf_inaviladion(struct terminal *term, struct wl_surf *surf) {
|
||||
surf->term = term;
|
||||
#if defined (HAVE_SURFACE_INVALIDATION)
|
||||
if (!term->wl->surface_invalidation_manager)
|
||||
return;
|
||||
|
||||
struct wp_surface_invalidation_v1 *surface_invalidation
|
||||
= wp_surface_invalidation_manager_v1_get_surface_invalidation(
|
||||
term->wl->surface_invalidation_manager, surf->surf);
|
||||
wp_surface_invalidation_v1_add_listener(surface_invalidation,
|
||||
&surface_invalidation_listener, surf);
|
||||
#endif
|
||||
}
|
||||
|
||||
struct wl_window *
|
||||
wayl_win_init(struct terminal *term, const char *token)
|
||||
{
|
||||
|
|
@ -1531,6 +1577,8 @@ wayl_win_init(struct terminal *term, const char *token)
|
|||
LOG_WARN("no decoration manager available - using CSDs unconditionally");
|
||||
}
|
||||
|
||||
init_wl_surf_inaviladion(term, &win->main);
|
||||
|
||||
wl_surface_commit(win->main.surf);
|
||||
|
||||
#if defined(HAVE_XDG_ACTIVATION)
|
||||
|
|
@ -1873,6 +1921,8 @@ wayl_win_subsurface_new_with_custom_parent(
|
|||
|
||||
surf->surf = main_surface;
|
||||
surf->sub = sub;
|
||||
|
||||
init_wl_surf_inaviladion(win->term, surf);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
11
wayland.h
11
wayland.h
|
|
@ -20,6 +20,10 @@
|
|||
#include <xdg-activation-v1.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SURFACE_INVALIDATION)
|
||||
#include <surface-invalidation-v1.h>
|
||||
#endif
|
||||
|
||||
#include <fcft/fcft.h>
|
||||
#include <tllist.h>
|
||||
|
||||
|
|
@ -292,6 +296,9 @@ struct monitor {
|
|||
struct wl_surf {
|
||||
struct wl_surface *surf;
|
||||
struct wl_subsurface *sub;
|
||||
struct terminal *term;
|
||||
|
||||
void (*invalidated)(struct terminal *term);
|
||||
};
|
||||
|
||||
struct wl_url {
|
||||
|
|
@ -405,6 +412,10 @@ struct wayland {
|
|||
struct xdg_activation_v1 *xdg_activation;
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SURFACE_INVALIDATION)
|
||||
struct wp_surface_invalidation_manager_v1 *surface_invalidation_manager;
|
||||
#endif
|
||||
|
||||
bool presentation_timings;
|
||||
struct wp_presentation *presentation;
|
||||
uint32_t presentation_clock_id;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue