backend/wayland: use xdga client activation

This commit is contained in:
Ronan Pigott 2021-10-25 23:31:48 -07:00 committed by Simon Ser
parent e2aff8a9b0
commit 8e225261f0
4 changed files with 21 additions and 0 deletions

View File

@ -24,6 +24,7 @@
#include "linux-dmabuf-unstable-v1-client-protocol.h"
#include "pointer-gestures-unstable-v1-client-protocol.h"
#include "presentation-time-client-protocol.h"
#include "xdg-activation-v1-client-protocol.h"
#include "xdg-decoration-unstable-v1-client-protocol.h"
#include "xdg-shell-client-protocol.h"
#include "tablet-unstable-v2-client-protocol.h"
@ -244,6 +245,9 @@ static void registry_global(void *data, struct wl_registry *registry,
} else if (strcmp(iface, wl_shm_interface.name) == 0) {
wl->shm = wl_registry_bind(registry, name, &wl_shm_interface, 1);
wl_shm_add_listener(wl->shm, &shm_listener, wl);
} else if (strcmp(iface, xdg_activation_v1_interface.name) == 0) {
wl->activation_v1 = wl_registry_bind(registry, name,
&xdg_activation_v1_interface, 1);
}
}
@ -339,6 +343,7 @@ static void backend_destroy(struct wlr_backend *backend) {
zwp_relative_pointer_manager_v1_destroy(wl->zwp_relative_pointer_manager_v1);
}
free(wl->drm_render_name);
free(wl->activation_token);
xdg_wm_base_destroy(wl->xdg_wm_base);
wl_compositor_destroy(wl->compositor);
wl_registry_destroy(wl->registry);
@ -445,6 +450,12 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
wl->local_display_destroy.notify = handle_display_destroy;
wl_display_add_destroy_listener(display, &wl->local_display_destroy);
const char *token = getenv("XDG_ACTIVATION_TOKEN");
if (token != NULL) {
wl->activation_token = strdup(token);
unsetenv("XDG_ACTIVATION_TOKEN");
}
return &wl->backend;
error_remote_display_src:

View File

@ -12,6 +12,7 @@ client_protos = [
'presentation-time',
'relative-pointer-unstable-v1',
'tablet-unstable-v2',
'xdg-activation-v1',
'xdg-decoration-unstable-v1',
'xdg-shell',
]

View File

@ -23,6 +23,7 @@
#include "linux-dmabuf-unstable-v1-client-protocol.h"
#include "presentation-time-client-protocol.h"
#include "xdg-activation-v1-client-protocol.h"
#include "xdg-decoration-unstable-v1-client-protocol.h"
#include "xdg-shell-client-protocol.h"
@ -594,6 +595,12 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *wlr_backend) {
}
}
// TODO: let the compositor do this bit
if (backend->activation_v1 && backend->activation_token) {
xdg_activation_v1_activate(backend->activation_v1,
backend->activation_token, output->surface);
}
// Start the rendering loop by requesting the compositor to render a frame
wlr_output_schedule_frame(wlr_output);

View File

@ -24,6 +24,7 @@ struct wlr_wl_backend {
size_t requested_outputs;
size_t last_output_num;
struct wl_listener local_display_destroy;
char *activation_token;
/* remote state */
struct wl_display *remote_display;
@ -42,6 +43,7 @@ struct wlr_wl_backend {
struct wlr_drm_format_set shm_formats;
struct wlr_drm_format_set linux_dmabuf_v1_formats;
struct wl_drm *legacy_drm;
struct xdg_activation_v1 *activation_v1;
char *drm_render_name;
};