From 7ec585b8eb5169896876f11a68c12311237fd9e1 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Sun, 9 Feb 2020 14:56:27 +0000 Subject: [PATCH] wl: deactivate 'viewporter' decorations --- src/wl_init.c | 13 +++++++++++ src/wl_platform.h | 10 +++++++++ src/wl_window.c | 57 ++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 74 insertions(+), 6 deletions(-) diff --git a/src/wl_init.c b/src/wl_init.c index 1ba497b7..d49e44e7 100644 --- a/src/wl_init.c +++ b/src/wl_init.c @@ -56,6 +56,7 @@ static _GLFWwindow* findWindowFromDecorationSurface(struct wl_surface* surface, _GLFWwindow* window = _glfw.windowListHead; if (!which) which = &focus; +#ifndef WITH_DECORATION while (window) { if (surface == window->wl.decorations.top.surface) @@ -80,6 +81,7 @@ static _GLFWwindow* findWindowFromDecorationSurface(struct wl_surface* surface, } window = window->next; } +#endif return window; } @@ -103,7 +105,10 @@ static void pointerHandleEnter(void* data, return; } +#ifndef WITH_DECORATION window->wl.decorations.focus = focus; +#endif + _glfw.wl.serial = serial; _glfw.wl.pointerFocus = window; @@ -194,6 +199,7 @@ static void pointerHandleMotion(void* data, x = wl_fixed_to_double(sx); y = wl_fixed_to_double(sy); +#ifndef WITH_DECORATION switch (window->wl.decorations.focus) { case mainWindow: @@ -231,6 +237,7 @@ static void pointerHandleMotion(void* data, default: assert(0); } +#endif if (_glfw.wl.cursorPreviousName != cursorName) setCursor(window, cursorName); } @@ -248,6 +255,7 @@ static void pointerHandleButton(void* data, if (!window) return; +#ifndef WITH_DECORATION if (button == BTN_LEFT) { switch (window->wl.decorations.focus) @@ -306,6 +314,7 @@ static void pointerHandleButton(void* data, // Don’t pass the button to the user if it was related to a decoration. if (window->wl.decorations.focus != mainWindow) return; +#endif _glfw.wl.serial = serial; @@ -840,11 +849,13 @@ static void registryHandleGlobal(void* data, &zxdg_decoration_manager_v1_interface, 1); } +#ifndef WITH_DECORATION else if (strcmp(interface, "wp_viewporter") == 0) { _glfw.wl.viewporter = wl_registry_bind(registry, name, &wp_viewporter_interface, 1); } +#endif else if (strcmp(interface, "zwp_relative_pointer_manager_v1") == 0) { _glfw.wl.relativePointerManager = @@ -1249,8 +1260,10 @@ void _glfwPlatformTerminate(void) wl_compositor_destroy(_glfw.wl.compositor); if (_glfw.wl.shm) wl_shm_destroy(_glfw.wl.shm); +#ifndef WITH_DECORATION if (_glfw.wl.viewporter) wp_viewporter_destroy(_glfw.wl.viewporter); +#endif if (_glfw.wl.decorationManager) zxdg_decoration_manager_v1_destroy(_glfw.wl.decorationManager); if (_glfw.wl.wmBase) diff --git a/src/wl_platform.h b/src/wl_platform.h index 966155fd..4591becb 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -56,7 +56,9 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR #include "wayland-xdg-shell-client-protocol.h" #include "wayland-xdg-decoration-client-protocol.h" +#ifndef WITH_DECORATION #include "wayland-viewporter-client-protocol.h" +#endif #include "wayland-relative-pointer-unstable-v1-client-protocol.h" #include "wayland-pointer-constraints-unstable-v1-client-protocol.h" #include "wayland-idle-inhibit-unstable-v1-client-protocol.h" @@ -146,6 +148,7 @@ typedef xkb_keysym_t (* PFN_xkb_compose_state_get_one_sym)(struct xkb_compose_st #define _GLFW_DECORATION_VERTICAL (_GLFW_DECORATION_TOP + _GLFW_DECORATION_WIDTH) #define _GLFW_DECORATION_HORIZONTAL (2 * _GLFW_DECORATION_WIDTH) +#ifndef WITH_DECORATION typedef enum _GLFWdecorationSideWayland { mainWindow, @@ -163,6 +166,7 @@ typedef struct _GLFWdecorationWayland struct wp_viewport* viewport; } _GLFWdecorationWayland; +#endif // Wayland-specific per-window data // @@ -204,12 +208,16 @@ typedef struct _GLFWwindowWayland GLFWbool wasFullscreen; +#ifndef WITH_DECORATION struct { GLFWbool serverSide; struct wl_buffer* buffer; _GLFWdecorationWayland top, left, right, bottom; int focus; } decorations; +#else + GLFWbool ssd; +#endif } _GLFWwindowWayland; @@ -231,7 +239,9 @@ typedef struct _GLFWlibraryWayland struct wl_data_source* dataSource; struct xdg_wm_base* wmBase; struct zxdg_decoration_manager_v1* decorationManager; +#ifndef WITH_DECORATION struct wp_viewporter* viewporter; +#endif struct zwp_relative_pointer_manager_v1* relativePointerManager; struct zwp_pointer_constraints_v1* pointerConstraints; struct zwp_idle_inhibit_manager_v1* idleInhibitManager; diff --git a/src/wl_window.c b/src/wl_window.c index 46cd742c..9e10e8a3 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -40,6 +40,10 @@ #include #include +#ifdef WITH_DECORATION +#include +#endif + static int createTmpfileCloexec(char* tmpname) { @@ -182,6 +186,7 @@ static struct wl_buffer* createShmBuffer(const GLFWimage* image) return buffer; } +#ifndef WITH_DECORATION static void createDecoration(_GLFWdecorationWayland* decoration, struct wl_surface* parent, struct wl_buffer* buffer, GLFWbool opaque, @@ -211,7 +216,14 @@ static void createDecoration(_GLFWdecorationWayland* decoration, else wl_surface_commit(decoration->surface); } +#endif +#ifdef WITH_DECORATION +static void createDecorations(_GLFWwindow* window) +{ + // +} +#else static void createDecorations(_GLFWwindow* window) { unsigned char data[] = { 224, 224, 224, 255 }; @@ -243,7 +255,9 @@ static void createDecorations(_GLFWwindow* window) -_GLFW_DECORATION_WIDTH, window->wl.height, window->wl.width + _GLFW_DECORATION_HORIZONTAL, _GLFW_DECORATION_WIDTH); } +#endif +#ifndef WITH_DECORATION static void destroyDecoration(_GLFWdecorationWayland* decoration) { if (decoration->subsurface) @@ -256,7 +270,14 @@ static void destroyDecoration(_GLFWdecorationWayland* decoration) decoration->subsurface = NULL; decoration->viewport = NULL; } +#endif +#ifdef WITH_DECORATION +static void destroyDecorations(_GLFWwindow* window) +{ + // +} +#else static void destroyDecorations(_GLFWwindow* window) { destroyDecoration(&window->wl.decorations.top); @@ -264,6 +285,7 @@ static void destroyDecorations(_GLFWwindow* window) destroyDecoration(&window->wl.decorations.right); destroyDecoration(&window->wl.decorations.bottom); } +#endif static void xdgDecorationHandleConfigure(void* data, struct zxdg_toplevel_decoration_v1* decoration, @@ -271,9 +293,11 @@ static void xdgDecorationHandleConfigure(void* data, { _GLFWwindow* window = data; - window->wl.decorations.serverSide = (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); - - if (!window->wl.decorations.serverSide) +#ifdef WITH_DECORATION + if (!(window->wl.ssd = (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE))) +#else + if (!(window->wl.decorations.serverSide = (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE))) +#endif createDecorations(window); } @@ -307,6 +331,7 @@ static void resizeWindow(_GLFWwindow* window) _glfwInputFramebufferSize(window, scaledWidth, scaledHeight); _glfwInputWindowContentScale(window, scale, scale); +#ifndef WITH_DECORATION if (!window->wl.decorations.top.surface) return; @@ -333,6 +358,7 @@ static void resizeWindow(_GLFWwindow* window) wp_viewport_set_destination(window->wl.decorations.bottom.viewport, window->wl.width + _GLFW_DECORATION_HORIZONTAL, _GLFW_DECORATION_WIDTH); wl_surface_commit(window->wl.decorations.bottom.surface); +#endif } static void checkScaleChange(_GLFWwindow* window) @@ -465,7 +491,11 @@ static void setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor, monitor->wl.output); } setIdleInhibitor(window, GLFW_TRUE); +#ifdef WITH_DECORATION + if (!window->wl.ssd) +#else if (!window->wl.decorations.serverSide) +#endif destroyDecorations(window); } @@ -573,7 +603,11 @@ static void setXdgDecorations(_GLFWwindow* window) } else { +#ifdef WITH_DECORATION + window->wl.ssd = GLFW_FALSE; +#else window->wl.decorations.serverSide = GLFW_FALSE; +#endif createDecorations(window); } } @@ -689,8 +723,12 @@ static void incrementCursorImage(_GLFWwindow* window) { _GLFWcursor* cursor; - if (!window || window->wl.decorations.focus != mainWindow) + if (!window) return; + +#ifndef WITH_DECORATION + if (window->wl.decorations.focus != mainWindow) return; +#endif cursor = window->wl.currentCursor; if (cursor && cursor->wl.cursor) @@ -860,9 +898,10 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) destroyDecorations(window); if (window->wl.xdg.decoration) zxdg_toplevel_decoration_v1_destroy(window->wl.xdg.decoration); - +#ifndef WITH_DECORATION if (window->wl.decorations.buffer) wl_buffer_destroy(window->wl.decorations.buffer); +#endif if (window->wl.native) wl_egl_window_destroy(window->wl.native); @@ -967,6 +1006,7 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, int* left, int* top, int* right, int* bottom) { +#ifndef WITH_DECORATION if (window->decorated && !window->monitor && !window->wl.decorations.serverSide) { if (top) @@ -978,6 +1018,7 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, if (bottom) *bottom = _GLFW_DECORATION_WIDTH; } +#endif } void _glfwPlatformGetWindowContentScale(_GLFWwindow* window, @@ -1461,10 +1502,14 @@ void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor) window->wl.currentCursor = cursor; + if (window != _glfw.wl.pointerFocus) return; + +#ifndef WITH_DECORATION // If we're not in the correct window just save the cursor // the next time the pointer enters the window the cursor will change - if (window != _glfw.wl.pointerFocus || window->wl.decorations.focus != mainWindow) + if (window->wl.decorations.focus != mainWindow) return; +#endif // Unlock possible pointer lock if no longer disabled. if (window->cursorMode != GLFW_CURSOR_DISABLED && isPointerLocked(window))