From ba40bf5e6fae2e2c1e715d1931382f7ff58f2b9f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 20 Nov 2017 14:45:31 +0530 Subject: [PATCH] remove no longer needed code --- kitty/cocoa_window.m | 28 +++------------------------- kitty/glfw.c | 4 ++++ kitty/main.py | 6 +----- 3 files changed, 8 insertions(+), 30 deletions(-) diff --git a/kitty/cocoa_window.m b/kitty/cocoa_window.m index 7859eb1af..c81752a87 100644 --- a/kitty/cocoa_window.m +++ b/kitty/cocoa_window.m @@ -20,13 +20,6 @@ #define NSEventModifierFlagControl NSControlKeyMask #endif -@interface MenuDispatcher : NSObject -@end - -@implementation MenuDispatcher -@end - -static NSObject* menu_dispatcher = NULL; static NSMenuItem* title_menu = NULL; static NSString* @@ -62,21 +55,9 @@ find_app_name(void) { } -PyObject* -cocoa_init(PyObject UNUSED *_self) { - // Press and Hold prevents some keys from emitting repeated characters - // See https://github.com/glfw/glfw/issues/1010 - NSDictionary* defaults = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], @"ApplePressAndHoldEnabled", nil]; - [[NSUserDefaults standardUserDefaults] registerDefaults:defaults]; - Py_RETURN_NONE; -} - - -PyObject* -cocoa_create_global_menu(PyObject UNUSED *_self) { - if (menu_dispatcher != NULL) { Py_RETURN_NONE; } +void +cocoa_create_global_menu(void) { NSString* app_name = find_app_name(); - menu_dispatcher = [[MenuDispatcher alloc] init]; NSMenu* bar = [[NSMenu alloc] init]; [NSApp setMainMenu:bar]; @@ -141,7 +122,6 @@ cocoa_create_global_menu(PyObject UNUSED *_self) { [bar release]; - Py_RETURN_NONE; } void @@ -188,9 +168,7 @@ cocoa_get_lang(PyObject UNUSED *self) { } static PyMethodDef module_methods[] = { - {"cocoa_get_lang", (PyCFunction)cocoa_get_lang, METH_NOARGS, ""}, \ - {"cocoa_create_global_menu", (PyCFunction)cocoa_create_global_menu, METH_NOARGS, ""}, \ - {"cocoa_init", (PyCFunction)cocoa_init, METH_NOARGS, ""}, \ + {"cocoa_get_lang", (PyCFunction)cocoa_get_lang, METH_NOARGS, ""}, {NULL, NULL, 0, NULL} /* Sentinel */ }; diff --git a/kitty/glfw.c b/kitty/glfw.c index 6d2c387b5..67c2b2305 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -8,6 +8,7 @@ #include #include "glfw-wrapper.h" extern bool cocoa_make_window_resizable(void *w); +extern void cocoa_create_global_menu(void); #if GLFW_KEY_LAST >= MAX_KEY_COUNT #error "glfw has too many keys, you should increase MAX_KEY_COUNT" @@ -243,6 +244,9 @@ create_os_window(PyObject UNUSED *self, PyObject *args) { PyObject *ret = PyObject_CallFunction(load_programs, NULL); if (ret == NULL) return NULL; Py_DECREF(ret); +#ifdef __APPLE__ + cocoa_create_global_menu(); +#endif } OSWindow *w = add_os_window(); diff --git a/kitty/main.py b/kitty/main.py index 4e57e04e8..08d4a48d8 100644 --- a/kitty/main.py +++ b/kitty/main.py @@ -38,11 +38,7 @@ def run_app(opts, args): w, h = initial_window_size(opts) window_id = create_os_window(w, h, args.cls, True, load_all_shaders) startup_ctx = init_startup_notification(window_id) - if isosx: - from .fast_data_types import cocoa_create_global_menu, cocoa_init - cocoa_init() - cocoa_create_global_menu() - elif not iswayland: # no window icons on wayland + if not iswayland and not isosx: # no window icons on wayland with open(logo_data_file, 'rb') as f: set_default_window_icon(f.read(), 256, 256) set_logical_dpi(*get_logical_dpi())