Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement surface-invalidation-v1 #449

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/mako.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
#include "xdg-output-unstable-v1-client-protocol.h"
#include "xdg-activation-v1-client-protocol.h"
#include "surface-invalidation-v1-client-protocol.h"

struct mako_state;

Expand Down Expand Up @@ -58,6 +59,7 @@ struct mako_state {
struct zwlr_layer_shell_v1 *layer_shell;
struct zxdg_output_manager_v1 *xdg_output_manager;
struct xdg_activation_v1 *xdg_activation;
struct wp_surface_invalidation_manager_v1 *surface_invalidation_manager;
struct wl_list outputs; // mako_output::link
struct wl_list seats; // mako_seat::link

Expand Down
1 change: 1 addition & 0 deletions protocol/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ wayland_scanner_client = generator(
client_protocols = [
wl_protocol_dir / 'stable/xdg-shell/xdg-shell.xml',
wl_protocol_dir / 'staging/xdg-activation/xdg-activation-v1.xml',
wl_protocol_dir / 'staging/surface-invalidation/surface-invalidation-v1.xml',
wl_protocol_dir / 'unstable/xdg-output/xdg-output-unstable-v1.xml',
'wlr-layer-shell-unstable-v1.xml',
]
Expand Down
25 changes: 24 additions & 1 deletion wayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ static const struct zwlr_layer_surface_v1_listener layer_surface_listener = {
.closed = layer_surface_handle_closed,
};


static void handle_global(void *data, struct wl_registry *registry,
uint32_t name, const char *interface, uint32_t version) {
struct mako_state *state = data;
Expand Down Expand Up @@ -457,6 +456,9 @@ static void handle_global(void *data, struct wl_registry *registry,
} else if (strcmp(interface, xdg_activation_v1_interface.name) == 0) {
state->xdg_activation = wl_registry_bind(registry, name,
&xdg_activation_v1_interface, 1);
} else if (strcmp(interface, wp_surface_invalidation_manager_v1_interface.name)) {
state->surface_invalidation_manager = wl_registry_bind(registry, name,
&wp_surface_invalidation_manager_v1_interface, 1);
}
}

Expand Down Expand Up @@ -613,8 +615,21 @@ static struct mako_output *get_configured_output(struct mako_surface *surface) {
return NULL;
}

static void send_frame(struct mako_surface *surface);
static void schedule_frame_and_commit(struct mako_surface *surface);

static void surface_invalidation_handle_invalidated(void *data,
struct wp_surface_invalidation_v1 *wp_surface_invalidation_v1, uint32_t serial) {
struct mako_surface *surface = data;

wp_surface_invalidation_v1_ack(wp_surface_invalidation_v1, serial);
send_frame(surface);
}

static struct wp_surface_invalidation_v1_listener surface_invalidation_listener = {
.invalidated = surface_invalidation_handle_invalidated,
};

// Draw and commit a new frame.
static void send_frame(struct mako_surface *surface) {
struct mako_state *state = surface->state;
Expand Down Expand Up @@ -676,6 +691,14 @@ static void send_frame(struct mako_surface *surface) {
surface->surface = wl_compositor_create_surface(state->compositor);
wl_surface_add_listener(surface->surface, &surface_listener, surface);

if (state->surface_invalidation_manager) {
struct wp_surface_invalidation_v1 *surface_invalidation =
wp_surface_invalidation_manager_v1_get_surface_invalidation(
state->surface_invalidation_manager, surface->surface);
wp_surface_invalidation_v1_add_listener(surface_invalidation,
&surface_invalidation_listener, surface);
}

surface->layer_surface = zwlr_layer_shell_v1_get_layer_surface(
state->layer_shell, surface->surface, wl_output,
surface->layer, "notifications");
Expand Down