0
0
mirror of https://github.com/vim/vim.git synced 2025-10-21 08:24:06 -04:00

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

@@ -51,6 +51,8 @@ TabLineFill
TabLineSel
Terminal
Title
TitleBar
TitleBarNC
TOhtmlProgress
TOhtml-progress-color
ToolbarButton

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: ~

View File

@@ -2,7 +2,7 @@
" Language: Vim script
" Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com>
" Doug Kearns <dougkearns@gmail.com>
" Last Change: 2025 Sep 27
" Last Change: 2025 Oct 07
" Former Maintainer: Charles E. Campbell
" DO NOT CHANGE DIRECTLY.
@@ -34,8 +34,8 @@ syn cluster vimCommentGroup contains=vimTodo,@Spell
" regular vim commands {{{2
" GEN_SYN_VIM: vimCommand normal, START_STR='syn keyword vimCommand contained', END_STR='nextgroup=vimBang'
syn keyword vimCommand contained al[l] ar[gs] arga[dd] argd[elete] argdo argded[upe] arge[dit] argg[lobal] argl[ocal] argu[ment] as[cii] b[uffer] bN[ext] ba[ll] bad[d] balt bd[elete] bf[irst] bl[ast] bm[odified] bn[ext] bp[revious] br[ewind] brea[k] breaka[dd] breakd[el] breakl[ist] bro[wse] buffers bufd[o] bun[load] bw[ipeout] c[hange] cN[ext] cNf[ile] cabo[ve] cad[dbuffer] cadde[xpr] caddf[ile] caf[ter] cb[uffer] cbe[fore] cbel[ow] cbo[ttom] cc ccl[ose] cd cdo ce[nter] cex[pr] cf[ile] cfd[o] cfir[st] cg[etfile] cgetb[uffer] cgete[xpr] changes che[ckpath] checkt[ime] chi[story] cl[ist] clip[reset] cla[st] clo[se] cle[arjumps] cn[ext] cnew[er] cnf[ile] col[der] colo[rscheme] com[mand] comc[lear] comp[iler] con[tinue] conf[irm] cons[t] cope[n] cp[revious] cpf[ile] nextgroup=vimBang
syn keyword vimCommand contained cq[uit] cr[ewind] cs[cope] cst[ag] cw[indow] delm[arks] deb[ug] defc[ompile] di[splay] dif[fupdate] diffg[et] diffo[ff] diffp[atch] diffpu[t] diffs[plit] difft[his] dig[raphs] disa[ssemble] dj[ump] dli[st] dr[op] ds[earch] dsp[lit] e[dit] ea[rlier] em[enu] endfo[r] endt[ry] endw[hile] ene[w] ex exi[t] exu[sage] f[ile] files fin[d] fina[lly] fini[sh] fir[st] fix[del] fo[ld] foldc[lose] foldd[oopen] folddoc[losed] foldo[pen] g[lobal] go[to] gu[i] gv[im] h[elp] helpc[lose] helpf[ind] helpt[ags] ha[rdcopy] hi[ghlight] his[tory] ij[ump] il[ist] int[ro] ip[ut] is[earch] isp[lit] ju[mps] l[ist] lN[ext] lNf[ile] la[st] lab[ove] lan[guage] lad[dexpr] laddb[uffer] laddf[ile] laf[ter] lat[er] lb[uffer] lbe[fore] lbel[ow] lbo[ttom] lc[d] lch[dir] nextgroup=vimBang
syn keyword vimCommand contained al[l] ar[gs] arga[dd] argd[elete] argdo argded[upe] arge[dit] argg[lobal] argl[ocal] argu[ment] as[cii] b[uffer] bN[ext] ba[ll] bad[d] balt bd[elete] bf[irst] bl[ast] bm[odified] bn[ext] bp[revious] br[ewind] brea[k] breaka[dd] breakd[el] breakl[ist] bro[wse] buffers bufd[o] bun[load] bw[ipeout] c[hange] cN[ext] cNf[ile] cabo[ve] cad[dbuffer] cadde[xpr] caddf[ile] caf[ter] cb[uffer] cbe[fore] cbel[ow] cbo[ttom] cc ccl[ose] cd cdo ce[nter] cex[pr] cf[ile] cfd[o] cfir[st] cg[etfile] cgetb[uffer] cgete[xpr] changes che[ckpath] checkt[ime] chi[story] cl[ist] clip[reset] cla[st] clo[se] cle[arjumps] cn[ext] cnew[er] cnf[ile] col[der] colo[rscheme] comc[lear] comp[iler] con[tinue] conf[irm] cons[t] cope[n] cp[revious] cpf[ile] cq[uit] nextgroup=vimBang
syn keyword vimCommand contained cr[ewind] cs[cope] cst[ag] cw[indow] delm[arks] deb[ug] defc[ompile] di[splay] dif[fupdate] diffg[et] diffo[ff] diffp[atch] diffpu[t] diffs[plit] difft[his] dig[raphs] disa[ssemble] dj[ump] dli[st] dr[op] ds[earch] dsp[lit] e[dit] ea[rlier] em[enu] endfo[r] endt[ry] endw[hile] ene[w] ex exi[t] exu[sage] f[ile] files fin[d] fina[lly] fini[sh] fir[st] fix[del] fo[ld] foldc[lose] foldd[oopen] folddoc[losed] foldo[pen] g[lobal] go[to] gu[i] gv[im] h[elp] helpc[lose] helpf[ind] helpt[ags] ha[rdcopy] hi[ghlight] his[tory] ij[ump] il[ist] int[ro] ip[ut] is[earch] isp[lit] ju[mps] l[ist] lN[ext] lNf[ile] la[st] lab[ove] lan[guage] lad[dexpr] laddb[uffer] laddf[ile] laf[ter] lat[er] lb[uffer] lbe[fore] lbel[ow] lbo[ttom] lc[d] lch[dir] nextgroup=vimBang
syn keyword vimCommand contained lcl[ose] lcs[cope] ld[o] le[ft] lex[pr] lf[ile] lfd[o] lfir[st] lg[etfile] lgetb[uffer] lgete[xpr] lgr[ep] lgrepa[dd] lhi[story] ll lla[st] lli[st] lmak[e] lne[xt] lnew[er] lnf[ile] lo[adview] lockv[ar] lol[der] lop[en] lp[revious] lpf[ile] lr[ewind] lt[ag] lw[indow] ls m[ove] marks menut[ranslate] mes[sages] mk[exrc] mks[ession] mksp[ell] mkv[imrc] mkvie[w] mod[e] n[ext] nb[key] nbc[lose] nbs[tart] noh[lsearch] nu[mber] o[pen] ol[dfiles] on[ly] opt[ions] ow[nsyntax] p[rint] pa[ckadd] packl[oadall] pb[uffer] pc[lose] ped[it] po[p] pp[op] pre[serve] prev[ious] pro[mptfind] promptr[epl] ps[earch] pt[ag] ptN[ext] ptf[irst] ptj[ump] ptl[ast] ptn[ext] ptp[revious] ptr[ewind] pts[elect] pu[t] pw[d] q[uit] quita[ll] qa[ll] r[ead] rec[over] nextgroup=vimBang
syn keyword vimCommand contained red[o] redr[aw] redraws[tatus] redrawt[abline] redrawtabp[anel] reg[isters] res[ize] ret[ab] rew[ind] ri[ght] ru[ntime] rub[y] rubyd[o] rubyf[ile] rund[o] rv[iminfo] sN[ext] sa[rgument] sal[l] sav[eas] sb[uffer] sbN[ext] sba[ll] sbf[irst] sbl[ast] sbm[odified] sbn[ext] sbp[revious] sbr[ewind] scr[iptnames] scripte[ncoding] scriptv[ersion] scs[cope] setf[iletype] sf[ind] sfir[st] sh[ell] sim[alt] sig[n] sla[st] sn[ext] so[urce] spe[llgood] spelld[ump] spelli[nfo] spellr[epall] spellra[re] spellu[ndo] spellw[rong] spr[evious] sre[wind] st[op] sta[g] star[tinsert] startg[replace] startr[eplace] stopi[nsert] stj[ump] sts[elect] sun[hide] sus[pend] sv[iew] synti[me] sync[bind] smi[le] t tN[ext] ta[g] tags tabc[lose] tabd[o] tabe[dit] nextgroup=vimBang
syn keyword vimCommand contained tabf[ind] tabfir[st] tabm[ove] tabl[ast] tabn[ext] tabnew tabo[nly] tabp[revious] tabN[ext] tabr[ewind] tabs tc[d] tch[dir] te[aroff] tf[irst] tj[ump] tl[ast] tn[ext] tp[revious] tr[ewind] try ts[elect] u[ndo] undoj[oin] undol[ist] unh[ide] unlo[ckvar] up[date] v[global] ve[rsion] vi[sual] vie[w] viu[sage] vne[w] vs[plit] w[rite] wN[ext] wa[ll] wi[nsize] wind[o] winp[os] wl[restore] wn[ext] wp[revious] wq wqa[ll] wu[ndo] wv[iminfo] x[it] xa[ll] xr[estore] y[ank] z dl dell delel deletl deletel dp dep delp delep deletp deletep a i nextgroup=vimBang
@@ -146,8 +146,8 @@ syn keyword vimGroup contained Added Bold BoldItalic Boolean Changed Character C
" Default highlighting groups {{{2
" GEN_SYN_VIM: vimHLGroup, START_STR='syn keyword vimHLGroup contained', END_STR=''
syn keyword vimHLGroup contained ErrorMsg IncSearch ModeMsg NonText StatusLine StatusLineNC EndOfBuffer VertSplit VisualNOS DiffText DiffTextAdd PmenuSbar TabLineSel TabLineFill TabPanel TabPanelSel TabPanelFill Cursor lCursor QuickFixLine CursorLineSign CursorLineFold CurSearch PmenuKind PmenuKindSel PmenuMatch PmenuMatchSel PmenuExtra PmenuExtraSel PopupSelected MessageWindow PopupNotification PreInsert Normal Directory LineNr CursorLineNr MoreMsg Question Search SpellBad SpellCap SpellRare SpellLocal PmenuThumb Pmenu PmenuSel SpecialKey Title WarningMsg WildMenu Folded FoldColumn SignColumn Visual DiffAdd DiffChange DiffDelete TabLine CursorColumn CursorLine ColorColumn MatchParen StatusLineTerm StatusLineTermNC ToolbarLine ToolbarButton Menu Tooltip Scrollbar
syn keyword vimHLGroup contained CursorIM ComplMatchIns LineNrAbove LineNrBelow MsgArea Terminal User1 User2 User3 User4 User5 User6 User7 User8 User9
syn keyword vimHLGroup contained ErrorMsg IncSearch ModeMsg NonText StatusLine StatusLineNC EndOfBuffer VertSplit VisualNOS DiffText DiffTextAdd PmenuSbar TabLineSel TabLineFill TabPanel TabPanelSel TabPanelFill Cursor lCursor TitleBar TitleBarNC QuickFixLine CursorLineSign CursorLineFold CurSearch PmenuKind PmenuKindSel PmenuMatch PmenuMatchSel PmenuExtra PmenuExtraSel PopupSelected MessageWindow PopupNotification PreInsert Normal Directory LineNr CursorLineNr MoreMsg Question Search SpellBad SpellCap SpellRare SpellLocal PmenuThumb Pmenu PmenuSel SpecialKey Title WarningMsg WildMenu Folded FoldColumn SignColumn Visual DiffAdd DiffChange DiffDelete TabLine CursorColumn CursorLine ColorColumn MatchParen StatusLineTerm StatusLineTermNC ToolbarLine ToolbarButton
syn keyword vimHLGroup contained TitleBar TitleBarNC Menu Tooltip Scrollbar CursorIM ComplMatchIns LineNrAbove LineNrBelow MsgArea Terminal User1 User2 User3 User4 User5 User6 User7 User8 User9
syn match vimHLGroup contained "\<Conceal\>"
syn case match
@@ -1368,7 +1368,7 @@ syn region vimEval
\ end="\ze|"
\ excludenl end="$"
\ nextgroup=vimCmdSep
\ contains=@vimContinue,@vimExprList,vimComment,vim9Comment
\ contains=@vimContinue,@vimExprList,vim9Comment
\ transparent
" Filter: {{{2

View File

@@ -3491,6 +3491,10 @@ gui_init_which_components(char_u *oldval UNUSED)
#ifdef FEAT_GUI_TABLINE
int using_tabline;
#endif
#ifdef FEAT_GUI_MSWIN
static int prev_titlebar = -1;
int using_titlebar = FALSE;
#endif
#if defined(FEAT_MENU)
static int prev_tearoff = -1;
int using_tearoff = FALSE;
@@ -3560,6 +3564,11 @@ gui_init_which_components(char_u *oldval UNUSED)
case GO_GREY:
// make menu's have grey items, ignored here
break;
#ifdef FEAT_GUI_MSWIN
case GO_TITLEBAR:
using_titlebar = TRUE;
break;
#endif
#ifdef FEAT_TOOLBAR
case GO_TOOLBAR:
using_toolbar = TRUE;
@@ -3581,6 +3590,14 @@ gui_init_which_components(char_u *oldval UNUSED)
need_set_size = 0;
fix_size = FALSE;
#ifdef FEAT_GUI_MSWIN
if (using_titlebar != prev_titlebar)
{
gui_mch_set_titlebar_colors();
prev_titlebar = using_titlebar;
}
#endif
#ifdef FEAT_GUI_DARKTHEME
if (using_dark_theme != prev_dark_theme)
{
@@ -4751,6 +4768,10 @@ gui_focus_change(int in_focus)
gui.in_focus = in_focus;
out_flush_cursor(TRUE, FALSE);
# ifdef FEAT_GUI_MSWIN
gui_mch_set_titlebar_colors();
# endif
# ifdef FEAT_XIM
xim_set_focus(in_focus);
# endif

View File

@@ -422,6 +422,11 @@ typedef struct Gui
guicolor_T currFgColor; // Current foreground text color
guicolor_T currBgColor; // Current background text color
guicolor_T currSpColor; // Current special text color
guicolor_T title_bg_pixel; // window title bar color
guicolor_T title_fg_pixel; // window title bar's text color
guicolor_T titlenc_bg_pixel; // window title bar color not current
guicolor_T titlenc_fg_pixel; // window title bar's text color not current
#endif
#ifdef FEAT_GUI_HAIKU

View File

@@ -318,6 +318,14 @@ gui_mch_set_rendering_options(char_u *s)
# define SPI_SETWHEELSCROLLCHARS 0x006D
#endif
#ifndef DWMWA_CAPTION_COLOR
# define DWMWA_CAPTION_COLOR 35
#endif
#ifndef DWMWA_TEXT_COLOR
# define DWMWA_TEXT_COLOR 36
#endif
#ifdef PROTO
/*
* Define a few things for generating prototypes. This is just to avoid
@@ -468,6 +476,10 @@ static int (WINAPI *pGetSystemMetricsForDpi)(int, UINT) = NULL;
static DPI_AWARENESS_CONTEXT (WINAPI *pSetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT dpiContext) = NULL;
static DPI_AWARENESS (WINAPI *pGetAwarenessFromDpiAwarenessContext)(DPI_AWARENESS_CONTEXT) = NULL;
static HINSTANCE hLibDwm = NULL;
static HRESULT (WINAPI *pDwmSetWindowAttribute)(HWND, DWORD, LPCVOID, DWORD);
static void dyn_dwm_load(void);
static int WINAPI
stubGetSystemMetricsForDpi(int nIndex, UINT dpi UNUSED)
{
@@ -1591,6 +1603,67 @@ _TextAreaWndProc(
}
}
static void
dyn_dwm_load(void)
{
hLibDwm = vimLoadLib("dwmapi.dll");
if (hLibDwm == NULL)
return;
pDwmSetWindowAttribute = (HRESULT (WINAPI *)(HWND, DWORD, LPCVOID, DWORD))
GetProcAddress(hLibDwm, "DwmSetWindowAttribute");
if (pDwmSetWindowAttribute == NULL)
{
FreeLibrary(hLibDwm);
hLibDwm = NULL;
return;
}
}
extern BOOL win11_or_later; // this is in os_win32.c
/*
* Set TitleBar's color. Handle hl-TitleBar and hl-TitleBarNC.
*
* Only enabled when 'guioptions' has 'C'.
* if "TitleBar guibg=NONE guifg=NONE" reset the window back to using the
* system's default behavior for the border color.
*/
void
gui_mch_set_titlebar_colors(void)
{
if (pDwmSetWindowAttribute == NULL || !win11_or_later)
return;
guicolor_T captionColor = 0xFFFFFFFF;
guicolor_T textColor = 0xFFFFFFFF;
if (vim_strchr(p_go, GO_TITLEBAR) != NULL)
{
if (gui.in_focus)
{
captionColor = gui.title_bg_pixel;
textColor = gui.title_fg_pixel;
}
else
{
captionColor = gui.titlenc_bg_pixel;
textColor = gui.titlenc_fg_pixel;
}
if (captionColor == INVALCOLOR)
captionColor = 0xFFFFFFFF;
if (textColor == INVALCOLOR)
textColor = 0xFFFFFFFF;
}
pDwmSetWindowAttribute(s_hwnd, DWMWA_CAPTION_COLOR,
&captionColor, sizeof(captionColor));
pDwmSetWindowAttribute(s_hwnd, DWMWA_TEXT_COLOR,
&textColor, sizeof(textColor));
}
/*
* Called when the foreground or background color has been changed.
*/
@@ -5636,6 +5709,8 @@ gui_mch_init(void)
load_dpi_func();
dyn_dwm_load();
s_dpi = pGetDpiForSystem();
update_scrollbar_size();

View File

@@ -255,6 +255,10 @@ static char *(highlight_init_both[]) = {
#ifdef FEAT_GUI
"Cursor guibg=fg guifg=bg",
"lCursor guibg=fg guifg=bg", // should be different, but what?
#endif
#ifdef FEAT_GUI_MSWIN
"TitleBar guibg=bg guifg=fg",
"TitleBarNC guibg=NONE guifg=NONE",
#endif
"default link QuickFixLine Search",
"default link CursorLineSign SignColumn",
@@ -817,6 +821,10 @@ highlight_reset_all(void)
# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_X11)
gui_mch_def_colors();
# endif
# ifdef FEAT_GUI_MSWIN
if (gui.in_use)
gui_mch_set_titlebar_colors();
# endif
# ifdef FEAT_GUI_X11
# ifdef FEAT_MENU
@@ -1272,6 +1280,8 @@ highlight_set_guifg(
int is_menu_group UNUSED,
int is_scrollbar_group UNUSED,
int is_tooltip_group UNUSED,
int is_titlebar_group UNUSED,
int is_titlebarnc_group UNUSED,
int *do_colors UNUSED,
int init)
{
@@ -1305,6 +1315,18 @@ highlight_set_guifg(
did_change = TRUE;
}
# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
# ifdef FEAT_GUI_MSWIN
if (is_titlebar_group && gui.title_fg_pixel != i)
{
gui.title_fg_pixel = i;
*do_colors = TRUE;
}
if (is_titlebarnc_group && gui.titlenc_fg_pixel != i)
{
gui.titlenc_fg_pixel = i;
*do_colors = TRUE;
}
# endif
# ifdef FEAT_GUI_X11
if (is_menu_group && gui.menu_fg_pixel != i)
{
@@ -1341,6 +1363,8 @@ highlight_set_guibg(
int is_menu_group UNUSED,
int is_scrollbar_group UNUSED,
int is_tooltip_group UNUSED,
int is_titlebar_group UNUSED,
int is_titlebarnc_group UNUSED,
int *do_colors UNUSED,
int init)
{
@@ -1374,6 +1398,18 @@ highlight_set_guibg(
did_change = TRUE;
}
# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
# ifdef FEAT_GUI_MSWIN
if (is_titlebar_group && gui.title_bg_pixel != i)
{
gui.title_bg_pixel = i;
*do_colors = TRUE;
}
if (is_titlebarnc_group && gui.titlenc_bg_pixel != i)
{
gui.titlenc_bg_pixel = i;
*do_colors = TRUE;
}
# endif
# ifdef FEAT_GUI_X11
if (is_menu_group && gui.menu_bg_pixel != i)
{
@@ -1551,6 +1587,13 @@ do_highlight(
int dolink = FALSE;
int error = FALSE;
int is_normal_group = FALSE; // "Normal" group
#ifdef FEAT_GUI_MSWIN
int is_titlebar_group = FALSE; // "TitleBar" group
int is_titlebarnc_group = FALSE; // "TitleBarNC" group
#else
# define is_titlebar_group 0
# define is_titlebarnc_group 0
#endif
#ifdef FEAT_GUI_X11
int is_menu_group = FALSE; // "Menu" group
int is_scrollbar_group = FALSE; // "Scrollbar" group
@@ -1668,6 +1711,12 @@ do_highlight(
if (STRCMP(HL_TABLE()[idx].sg_name_u, "NORMAL") == 0)
is_normal_group = TRUE;
#ifdef FEAT_GUI_MSWIN
else if (STRCMP(HL_TABLE()[idx].sg_name_u, "TITLEBAR") == 0)
is_titlebar_group = TRUE;
else if (STRCMP(HL_TABLE()[idx].sg_name_u, "TITLEBARNC") == 0)
is_titlebarnc_group = TRUE;
#endif
#ifdef FEAT_GUI_X11
else if (STRCMP(HL_TABLE()[idx].sg_name_u, "MENU") == 0)
is_menu_group = TRUE;
@@ -1809,6 +1858,7 @@ do_highlight(
#if defined(FEAT_GUI) || defined(FEAT_EVAL)
if (highlight_set_guifg(idx, arg, is_menu_group,
is_scrollbar_group, is_tooltip_group,
is_titlebar_group, is_titlebarnc_group,
&do_colors, init))
did_change = TRUE;
#endif
@@ -1818,6 +1868,7 @@ do_highlight(
#if defined(FEAT_GUI) || defined(FEAT_EVAL)
if (highlight_set_guibg(idx, arg, is_menu_group,
is_scrollbar_group, is_tooltip_group,
is_titlebar_group, is_titlebarnc_group,
&do_colors, init))
did_change = TRUE;
#endif
@@ -1879,6 +1930,18 @@ do_highlight(
control_console_color_rgb();
#endif
}
#ifdef FEAT_GUI_MSWIN
else if (is_titlebar_group)
{
if (gui.in_use && do_colors)
gui_mch_set_titlebar_colors();
}
else if (is_titlebarnc_group)
{
if (gui.in_use && do_colors)
gui_mch_set_titlebar_colors();
}
#endif
#ifdef FEAT_GUI_X11
# ifdef FEAT_MENU
else if (is_menu_group)
@@ -2052,8 +2115,8 @@ highlight_clear(int idx)
#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) || defined(PROTO)
/*
* Set the normal foreground and background colors according to the "Normal"
* highlighting group. For X11 also set "Menu", "Scrollbar", and
* "Tooltip" colors.
* highlighting group. For X11 also set "Menu", "Scrollbar" and "Tooltip"
* colors. For MS-Windows also set "TitleBar" and "TitleBarNC" colors.
*/
void
set_normal_colors(void)
@@ -2070,6 +2133,22 @@ set_normal_colors(void)
gui_mch_new_colors();
set_must_redraw(UPD_CLEAR);
}
# ifdef FEAT_GUI_MSWIN
if (set_group_colors((char_u *)"TitleBar",
&gui.title_fg_pixel, &gui.title_bg_pixel,
FALSE, FALSE, FALSE))
{
gui_mch_set_titlebar_colors();
set_must_redraw(UPD_CLEAR);
}
if (set_group_colors((char_u *)"TitleBarNC",
&gui.titlenc_fg_pixel, &gui.titlenc_bg_pixel,
FALSE, FALSE, FALSE))
{
gui_mch_set_titlebar_colors();
set_must_redraw(UPD_CLEAR);
}
# endif
# ifdef FEAT_GUI_X11
if (set_group_colors((char_u *)"Menu",
&gui.menu_fg_pixel, &gui.menu_bg_pixel,
@@ -2132,7 +2211,8 @@ set_normal_colors(void)
#if defined(FEAT_GUI) || defined(PROTO)
/*
* Set the colors for "Normal", "Menu", "Tooltip" or "Scrollbar".
* Set the colors for "Normal", "Menu", "TitleBar", "TitleBarNC", "Tooltip" or
* "Scrollbar".
*/
static int
set_group_colors(

View File

@@ -288,6 +288,7 @@ typedef enum {
#define GO_ASELML 'A' // autoselect modeless selection
#define GO_BOT 'b' // use bottom scrollbar
#define GO_CONDIALOG 'c' // use console dialog
#define GO_TITLEBAR 'C' // use 'hl-TitleBar'
#define GO_DARKTHEME 'd' // use dark theme variant
#define GO_TABLINE 'e' // may show tabline
#define GO_FORG 'f' // start GUI in foreground
@@ -308,7 +309,7 @@ typedef enum {
#define GO_VERTICAL 'v' // arrange dialog buttons vertically
#define GO_KEEPWINSIZE 'k' // keep GUI window size
// all possible flags for 'go'
#define GO_ALL "!aAbcdefFghilLmMpPrRtTvk"
#define GO_ALL "!aAbcCdefFghilLmMpPrRtTvk"
// flags for 'comments' option
#define COM_NEST 'n' // comments strings nest

View File

@@ -224,6 +224,8 @@ static WCHAR *exe_pathw = NULL;
static BOOL win8_or_later = FALSE;
static BOOL win10_22H2_or_later = FALSE;
BOOL win11_or_later = FALSE; // used in gui_mch_set_titlebar_colors(void)
#if !defined(FEAT_GUI_MSWIN) || defined(VIMDLL)
static BOOL use_alternate_screen_buffer = FALSE;
#endif
@@ -1010,6 +1012,10 @@ PlatformId(void)
|| ovi.dwMajorVersion > 10)
win10_22H2_or_later = TRUE;
if ((ovi.dwMajorVersion == 10 && ovi.dwBuildNumber >= 22000)
|| ovi.dwMajorVersion > 10)
win11_or_later = TRUE;
#ifdef HAVE_ACL
// Enable privilege for getting or setting SACLs.
if (!win32_enable_privilege(SE_SECURITY_NAME))

View File

@@ -5,6 +5,7 @@ int gui_mch_is_blink_off(void);
void gui_mch_set_blinking(long wait, long on, long off);
void gui_mch_stop_blink(int may_call_gui_update_cursor);
void gui_mch_start_blink(void);
void gui_mch_set_titlebar_colors(void);
void gui_mch_new_colors(void);
void gui_mch_def_colors(void);
int gui_mch_open(void);

View File

@@ -664,6 +664,13 @@ func Test_set_guioptions()
set guioptions&
call assert_equal('egmrLtT', &guioptions)
set guioptions+=C
exec 'sleep' . duration
call assert_equal('egmrLtTC', &guioptions)
set guioptions-=C
exec 'sleep' . duration
call assert_equal('egmrLtT', &guioptions)
else
" Default Value
set guioptions&

View File

@@ -729,6 +729,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1834,
/**/
1833,
/**/