Forgot you cant use sizeof on arrays passed as function parameters
This commit is contained in:
parent
c8f20d0edf
commit
296f512bfb
@ -2179,9 +2179,9 @@ GLFWAPI void glfwCocoaRequestRenderFrame(GLFWwindow *w, GLFWcocoarenderframefun
|
||||
requestRenderFrame((_GLFWwindow*)w, callback);
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetCocoaKeyEquivalent(int glfw_key, int glfw_mods, char cocoa_key[32], int *cocoa_mods) {
|
||||
GLFWAPI void glfwGetCocoaKeyEquivalent(int glfw_key, int glfw_mods, char *cocoa_key, size_t key_sz, int *cocoa_mods) {
|
||||
*cocoa_mods = 0;
|
||||
memset(cocoa_key, 0, sizeof(cocoa_key));
|
||||
memset(cocoa_key, 0, key_sz);
|
||||
|
||||
if (glfw_mods & GLFW_MOD_SHIFT)
|
||||
*cocoa_mods |= NSEventModifierFlagShift;
|
||||
@ -2334,13 +2334,13 @@ START_ALLOW_CASE_RANGE
|
||||
END_ALLOW_CASE_RANGE
|
||||
}
|
||||
if (utf_16_key != 0) {
|
||||
strncpy(cocoa_key, [[NSString stringWithCharacters:&utf_16_key length:1] UTF8String], sizeof(cocoa_key) - 1);
|
||||
strncpy(cocoa_key, [[NSString stringWithCharacters:&utf_16_key length:1] UTF8String], key_sz - 1);
|
||||
} else {
|
||||
unsigned str_pos = 0;
|
||||
for (unsigned i = 0; i < 4 && str_pos < sizeof(cocoa_key) - 1; i++) {
|
||||
for (unsigned i = 0; i < 4 && str_pos < key_sz - 1; i++) {
|
||||
uint8_t byte = (utf_8_key >> 24) & 0xff;
|
||||
utf_8_key <<= 8;
|
||||
if (byte != 0) tmp_cocoa_key[str_pos++] = byte;
|
||||
if (byte != 0) cocoa_key[str_pos++] = byte;
|
||||
}
|
||||
cocoa_key[str_pos] = 0;
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ def generate_wrappers(glfw_header):
|
||||
GLFWcocoatogglefullscreenfun glfwSetCocoaToggleFullscreenIntercept(GLFWwindow *window, GLFWcocoatogglefullscreenfun callback)
|
||||
GLFWapplicationshouldhandlereopenfun glfwSetApplicationShouldHandleReopen(GLFWapplicationshouldhandlereopenfun callback)
|
||||
GLFWapplicationwillfinishlaunchingfun glfwSetApplicationWillFinishLaunching(GLFWapplicationwillfinishlaunchingfun callback)
|
||||
void glfwGetCocoaKeyEquivalent(int glfw_key, int glfw_mods, char[32] cocoa_key, int* cocoa_mods)
|
||||
void glfwGetCocoaKeyEquivalent(int glfw_key, int glfw_mods, char* cocoa_key, size_t key_sz, int* cocoa_mods)
|
||||
void glfwCocoaRequestRenderFrame(GLFWwindow *w, GLFWcocoarenderframefun callback)
|
||||
void* glfwGetX11Display(void)
|
||||
int32_t glfwGetX11Window(GLFWwindow* window)
|
||||
|
||||
@ -105,7 +105,7 @@ cocoa_set_new_window_trigger(PyObject *self UNUSED, PyObject *args) {
|
||||
int mods, key;
|
||||
if (!PyArg_ParseTuple(args, "ii", &mods, &key)) return NULL;
|
||||
int nwm;
|
||||
get_cocoa_key_equivalent(key, mods, new_window_key, &nwm);
|
||||
get_cocoa_key_equivalent(key, mods, new_window_key, sizeof(new_window_key), &nwm);
|
||||
new_window_mods = nwm;
|
||||
if (new_window_key[0]) Py_RETURN_TRUE;
|
||||
Py_RETURN_FALSE;
|
||||
|
||||
2
kitty/glfw-wrapper.h
generated
2
kitty/glfw-wrapper.h
generated
@ -2083,7 +2083,7 @@ typedef GLFWapplicationwillfinishlaunchingfun (*glfwSetApplicationWillFinishLaun
|
||||
glfwSetApplicationWillFinishLaunching_func glfwSetApplicationWillFinishLaunching_impl;
|
||||
#define glfwSetApplicationWillFinishLaunching glfwSetApplicationWillFinishLaunching_impl
|
||||
|
||||
typedef void (*glfwGetCocoaKeyEquivalent_func)(int, int, char[32], int*);
|
||||
typedef void (*glfwGetCocoaKeyEquivalent_func)(int, int, char*, size_t, int*);
|
||||
glfwGetCocoaKeyEquivalent_func glfwGetCocoaKeyEquivalent_impl;
|
||||
#define glfwGetCocoaKeyEquivalent glfwGetCocoaKeyEquivalent_impl
|
||||
|
||||
|
||||
@ -1079,8 +1079,8 @@ set_custom_cursor(PyObject *self UNUSED, PyObject *args) {
|
||||
|
||||
#ifdef __APPLE__
|
||||
void
|
||||
get_cocoa_key_equivalent(int key, int mods, char cocoa_key[32], int *cocoa_mods) {
|
||||
glfwGetCocoaKeyEquivalent(key, mods, cocoa_key, cocoa_mods);
|
||||
get_cocoa_key_equivalent(int key, int mods, char cocoa_key, size_t key_sz, int *cocoa_mods) {
|
||||
glfwGetCocoaKeyEquivalent(key, mods, cocoa_key, key_sz, cocoa_mods);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@ -225,7 +225,7 @@ void set_titlebar_color(OSWindow *w, color_type color);
|
||||
FONTS_DATA_HANDLE load_fonts_data(double, double, double);
|
||||
void send_prerendered_sprites_for_window(OSWindow *w);
|
||||
#ifdef __APPLE__
|
||||
void get_cocoa_key_equivalent(int, int, char key[32], int*);
|
||||
void get_cocoa_key_equivalent(int, int, char key, size_t key_sz, int*);
|
||||
typedef enum {
|
||||
PREFERENCES_WINDOW = 1,
|
||||
NEW_OS_WINDOW = 2,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user