Skip to content

Commit

Permalink
Add linux_dmabuf to registry
Browse files Browse the repository at this point in the history
  • Loading branch information
columbarius committed Sep 13, 2020
1 parent b2cb766 commit 2122757
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/screencast_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <spa/param/video/format-utils.h>
#include <wayland-client-protocol.h>

#include "linux-dmabuf-unstable-v1-client-protocol.h"
#include <gbm.h>

// this seems to be right based on
Expand Down Expand Up @@ -79,6 +80,7 @@ struct xdpw_screencast_context {
struct zxdg_output_manager_v1* xdg_output_manager;
struct wl_shm *shm;
struct gbm_device *gbm;
struct zwp_linux_dmabuf_v1 *linux_dmabuf;

// cli options
const char *output_name;
Expand Down
2 changes: 2 additions & 0 deletions include/wlr_screencast.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#define XDG_OUTPUT_MANAGER_VERSION 3

#define LINUX_DMABUF_VERSION 3

struct xdpw_state;

int xdpw_wlr_screencast_init(struct xdpw_state *state);
Expand Down
9 changes: 9 additions & 0 deletions src/screencast/wlr_screencast.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "xdpw.h"
#include "logger.h"

#include "linux-dmabuf-unstable-v1-client-protocol.h"

void xdpw_wlr_frame_free(struct xdpw_screencast_instance *cast) {
xdpw_wlr_screencopy_frame_free(cast);

Expand Down Expand Up @@ -170,6 +172,10 @@ static void wlr_registry_handle_add(void *data, struct wl_registry *reg,
ctx->xdg_output_manager =
wl_registry_bind(reg, id, &zxdg_output_manager_v1_interface, XDG_OUTPUT_MANAGER_VERSION);
}
if (strcmp(interface, zwp_linux_dmabuf_v1_interface.name) == 0) {
logprint(DEBUG, "wlroots: |-- registered to interface %s (Version %u)", interface, LINUX_DMABUF_VERSION);
ctx->linux_dmabuf = wl_registry_bind(reg, id, &zwp_linux_dmabuf_v1_interface, LINUX_DMABUF_VERSION);
}
}

static void wlr_registry_handle_remove(void *data, struct wl_registry *reg,
Expand Down Expand Up @@ -245,6 +251,9 @@ void xdpw_wlr_screencast_finish(struct xdpw_screencast_context *ctx) {
if (ctx->shm) {
wl_shm_destroy(ctx->shm);
}
if (ctx->linux_dmabuf) {
zwp_linux_dmabuf_v1_destroy(ctx->linux_dmabuf);
}
if (ctx->gbm) {
destroy_gbm_device(ctx->gbm);
}
Expand Down

0 comments on commit 2122757

Please sign in to comment.