[vim/vim] Add --enable-gui=gtk4 support (PR #19815)

23 views
Skip to first unread message

mattn

unread,
Mar 25, 2026, 3:50:24 AM (yesterday) Mar 25
to vim/vim, Subscribed

Add GTK4 GUI backend using separate source files instead of adding conditional branches to the existing GTK2/GTK3 code. GTK4's API changes are too fundamental for #if branching to be maintainable.

This PR was developed with the assistance of Claude Code (Anthropic).

Build

./configure --enable-gui=gtk4
make

Requires GTK 4.10+ (for GtkFontDialog).

New files

  • gui_gtk4_f.c/h — GtkForm widget (extends GtkWidget, uses GskTransform)
  • gui_gtk4_x11.c — Main GUI implementation (events, drawing, fonts, colors)
  • gui_gtk4.c — Scrollbars, dialogs, menu stubs

What works

  • Window display and resizing
  • Text rendering (Pango glyph string based)
  • Key input via GtkEventController
  • Mouse events (click, motion, scroll, focus)
  • Background/foreground colors and colorschemes
  • Font selection dialog (:set guifont=*) via GtkFontDialog
  • Scrollbar show/hide
  • :q! exit
  • Plugin compatibility (vim-lsp, vim-lsp-settings)

What's not implemented yet

  • Menu system (GTK4 uses GMenu/GtkPopoverMenuBar)
  • Toolbar
  • File chooser dialog (:browse)
  • Message dialog (gui_mch_dialog)
  • Find/Replace dialog
  • Clipboard (GTK4 uses GdkClipboard)
  • Cursor blinking
  • Screen scrolling (gui_mch_delete_lines / gui_mch_insert_lines)
  • Drag and drop
  • XIM input method support
  • Sign icons
  • Balloon eval (tooltips)

This is a work in progress.


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

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

Commit Summary

  • f58481f Add 'pumopacity' option for popup menu transparency
  • c072e40 pumopacity: move blend processing into screen_puts_len/screen_fill
  • 31efdf1 pumopacity: add hl_pum_blend_attr() for correct fg/bg blending
  • 97c745e pumopacity: remove dead code and fix duplicate condition
  • 5311443 pumopacity: add tests for 'pumopacity' option
  • f7cf5cb pumopacity: remove stray blank line in popupmenu.c
  • 1abdde6 pumopacity: fix build error when FEAT_PROP_POPUP is not defined
  • 26ba5c6 pumopacity: mark blend param UNUSED in hl_pum_blend_attr()
  • 79ef5cd pumopacity: fix did_set_pumopacity() order in proto file
  • 5aedbfe Fix pum opacity background mismatch after window resize
  • c563743 pumopacity: fix option sort order in optiondefs.h
  • 1667043 Add 'pumopt' option to consolidate pum settings
  • 6f50ba8 Remove 'pumopacity' option, use 'pumopt' opacity: instead
  • b584731 Add 'pumopt' tag to doc/tags
  • f3f49e6 Add --enable-gui=gtk4 support with separate GTK4 implementation

File Changes

(36 files)

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/19815@github.com>

mattn

unread,
Mar 25, 2026, 3:52:34 AM (yesterday) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • 311b6cf Add --enable-gui=gtk4 support with separate GTK4 implementation


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/f3f49e6bf44e9bc46b14da835c156d125a92be46/after/311b6cf711abd65e5f85c04da375ed84716e1ad1@github.com>

mattn

unread,
Mar 25, 2026, 9:50:19 AM (21 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • 7328942 GTK4: implement cursor, scrolling, mouse, dialogs


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/311b6cf711abd65e5f85c04da375ed84716e1ad1/after/7328942e9f8cb070a3d3e9c977eb65bd6bd87fee@github.com>

mattn

unread,
Mar 25, 2026, 10:11:32 AM (20 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • 0a8b2b7 GTK4: implement clipboard, signs, tabline, mouse shape, and more


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/7328942e9f8cb070a3d3e9c977eb65bd6bd87fee/after/0a8b2b75f470ed98bce0fddf74aa557383517ef2@github.com>

mattn

unread,
Mar 25, 2026, 10:18:28 AM (20 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • 3965ef6 GTK4: default window size to 80x24


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/0a8b2b75f470ed98bce0fddf74aa557383517ef2/after/3965ef63426365712adf3c0aefd6ebc256b4c00a@github.com>

mattn

unread,
Mar 25, 2026, 10:22:41 AM (20 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • 9d95aae GTK4: implement drag-and-drop, geometry, cleanup


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/3965ef63426365712adf3c0aefd6ebc256b4c00a/after/9d95aaee9e8162cc38ffac54962dfe98d6f24094@github.com>

mattn

unread,
Mar 25, 2026, 11:01:51 AM (20 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • 7f9cead GTK4: add GtkIMContext input method support


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/9d95aaee9e8162cc38ffac54962dfe98d6f24094/after/7f9cead4895cadea16bb2b7e800e9a9973e7d737@github.com>

mattn

unread,
Mar 25, 2026, 11:09:12 AM (19 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • 2c5b2f2 GTK4: implement Find/Replace dialog


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/7f9cead4895cadea16bb2b7e800e9a9973e7d737/after/2c5b2f28c0c1b790023a6fdbddc1b6bee5233d3c@github.com>

mattn

unread,
Mar 25, 2026, 11:13:52 AM (19 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/2c5b2f28c0c1b790023a6fdbddc1b6bee5233d3c/after/8f930602896e12971f2908865c6dbb69debe4217@github.com>

mattn

unread,
Mar 25, 2026, 11:18:39 AM (19 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/8f930602896e12971f2908865c6dbb69debe4217/after/2a841df6e91a95dd20cd42b46be4cdd49c074c83@github.com>

mattn

unread,
Mar 25, 2026, 12:01:52 PM (19 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • 006fedf GTK4: fix white screen and resize loop


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/565b3198d51c34c79ab8387f936b2ec83923b399/after/006fedfa8dbafe2c7b5f2fe04f9c2fe83cda1992@github.com>

mattn

unread,
Mar 25, 2026, 12:11:08 PM (18 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • 84765e0 GTK4: implement menu system with GMenu/GtkPopoverMenuBar


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/006fedfa8dbafe2c7b5f2fe04f9c2fe83cda1992/after/84765e05d40a02c38e6f1b60b74930f6886b1c88@github.com>

mattn

unread,
Mar 25, 2026, 12:55:04 PM (18 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • 6d5eb11 GTK4: fix resize handling and scrollbar layout


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/84765e05d40a02c38e6f1b60b74930f6886b1c88/after/6d5eb1115eab11c9c2a0209a20e922d5ca738513@github.com>

mattn

unread,
Mar 25, 2026, 1:18:46 PM (17 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • 94732fa GTK4: fix vertical resize shrink


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/6d5eb1115eab11c9c2a0209a20e922d5ca738513/after/94732fa4255a8a7e0de5a13e0e3272aa77d4c273@github.com>

Christian Brabandt

unread,
Mar 25, 2026, 3:46:54 PM (15 hours ago) Mar 25
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19815)

wow, very nice. Can you share a screenshot of vim --clean -g ?


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/19815/c4129319385@github.com>

Foxe Chen

unread,
Mar 25, 2026, 7:07:00 PM (12 hours ago) Mar 25
to vim/vim, Subscribed
64-bitman left a comment (vim/vim#19815)

I think the GTK4 port of GVim should focus more on Wayland instead of X11, which is already deprecated and will be removed in GTK5. I suppose there are issues with keyboard layout detection, but there a much more users that have it working fine. Having a 2800 line file called "gui_gtk4_x11.c" does not feel right...


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/19815/c4130395354@github.com>

mattn

unread,
Mar 25, 2026, 8:27:29 PM (10 hours ago) Mar 25
to vim/vim, Subscribed
mattn left a comment (vim/vim#19815)

@chrisbra

Default GDK backend is x11

image.png (view on web) image.png (view on web) image.png (view on web) image.png (view on web)
$ GDK_BACKEND=wayland GSK_RENDERER=cairo ./vim -gf
image.png (view on web)


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/19815/c4130712103@github.com>

mattn

unread,
Mar 25, 2026, 8:28:11 PM (10 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • cd26f51 GTK4: use GtkOverlay for drawarea auto-resize


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/94732fa4255a8a7e0de5a13e0e3272aa77d4c273/after/cd26f519ae83fa838b57c47e999181c1276fbcd1@github.com>

mattn

unread,
Mar 25, 2026, 8:31:12 PM (10 hours ago) Mar 25
to vim/vim, Subscribed
mattn left a comment (vim/vim#19815)

Currently the only X11 dependency in the GTK4 backend is XParseGeometry from <X11/Xutil.h>. By implementing our own geometry parser, we can remove the X11 dependency entirely and switch the default GDK_BACKEND to Wayland.


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/19815/c4130724398@github.com>

mattn

unread,
Mar 25, 2026, 8:32:11 PM (10 hours ago) Mar 25
to vim/vim, Subscribed
mattn left a comment (vim/vim#19815)

This also means we could rename gui_gtk4_x11.c to gui_gtk4.c since it would no longer have any X11 dependency.


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/19815/c4130727588@github.com>

mattn

unread,
Mar 25, 2026, 9:12:15 PM (9 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • 3c70ced GTK4: add new files to Filelist for CI packaging check


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/cd26f519ae83fa838b57c47e999181c1276fbcd1/after/3c70cedc32f08c19673a8d092a33c4bca8f9bed8@github.com>

mattn

unread,
Mar 25, 2026, 10:44:52 PM (8 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • 42c3d16 GTK4: merge gui_gtk4_x11.c into gui_gtk4.c


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/3c70cedc32f08c19673a8d092a33c4bca8f9bed8/after/42c3d1697f0659d90c966426e8e08f36fd1eb6b7@github.com>

mattn

unread,
Mar 25, 2026, 11:01:42 PM (8 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • 13343a1 GTK4: fix preprocessor indent in gui_xim.c


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/42c3d1697f0659d90c966426e8e08f36fd1eb6b7/after/13343a1106d36791c86b18ec587c3f9db9c97548@github.com>

mattn

unread,
Mar 25, 2026, 11:06:41 PM (8 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • ab3601d GTK4: suppress EGL warnings when GL is unavailable


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/13343a1106d36791c86b18ec587c3f9db9c97548/after/ab3601d18477100a1a0cc53e7e531a03929fd3af@github.com>

mattn

unread,
Mar 25, 2026, 11:28:03 PM (7 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • 37cfce5 GTK4: fix scrollbar CRITICAL warnings


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/ab3601d18477100a1a0cc53e7e531a03929fd3af/after/37cfce59dd787747547f0576a5a4f102d61169ee@github.com>

mattn

unread,
Mar 25, 2026, 11:43:21 PM (7 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • 4d8ff9f GTK4: remove direct X11 dependency


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/37cfce59dd787747547f0576a5a4f102d61169ee/after/4d8ff9f59a36e290753e5d8a828d6604ddbc04d6@github.com>

mattn

unread,
Mar 25, 2026, 11:46:14 PM (7 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • 3c84d69 GTK4: remove direct X11 dependency


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/4d8ff9f59a36e290753e5d8a828d6604ddbc04d6/after/3c84d69946c1a4f78ca78ee804c99d30c68efc06@github.com>

mattn

unread,
Mar 25, 2026, 11:47:43 PM (7 hours ago) Mar 25
to vim/vim, Push

@mattn pushed 1 commit.

  • cb39dfa GTK4: remove direct X11 dependency


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/3c84d69946c1a4f78ca78ee804c99d30c68efc06/after/cb39dfa10795a9743bd4c8a9734d90a598e9304a@github.com>

mattn

unread,
Mar 25, 2026, 11:53:22 PM (7 hours ago) Mar 25
to vim/vim, Subscribed
mattn left a comment (vim/vim#19815)
The GTK4 port now has zero direct X11 dependency 💪

$ nm -u ./vim | grep -i '^.\+U.*X[A-Z]' | grep -v 'gdk\|gtk\|glib\|pango\|cairo\|GLIBC\|g_\|getx'
(no output)

The X11 libraries shown by ldd are all indirect dependencies pulled in by libgtk-4.so itself, not by Vim's code.


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/19815/c4131448529@github.com>

mattn

unread,
12:33 AM (6 hours ago) 12:33 AM
to vim/vim, Push

@mattn pushed 1 commit.

  • 3faccb8 GTK4: fix text rendering, wide chars, and cursor focus


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/cb39dfa10795a9743bd4c8a9734d90a598e9304a/after/3faccb889a0856d6d5a8e3c7c670b4f2ebafd241@github.com>

mattn

unread,
12:35 AM (6 hours ago) 12:35 AM
to vim/vim, Subscribed
mattn left a comment (vim/vim#19815)

Multi-byte characters are now rendering correctly. Getting close to completion.

image.png (view on web)


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/19815/c4131597573@github.com>

Foxe Chen

unread,
5:03 AM (2 hours ago) 5:03 AM
to vim/vim, Subscribed
64-bitman left a comment (vim/vim#19815)

I am getting build errors when trying to compile this PR. It seems that multiple functions in gui_gtk4.c are not exposed in the .pro file


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/19815/c4132849630@github.com>

mattn

unread,
6:24 AM (14 minutes ago) 6:24 AM
to vim/vim, Push

@mattn pushed 1 commit.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19815/before/3faccb889a0856d6d5a8e3c7c670b4f2ebafd241/after/7db1c98d1dba503ad00312cab3603ff94732264a@github.com>

mattn

unread,
6:25 AM (13 minutes ago) 6:25 AM
to vim/vim, Subscribed
mattn left a comment (vim/vim#19815)

Sorry, the proto file was broken when gui_gtk4_x11.c was merged into gui_gtk4.c. It should be fixed now.


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/19815/c4133397059@github.com>

Reply all
Reply to author
Forward
0 new messages