From 3df80545bddc7b0b3c0b3ab6d52842b28e6d19a5 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Sun, 25 Oct 2020 22:44:47 +0100 Subject: [PATCH] Reduce the difference of GLFW to upstream --- glfw/memfd.h | 3 +-- glfw/wl_platform.h | 8 +++++--- glfw/wl_window.c | 19 ++++++++----------- glfw/x11_window.c | 6 ++++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/glfw/memfd.h b/glfw/memfd.h index 7c1797865..9afc0db93 100644 --- a/glfw/memfd.h +++ b/glfw/memfd.h @@ -39,8 +39,7 @@ static inline int memfd_create(const char *name, unsigned int flags) { #include #include -static inline int -createTmpfileCloexec(char* tmpname) +static inline int createTmpfileCloexec(char* tmpname) { int fd; diff --git a/glfw/wl_platform.h b/glfw/wl_platform.h index aed141a3a..70184577e 100644 --- a/glfw/wl_platform.h +++ b/glfw/wl_platform.h @@ -204,14 +204,14 @@ typedef struct _GLFWlibraryWayland struct wl_seat* seat; struct wl_pointer* pointer; struct wl_keyboard* keyboard; + struct wl_data_device_manager* dataDeviceManager; + struct wl_data_device* dataDevice; struct xdg_wm_base* wmBase; struct zxdg_decoration_manager_v1* decorationManager; struct wp_viewporter* viewporter; struct zwp_relative_pointer_manager_v1* relativePointerManager; struct zwp_pointer_constraints_v1* pointerConstraints; struct zwp_idle_inhibit_manager_v1* idleInhibitManager; - struct wl_data_device_manager* dataDeviceManager; - struct wl_data_device* dataDevice; struct wl_data_source* dataSourceForClipboard; struct zwp_primary_selection_device_manager_v1* primarySelectionDeviceManager; struct zwp_primary_selection_device_v1* primarySelectionDevice; @@ -226,6 +226,7 @@ typedef struct _GLFWlibraryWayland int32_t keyboardRepeatRate; monotonic_t keyboardRepeatDelay; + struct { uint32_t key; id_type keyRepeatTimer; @@ -275,7 +276,8 @@ typedef struct _GLFWmonitorWayland int x; int y; int scale; - } _GLFWmonitorWayland; + +} _GLFWmonitorWayland; // Wayland-specific per-cursor data // diff --git a/glfw/wl_window.c b/glfw/wl_window.c index 3b1fd1894..735590a45 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -42,8 +42,7 @@ #include -static void -setCursorImage(_GLFWwindow* window) +static void setCursorImage(_GLFWwindow* window) { _GLFWcursorWayland defaultCursor = {.shape = GLFW_ARROW_CURSOR}; _GLFWcursorWayland* cursorWayland = window->cursor ? &window->cursor->wl : &defaultCursor; @@ -247,8 +246,7 @@ static void dispatchChangesAfterConfigure(_GLFWwindow *window, int32_t width, in * is set to ENOSPC. If posix_fallocate() is not supported, program may * receive SIGBUS on accessing mmap()'ed file contents instead. */ -static int -createAnonymousFile(off_t size) +static int createAnonymousFile(off_t size) { int ret, fd = -1, shm_anon = 0; #ifdef HAS_MEMFD_CREATE @@ -439,7 +437,9 @@ static void xdgDecorationHandleConfigure(void* data, uint32_t mode) { _GLFWwindow* window = data; + window->wl.decorations.serverSide = (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); + if (!window->wl.decorations.serverSide) createDecorations(window); } @@ -547,8 +547,7 @@ static bool createSurface(_GLFWwindow* window, return true; } -static void -setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor, bool on) +static void setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor, bool on) { if (window->wl.xdg.toplevel) { @@ -739,8 +738,7 @@ static bool createXdgSurface(_GLFWwindow* window) return true; } -static void -incrementCursorImage(_GLFWwindow* window) +static void incrementCursorImage(_GLFWwindow* window) { if (window && window->wl.decorations.focus == mainWindow && window->cursorMode != GLFW_CURSOR_HIDDEN) { _GLFWcursor* cursor = window->wl.currentCursor; @@ -788,8 +786,7 @@ wayland_read_events(int poll_result, int events, void *data UNUSED) { else wl_display_cancel_read(_glfw.wl.display); } -static void -handleEvents(monotonic_t timeout) +static void handleEvents(monotonic_t timeout) { struct wl_display* display = _glfw.wl.display; errno = 0; @@ -958,7 +955,6 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) window->context.destroy(window); destroyDecorations(window); - if (window->wl.xdg.decoration) zxdg_toplevel_decoration_v1_destroy(window->wl.xdg.decoration); @@ -1362,6 +1358,7 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor, cursor->wl.buffer = createShmBuffer(image); if (!cursor->wl.buffer) return false; + cursor->wl.width = image->width; cursor->wl.height = image->height; cursor->wl.xhot = xhot; diff --git a/glfw/x11_window.c b/glfw/x11_window.c index c6464e184..d7c31e1b0 100644 --- a/glfw/x11_window.c +++ b/glfw/x11_window.c @@ -423,14 +423,16 @@ static char* convertLatin1toUTF8(const char* source) const char* sp; if (source) { - for (sp = source; *sp; sp++) size += (*sp & 0x80) ? 2 : 1; + for (sp = source; *sp; sp++) + size += (*sp & 0x80) ? 2 : 1; } char* target = calloc(size, 1); char* tp = target; if (source) { - for (sp = source; *sp; sp++) tp += encodeUTF8(tp, *sp); + for (sp = source; *sp; sp++) + tp += encodeUTF8(tp, *sp); } return target;