Skip to content

Commit 6a2bba0

Browse files
committed
Implement surface-invalidation-v1
1 parent 5eca7d5 commit 6a2bba0

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

include/mako.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
1919
#include "xdg-output-unstable-v1-client-protocol.h"
2020
#include "xdg-activation-v1-client-protocol.h"
21+
#include "surface-invalidation-v1-client-protocol.h"
2122

2223
struct mako_state;
2324

@@ -58,6 +59,7 @@ struct mako_state {
5859
struct zwlr_layer_shell_v1 *layer_shell;
5960
struct zxdg_output_manager_v1 *xdg_output_manager;
6061
struct xdg_activation_v1 *xdg_activation;
62+
struct wp_surface_invalidation_manager_v1 *surface_invalidation;
6163
struct wl_list outputs; // mako_output::link
6264
struct wl_list seats; // mako_seat::link
6365

protocol/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ wayland_scanner_client = generator(
2424
client_protocols = [
2525
wl_protocol_dir / 'stable/xdg-shell/xdg-shell.xml',
2626
wl_protocol_dir / 'staging/xdg-activation/xdg-activation-v1.xml',
27+
wl_protocol_dir / 'staging/surface-invalidation/surface-invalidation-v1.xml',
2728
wl_protocol_dir / 'unstable/xdg-output/xdg-output-unstable-v1.xml',
2829
'wlr-layer-shell-unstable-v1.xml',
2930
]

wayland.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ static const struct zwlr_layer_surface_v1_listener layer_surface_listener = {
427427
.closed = layer_surface_handle_closed,
428428
};
429429

430-
431430
static void handle_global(void *data, struct wl_registry *registry,
432431
uint32_t name, const char *interface, uint32_t version) {
433432
struct mako_state *state = data;
@@ -457,6 +456,9 @@ static void handle_global(void *data, struct wl_registry *registry,
457456
} else if (strcmp(interface, xdg_activation_v1_interface.name) == 0) {
458457
state->xdg_activation = wl_registry_bind(registry, name,
459458
&xdg_activation_v1_interface, 1);
459+
} else if (strcmp(interface, wp_surface_invalidation_manager_v1_interface.name)) {
460+
state->surface_invalidation = wl_registry_bind(registry, name,
461+
&wp_surface_invalidation_manager_v1_interface, 1);
460462
}
461463
}
462464

@@ -613,8 +615,21 @@ static struct mako_output *get_configured_output(struct mako_surface *surface) {
613615
return NULL;
614616
}
615617

618+
static void send_frame(struct mako_surface *surface);
616619
static void schedule_frame_and_commit(struct mako_surface *surface);
617620

621+
static void surface_invalidation_handle_invalidated(void *data,
622+
struct wp_surface_invalidation_v1 *wp_surface_invalidation_v1, uint32_t serial) {
623+
struct mako_surface *surface = data;
624+
625+
wp_surface_invalidation_v1_ack(wp_surface_invalidation_v1, serial);
626+
send_frame(surface);
627+
}
628+
629+
static struct wp_surface_invalidation_v1_listener surface_invalidation_listener = {
630+
.invalidated = surface_invalidation_handle_invalidated,
631+
};
632+
618633
// Draw and commit a new frame.
619634
static void send_frame(struct mako_surface *surface) {
620635
struct mako_state *state = surface->state;
@@ -676,6 +691,14 @@ static void send_frame(struct mako_surface *surface) {
676691
surface->surface = wl_compositor_create_surface(state->compositor);
677692
wl_surface_add_listener(surface->surface, &surface_listener, surface);
678693

694+
if (state->surface_invalidation) {
695+
struct wp_surface_invalidation_v1 *surface_invalidation =
696+
wp_surface_invalidation_manager_v1_get_surface_invalidation(
697+
state->surface_invalidation, surface->surface);
698+
wp_surface_invalidation_v1_add_listener(surface_invalidation,
699+
&surface_invalidation_listener, surface);
700+
}
701+
679702
surface->layer_surface = zwlr_layer_shell_v1_get_layer_surface(
680703
state->layer_shell, surface->surface, wl_output,
681704
surface->layer, "notifications");

0 commit comments

Comments
 (0)