|
| 1 | +commit 749772b8b8179eb3b71e542fd9ed5621feb578f5 |
| 2 | +Author: Matthew Glazar <strager.nds@gmail.com> |
| 3 | +Date: Thu Feb 28 22:01:32 2019 -0800 |
| 4 | + |
| 5 | + Support macOS 10.11 |
| 6 | + |
| 7 | + Allow Kitty to run on macOS 10.11 El Capitan. |
| 8 | + |
| 9 | +diff --git a/glfw/cocoa_init.m b/glfw/cocoa_init.m |
| 10 | +index 1e719d2e..05a680e4 100644 |
| 11 | +--- a/glfw/cocoa_init.m |
| 12 | ++++ b/glfw/cocoa_init.m |
| 13 | +@@ -30,6 +30,10 @@ |
| 14 | + #define NSEventMaskKeyUp NSKeyUpMask |
| 15 | + #define NSEventMaskKeyDown NSKeyDownMask |
| 16 | + #define NSEventModifierFlagCommand NSCommandKeyMask |
| 17 | ++ #define NSEventModifierFlagControl NSControlKeyMask |
| 18 | ++ #define NSEventModifierFlagDeviceIndependentFlagsMask NSDeviceIndependentModifierFlagsMask |
| 19 | ++ #define NSEventModifierFlagShift NSShiftKeyMask |
| 20 | ++ #define NSEventTypeApplicationDefined NSApplicationDefined |
| 21 | + #endif |
| 22 | + |
| 23 | + // Change to our application bundle's resources directory, if present |
| 24 | +diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m |
| 25 | +index 1ce79b56..fd2255fc 100644 |
| 26 | +--- a/glfw/cocoa_window.m |
| 27 | ++++ b/glfw/cocoa_window.m |
| 28 | +@@ -41,6 +41,7 @@ |
| 29 | + #define NSWindowStyleMaskTitled NSTitledWindowMask |
| 30 | + #define NSEventModifierFlagCommand NSCommandKeyMask |
| 31 | + #define NSEventModifierFlagControl NSControlKeyMask |
| 32 | ++ #define NSEventModifierFlagNumericPad NSNumericPadKeyMask |
| 33 | + #define NSEventModifierFlagOption NSAlternateKeyMask |
| 34 | + #define NSEventModifierFlagShift NSShiftKeyMask |
| 35 | + #define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask |
| 36 | +diff --git a/kitty/cocoa_window.m b/kitty/cocoa_window.m |
| 37 | +index 5e9252ba..99eb3352 100644 |
| 38 | +--- a/kitty/cocoa_window.m |
| 39 | ++++ b/kitty/cocoa_window.m |
| 40 | +@@ -15,6 +15,9 @@ |
| 41 | + #include <objc/runtime.h> |
| 42 | + |
| 43 | + #if (MAC_OS_X_VERSION_MAX_ALLOWED < 101200) |
| 44 | ++typedef NSUInteger NSWindowStyleMask; |
| 45 | ++#define NSWindowStyleMaskBorderless NSBorderlessWindowMask |
| 46 | ++#define NSWindowStyleMaskFullScreen NSFullScreenWindowMask |
| 47 | + #define NSWindowStyleMaskResizable NSResizableWindowMask |
| 48 | + #define NSEventModifierFlagOption NSAlternateKeyMask |
| 49 | + #define NSEventModifierFlagCommand NSCommandKeyMask |
| 50 | +diff --git a/kitty/logging.c b/kitty/logging.c |
| 51 | +index 45c88174..1ec9f1b0 100644 |
| 52 | +--- a/kitty/logging.c |
| 53 | ++++ b/kitty/logging.c |
| 54 | +@@ -5,12 +5,21 @@ |
| 55 | + * Distributed under terms of the GPL3 license. |
| 56 | + */ |
| 57 | + |
| 58 | ++#ifdef __APPLE__ |
| 59 | ++#include <AvailabilityMacros.h> |
| 60 | ++#endif |
| 61 | ++#if defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_12) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12 |
| 62 | ++#define USE_APPLE_OS_LOG 1 |
| 63 | ++#else |
| 64 | ++#define USE_APPLE_OS_LOG 0 |
| 65 | ++#endif |
| 66 | ++ |
| 67 | + #include "data-types.h" |
| 68 | + #include <stdlib.h> |
| 69 | + #include <stdarg.h> |
| 70 | + #include <time.h> |
| 71 | + #include <sys/time.h> |
| 72 | +-#ifdef __APPLE__ |
| 73 | ++#if USE_APPLE_OS_LOG |
| 74 | + #include <os/log.h> |
| 75 | + #endif |
| 76 | + |
| 77 | +@@ -21,7 +30,7 @@ void |
| 78 | + log_error(const char *fmt, ...) { |
| 79 | + va_list ar; |
| 80 | + struct timeval tv; |
| 81 | +-#ifdef __APPLE__ |
| 82 | ++#if USE_APPLE_OS_LOG |
| 83 | + // Apple does not provide a varargs style os_logv |
| 84 | + char logbuf[16 * 1024] = {0}; |
| 85 | + #else |
| 86 | +@@ -44,7 +53,7 @@ log_error(const char *fmt, ...) { |
| 87 | + if (use_os_log) { bufprint(vsnprintf, fmt, ar); } |
| 88 | + else vfprintf(stderr, fmt, ar); |
| 89 | + va_end(ar); |
| 90 | +-#ifdef __APPLE__ |
| 91 | ++#if USE_APPLE_OS_LOG |
| 92 | + if (use_os_log) os_log(OS_LOG_DEFAULT, "%{public}s", logbuf); |
| 93 | + #endif |
| 94 | + if (!use_os_log) fprintf(stderr, "\n"); |
| 95 | +@@ -66,7 +75,7 @@ static PyMethodDef module_methods[] = { |
| 96 | + bool |
| 97 | + init_logging(PyObject *module) { |
| 98 | + if (PyModule_AddFunctions(module, module_methods) != 0) return false; |
| 99 | +-#ifdef __APPLE__ |
| 100 | ++#if USE_APPLE_OS_LOG |
| 101 | + if (getenv("KITTY_LAUNCHED_BY_LAUNCH_SERVICES") != NULL) use_os_log = true; |
| 102 | + #endif |
| 103 | + return true; |
| 104 | +diff --git a/setup.py b/setup.py |
| 105 | +index f8643fce..55a96e73 100755 |
| 106 | +--- a/setup.py |
| 107 | ++++ b/setup.py |
| 108 | +@@ -711,7 +711,7 @@ Categories=System;TerminalEmulator; |
| 109 | + CFBundlePackageType='APPL', |
| 110 | + CFBundleSignature='????', |
| 111 | + CFBundleExecutable=appname, |
| 112 | +- LSMinimumSystemVersion='10.12.0', |
| 113 | ++ LSMinimumSystemVersion='10.11.0', |
| 114 | + LSRequiresNativeExecution=True, |
| 115 | + NSAppleScriptEnabled=False, |
| 116 | + # Needed for dark mode in Mojave when linking against older SDKs |
0 commit comments