mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-23 16:58:09 +02:00
fix blank screen on macOS resume from sleep
This commit is contained in:
@@ -3818,6 +3818,51 @@ GLFWAPI void glfwCocoaRequestRenderFrame(GLFWwindow *w, GLFWcocoarenderframefun
|
||||
requestRenderFrame((_GLFWwindow*)w, callback);
|
||||
}
|
||||
|
||||
GLFWAPI bool glfwCocoaRecreateGLDrawable(GLFWwindow *w) {
|
||||
_GLFWwindow* window = (_GLFWwindow*)w;
|
||||
if (window->context.client == GLFW_NO_API) return false;
|
||||
@try {
|
||||
// Save current state
|
||||
NSOpenGLPixelFormat *pixelFormat = window->context.nsgl.pixelFormat;
|
||||
NSOpenGLContext *oldContext = window->context.nsgl.object;
|
||||
|
||||
// Create a new context sharing resources with the old one
|
||||
NSOpenGLContext *newContext = [[NSOpenGLContext alloc]
|
||||
initWithFormat:pixelFormat
|
||||
shareContext:oldContext];
|
||||
if (newContext == nil) return false;
|
||||
|
||||
// Copy settings from old context
|
||||
GLint opacity = 0;
|
||||
[oldContext getValues:&opacity forParameter:NSOpenGLContextParameterSurfaceOpacity];
|
||||
[newContext setValues:&opacity forParameter:NSOpenGLContextParameterSurfaceOpacity];
|
||||
GLint interval = 0;
|
||||
[newContext setValues:&interval forParameter:NSOpenGLContextParameterSwapInterval];
|
||||
|
||||
// Detach old context
|
||||
[NSOpenGLContext clearCurrentContext];
|
||||
[oldContext clearDrawable];
|
||||
|
||||
// Attach new context to the view
|
||||
[window->ns.view setWantsBestResolutionOpenGLSurface:window->ns.retina];
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
[newContext setView:window->ns.view];
|
||||
#pragma clang diagnostic pop
|
||||
[newContext makeCurrentContext];
|
||||
[newContext update];
|
||||
|
||||
// Replace context
|
||||
window->context.nsgl.object = newContext;
|
||||
[oldContext release];
|
||||
|
||||
} @catch (NSException *e) {
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to recreate NSGL context: %s (%s)", [[e name] UTF8String], [[e reason] UTF8String]);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWcocoarenderframefun glfwCocoaSetWindowResizeCallback(GLFWwindow *w, GLFWcocoarenderframefun cb) {
|
||||
_GLFWwindow* window = (_GLFWwindow*)w;
|
||||
GLFWcocoarenderframefun current = window->ns.resizeCallback;
|
||||
|
||||
@@ -309,6 +309,7 @@ def generate_wrappers(glfw_header: str) -> None:
|
||||
GLFWapplicationwillfinishlaunchingfun glfwSetApplicationWillFinishLaunching(GLFWapplicationwillfinishlaunchingfun callback)
|
||||
uint32_t glfwGetCocoaKeyEquivalent(uint32_t glfw_key, int glfw_mods, int* cocoa_mods)
|
||||
void glfwCocoaRequestRenderFrame(GLFWwindow *w, GLFWcocoarenderframefun callback)
|
||||
bool glfwCocoaRecreateGLDrawable(GLFWwindow *w)
|
||||
GLFWcocoarenderframefun glfwCocoaSetWindowResizeCallback(GLFWwindow *w, GLFWcocoarenderframefun callback)
|
||||
void* glfwGetX11Display(void)
|
||||
unsigned long glfwGetX11Window(GLFWwindow* window)
|
||||
|
||||
Reference in New Issue
Block a user