Create macOS menu bar where GLFW creates it
GLFW creates the menu bar in the applicationWillFinishLaunching method, while kitty creates it in `create_os_window()`. This patch changes the behaviour to match GLFW. In practice, without this change, there can be a short time where the menu bar is not fully populated.
This commit is contained in:
parent
bd75157428
commit
f9fd39b8c1
@ -456,6 +456,8 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL;
|
|||||||
_glfwPollMonitorsNS();
|
_glfwPollMonitorsNS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GLFWapplicationwillfinishlaunchingfun finish_launching_callback = NULL;
|
||||||
|
|
||||||
- (void)applicationWillFinishLaunching:(NSNotification *)notification
|
- (void)applicationWillFinishLaunching:(NSNotification *)notification
|
||||||
{
|
{
|
||||||
(void)notification;
|
(void)notification;
|
||||||
@ -478,6 +480,8 @@ static GLFWapplicationshouldhandlereopenfun handle_reopen_callback = NULL;
|
|||||||
else */
|
else */
|
||||||
createMenuBar();
|
createMenuBar();
|
||||||
}
|
}
|
||||||
|
if (finish_launching_callback)
|
||||||
|
finish_launching_callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification
|
- (void)applicationDidFinishLaunching:(NSNotification *)notification
|
||||||
@ -555,6 +559,12 @@ GLFWAPI GLFWapplicationshouldhandlereopenfun glfwSetApplicationShouldHandleReope
|
|||||||
return previous;
|
return previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWAPI GLFWapplicationwillfinishlaunchingfun glfwSetApplicationWillFinishLaunching(GLFWapplicationwillfinishlaunchingfun callback) {
|
||||||
|
GLFWapplicationwillfinishlaunchingfun previous = finish_launching_callback;
|
||||||
|
finish_launching_callback = callback;
|
||||||
|
return previous;
|
||||||
|
}
|
||||||
|
|
||||||
int _glfwPlatformInit(void)
|
int _glfwPlatformInit(void)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
|
|||||||
1
glfw/cocoa_platform.h
vendored
1
glfw/cocoa_platform.h
vendored
@ -68,6 +68,7 @@ typedef void* CVDisplayLinkRef;
|
|||||||
typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
|
typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
|
||||||
typedef int (* GLFWcocoatextinputfilterfun)(int,int,unsigned int, unsigned long);
|
typedef int (* GLFWcocoatextinputfilterfun)(int,int,unsigned int, unsigned long);
|
||||||
typedef int (* GLFWapplicationshouldhandlereopenfun)(int);
|
typedef int (* GLFWapplicationshouldhandlereopenfun)(int);
|
||||||
|
typedef void (* GLFWapplicationwillfinishlaunchingfun)(void);
|
||||||
typedef int (* GLFWcocoatogglefullscreenfun)(GLFWwindow*);
|
typedef int (* GLFWcocoatogglefullscreenfun)(GLFWwindow*);
|
||||||
typedef void (* GLFWcocoarenderframefun)(GLFWwindow*);
|
typedef void (* GLFWcocoarenderframefun)(GLFWwindow*);
|
||||||
|
|
||||||
|
|||||||
@ -165,6 +165,7 @@ def generate_wrappers(glfw_header):
|
|||||||
GLFWcocoatextinputfilterfun glfwSetCocoaTextInputFilter(GLFWwindow* window, GLFWcocoatextinputfilterfun callback)
|
GLFWcocoatextinputfilterfun glfwSetCocoaTextInputFilter(GLFWwindow* window, GLFWcocoatextinputfilterfun callback)
|
||||||
GLFWcocoatogglefullscreenfun glfwSetCocoaToggleFullscreenIntercept(GLFWwindow *window, GLFWcocoatogglefullscreenfun callback)
|
GLFWcocoatogglefullscreenfun glfwSetCocoaToggleFullscreenIntercept(GLFWwindow *window, GLFWcocoatogglefullscreenfun callback)
|
||||||
GLFWapplicationshouldhandlereopenfun glfwSetApplicationShouldHandleReopen(GLFWapplicationshouldhandlereopenfun callback)
|
GLFWapplicationshouldhandlereopenfun glfwSetApplicationShouldHandleReopen(GLFWapplicationshouldhandlereopenfun callback)
|
||||||
|
GLFWapplicationwillfinishlaunchingfun glfwSetApplicationWillFinishLaunching(GLFWapplicationwillfinishlaunchingfun callback)
|
||||||
void glfwGetCocoaKeyEquivalent(int glfw_key, int glfw_mods, void* cocoa_key, void* cocoa_mods)
|
void glfwGetCocoaKeyEquivalent(int glfw_key, int glfw_mods, void* cocoa_key, void* cocoa_mods)
|
||||||
void glfwCocoaRequestRenderFrame(GLFWwindow *w, GLFWcocoarenderframefun callback)
|
void glfwCocoaRequestRenderFrame(GLFWwindow *w, GLFWcocoarenderframefun callback)
|
||||||
void* glfwGetX11Display(void)
|
void* glfwGetX11Display(void)
|
||||||
@ -200,6 +201,7 @@ const char *action_text, int32_t timeout, GLFWDBusnotificationcreatedfun callbac
|
|||||||
|
|
||||||
typedef int (* GLFWcocoatextinputfilterfun)(int,int,unsigned int,unsigned long);
|
typedef int (* GLFWcocoatextinputfilterfun)(int,int,unsigned int,unsigned long);
|
||||||
typedef int (* GLFWapplicationshouldhandlereopenfun)(int);
|
typedef int (* GLFWapplicationshouldhandlereopenfun)(int);
|
||||||
|
typedef void (* GLFWapplicationwillfinishlaunchingfun)(void);
|
||||||
typedef int (* GLFWcocoatogglefullscreenfun)(GLFWwindow*);
|
typedef int (* GLFWcocoatogglefullscreenfun)(GLFWwindow*);
|
||||||
typedef void (* GLFWcocoarenderframefun)(GLFWwindow*);
|
typedef void (* GLFWcocoarenderframefun)(GLFWwindow*);
|
||||||
typedef void (*GLFWwaylandframecallbackfunc)(unsigned long long id);
|
typedef void (*GLFWwaylandframecallbackfunc)(unsigned long long id);
|
||||||
|
|||||||
@ -232,8 +232,6 @@ cocoa_send_notification(PyObject *self UNUSED, PyObject *args) {
|
|||||||
// global menu {{{
|
// global menu {{{
|
||||||
void
|
void
|
||||||
cocoa_create_global_menu(void) {
|
cocoa_create_global_menu(void) {
|
||||||
@autoreleasepool {
|
|
||||||
|
|
||||||
NSString* app_name = find_app_name();
|
NSString* app_name = find_app_name();
|
||||||
NSMenu* bar = [[NSMenu alloc] init];
|
NSMenu* bar = [[NSMenu alloc] init];
|
||||||
GlobalMenuTarget *global_menu_target = [GlobalMenuTarget shared_instance];
|
GlobalMenuTarget *global_menu_target = [GlobalMenuTarget shared_instance];
|
||||||
@ -325,8 +323,6 @@ cocoa_create_global_menu(void) {
|
|||||||
|
|
||||||
|
|
||||||
[NSApp setServicesProvider:[[[ServiceProvider alloc] init] autorelease]];
|
[NSApp setServicesProvider:[[[ServiceProvider alloc] init] autorelease]];
|
||||||
|
|
||||||
} // autoreleasepool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
2
kitty/glfw-wrapper.c
generated
2
kitty/glfw-wrapper.c
generated
@ -389,6 +389,8 @@ load_glfw(const char* path) {
|
|||||||
|
|
||||||
*(void **) (&glfwSetApplicationShouldHandleReopen_impl) = dlsym(handle, "glfwSetApplicationShouldHandleReopen");
|
*(void **) (&glfwSetApplicationShouldHandleReopen_impl) = dlsym(handle, "glfwSetApplicationShouldHandleReopen");
|
||||||
|
|
||||||
|
*(void **) (&glfwSetApplicationWillFinishLaunching_impl) = dlsym(handle, "glfwSetApplicationWillFinishLaunching");
|
||||||
|
|
||||||
*(void **) (&glfwGetCocoaKeyEquivalent_impl) = dlsym(handle, "glfwGetCocoaKeyEquivalent");
|
*(void **) (&glfwGetCocoaKeyEquivalent_impl) = dlsym(handle, "glfwGetCocoaKeyEquivalent");
|
||||||
|
|
||||||
*(void **) (&glfwCocoaRequestRenderFrame_impl) = dlsym(handle, "glfwCocoaRequestRenderFrame");
|
*(void **) (&glfwCocoaRequestRenderFrame_impl) = dlsym(handle, "glfwCocoaRequestRenderFrame");
|
||||||
|
|||||||
5
kitty/glfw-wrapper.h
generated
5
kitty/glfw-wrapper.h
generated
@ -1576,6 +1576,7 @@ typedef struct GLFWgamepadstate
|
|||||||
|
|
||||||
typedef int (* GLFWcocoatextinputfilterfun)(int,int,unsigned int,unsigned long);
|
typedef int (* GLFWcocoatextinputfilterfun)(int,int,unsigned int,unsigned long);
|
||||||
typedef int (* GLFWapplicationshouldhandlereopenfun)(int);
|
typedef int (* GLFWapplicationshouldhandlereopenfun)(int);
|
||||||
|
typedef void (* GLFWapplicationwillfinishlaunchingfun)(void);
|
||||||
typedef int (* GLFWcocoatogglefullscreenfun)(GLFWwindow*);
|
typedef int (* GLFWcocoatogglefullscreenfun)(GLFWwindow*);
|
||||||
typedef void (* GLFWcocoarenderframefun)(GLFWwindow*);
|
typedef void (* GLFWcocoarenderframefun)(GLFWwindow*);
|
||||||
typedef void (*GLFWwaylandframecallbackfunc)(unsigned long long id);
|
typedef void (*GLFWwaylandframecallbackfunc)(unsigned long long id);
|
||||||
@ -2089,6 +2090,10 @@ typedef GLFWapplicationshouldhandlereopenfun (*glfwSetApplicationShouldHandleReo
|
|||||||
glfwSetApplicationShouldHandleReopen_func glfwSetApplicationShouldHandleReopen_impl;
|
glfwSetApplicationShouldHandleReopen_func glfwSetApplicationShouldHandleReopen_impl;
|
||||||
#define glfwSetApplicationShouldHandleReopen glfwSetApplicationShouldHandleReopen_impl
|
#define glfwSetApplicationShouldHandleReopen glfwSetApplicationShouldHandleReopen_impl
|
||||||
|
|
||||||
|
typedef GLFWapplicationwillfinishlaunchingfun (*glfwSetApplicationWillFinishLaunching_func)(GLFWapplicationwillfinishlaunchingfun);
|
||||||
|
glfwSetApplicationWillFinishLaunching_func glfwSetApplicationWillFinishLaunching_impl;
|
||||||
|
#define glfwSetApplicationWillFinishLaunching glfwSetApplicationWillFinishLaunching_impl
|
||||||
|
|
||||||
typedef void (*glfwGetCocoaKeyEquivalent_func)(int, int, void*, void*);
|
typedef void (*glfwGetCocoaKeyEquivalent_func)(int, int, void*, void*);
|
||||||
glfwGetCocoaKeyEquivalent_func glfwGetCocoaKeyEquivalent_impl;
|
glfwGetCocoaKeyEquivalent_func glfwGetCocoaKeyEquivalent_impl;
|
||||||
#define glfwGetCocoaKeyEquivalent glfwGetCocoaKeyEquivalent_impl
|
#define glfwGetCocoaKeyEquivalent glfwGetCocoaKeyEquivalent_impl
|
||||||
|
|||||||
@ -517,6 +517,7 @@ create_os_window(PyObject UNUSED *self, PyObject *args) {
|
|||||||
cocoa_set_activation_policy(OPT(macos_hide_from_tasks));
|
cocoa_set_activation_policy(OPT(macos_hide_from_tasks));
|
||||||
glfwWindowHint(GLFW_COCOA_GRAPHICS_SWITCHING, true);
|
glfwWindowHint(GLFW_COCOA_GRAPHICS_SWITCHING, true);
|
||||||
glfwSetApplicationShouldHandleReopen(on_application_reopen);
|
glfwSetApplicationShouldHandleReopen(on_application_reopen);
|
||||||
|
glfwSetApplicationWillFinishLaunching(cocoa_create_global_menu);
|
||||||
if (OPT(hide_window_decorations)) glfwWindowHint(GLFW_DECORATED, false);
|
if (OPT(hide_window_decorations)) glfwWindowHint(GLFW_DECORATED, false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -595,9 +596,6 @@ create_os_window(PyObject UNUSED *self, PyObject *args) {
|
|||||||
PyObject *ret = PyObject_CallFunction(load_programs, "O", is_semi_transparent ? Py_True : Py_False);
|
PyObject *ret = PyObject_CallFunction(load_programs, "O", is_semi_transparent ? Py_True : Py_False);
|
||||||
if (ret == NULL) return NULL;
|
if (ret == NULL) return NULL;
|
||||||
Py_DECREF(ret);
|
Py_DECREF(ret);
|
||||||
#ifdef __APPLE__
|
|
||||||
cocoa_create_global_menu();
|
|
||||||
#endif
|
|
||||||
#define CC(dest, shape) {\
|
#define CC(dest, shape) {\
|
||||||
if (!dest##_cursor) { \
|
if (!dest##_cursor) { \
|
||||||
dest##_cursor = glfwCreateStandardCursor(GLFW_##shape##_CURSOR); \
|
dest##_cursor = glfwCreateStandardCursor(GLFW_##shape##_CURSOR); \
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user