[vim/vim] Adopt GTK3 CSS cursor names (PR #14610)

41 views
Skip to first unread message

Drew Vogel

unread,
Apr 21, 2024, 10:39:44 AM4/21/24
to vim/vim, Subscribed

Problem: GTK4 will drop numeric cursor support.
Solution: Adopt GTK3 CSS cursor convention.


I've been working on GTK4 support. GTK3 began the transition to CSS styling for mouse cursors. GTK4 drops almost all X11-specific constructs, including the numeric X cursors. GTK3 began this transition by supporting CSS names for mouse cursors. This PR adopts that convention as a precursor to GTK4 support.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/14610

Commit Summary

  • a491f50 Problem: GTK4 will drop numeric cursor support.

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14610@github.com>

Drew Vogel

unread,
Apr 21, 2024, 10:40:29 AM4/21/24
to vim/vim, Subscribed

@dvogel commented on this pull request.


In src/gui_gtk_x11.c:

> +    "ns-resize",                // GDK_SB_V_DOUBLE_ARROW
+    "nwse-resize",              // GDK_SIZING
+    "ew-resize",                // GDK_SB_H_DOUBLE_ARROW
+    "ew-resize",                // GDK_SIZING
+    "progress",                 // GDK_WATCH
+    "not-allowed",              // GDK_X_CURSOR
+    "crosshair",                // GDK_CROSSHAIR
+    "pointer",                  // GDK_HAND1
+    "pointer",                  // GDK_HAND2
+    "pointer",                  // GDK_PENCIL (no good option for this one)
+    "help",                     // GDK_QUESTION_ARROW
+    "default",                  // GDK_RIGHT_PTR (no css analogue)
+    "default",                  // GDK_CENTER_PTR (no css analogue)
+    "default"                   // GDK_LEFT_PTR
+};
+# endif

These choices are best considered relative to the mshape_ids array above.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14610/review/2013453355@github.com>

Christian Brabandt

unread,
Apr 23, 2024, 2:20:33 PM4/23/24
to vim/vim, Subscribed

Thanks for working on that. I think that makes sense. Do I understand correctly, that this should not break anything on GUI (GTK3) Vim?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14610/c2073089868@github.com>

Drew Vogel

unread,
Apr 23, 2024, 6:33:10 PM4/23/24
to vim/vim, Subscribed

Thanks for working on that. I think that makes sense. Do I understand correctly, that this should not break anything on GUI (GTK3) Vim?

No errors or crashes will occur. However it is not backward compatible. Users who currently use numeric cursor shape IDs or any of the following vim shape names will see different icons. The underlying issue is that gdk_cursor_new_from_name supports fewer cursor shapes than gdk_cursor_new/GdkCursorType does. The latter is based on X11 conventions that are being deprecated by GTK.

  • hand1
  • hand2
  • pencil
  • rightup-arrow
  • up-arrow


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14610/c2073584657@github.com>

Christian Brabandt

unread,
Apr 24, 2024, 3:35:25 PM4/24/24
to vim/vim, Subscribed

Okay, so it looks like we will have those 'mouseshapes':

(System is w for Windows and x for X11, perhaps we should add a G for GTK).

System Vim Name GDK/CSS Name Desc
w x arrow default Normal mouse pointer
w x blank blank no pointer at all (use with care!)
x hand1 pointer black hand
x hand2 pointer white hand
x pencil pointer what you write with
x question help big ?
x crosshair crosshair like a big thin +
w x updown ns-resize up-down sizing arrows
w x leftright ew-resize left-right sizing arrows
w x no not-allowed The system's usual 'no input' pointer
x udsizing ns-resize indicates up-down resizing
x lrsizing ew-resize indicates left-right resizing

Missing:

System Vim Name GDK Name Desc
w x busy The system's usual busy pointer
w x beam I-beam
x rightup-arrow arrow pointing right-up
w x up-arrow arrow pointing up
x any X11 pointer number (see X11/cursorfont.h)

I am a bit surprised we don't have beam and busy. But when this is no longer supported by the underlying library :/

Currently the help states also this:

Any modes not specified or shapes not available use the normal mouse pointer.

So it seems more or less okay? Can we keep the current cursor shapes when we still use GTK2/3 UI?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14610/c2075697342@github.com>

Drew Vogel

unread,
Apr 27, 2024, 9:31:22 AM4/27/24
to vim/vim, Push

@dvogel pushed 1 commit.

  • 3a7fc8d Problem: GTK4 will drop numeric cursor support.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14610/push/18183884463@github.com>

Drew Vogel

unread,
Apr 27, 2024, 10:58:24 AM4/27/24
to vim/vim, Subscribed

We will have support for the vim names beam and busy. They translate to the CSS names text and progress. Here's a couple of screenshots showing how those look on my screen with vim -g --clean -U /dev/null. Please ignore the cursor size. It appears comically large here because the (a) it is configured to be extra large by preference and (b) the default font size is very small.

vim_mouseshape.a.beam.png (view on web)
vim_mouseshape.a.busy.png (view on web)

I like the idea of adding a g for GTK to that table. I'll incorporate that into my next update.

Regarding when to adopt this, I don't have a firm preference. I wanted to start on this because it is coming eventually and would take some discussion. If it is best to delay this until GTK4 that is fine with me. I think one argument for adopting this in GTK3 sooner rather than later relates to GTK2 support. I don't yet have a firm grasp on how hard it will be to maintain support for all of GTK2/3/4. Whatever the absolute effort required, on a relative basis it would be considerably easier to support any two versions of GTK at once. This seems to have been the approach so far. If we decide that we will support only GTK3/4 in vim10 then I think there's two ways to approach that:

  • We could decide that vim with GTK is meant to lean into all of the GTK-isms, including only supporting the X11-isms that have direct Wayland couterparts. This would make Motif the primary means of accessing X11-isms.
  • We could instead decide that vim's GTK3 integration will opt into all of the X11-isms to allow people to maximize their use of X11 until GTK5 support is added. This would mean the only way for gvim users to maximize their use of Wayland would be to use GTK4.

The first option would argue for merging this now. The second option would argue for folding this into the much larger effort to support GTK4.

We currently have a kludge that shunts vim users into X11 even with GTK3 unless they explicitly opt into Wayland. I think that was good when it was added but eventually this will have to be removed.

#if GTK_CHECK_VERSION(3,10,0)
    // Vim currently assumes that Gtk means X11, so it cannot use native Gtk
    // support for other backends such as Wayland.
    //
    // Use an environment variable to enable unfinished Wayland support.
    if (getenv("GVIM_ENABLE_WAYLAND") == NULL)
	gdk_set_allowed_backends("x11");
#endif


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14610/c2080844501@github.com>

Drew Vogel

unread,
Apr 27, 2025, 10:38:55 AM4/27/25
to vim/vim, Push

@dvogel pushed 1 commit.

  • 59d37c9 Problem: GTK4 will drop numeric cursor support.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14610/before/3a7fc8d70c10e7e8c41f3d2426b72813f9b209d8/after/59d37c94959415d1a0a7bb91a3222551a0032e28@github.com>

Christian Brabandt

unread,
May 4, 2025, 3:28:33 PM5/4/25
to vim/vim, Subscribed

@chrisbra commented on this pull request.

Thanks. this looks like we can clean up the GTK code a bit. Didn't you also want to update the help table at :h 'mouseshape'?


In src/gui_gtk_x11.c:

> @@ -7287,12 +7276,26 @@ mch_set_mouse_shape(int shape)
 	    else
 		id &= ~1;	// they are always even (why?)
 	}
+# if GTK_CHECK_VERSION(3,0,0)
+	else if (shape < (int)ARRAY_LENGTH(mshape_css_names))
+	{
+	    css_name = mshape_css_names[shape];
+	}

style, you can get rid of the braces for single line statements.


In src/gui_gtk_x11.c:

>  	else if (shape < (int)ARRAY_LENGTH(mshape_ids))
+	{

also here.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14610/review/2813543421@github.com>

Drew Vogel

unread,
May 6, 2025, 9:53:16 AM5/6/25
to vim/vim, Subscribed
dvogel left a comment (vim/vim#14610)

Thanks. this looks like we can clean up the GTK code a bit. Didn't you also want to update the help table at :h 'mouseshape'?

Yeah, thanks for the reminder. I'll try to update that later today.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14610/c2854665069@github.com>

Drew Vogel

unread,
May 6, 2025, 10:53:52 PM5/6/25
to vim/vim, Push

@dvogel pushed 1 commit.

  • 7839315 Problem: GTK4 will drop numeric cursor support.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14610/before/3a3a9305ac35ce99e8d8bf0476057e50dfc515e6/after/7839315f3c39b4b0457731fb69801dc3ea72843a@github.com>

Drew Vogel

unread,
May 6, 2025, 11:19:42 PM5/6/25
to vim/vim, Push

@dvogel pushed 1 commit.

  • 92617e6 Problem: GTK4 will drop numeric cursor support.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14610/before/7839315f3c39b4b0457731fb69801dc3ea72843a/after/92617e6760f0881fa75d02a7a64833a83ad31890@github.com>

Christian Brabandt

unread,
May 7, 2025, 3:38:34 PM5/7/25
to vim/vim, Subscribed

Closed #14610 via 48b19b2.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14610/issue_event/17562402991@github.com>

Christian Brabandt

unread,
May 7, 2025, 3:38:57 PM5/7/25
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#14610)

thanks


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/14610/c2860012787@github.com>

Reply all
Reply to author
Forward
0 new messages