mirror of
https://github.com/lingble/meta-tegra.git
synced 2025-10-31 20:37:58 +00:00
l4t-graphics-demos: update wayland support to use xdg-shell
Weston removed support for the wl_shell protocol in version 11.0. Clients are expected to use the xdg-shell extension instead, so convert the nvgldemo wayland adapter to do that. Signed-off-by: Matt Madison <matt@madison.systems>
This commit is contained in:
@@ -0,0 +1,327 @@
|
|||||||
|
From a3c37e751932847c633aea23c8da4d1ce3439012 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Matt Madison <matt@madison.systems>
|
||||||
|
Date: Sat, 25 May 2024 05:45:20 -0700
|
||||||
|
Subject: [PATCH] Convert nvgldemo-wayland to use xdg-shell
|
||||||
|
|
||||||
|
Upstream-Status: Pending
|
||||||
|
|
||||||
|
Signed-off-by: Matt Madison <matt@madison.systems>
|
||||||
|
---
|
||||||
|
.../nvidia/graphics_demos/nvgldemo/Makefile | 33 ++++-
|
||||||
|
.../nvgldemo/nvgldemo_win_wayland.c | 119 +++++++++---------
|
||||||
|
.../nvgldemo/nvgldemo_win_wayland.h | 6 +-
|
||||||
|
3 files changed, 95 insertions(+), 63 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/usr/src/nvidia/graphics_demos/nvgldemo/Makefile b/usr/src/nvidia/graphics_demos/nvgldemo/Makefile
|
||||||
|
index 2637b5a..7b26a64 100644
|
||||||
|
--- a/usr/src/nvidia/graphics_demos/nvgldemo/Makefile
|
||||||
|
+++ b/usr/src/nvidia/graphics_demos/nvgldemo/Makefile
|
||||||
|
@@ -28,6 +28,14 @@ ifeq ($(NV_WINSYS),screen)
|
||||||
|
endif
|
||||||
|
ifeq ($(NV_WINSYS),wayland)
|
||||||
|
NVGLDEMO_OBJS += wayland/nvgldemo_win_wayland.o
|
||||||
|
+ PROTOCOLS :=
|
||||||
|
+ PROTOCOLS += $(NV_WINSYS)/xdg-shell-client-protocol.h
|
||||||
|
+ INTERMEDIATES += $(PROTOCOLS)
|
||||||
|
+ CFLAGS += -I$(NV_WINSYS)/
|
||||||
|
+
|
||||||
|
+ PROTOCOLSDIR := $(shell pkg-config --variable=pkgdatadir wayland-protocols)
|
||||||
|
+
|
||||||
|
+ NVGLDEMO_OBJS += $(patsubst %.h,%.o,$(PROTOCOLS))
|
||||||
|
endif
|
||||||
|
ifeq ($(NV_WINSYS),x11)
|
||||||
|
NVGLDEMO_OBJS += x11/nvgldemo_win_x11.o
|
||||||
|
@@ -53,9 +61,32 @@ FORCE:
|
||||||
|
|
||||||
|
$(NV_WINSYS)/libnvgldemo.a: $(NV_WINSYS)/libnvgldemo.a($(NVGLDEMO_OBJS))
|
||||||
|
|
||||||
|
+ifeq ($(NV_WINSYS),wayland)
|
||||||
|
+wayland/nvgldemo_win_wayland.o: $(PROTOCOLS)
|
||||||
|
+endif
|
||||||
|
+
|
||||||
|
+define protocol-rule
|
||||||
|
+$(1).h: FORCE
|
||||||
|
+ @mkdir -p $(dir $(1))
|
||||||
|
+ifeq ($(findstring unstable,$(1)),)
|
||||||
|
+ wayland-scanner client-header $$(PROTOCOLSDIR)/stable/$$(shell echo $$(notdir $(1)) | sed -e's,-client-protocol.*,,')/$(patsubst %-client-protocol,%.xml,$(notdir $(1))) $$@
|
||||||
|
+else
|
||||||
|
+ wayland-scanner client-header $$(PROTOCOLSDIR)/unstable/$$(shell echo $$(notdir $(1)) | sed -e's,-unstable.*,,')/$(patsubst %-client-protocol,%.xml,$(notdir $(1))) $$@
|
||||||
|
+endif
|
||||||
|
+$(1).c: $(1).h
|
||||||
|
+ifeq ($(findstring unstable,$(1)),)
|
||||||
|
+ wayland-scanner code $$(PROTOCOLSDIR)/stable/$$(shell echo $$(notdir $(1)) | sed -e's,-client-protocol.*,,')/$(patsubst %-client-protocol,%.xml,$(notdir $(1))) $$@
|
||||||
|
+else
|
||||||
|
+ wayland-scanner code $$(PROTOCOLSDIR)/unstable/$$(shell echo $$(notdir $(1)) | sed -e's,-unstable.*,,')/$(patsubst %-client-protocol,%.xml,$(notdir $(1))) $$@
|
||||||
|
+endif
|
||||||
|
+$(1).o: $(1).c
|
||||||
|
+ @mkdir -p $(dir $(1))
|
||||||
|
+ $$(COMPILE.c) $$(OUTPUT_OPTION) $$<
|
||||||
|
+endef
|
||||||
|
+
|
||||||
|
define demolib-rule
|
||||||
|
$(1): FORCE
|
||||||
|
$(MAKE) -C $$(subst $$(NV_WINSYS)/,,$$(dir $$@))
|
||||||
|
endef
|
||||||
|
$(foreach demolib,$(NVGLDEMO_DEMOLIBS),$(eval $(call demolib-rule,$(demolib))))
|
||||||
|
-
|
||||||
|
+$(foreach protocol,$(PROTOCOLS),$(eval $(call protocol-rule,$(basename $(protocol)))))
|
||||||
|
diff --git a/usr/src/nvidia/graphics_demos/nvgldemo/nvgldemo_win_wayland.c b/usr/src/nvidia/graphics_demos/nvgldemo/nvgldemo_win_wayland.c
|
||||||
|
index 1ac060a..711ae50 100644
|
||||||
|
--- a/usr/src/nvidia/graphics_demos/nvgldemo/nvgldemo_win_wayland.c
|
||||||
|
+++ b/usr/src/nvidia/graphics_demos/nvgldemo/nvgldemo_win_wayland.c
|
||||||
|
@@ -48,18 +48,27 @@ static NvGlDemoPointerCB pointerCB = NULL;
|
||||||
|
static NvGlDemoButtonCB buttonCB = NULL;
|
||||||
|
|
||||||
|
static void
|
||||||
|
-handle_ping(void *data, struct wl_shell_surface *wlShellSurface,
|
||||||
|
+handle_ping(void *data, struct xdg_wm_base *xdgWmBase,
|
||||||
|
uint32_t serial)
|
||||||
|
{
|
||||||
|
- wl_shell_surface_pong(wlShellSurface, serial);
|
||||||
|
+ xdg_wm_base_pong(xdgWmBase, serial);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static const struct xdg_wm_base_listener xdg_wm_base_listener =
|
||||||
|
+{
|
||||||
|
+ handle_ping,
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
static void
|
||||||
|
-handle_configure(void *data, struct wl_shell_surface *shell_surface,
|
||||||
|
- uint32_t edges, int32_t width, int32_t height)
|
||||||
|
+handle_configure(void *data, struct xdg_toplevel *xdgTopLevel,
|
||||||
|
+ int32_t width, int32_t height,
|
||||||
|
+ struct wl_array *states)
|
||||||
|
{
|
||||||
|
struct Window *window = data;
|
||||||
|
|
||||||
|
+ if (width == 0 || height == 0)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
if (window->wlEGLNativeWindow) {
|
||||||
|
wl_egl_window_resize(window->wlEGLNativeWindow, width, height, 0, 0);
|
||||||
|
}
|
||||||
|
@@ -76,10 +85,28 @@ handle_configure(void *data, struct wl_shell_surface *shell_surface,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-static const struct wl_shell_surface_listener shell_surface_listener =
|
||||||
|
+static void
|
||||||
|
+handle_toplevel_close(void *data, struct xdg_toplevel *xdgTopLevel)
|
||||||
|
{
|
||||||
|
- handle_ping,
|
||||||
|
+ struct Window *window = data;
|
||||||
|
+ NvGlDemoWindowTerm();
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static const struct xdg_toplevel_listener xdg_toplevel_listener = {
|
||||||
|
handle_configure,
|
||||||
|
+ handle_toplevel_close
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static void xdg_surface_configure(void *data, struct xdg_surface *xdgSurface,
|
||||||
|
+ uint32_t serial)
|
||||||
|
+{
|
||||||
|
+ struct Window *window = data;
|
||||||
|
+ xdg_surface_ack_configure(xdgSurface, serial);
|
||||||
|
+ window->configured = 1;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static const struct xdg_surface_listener xdg_surface_listener = {
|
||||||
|
+ xdg_surface_configure
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef ENABLE_IVI_SHELL
|
||||||
|
@@ -108,21 +135,6 @@ static const struct ivi_surface_listener ivi_surface_listener = {
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
-static void
|
||||||
|
-configure_callback(void *data, struct wl_callback *callback, uint32_t time)
|
||||||
|
-{
|
||||||
|
- struct Window *window = data;
|
||||||
|
-
|
||||||
|
- wl_callback_destroy(callback);
|
||||||
|
-
|
||||||
|
- window->configured = 1;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-static struct wl_callback_listener configure_callback_listener =
|
||||||
|
-{
|
||||||
|
- configure_callback,
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
static void
|
||||||
|
toggle_fullscreen(struct Window *window, int fullscreen)
|
||||||
|
{
|
||||||
|
@@ -133,20 +145,11 @@ toggle_fullscreen(struct Window *window, int fullscreen)
|
||||||
|
window->configured = 0;
|
||||||
|
|
||||||
|
if (fullscreen) {
|
||||||
|
- wl_shell_surface_set_fullscreen(
|
||||||
|
- window->wlShellSurface,
|
||||||
|
- WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,0, NULL);
|
||||||
|
+ xdg_toplevel_set_fullscreen(window->xdgTopLevel, NULL);
|
||||||
|
} else {
|
||||||
|
- wl_shell_surface_set_toplevel(window->wlShellSurface);
|
||||||
|
- handle_configure(window, window->wlShellSurface, 0,
|
||||||
|
- window->window_size.width,
|
||||||
|
- window->window_size.height);
|
||||||
|
+ xdg_toplevel_unset_fullscreen(window->xdgTopLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
- callback = wl_display_sync(window->display->wlDisplay);
|
||||||
|
- wl_callback_add_listener(callback, &configure_callback_listener,
|
||||||
|
- window);
|
||||||
|
-
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
@@ -419,10 +422,10 @@ registry_handle_global(void *data, struct wl_registry *registry,
|
||||||
|
{
|
||||||
|
struct Display *d = data;
|
||||||
|
|
||||||
|
- if (strcmp(interface, "wl_compositor") == 0) {
|
||||||
|
+ if (strcmp(interface, wl_compositor_interface.name) == 0) {
|
||||||
|
d->wlCompositor = wl_registry_bind(registry, name,
|
||||||
|
&wl_compositor_interface, 1);
|
||||||
|
- } else if (strcmp(interface, "wl_subcompositor") == 0) {
|
||||||
|
+ } else if (strcmp(interface, wl_subcompositor_interface.name) == 0) {
|
||||||
|
d->wlSubcompositor = wl_registry_bind(registry, name,
|
||||||
|
&wl_subcompositor_interface, 1);
|
||||||
|
#ifdef NVGLDEMO_ENABLE_DMABUF
|
||||||
|
@@ -436,9 +439,10 @@ registry_handle_global(void *data, struct wl_registry *registry,
|
||||||
|
d->wlExplicitSync = wl_registry_bind(registry, name,
|
||||||
|
&zwp_linux_explicit_synchronization_v1_interface, 1);
|
||||||
|
#endif
|
||||||
|
- } else if (strcmp(interface, "wl_shell") == 0) {
|
||||||
|
- d->wlShell = wl_registry_bind(registry, name,
|
||||||
|
- &wl_shell_interface, 1);
|
||||||
|
+ } else if (strcmp(interface, xdg_wm_base_interface.name) == 0) {
|
||||||
|
+ d->xdgWmBase = wl_registry_bind(registry, name,
|
||||||
|
+ &xdg_wm_base_interface, 1);
|
||||||
|
+ xdg_wm_base_add_listener(d->xdgWmBase, &xdg_wm_base_listener, d);
|
||||||
|
} else if (strcmp(interface, "wl_seat") == 0) {
|
||||||
|
d->wlSeat = wl_registry_bind(registry, name,
|
||||||
|
&wl_seat_interface, 1);
|
||||||
|
@@ -595,8 +599,8 @@ NvGlDemoDisplayTerm(void)
|
||||||
|
wl_seat_destroy(demoState.platform->display.wlSeat);
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (demoState.platform->display.wlShell) {
|
||||||
|
- wl_shell_destroy(demoState.platform->display.wlShell);
|
||||||
|
+ if (demoState.platform->display.xdgWmBase) {
|
||||||
|
+ xdg_wm_base_destroy(demoState.platform->display.xdgWmBase);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_IVI_SHELL
|
||||||
|
@@ -653,16 +657,12 @@ NvGlDemoDisplayTerm(void)
|
||||||
|
|
||||||
|
static int create_shell_surface(struct Window *window, struct Display *display)
|
||||||
|
{
|
||||||
|
- window->wlShellSurface = wl_shell_get_shell_surface(
|
||||||
|
- display->wlShell, window->wlSurface);
|
||||||
|
-
|
||||||
|
- if (window->wlShellSurface == NULL) {
|
||||||
|
- NvGlDemoLog("Failed to create wayland shell surface.\n");
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- wl_shell_surface_add_listener(window->wlShellSurface,
|
||||||
|
- &shell_surface_listener, window);
|
||||||
|
+ window->xdgSurface = xdg_wm_base_get_xdg_surface(
|
||||||
|
+ display->xdgWmBase, window->wlSurface);
|
||||||
|
+ xdg_surface_add_listener(window->xdgSurface, &xdg_surface_listener, window);
|
||||||
|
+ window->xdgTopLevel = xdg_surface_get_toplevel(window->xdgSurface);
|
||||||
|
+ xdg_toplevel_add_listener(window->xdgTopLevel, &xdg_toplevel_listener, window);
|
||||||
|
+ wl_surface_commit(window->wlSurface);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
@@ -705,7 +705,7 @@ NvGlDemoWindowInit(
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!demoState.platform->display.wlCompositor ||
|
||||||
|
- !(demoState.platform->display.wlShell
|
||||||
|
+ !(demoState.platform->display.xdgWmBase
|
||||||
|
#ifdef ENABLE_IVI_SHELL
|
||||||
|
|| demoState.platform->display.ivi_application
|
||||||
|
#endif
|
||||||
|
@@ -751,7 +751,7 @@ NvGlDemoWindowInit(
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
- if (demoState.platform->display.wlShell) {
|
||||||
|
+ if (demoState.platform->display.xdgWmBase) {
|
||||||
|
if (!create_shell_surface(&demoState.platform->window,
|
||||||
|
&demoState.platform->display)) {
|
||||||
|
goto fail;
|
||||||
|
@@ -774,7 +774,7 @@ NvGlDemoWindowInit(
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (demoState.platform->display.wlShell
|
||||||
|
+ if (demoState.platform->display.xdgWmBase
|
||||||
|
#ifdef ENABLE_IVI_SHELL
|
||||||
|
&& !demoState.platform->display.ivi_application
|
||||||
|
#endif
|
||||||
|
@@ -811,9 +811,13 @@ void NvGlDemoWindowTerm(void)
|
||||||
|
demoState.platform->window.wlEGLNativeWindow = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (demoState.platform->window.wlShellSurface) {
|
||||||
|
- wl_shell_surface_destroy(demoState.platform->window.wlShellSurface);
|
||||||
|
- demoState.platform->window.wlShellSurface = 0;
|
||||||
|
+ if (demoState.platform->window.xdgTopLevel) {
|
||||||
|
+ xdg_toplevel_destroy(demoState.platform->window.xdgTopLevel);
|
||||||
|
+ demoState.platform->window.xdgTopLevel = 0;
|
||||||
|
+ }
|
||||||
|
+ if (demoState.platform->window.xdgSurface) {
|
||||||
|
+ xdg_surface_destroy(demoState.platform->window.xdgSurface);
|
||||||
|
+ demoState.platform->window.xdgSurface = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_IVI_SHELL
|
||||||
|
@@ -823,11 +827,6 @@ void NvGlDemoWindowTerm(void)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
- if (demoState.platform->window.wlSurface) {
|
||||||
|
- wl_surface_destroy(demoState.platform->window.wlSurface);
|
||||||
|
- demoState.platform->window.wlSurface = 0;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
if (demoState.platform->window.callback) {
|
||||||
|
wl_callback_destroy(demoState.platform->window.callback);
|
||||||
|
demoState.platform->window.callback = 0;
|
||||||
|
diff --git a/usr/src/nvidia/graphics_demos/nvgldemo/nvgldemo_win_wayland.h b/usr/src/nvidia/graphics_demos/nvgldemo/nvgldemo_win_wayland.h
|
||||||
|
index 0e84f41..24eca67 100644
|
||||||
|
--- a/usr/src/nvidia/graphics_demos/nvgldemo/nvgldemo_win_wayland.h
|
||||||
|
+++ b/usr/src/nvidia/graphics_demos/nvgldemo/nvgldemo_win_wayland.h
|
||||||
|
@@ -39,6 +39,7 @@
|
||||||
|
#endif
|
||||||
|
#include "wayland-client.h"
|
||||||
|
#include "wayland-egl.h"
|
||||||
|
+#include "xdg-shell-client-protocol.h"
|
||||||
|
|
||||||
|
#ifdef ENABLE_IVI_SHELL
|
||||||
|
#include "ivi-application-client-protocol.h"
|
||||||
|
@@ -70,7 +71,7 @@ struct Display {
|
||||||
|
uint64_t formatModifiers_XRGB8[NVGLDEMO_MAX_DRM_MODIFIERS];
|
||||||
|
uint64_t formatModifiers_ARGB8[NVGLDEMO_MAX_DRM_MODIFIERS];
|
||||||
|
#endif
|
||||||
|
- struct wl_shell *wlShell;
|
||||||
|
+ struct xdg_wm_base *xdgWmBase;
|
||||||
|
#ifdef ENABLE_IVI_SHELL
|
||||||
|
struct ivi_application *ivi_application;
|
||||||
|
enum ivi_interface_type ivi_type;
|
||||||
|
@@ -102,7 +103,8 @@ struct Window {
|
||||||
|
struct Display *display;
|
||||||
|
struct wl_egl_window *wlEGLNativeWindow;
|
||||||
|
struct wl_surface *wlSurface;
|
||||||
|
- struct wl_shell_surface *wlShellSurface;
|
||||||
|
+ struct xdg_surface *xdgSurface;
|
||||||
|
+ struct xdg_toplevel *xdgTopLevel;
|
||||||
|
#ifdef ENABLE_IVI_SHELL
|
||||||
|
struct ivi_surface *ivi_surface;
|
||||||
|
unsigned int ivi_surfaceId;
|
||||||
@@ -8,6 +8,7 @@ LIC_FILES_CHKSUM = "file://README;endline=21;md5=17bf753e98379a9888c5bd3f81da8d4
|
|||||||
SRC_URI += "\
|
SRC_URI += "\
|
||||||
file://0001-Fix-stdbool.h-inclusion-check.patch;patchdir=../../../.. \
|
file://0001-Fix-stdbool.h-inclusion-check.patch;patchdir=../../../.. \
|
||||||
file://0002-weston-dmabuf-formats-cross-build-fixes.patch;patchdir=../../../.. \
|
file://0002-weston-dmabuf-formats-cross-build-fixes.patch;patchdir=../../../.. \
|
||||||
|
file://0003-Convert-nvgldemo-wayland-to-use-xdg-shell.patch;patchdir=../../../.. \
|
||||||
"
|
"
|
||||||
|
|
||||||
REQUIRED_DISTRO_FEATURES = "opengl"
|
REQUIRED_DISTRO_FEATURES = "opengl"
|
||||||
@@ -18,7 +19,7 @@ inherit pkgconfig features_check
|
|||||||
|
|
||||||
PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'x11 wayland', d)}"
|
PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'x11 wayland', d)}"
|
||||||
PACKAGECONFIG[x11] = ",,libx11 virtual/libgbm"
|
PACKAGECONFIG[x11] = ",,libx11 virtual/libgbm"
|
||||||
PACKAGECONFIG[wayland] = ",,libxkbcommon wayland wayland-native weston libffi virtual/libgbm tegra-mmapi tegra-libraries-multimedia-utils"
|
PACKAGECONFIG[wayland] = ",,libxkbcommon wayland wayland-native weston wayland-protocols libffi virtual/libgbm tegra-mmapi tegra-libraries-multimedia-utils"
|
||||||
|
|
||||||
CONFIGURESTAMPFILE = "${WORKDIR}/configure.sstate"
|
CONFIGURESTAMPFILE = "${WORKDIR}/configure.sstate"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user