mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-05-13 08:26:56 +00:00
Move preservation of OpenGL context into glfw
Allows us to avoid creating an extra hidden window.
This commit is contained in:
parent
b241811a74
commit
b7c4f42e96
2 changed files with 16 additions and 15 deletions
|
|
@ -107,12 +107,22 @@ bool _glfwInitNSGL(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
// We use a globally shared context across all OS Windows so that
|
||||
// if all OS Windows are closed the context does not have to be recreated
|
||||
// with all associated data lost. On Apple kitty can remain running with no
|
||||
// OS Windows.
|
||||
static NSOpenGLContext* globally_shared_context = nil;
|
||||
|
||||
// Terminate OpenGL support
|
||||
//
|
||||
void _glfwTerminateNSGL(void)
|
||||
{
|
||||
void _glfwTerminateNSGL(void) {
|
||||
if (globally_shared_context != nil) {
|
||||
[globally_shared_context release];
|
||||
globally_shared_context = nil;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Create the OpenGL context
|
||||
//
|
||||
bool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||
|
|
@ -272,7 +282,7 @@ bool _glfwCreateContextNSGL(_GLFWwindow* window,
|
|||
return false;
|
||||
}
|
||||
|
||||
NSOpenGLContext* share = nil;
|
||||
NSOpenGLContext* share = globally_shared_context;
|
||||
|
||||
if (ctxconfig->share)
|
||||
share = ctxconfig->share->context.nsgl.object;
|
||||
|
|
@ -286,6 +296,9 @@ bool _glfwCreateContextNSGL(_GLFWwindow* window,
|
|||
"NSGL: Failed to create OpenGL context");
|
||||
return false;
|
||||
}
|
||||
if (globally_shared_context == nil) {
|
||||
globally_shared_context = [window->context.nsgl.object retain];
|
||||
}
|
||||
|
||||
if (fbconfig->transparent)
|
||||
{
|
||||
|
|
|
|||
12
kitty/glfw.c
12
kitty/glfw.c
|
|
@ -1092,7 +1092,6 @@ change_state_for_os_window(OSWindow *w, int state) {
|
|||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
static GLFWwindow *apple_preserve_common_context = NULL;
|
||||
|
||||
static int
|
||||
filter_option(int key UNUSED, int mods, unsigned int native_key UNUSED, unsigned long flags) {
|
||||
|
|
@ -1410,13 +1409,6 @@ create_os_window(PyObject UNUSED *self, PyObject *args, PyObject *kw) {
|
|||
// used, so start with window visible unless hidden window requested.
|
||||
GLFWwindow *common_context = global_state.num_os_windows ? global_state.os_windows[0].handle : NULL;
|
||||
GLFWwindow *temp_window = NULL;
|
||||
#ifdef __APPLE__
|
||||
if (!apple_preserve_common_context) {
|
||||
glfwWindowHint(GLFW_VISIBLE, false);
|
||||
apple_preserve_common_context = glfwCreateWindow(1, 1, "kitty", NULL, common_context, NULL);
|
||||
}
|
||||
if (!common_context) common_context = apple_preserve_common_context;
|
||||
#endif
|
||||
glfwWindowHint(GLFW_VISIBLE, window_state != WINDOW_HIDDEN && global_state.is_wayland);
|
||||
float xscale, yscale;
|
||||
double xdpi, ydpi;
|
||||
|
|
@ -2461,10 +2453,6 @@ run_main_loop(tick_callback_fun cb, void* cb_data) {
|
|||
|
||||
void
|
||||
stop_main_loop(void) {
|
||||
#ifdef __APPLE__
|
||||
if (apple_preserve_common_context) glfwDestroyWindow(apple_preserve_common_context);
|
||||
apple_preserve_common_context = NULL;
|
||||
#endif
|
||||
glfwStopMainLoop();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue