mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-22 18:09:49 +01:00
render: egl: Use current display to restore NULL context
eglGetCurrentDisplay() returns EGL_NO_DISPLAY when there is no context current and eglMakeCurrent() needs a display argument. Fixes #2327
This commit is contained in:
parent
842df2bd6c
commit
6ef5d18757
1 changed files with 14 additions and 1 deletions
15
render/egl.c
15
render/egl.c
|
@ -459,7 +459,20 @@ void wlr_egl_save_context(struct wlr_egl_context *context) {
|
|||
}
|
||||
|
||||
bool wlr_egl_restore_context(struct wlr_egl_context *context) {
|
||||
return eglMakeCurrent(context->display, context->draw_surface,
|
||||
// If the saved context is a null-context, we must use the current
|
||||
// display instead of the saved display because eglMakeCurrent() can't
|
||||
// handle EGL_NO_DISPLAY.
|
||||
EGLDisplay display = context->display == EGL_NO_DISPLAY ?
|
||||
eglGetCurrentDisplay() : context->display;
|
||||
|
||||
// If the current display is also EGL_NO_DISPLAY, we assume that there
|
||||
// is currently no context set and no action needs to be taken to unset
|
||||
// the context.
|
||||
if (display == EGL_NO_DISPLAY) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return eglMakeCurrent(display, context->draw_surface,
|
||||
context->read_surface, context->context);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue