[client] wayland: decorate window unless borderless is requested

Show server-side decoration with the xdg_decoration protocol unless
win:borderless=yes.
This commit is contained in:
Quantum 2021-01-26 23:53:02 -05:00 committed by Geoffrey McRae
parent 5dad69675b
commit b8bf980a29
2 changed files with 22 additions and 0 deletions

View File

@ -49,6 +49,9 @@ include_directories("${CMAKE_BINARY_DIR}/wayland")
wayland_generate( wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml" "${WAYLAND_PROTOCOLS_BASE}/stable/xdg-shell/xdg-shell.xml"
"${CMAKE_BINARY_DIR}/wayland/wayland-xdg-shell-client-protocol") "${CMAKE_BINARY_DIR}/wayland/wayland-xdg-shell-client-protocol")
wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
"${CMAKE_BINARY_DIR}/wayland/wayland-xdg-decoration-unstable-v1-client-protocol")
wayland_generate( wayland_generate(
"${WAYLAND_PROTOCOLS_BASE}/unstable/relative-pointer/relative-pointer-unstable-v1.xml" "${WAYLAND_PROTOCOLS_BASE}/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
"${CMAKE_BINARY_DIR}/wayland/wayland-relative-pointer-unstable-v1-client-protocol") "${CMAKE_BINARY_DIR}/wayland/wayland-relative-pointer-unstable-v1-client-protocol")

View File

@ -41,6 +41,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include "common/debug.h" #include "common/debug.h"
#include "wayland-xdg-shell-client-protocol.h" #include "wayland-xdg-shell-client-protocol.h"
#include "wayland-xdg-decoration-unstable-v1-client-protocol.h"
#include "wayland-keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h" #include "wayland-keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h"
#include "wayland-pointer-constraints-unstable-v1-client-protocol.h" #include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
#include "wayland-relative-pointer-unstable-v1-client-protocol.h" #include "wayland-relative-pointer-unstable-v1-client-protocol.h"
@ -70,6 +71,8 @@ struct WaylandDSState
struct xdg_wm_base * xdgWmBase; struct xdg_wm_base * xdgWmBase;
struct xdg_surface * xdgSurface; struct xdg_surface * xdgSurface;
struct xdg_toplevel * xdgToplevel; struct xdg_toplevel * xdgToplevel;
struct zxdg_decoration_manager_v1 * xdgDecorationManager;
struct zxdg_toplevel_decoration_v1 * xdgToplevelDecoration;
struct wl_surface * cursor; struct wl_surface * cursor;
@ -185,6 +188,9 @@ static void registryGlobalHandler(void * data, struct wl_registry * registry,
wm.compositor = wl_registry_bind(wm.registry, name, &wl_compositor_interface, 4); wm.compositor = wl_registry_bind(wm.registry, name, &wl_compositor_interface, 4);
else if (!strcmp(interface, xdg_wm_base_interface.name)) else if (!strcmp(interface, xdg_wm_base_interface.name))
wm.xdgWmBase = wl_registry_bind(wm.registry, name, &xdg_wm_base_interface, 1); wm.xdgWmBase = wl_registry_bind(wm.registry, name, &xdg_wm_base_interface, 1);
else if (!strcmp(interface, zxdg_decoration_manager_v1_interface.name))
wm.xdgDecorationManager = wl_registry_bind(wm.registry, name,
&zxdg_decoration_manager_v1_interface, 1);
else if (!strcmp(interface, zwp_relative_pointer_manager_v1_interface.name)) else if (!strcmp(interface, zwp_relative_pointer_manager_v1_interface.name))
wm.relativePointerManager = wl_registry_bind(wm.registry, name, wm.relativePointerManager = wl_registry_bind(wm.registry, name,
&zwp_relative_pointer_manager_v1_interface, 1); &zwp_relative_pointer_manager_v1_interface, 1);
@ -528,6 +534,19 @@ static bool waylandInit(const LG_DSInitParams params)
wl_surface_commit(wm.surface); wl_surface_commit(wm.surface);
if (wm.xdgDecorationManager)
{
wm.xdgToplevelDecoration = zxdg_decoration_manager_v1_get_toplevel_decoration(
wm.xdgDecorationManager, wm.xdgToplevel);
if (wm.xdgToplevelDecoration)
{
zxdg_toplevel_decoration_v1_set_mode(wm.xdgToplevelDecoration,
params.borderless ?
ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE :
ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
}
}
struct wl_buffer * cursorBuffer = createCursorBuffer(); struct wl_buffer * cursorBuffer = createCursorBuffer();
if (cursorBuffer) if (cursorBuffer)
{ {