This commit is contained in:
Kovid Goyal 2017-09-25 17:47:30 +05:30
parent 3ca45ab241
commit cd88505ca7
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 13 additions and 1 deletions

View File

@ -59,6 +59,16 @@ 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; }
@ -177,6 +187,7 @@ static PyMethodDef module_methods[] = {
{"cocoa_get_lang", (PyCFunction)cocoa_get_lang, METH_NOARGS, ""}, \
{"cocoa_make_window_resizable", (PyCFunction)cocoa_make_window_resizable, METH_O, ""}, \
{"cocoa_create_global_menu", (PyCFunction)cocoa_create_global_menu, METH_NOARGS, ""}, \
{"cocoa_init", (PyCFunction)cocoa_init, METH_NOARGS, ""}, \
{NULL, NULL, 0, NULL} /* Sentinel */
};

View File

@ -177,8 +177,9 @@ def run_app(opts, args):
window = GLFWWindow(viewport_size.width, viewport_size.height, args.cls)
window.make_context_current()
if isosx:
from .fast_data_types import cocoa_make_window_resizable, cocoa_create_global_menu
from .fast_data_types import cocoa_make_window_resizable, cocoa_create_global_menu, cocoa_init
check_for_extensions()
cocoa_init()
cocoa_create_global_menu()
if opts.macos_hide_titlebar:
cocoa_make_window_resizable(window.cocoa_window_id())