Reduce the difference of GLFW to upstream

This commit is contained in:
Luflosi 2020-10-25 22:44:47 +01:00
parent c605fd9783
commit 3df80545bd
No known key found for this signature in database
GPG Key ID: 4E41E29EDCC345D0
4 changed files with 18 additions and 18 deletions

3
glfw/memfd.h vendored
View File

@ -39,8 +39,7 @@ static inline int memfd_create(const char *name, unsigned int flags) {
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
static inline int static inline int createTmpfileCloexec(char* tmpname)
createTmpfileCloexec(char* tmpname)
{ {
int fd; int fd;

6
glfw/wl_platform.h vendored
View File

@ -204,14 +204,14 @@ typedef struct _GLFWlibraryWayland
struct wl_seat* seat; struct wl_seat* seat;
struct wl_pointer* pointer; struct wl_pointer* pointer;
struct wl_keyboard* keyboard; struct wl_keyboard* keyboard;
struct wl_data_device_manager* dataDeviceManager;
struct wl_data_device* dataDevice;
struct xdg_wm_base* wmBase; struct xdg_wm_base* wmBase;
struct zxdg_decoration_manager_v1* decorationManager; struct zxdg_decoration_manager_v1* decorationManager;
struct wp_viewporter* viewporter; struct wp_viewporter* viewporter;
struct zwp_relative_pointer_manager_v1* relativePointerManager; struct zwp_relative_pointer_manager_v1* relativePointerManager;
struct zwp_pointer_constraints_v1* pointerConstraints; struct zwp_pointer_constraints_v1* pointerConstraints;
struct zwp_idle_inhibit_manager_v1* idleInhibitManager; struct zwp_idle_inhibit_manager_v1* idleInhibitManager;
struct wl_data_device_manager* dataDeviceManager;
struct wl_data_device* dataDevice;
struct wl_data_source* dataSourceForClipboard; struct wl_data_source* dataSourceForClipboard;
struct zwp_primary_selection_device_manager_v1* primarySelectionDeviceManager; struct zwp_primary_selection_device_manager_v1* primarySelectionDeviceManager;
struct zwp_primary_selection_device_v1* primarySelectionDevice; struct zwp_primary_selection_device_v1* primarySelectionDevice;
@ -226,6 +226,7 @@ typedef struct _GLFWlibraryWayland
int32_t keyboardRepeatRate; int32_t keyboardRepeatRate;
monotonic_t keyboardRepeatDelay; monotonic_t keyboardRepeatDelay;
struct { struct {
uint32_t key; uint32_t key;
id_type keyRepeatTimer; id_type keyRepeatTimer;
@ -275,6 +276,7 @@ typedef struct _GLFWmonitorWayland
int x; int x;
int y; int y;
int scale; int scale;
} _GLFWmonitorWayland; } _GLFWmonitorWayland;
// Wayland-specific per-cursor data // Wayland-specific per-cursor data

19
glfw/wl_window.c vendored
View File

@ -42,8 +42,7 @@
#include <sys/mman.h> #include <sys/mman.h>
static void static void setCursorImage(_GLFWwindow* window)
setCursorImage(_GLFWwindow* window)
{ {
_GLFWcursorWayland defaultCursor = {.shape = GLFW_ARROW_CURSOR}; _GLFWcursorWayland defaultCursor = {.shape = GLFW_ARROW_CURSOR};
_GLFWcursorWayland* cursorWayland = window->cursor ? &window->cursor->wl : &defaultCursor; _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 * is set to ENOSPC. If posix_fallocate() is not supported, program may
* receive SIGBUS on accessing mmap()'ed file contents instead. * receive SIGBUS on accessing mmap()'ed file contents instead.
*/ */
static int static int createAnonymousFile(off_t size)
createAnonymousFile(off_t size)
{ {
int ret, fd = -1, shm_anon = 0; int ret, fd = -1, shm_anon = 0;
#ifdef HAS_MEMFD_CREATE #ifdef HAS_MEMFD_CREATE
@ -439,7 +437,9 @@ static void xdgDecorationHandleConfigure(void* data,
uint32_t mode) uint32_t mode)
{ {
_GLFWwindow* window = data; _GLFWwindow* window = data;
window->wl.decorations.serverSide = (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); window->wl.decorations.serverSide = (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
if (!window->wl.decorations.serverSide) if (!window->wl.decorations.serverSide)
createDecorations(window); createDecorations(window);
} }
@ -547,8 +547,7 @@ static bool createSurface(_GLFWwindow* window,
return true; return true;
} }
static void static void setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor, bool on)
setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor, bool on)
{ {
if (window->wl.xdg.toplevel) if (window->wl.xdg.toplevel)
{ {
@ -739,8 +738,7 @@ static bool createXdgSurface(_GLFWwindow* window)
return true; return true;
} }
static void static void incrementCursorImage(_GLFWwindow* window)
incrementCursorImage(_GLFWwindow* window)
{ {
if (window && window->wl.decorations.focus == mainWindow && window->cursorMode != GLFW_CURSOR_HIDDEN) { if (window && window->wl.decorations.focus == mainWindow && window->cursorMode != GLFW_CURSOR_HIDDEN) {
_GLFWcursor* cursor = window->wl.currentCursor; _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); else wl_display_cancel_read(_glfw.wl.display);
} }
static void static void handleEvents(monotonic_t timeout)
handleEvents(monotonic_t timeout)
{ {
struct wl_display* display = _glfw.wl.display; struct wl_display* display = _glfw.wl.display;
errno = 0; errno = 0;
@ -958,7 +955,6 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
window->context.destroy(window); window->context.destroy(window);
destroyDecorations(window); destroyDecorations(window);
if (window->wl.xdg.decoration) if (window->wl.xdg.decoration)
zxdg_toplevel_decoration_v1_destroy(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); cursor->wl.buffer = createShmBuffer(image);
if (!cursor->wl.buffer) if (!cursor->wl.buffer)
return false; return false;
cursor->wl.width = image->width; cursor->wl.width = image->width;
cursor->wl.height = image->height; cursor->wl.height = image->height;
cursor->wl.xhot = xhot; cursor->wl.xhot = xhot;

6
glfw/x11_window.c vendored
View File

@ -423,14 +423,16 @@ static char* convertLatin1toUTF8(const char* source)
const char* sp; const char* sp;
if (source) { 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* target = calloc(size, 1);
char* tp = target; char* tp = target;
if (source) { if (source) {
for (sp = source; *sp; sp++) tp += encodeUTF8(tp, *sp); for (sp = source; *sp; sp++)
tp += encodeUTF8(tp, *sp);
} }
return target; return target;