From 187fa996f89295e3fe30c0ab10061c5e5a5f2c2b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 16 Oct 2023 20:33:12 +0530 Subject: [PATCH] Add the cell pointer shape --- docs/pointer-shapes.rst | 1 + gen/cursors.py | 1 + glfw/cocoa_window.m | 1 + glfw/glfw3.h | 1 + glfw/wl_window.c | 1 + glfw/x11_window.c | 1 + kitty/data-types.h | 1 + kitty/glfw-wrapper.h | 1 + kitty/glfw.c | 3 +++ kitty/options/definition.py | 1 + kitty/options/to-c.h | 1 + kitty/screen.c | 4 ++++ tools/tui/loop/mouse.go | 47 ++++++++++++++++++++----------------- 13 files changed, 42 insertions(+), 22 deletions(-) diff --git a/docs/pointer-shapes.rst b/docs/pointer-shapes.rst index 20b95148c..34698e899 100644 --- a/docs/pointer-shapes.rst +++ b/docs/pointer-shapes.rst @@ -119,6 +119,7 @@ characters from the set ``a-z0-9_-``. .. start list of shape css names (auto generated by gen-key-constants.py do not edit) #. alias +#. cell #. copy #. crosshair #. default diff --git a/gen/cursors.py b/gen/cursors.py index 9eb39d430..8b0703f94 100755 --- a/gen/cursors.py +++ b/gen/cursors.py @@ -28,6 +28,7 @@ help help help,!question_arrow,whats_this help wait wait wait,!clock,watch wait busybutclickable:arrowCursor progress progress progress,half-busy,left_ptr_watch progress busybutclickable:arrowCursor crosshair crosshair crosshair,!tcross crosshair crosshairCursor +cell cell cell,!plus,!cross cell cell:crosshairCursor vertical-text vertical-text vertical-text vertical-text IBeamCursorForVerticalLayout move move move,!fleur,pointer-move move move:openHandCursor diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index a4d542346..5450eded5 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -2556,6 +2556,7 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, GLFWCursorShape shape S(GLFW_WAIT_CURSOR, busybutclickable, arrowCursor); S(GLFW_PROGRESS_CURSOR, busybutclickable, arrowCursor); C(GLFW_CROSSHAIR_CURSOR, crosshairCursor); + S(GLFW_CELL_CURSOR, cell, crosshairCursor); C(GLFW_VERTICAL_TEXT_CURSOR, IBeamCursorForVerticalLayout); S(GLFW_MOVE_CURSOR, move, openHandCursor); C(GLFW_E_RESIZE_CURSOR, resizeRightCursor); diff --git a/glfw/glfw3.h b/glfw/glfw3.h index 7e5cde34c..28b2fcb0e 100644 --- a/glfw/glfw3.h +++ b/glfw/glfw3.h @@ -1107,6 +1107,7 @@ typedef enum { GLFW_WAIT_CURSOR, GLFW_PROGRESS_CURSOR, GLFW_CROSSHAIR_CURSOR, + GLFW_CELL_CURSOR, GLFW_VERTICAL_TEXT_CURSOR, GLFW_MOVE_CURSOR, GLFW_E_RESIZE_CURSOR, diff --git a/glfw/wl_window.c b/glfw/wl_window.c index bb9752fd6..f812d4e63 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -839,6 +839,7 @@ struct wl_cursor* _glfwLoadCursor(GLFWCursorShape shape, struct wl_cursor_theme* C(GLFW_WAIT_CURSOR, "wait", "clock", "watch"); C(GLFW_PROGRESS_CURSOR, "progress", "half-busy", "left_ptr_watch"); C(GLFW_CROSSHAIR_CURSOR, "crosshair", "tcross"); + C(GLFW_CELL_CURSOR, "cell", "plus", "cross"); C(GLFW_VERTICAL_TEXT_CURSOR, "vertical-text"); C(GLFW_MOVE_CURSOR, "move", "fleur", "pointer-move"); C(GLFW_E_RESIZE_CURSOR, "e-resize", "right_side"); diff --git a/glfw/x11_window.c b/glfw/x11_window.c index e4fb5cbfc..23efd4893 100644 --- a/glfw/x11_window.c +++ b/glfw/x11_window.c @@ -2854,6 +2854,7 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, GLFWCursorShape shape case GLFW_WAIT_CURSOR: return set_cursor_from_font(cursor, XC_clock); case GLFW_PROGRESS_CURSOR: return try_cursor_names(cursor, 3, "progress", "half-busy", "left_ptr_watch"); case GLFW_CROSSHAIR_CURSOR: return set_cursor_from_font(cursor, XC_tcross); + case GLFW_CELL_CURSOR: return set_cursor_from_font(cursor, XC_plus); case GLFW_VERTICAL_TEXT_CURSOR: return try_cursor_names(cursor, 1, "vertical-text"); case GLFW_MOVE_CURSOR: return set_cursor_from_font(cursor, XC_fleur); case GLFW_E_RESIZE_CURSOR: return set_cursor_from_font(cursor, XC_right_side); diff --git a/kitty/data-types.h b/kitty/data-types.h index 23fc17f27..440eea9cb 100644 --- a/kitty/data-types.h +++ b/kitty/data-types.h @@ -78,6 +78,7 @@ typedef enum MouseShapes { WAIT_POINTER, PROGRESS_POINTER, CROSSHAIR_POINTER, + CELL_POINTER, VERTICAL_TEXT_POINTER, MOVE_POINTER, E_RESIZE_POINTER, diff --git a/kitty/glfw-wrapper.h b/kitty/glfw-wrapper.h index 941a164f3..88b3a2e71 100644 --- a/kitty/glfw-wrapper.h +++ b/kitty/glfw-wrapper.h @@ -845,6 +845,7 @@ typedef enum { GLFW_WAIT_CURSOR, GLFW_PROGRESS_CURSOR, GLFW_CROSSHAIR_CURSOR, + GLFW_CELL_CURSOR, GLFW_VERTICAL_TEXT_CURSOR, GLFW_MOVE_CURSOR, GLFW_E_RESIZE_CURSOR, diff --git a/kitty/glfw.c b/kitty/glfw.c index 7508a7964..c34db7393 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -703,6 +703,7 @@ set_mouse_cursor(MouseShape type) { case WAIT_POINTER: set_glfw_mouse_cursor(w, GLFW_WAIT_CURSOR); break; case PROGRESS_POINTER: set_glfw_mouse_cursor(w, GLFW_PROGRESS_CURSOR); break; case CROSSHAIR_POINTER: set_glfw_mouse_cursor(w, GLFW_CROSSHAIR_CURSOR); break; + case CELL_POINTER: set_glfw_mouse_cursor(w, GLFW_CELL_CURSOR); break; case VERTICAL_TEXT_POINTER: set_glfw_mouse_cursor(w, GLFW_VERTICAL_TEXT_CURSOR); break; case MOVE_POINTER: set_glfw_mouse_cursor(w, GLFW_MOVE_CURSOR); break; case E_RESIZE_POINTER: set_glfw_mouse_cursor(w, GLFW_E_RESIZE_CURSOR); break; @@ -1740,6 +1741,7 @@ pointer_name_to_glfw_name(const char *name) { if (strcmp(name, "wait") == 0) return GLFW_WAIT_CURSOR; if (strcmp(name, "progress") == 0) return GLFW_PROGRESS_CURSOR; if (strcmp(name, "crosshair") == 0) return GLFW_CROSSHAIR_CURSOR; + if (strcmp(name, "cell") == 0) return GLFW_CELL_CURSOR; if (strcmp(name, "vertical-text") == 0) return GLFW_VERTICAL_TEXT_CURSOR; if (strcmp(name, "move") == 0) return GLFW_MOVE_CURSOR; if (strcmp(name, "e-resize") == 0) return GLFW_E_RESIZE_CURSOR; @@ -1787,6 +1789,7 @@ glfw_name_to_css_pointer_name(GLFWCursorShape q) { case GLFW_WAIT_CURSOR: return "wait"; case GLFW_PROGRESS_CURSOR: return "progress"; case GLFW_CROSSHAIR_CURSOR: return "crosshair"; + case GLFW_CELL_CURSOR: return "cell"; case GLFW_VERTICAL_TEXT_CURSOR: return "vertical-text"; case GLFW_MOVE_CURSOR: return "move"; case GLFW_E_RESIZE_CURSOR: return "e-resize"; diff --git a/kitty/options/definition.py b/kitty/options/definition.py index 9a5a41c6a..8e0e72217 100644 --- a/kitty/options/definition.py +++ b/kitty/options/definition.py @@ -601,6 +601,7 @@ pointer_shape_names = ( 'wait', 'progress', 'crosshair', + 'cell', 'vertical-text', 'move', 'e-resize', diff --git a/kitty/options/to-c.h b/kitty/options/to-c.h index 9356751ee..b9b0f0b0f 100644 --- a/kitty/options/to-c.h +++ b/kitty/options/to-c.h @@ -144,6 +144,7 @@ pointer_shape(PyObject *shape_name) { else if (strcmp(name, "wait") == 0) return WAIT_POINTER; else if (strcmp(name, "progress") == 0) return PROGRESS_POINTER; else if (strcmp(name, "crosshair") == 0) return CROSSHAIR_POINTER; + else if (strcmp(name, "cell") == 0) return CELL_POINTER; else if (strcmp(name, "vertical-text") == 0) return VERTICAL_TEXT_POINTER; else if (strcmp(name, "move") == 0) return MOVE_POINTER; else if (strcmp(name, "e-resize") == 0) return E_RESIZE_POINTER; diff --git a/kitty/screen.c b/kitty/screen.c index ecd6b1b56..b5c516a23 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -1164,6 +1164,7 @@ current_pointer_shape(Screen *self, PyObject *args UNUSED) { case WAIT_POINTER: ans = "wait"; break; case PROGRESS_POINTER: ans = "progress"; break; case CROSSHAIR_POINTER: ans = "crosshair"; break; + case CELL_POINTER: ans = "cell"; break; case VERTICAL_TEXT_POINTER: ans = "vertical-text"; break; case MOVE_POINTER: ans = "move"; break; case E_RESIZE_POINTER: ans = "e-resize"; break; @@ -1212,6 +1213,7 @@ change_pointer_shape(Screen *self, PyObject *args) { else if (strcmp("wait", css_name) == 0) s = WAIT_POINTER; else if (strcmp("progress", css_name) == 0) s = PROGRESS_POINTER; else if (strcmp("crosshair", css_name) == 0) s = CROSSHAIR_POINTER; + else if (strcmp("cell", css_name) == 0) s = CELL_POINTER; else if (strcmp("vertical-text", css_name) == 0) s = VERTICAL_TEXT_POINTER; else if (strcmp("move", css_name) == 0) s = MOVE_POINTER; else if (strcmp("e-resize", css_name) == 0) s = E_RESIZE_POINTER; @@ -1247,6 +1249,8 @@ change_pointer_shape(Screen *self, PyObject *args) { else if (strcmp("half-busy", css_name) == 0) s = PROGRESS_POINTER; else if (strcmp("left_ptr_watch", css_name) == 0) s = PROGRESS_POINTER; else if (strcmp("tcross", css_name) == 0) s = CROSSHAIR_POINTER; + else if (strcmp("plus", css_name) == 0) s = CELL_POINTER; + else if (strcmp("cross", css_name) == 0) s = CELL_POINTER; else if (strcmp("fleur", css_name) == 0) s = MOVE_POINTER; else if (strcmp("pointer-move", css_name) == 0) s = MOVE_POINTER; else if (strcmp("right_side", css_name) == 0) s = E_RESIZE_POINTER; diff --git a/tools/tui/loop/mouse.go b/tools/tui/loop/mouse.go index e2592f129..57755459f 100644 --- a/tools/tui/loop/mouse.go +++ b/tools/tui/loop/mouse.go @@ -45,28 +45,29 @@ const ( WAIT_POINTER PointerShape = 4 PROGRESS_POINTER PointerShape = 5 CROSSHAIR_POINTER PointerShape = 6 - VERTICAL_TEXT_POINTER PointerShape = 7 - MOVE_POINTER PointerShape = 8 - E_RESIZE_POINTER PointerShape = 9 - NE_RESIZE_POINTER PointerShape = 10 - NW_RESIZE_POINTER PointerShape = 11 - N_RESIZE_POINTER PointerShape = 12 - SE_RESIZE_POINTER PointerShape = 13 - SW_RESIZE_POINTER PointerShape = 14 - S_RESIZE_POINTER PointerShape = 15 - W_RESIZE_POINTER PointerShape = 16 - EW_RESIZE_POINTER PointerShape = 17 - NS_RESIZE_POINTER PointerShape = 18 - NESW_RESIZE_POINTER PointerShape = 19 - NWSE_RESIZE_POINTER PointerShape = 20 - ZOOM_IN_POINTER PointerShape = 21 - ZOOM_OUT_POINTER PointerShape = 22 - ALIAS_POINTER PointerShape = 23 - COPY_POINTER PointerShape = 24 - NOT_ALLOWED_POINTER PointerShape = 25 - NO_DROP_POINTER PointerShape = 26 - GRAB_POINTER PointerShape = 27 - GRABBING_POINTER PointerShape = 28 + CELL_POINTER PointerShape = 7 + VERTICAL_TEXT_POINTER PointerShape = 8 + MOVE_POINTER PointerShape = 9 + E_RESIZE_POINTER PointerShape = 10 + NE_RESIZE_POINTER PointerShape = 11 + NW_RESIZE_POINTER PointerShape = 12 + N_RESIZE_POINTER PointerShape = 13 + SE_RESIZE_POINTER PointerShape = 14 + SW_RESIZE_POINTER PointerShape = 15 + S_RESIZE_POINTER PointerShape = 16 + W_RESIZE_POINTER PointerShape = 17 + EW_RESIZE_POINTER PointerShape = 18 + NS_RESIZE_POINTER PointerShape = 19 + NESW_RESIZE_POINTER PointerShape = 20 + NWSE_RESIZE_POINTER PointerShape = 21 + ZOOM_IN_POINTER PointerShape = 22 + ZOOM_OUT_POINTER PointerShape = 23 + ALIAS_POINTER PointerShape = 24 + COPY_POINTER PointerShape = 25 + NOT_ALLOWED_POINTER PointerShape = 26 + NO_DROP_POINTER PointerShape = 27 + GRAB_POINTER PointerShape = 28 + GRABBING_POINTER PointerShape = 29 // end pointer shape enum ) @@ -88,6 +89,8 @@ func (e PointerShape) String() string { return "progress" case CROSSHAIR_POINTER: return "crosshair" + case CELL_POINTER: + return "cell" case VERTICAL_TEXT_POINTER: return "vertical-text" case MOVE_POINTER: