@@ -427,7 +427,6 @@ static const struct zwlr_layer_surface_v1_listener layer_surface_listener = {
427427 .closed = layer_surface_handle_closed ,
428428};
429429
430-
431430static 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 );
616619static 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.
619634static 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