Dont store standard cursors on the window object
This commit is contained in:
parent
eb32423fb6
commit
6b9303ba7d
19
kitty/glfw.c
19
kitty/glfw.c
@ -41,12 +41,13 @@ typedef struct {
|
|||||||
bool is_set;
|
bool is_set;
|
||||||
} GLFWWindowGeometry;
|
} GLFWWindowGeometry;
|
||||||
|
|
||||||
|
static GLFWcursor *standard_cursor = NULL, *click_cursor = NULL, *arrow_cursor = NULL;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
|
|
||||||
GLFWwindow *window;
|
GLFWwindow *window;
|
||||||
PyObject *framebuffer_size_callback, *window_focus_callback;
|
PyObject *framebuffer_size_callback, *window_focus_callback;
|
||||||
GLFWcursor *standard_cursor, *click_cursor, *arrow_cursor;
|
|
||||||
GLFWWindowGeometry before_fullscreen;
|
GLFWWindowGeometry before_fullscreen;
|
||||||
} WindowWrapper;
|
} WindowWrapper;
|
||||||
|
|
||||||
@ -130,13 +131,13 @@ void
|
|||||||
set_mouse_cursor(MouseShape type) {
|
set_mouse_cursor(MouseShape type) {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case HAND:
|
case HAND:
|
||||||
glfwSetCursor(the_window->window, the_window->click_cursor);
|
glfwSetCursor(the_window->window, click_cursor);
|
||||||
break;
|
break;
|
||||||
case ARROW:
|
case ARROW:
|
||||||
glfwSetCursor(the_window->window, the_window->arrow_cursor);
|
glfwSetCursor(the_window->window, arrow_cursor);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
glfwSetCursor(the_window->window, the_window->standard_cursor);
|
glfwSetCursor(the_window->window, standard_cursor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,11 +156,13 @@ new(PyTypeObject *type, PyObject *args, PyObject UNUSED *kwds) {
|
|||||||
self->window = glfwCreateWindow(width, height, title, NULL, NULL);
|
self->window = glfwCreateWindow(width, height, title, NULL, NULL);
|
||||||
if (self->window == NULL) { Py_CLEAR(self); the_window = NULL; PyErr_SetString(PyExc_ValueError, "Failed to create GLFWwindow"); return NULL; }
|
if (self->window == NULL) { Py_CLEAR(self); the_window = NULL; PyErr_SetString(PyExc_ValueError, "Failed to create GLFWwindow"); return NULL; }
|
||||||
update_viewport(self->window);
|
update_viewport(self->window);
|
||||||
self->standard_cursor = glfwCreateStandardCursor(GLFW_IBEAM_CURSOR);
|
if (standard_cursor == NULL) {
|
||||||
self->click_cursor = glfwCreateStandardCursor(GLFW_HAND_CURSOR);
|
standard_cursor = glfwCreateStandardCursor(GLFW_IBEAM_CURSOR);
|
||||||
self->arrow_cursor = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
|
click_cursor = glfwCreateStandardCursor(GLFW_HAND_CURSOR);
|
||||||
if (self->standard_cursor == NULL || self->click_cursor == NULL || self->arrow_cursor == NULL) {
|
arrow_cursor = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
|
||||||
|
if (standard_cursor == NULL || click_cursor == NULL || arrow_cursor == NULL) {
|
||||||
Py_CLEAR(self); PyErr_SetString(PyExc_ValueError, "Failed to create standard mouse cursors"); return NULL; }
|
Py_CLEAR(self); PyErr_SetString(PyExc_ValueError, "Failed to create standard mouse cursors"); return NULL; }
|
||||||
|
}
|
||||||
set_mouse_cursor(0);
|
set_mouse_cursor(0);
|
||||||
glfwSetFramebufferSizeCallback(self->window, framebuffer_size_callback);
|
glfwSetFramebufferSizeCallback(self->window, framebuffer_size_callback);
|
||||||
glfwSetCharModsCallback(self->window, char_mods_callback);
|
glfwSetCharModsCallback(self->window, char_mods_callback);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user