Get rid of extra global variable

This commit is contained in:
Kovid Goyal
2018-09-07 14:53:29 +05:30
parent b9a93b68c4
commit 1eeaef6dbb

View File

@@ -278,12 +278,11 @@ set_default_window_icon(PyObject UNUSED *self, PyObject *args) {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
static GLFWwindow *current_os_window_ctx = NULL;
void void
make_os_window_context_current(OSWindow *w) { make_os_window_context_current(OSWindow *w) {
if (w->handle != current_os_window_ctx) { GLFWwindow *current_context = glfwGetCurrentContext();
current_os_window_ctx = w->handle; if (w->handle != current_context) {
glfwMakeContextCurrent(w->handle); glfwMakeContextCurrent(w->handle);
} }
} }
@@ -489,7 +488,6 @@ create_os_window(PyObject UNUSED *self, PyObject *args) {
} }
w->logical_dpi_x = dpi_x; w->logical_dpi_y = dpi_y; w->logical_dpi_x = dpi_x; w->logical_dpi_y = dpi_y;
w->fonts_data = fonts_data; w->fonts_data = fonts_data;
current_os_window_ctx = glfw_window;
w->shown_once = true; w->shown_once = true;
push_focus_history(w); push_focus_history(w);
glfwSwapInterval(OPT(sync_to_monitor) ? 1 : 0); glfwSwapInterval(OPT(sync_to_monitor) ? 1 : 0);
@@ -536,7 +534,6 @@ destroy_os_window(OSWindow *w) {
show_mouse_cursor(w->handle); show_mouse_cursor(w->handle);
glfwSetCursor(w->handle, NULL); glfwSetCursor(w->handle, NULL);
glfwDestroyWindow(w->handle); glfwDestroyWindow(w->handle);
if (current_os_window_ctx == w->handle) current_os_window_ctx = NULL;
} }
w->handle = NULL; w->handle = NULL;
#ifdef __APPLE__ #ifdef __APPLE__