From 94aab5503d51f648f6a17ff3892cffbefbbd1425 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Sun, 9 Aug 2020 13:31:05 +0900 Subject: [PATCH] samples: use xdg shell at samples Change-Id: Iabe2a0793bb0e9565c0e25b13971bfdb508e3734 --- packaging/libds.spec | 2 ++ samples/exampleClientNoShellRendering.cpp | 4 +-- samples/exampleClientShellRendering.cpp | 44 +++++++++++++++++-------------- samples/meson.build | 6 +++-- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/packaging/libds.spec b/packaging/libds.spec index 9e330b4..6366760 100644 --- a/packaging/libds.spec +++ b/packaging/libds.spec @@ -36,6 +36,8 @@ BuildRequires: pkgconfig(dali2-extension) BuildRequires: pkgconfig(wayland-client) BuildRequires: pkgconfig(xkbcommon) BuildRequires: pkgconfig(wayland-tbm-client) +BuildRequires: pkgconfig(xdg-shell-client) +BuildRequires: pkgconfig(xdg-shell-unstable-v6-client) # for ignoring the libds.a %define _unpackaged_files_terminate_build 0 diff --git a/samples/exampleClientNoShellRendering.cpp b/samples/exampleClientNoShellRendering.cpp index 1cbe5cc..f08ee70 100644 --- a/samples/exampleClientNoShellRendering.cpp +++ b/samples/exampleClientNoShellRendering.cpp @@ -279,8 +279,6 @@ int WlClientSimpleRendering::RenderingBuffer(int bufferNum, unsigned char color) void WlClientSimpleRendering::CommitBuffer(int bufferNum) { - int ret = 0; - if (__wlSurface == nullptr || __wlDisplay == nullptr) { std::cout << __func__ << " Error. execute connect first" << std::endl; @@ -299,6 +297,8 @@ void WlClientSimpleRendering::CommitBuffer(int bufferNum) std::cout << __func__ << " commit " << bufferNum << " buffer(tbm_surface:" << __tbmSurface[bufferNum] << ", wl_buffer:" << __wlBuffer[bufferNum] << ")" << std::endl; #if 0 + int ret = 0; + ret = wl_display_dispatch(__wlDisplay); if (ret < 0) { std::cout << __func__ << " Error. wl_display_dispatch error:" << ret << std::endl; diff --git a/samples/exampleClientShellRendering.cpp b/samples/exampleClientShellRendering.cpp index 91f6006..c34dd90 100644 --- a/samples/exampleClientShellRendering.cpp +++ b/samples/exampleClientShellRendering.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include #include #include @@ -45,15 +47,15 @@ public: __wlDisplay = nullptr; __wlRegistry = nullptr; __wlCompositor = nullptr; - __wlShell = nullptr; + __zxdgShell = nullptr; __wlSurface = nullptr; - __wlShellSurface = nullptr; + __zxdgShellSurface = nullptr; __wlTbmClient = nullptr; } ~WlClientSimpleRendering() { - if (__wlShellSurface != nullptr) wl_shell_surface_destroy(__wlShellSurface); + if (__zxdgShellSurface != nullptr) zxdg_surface_v6_destroy(__zxdgShellSurface); if (__wlSurface != nullptr) wl_surface_destroy(__wlSurface); for (int i = 0; i < BUF_NUM; i++) { @@ -61,7 +63,7 @@ public: if (__tbmSurface[i] != nullptr) tbm_surface_destroy(__tbmSurface[i]); } if (__wlTbmClient != nullptr) wayland_tbm_client_deinit(__wlTbmClient); - if (__wlShell != nullptr) wl_shell_destroy(__wlShell); + if (__zxdgShell != nullptr) zxdg_shell_v6_destroy(__zxdgShell); if (__wlCompositor != nullptr) wl_compositor_destroy(__wlCompositor); if (__wlRegistry != nullptr) wl_registry_destroy(__wlRegistry); @@ -76,9 +78,9 @@ public: void CommitBuffer(int bufferNum); struct wl_compositor *__wlCompositor; - struct wl_shell *__wlShell; + struct zxdg_shell_v6 *__zxdgShell; struct wl_surface *__wlSurface; - struct wl_shell_surface *__wlShellSurface; + struct zxdg_surface_v6 *__zxdgShellSurface; struct wl_buffer *__wlBuffer[BUF_NUM]; struct wayland_tbm_client *__wlTbmClient; }; @@ -94,9 +96,9 @@ handle_global(void *data, struct wl_registry *registry, uint32_t name, const cha std::cout << __func__ << " Error. fail to bind " << interface << std::endl; else std::cout << __func__ << " bind " << interface << std::endl; - } else if (strcmp(interface, "wl_shell") == 0) { - temp->__wlShell = (struct wl_shell *)wl_registry_bind(registry, name, &wl_shell_interface, 1); - if (temp->__wlShell == nullptr) + } else if (strcmp(interface, "zxdg_shell_v6") == 0) { + temp->__zxdgShell = (struct zxdg_shell_v6 *)wl_registry_bind(registry, name, &zxdg_shell_v6_interface, 1); + if (temp->__zxdgShell == nullptr) std::cout << __func__ << " Error. fail to bind " << interface << std::endl; else std::cout << __func__ << " bind " << interface << std::endl; @@ -144,7 +146,7 @@ int WlClientSimpleRendering::ConnectDisplay() wl_display_dispatch(__wlDisplay); wl_display_roundtrip(__wlDisplay); - if (__wlCompositor == nullptr || __wlShell == nullptr) + if (__wlCompositor == nullptr || __zxdgShell == nullptr) { std::cout << __func__ << " Error. fail binding" << std::endl; this->DisconnectDisplay(); @@ -167,10 +169,10 @@ int WlClientSimpleRendering::ConnectDisplay() return -1; } - __wlShellSurface = wl_shell_get_shell_surface(__wlShell, __wlSurface); - if (__wlShellSurface == nullptr) + __zxdgShellSurface = zxdg_shell_v6_get_xdg_surface(__zxdgShell, __wlSurface); + if (__zxdgShellSurface == nullptr) { - std::cout << __func__ << " Error. fail wl_shell_get_shell_surface" << std::endl; + std::cout << __func__ << " Error. fail zxdg_shell_v6_get_xdg_surface" << std::endl; this->DisconnectDisplay(); return -1; } @@ -182,8 +184,8 @@ void WlClientSimpleRendering::DisconnectDisplay() { int i; - if (__wlShellSurface != nullptr) wl_shell_surface_destroy(__wlShellSurface); - __wlShellSurface = nullptr; + if (__zxdgShellSurface != nullptr) zxdg_surface_v6_destroy(__zxdgShellSurface); + __zxdgShellSurface = nullptr; if (__wlSurface != nullptr) wl_surface_destroy(__wlSurface); __wlSurface = nullptr; for (i = 0; i < BUF_NUM; i++) @@ -193,8 +195,8 @@ void WlClientSimpleRendering::DisconnectDisplay() if (__wlTbmClient != nullptr) wayland_tbm_client_deinit(__wlTbmClient); __wlTbmClient = nullptr; - if (__wlShell != nullptr) wl_shell_destroy(__wlShell); - __wlShell = nullptr; + if (__zxdgShell != nullptr) zxdg_shell_v6_destroy(__zxdgShell); + __zxdgShell = nullptr; if (__wlCompositor) wl_compositor_destroy(__wlCompositor); __wlCompositor = nullptr; @@ -306,8 +308,6 @@ int WlClientSimpleRendering::RenderingBuffer(int bufferNum, unsigned char color) void WlClientSimpleRendering::CommitBuffer(int bufferNum) { - int ret = 0; - if (__wlSurface == nullptr || __wlDisplay == nullptr) { std::cout << __func__ << " Error. execute connect first" << std::endl; @@ -326,11 +326,15 @@ void WlClientSimpleRendering::CommitBuffer(int bufferNum) std::cout << __func__ << " commit " << bufferNum << " buffer(tbm_surface:" << __tbmSurface[bufferNum] << ", wl_buffer:" << __wlBuffer[bufferNum] << ")" << std::endl; +#if 0 + int ret = 0; + ret = wl_display_dispatch(__wlDisplay); if (ret < 0) { std::cout << __func__ << " Error. wl_display_dispatch error:" << ret << std::endl; return; } +#endif wl_display_roundtrip(__wlDisplay); } @@ -371,7 +375,7 @@ int main (void) } } - wl_shell_surface_set_toplevel(simpleRenderSample->__wlShellSurface); + zxdg_surface_v6_get_toplevel(simpleRenderSample->__zxdgShellSurface); /* main loop */ i = 0; diff --git a/samples/meson.build b/samples/meson.build index 435afec..50d5216 100644 --- a/samples/meson.build +++ b/samples/meson.build @@ -42,15 +42,17 @@ ecore_wayland2_dep = dependency('ecore-wl2') wayland_tbm_client_dep = dependency('wayland-tbm-client') executable('exampleClientNoShellRendering', 'exampleClientNoShellRendering.cpp', - dependencies : [libds_declared_dep, wayland_client_dep, ecore_wayland2_dep, wayland_tbm_client_dep], + dependencies : [libds_declared_dep, wayland_client_dep, tizen_extension_client_dep, ecore_wayland2_dep, wayland_tbm_client_dep], install_dir : libds_prefix_bindir, install : true ) wayland_tbm_client_dep = dependency('wayland-tbm-client') +xdg_shell_client_dep = dependency('xdg-shell-client') +xdg_shell_unstable_v6_client_dep = dependency('xdg-shell-unstable-v6-client') executable('exampleClientShellRendering', 'exampleClientShellRendering.cpp', - dependencies : [libds_declared_dep, wayland_client_dep, ecore_wayland2_dep, wayland_tbm_client_dep], + dependencies : [libds_declared_dep, wayland_client_dep, xdg_shell_client_dep, xdg_shell_unstable_v6_client_dep, ecore_wayland2_dep, wayland_tbm_client_dep], install_dir : libds_prefix_bindir, install : true ) -- 2.7.4