patch 9.1.1834: MS-Windows: not possible to highlight the title bar

Problem:  MS-Windows: not possible to highlight the title bar
Solution: Make the title/caption bar configurable by introducing the
          'go-C' option value which allows to highlight it using the
          TitleBar and TitleBarNC highlighting groups (Mao-Yining).

Introduce titlebar color customization for Windows 11 GUI through
highlight groups and new 'guioptions' flag:

- Add 'C' flag to enable titlebar color customization (opt-in)
- New highlight groups: TitleBar (active) and TitleBarNC (inactive)
- Uses DWMWA_CAPTION_COLOR and DWMWA_TEXT_COLOR DWM attributes
- Dynamically loads dwmapi.dll for Windows 11 compatibility
- Defaults to system colors when set to NONE or feature disabled

closes: #18449

Signed-off-by: Mao-Yining <mao.yining@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Mao-Yining
2025-10-07 19:31:22 +00:00
committed by Christian Brabandt
parent f8b9251d8f
commit 2c09368273
16 changed files with 255 additions and 15 deletions

View File

@ -1,4 +1,4 @@
*gui_w32.txt* For Vim version 9.1. Last change: 2025 Aug 06
*gui_w32.txt* For Vim version 9.1. Last change: 2025 Oct 07
VIM REFERENCE MANUAL by Bram Moolenaar
@ -488,4 +488,20 @@ VIM_KEYCODE_TRANS_STRATEGY can be set to the desired value ("experimental" or
set VIM_KEYCODE_TRANS_STRATEGY=experimental
gvim.exe
<
Title Bar *gui-w32-title-bar*
Starting with Windows 11, you can customize the gVim title bar (also known as
the caption bar) by enabling the |'go-C'| option.
Once enabled, the appearance is controlled by two highlighting groups:
1. |hl-TitleBar| -- Sets the color of the title bar for the active window.
2. |hl-TitleBarNC| -- Sets the color of the title bar for inactive windows.
To use the system's default title bar colors, set highlighting groups to
`NONE`: >
hi TitleBar guibg=NONE guifg=NONE
hi TitleBarNC guibg=NONE guifg=NONE
vim:tw=78:sw=4:ts=8:noet:ft=help:norl:

View File

@ -1,4 +1,4 @@
*options.txt* For Vim version 9.1. Last change: 2025 Oct 03
*options.txt* For Vim version 9.1. Last change: 2025 Oct 07
VIM REFERENCE MANUAL by Bram Moolenaar
@ -4487,6 +4487,10 @@ A jump table for the options with a short description can be found at |Q_op|.
*'go-c'*
'c' Use console dialogs instead of popup dialogs for simple
choices.
*'go-C'*
'C' Use |hl-TitleBar| and |hl-TitleBarNC| if available.
Currently only works for MS-Window GUI.
See |gui-w32-title-bar| for details.
*'go-d'*
'd' Use dark theme variant if available. Currently only works for
GTK+ GUI.

View File

@ -6092,6 +6092,16 @@ TabPanelSel TabPanel, active tab page label.
Terminal |terminal| window (see |terminal-size-color|).
*hl-Title*
Title Titles for output from ":set all", ":autocmd" etc.
*hl-TitleBar*
TitleBar Title bar for the active Gui's window.
This feature is supported only in the MS-Windows GUI.
See |gui-w32-title-bar| for details
Only the `guibg` and `guifg` highlight arguments are effective.
*hl-TitleBarNC*
TitleBarNC Title bar for inactive Gui's window.
This feature is supported only in the MS-Windows GUI.
See |gui-w32-title-bar| for details
Only the `guibg` and `guifg` highlight arguments are effective.
*hl-Visual*
Visual Visual mode selection.
*hl-VisualNOS*

View File

@ -355,6 +355,7 @@ $quote eval.txt /*$quote*
'go' options.txt /*'go'*
'go-!' options.txt /*'go-!'*
'go-A' options.txt /*'go-A'*
'go-C' options.txt /*'go-C'*
'go-F' options.txt /*'go-F'*
'go-L' options.txt /*'go-L'*
'go-M' options.txt /*'go-M'*
@ -8224,6 +8225,7 @@ gui-w32-cmdargs gui_w32.txt /*gui-w32-cmdargs*
gui-w32-dialogs gui_w32.txt /*gui-w32-dialogs*
gui-w32-printing gui_w32.txt /*gui-w32-printing*
gui-w32-start gui_w32.txt /*gui-w32-start*
gui-w32-title-bar gui_w32.txt /*gui-w32-title-bar*
gui-w32-various gui_w32.txt /*gui-w32-various*
gui-w32-windowid gui_w32.txt /*gui-w32-windowid*
gui-w32s os_win32.txt /*gui-w32s*
@ -8417,6 +8419,8 @@ hl-TabPanelFill syntax.txt /*hl-TabPanelFill*
hl-TabPanelSel syntax.txt /*hl-TabPanelSel*
hl-Terminal syntax.txt /*hl-Terminal*
hl-Title syntax.txt /*hl-Title*
hl-TitleBar syntax.txt /*hl-TitleBar*
hl-TitleBarNC syntax.txt /*hl-TitleBarNC*
hl-ToolbarButton gui.txt /*hl-ToolbarButton*
hl-ToolbarLine gui.txt /*hl-ToolbarLine*
hl-Tooltip syntax.txt /*hl-Tooltip*

View File

@ -1,4 +1,4 @@
*version9.txt* For Vim version 9.1. Last change: 2025 Oct 05
*version9.txt* For Vim version 9.1. Last change: 2025 Oct 07
VIM REFERENCE MANUAL by Bram Moolenaar
@ -41715,6 +41715,8 @@ Options: ~
- Setting 'nowrap' in a modeline could cause long lines to be hidden
off-screen. To make this visible, the listchars "extend" suboption is set
to ">" by default, indicating text that extends beyond the window width.
- 'guioptions': New value |'go-C'| to style the title/caption bar on Windows 11
(see also the below platform specific change).
Ex commands: ~
- allow to specify a priority when defining a new sign |:sign-define|
@ -41750,6 +41752,8 @@ Plugins~
Platform specific ~
- MS-Winodws: Paths like "\Windows" and "/Windows" are now considered to be
absolute paths (to the current drive) and no longer relative.
- MS-Windows: The title bar follows the |hl-TitleBar| and |hl-TitleBarNC|
highlighting group |gui-w32-title-bar|.
- macOS: increase default scheduler priority to TASK_DEFAULT_APPLICATION.
Others: ~
@ -41841,6 +41845,8 @@ Highlighting: ~
|hl-TabPanel| |tabpanel|: not active tab page label
|hl-TabPanelFill| |tabpanel|: filler space
|hl-TabPanelSel| |tabpanel|: active tab page label
|hl-TitleBarNC| Configure the inactive title/bar on MS-Windows 11
|hl-TitleBar| Configure the active title/bar on MS-Windows 11
Commands: ~