patch 9.1.1813: MS-Windows: title bar is always white
Problem: MS-Windows: title bar is always white
Solution: Set_caption() and set the title bars color to the
Normal highlighting background (Mao-Yining)
The implement of 'guidarkmode' is a much longer task, so I would like to
complete this most needed feature.
This commit seen the caption bar as the extension of the background so
it is follow the option 'background' before Windows 11 and follow the
background color after Windows 11.
fixes: #3922
fixes: #18028
closes: #18282
Signed-off-by: Mao-Yining <mao.yining@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
71b97f2905
commit
dddde9ce12
@ -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,9 @@ 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;
|
||||
|
||||
// Sets the value of Desktop Window Manager (DWM) non-client rendering attributes for a window.
|
||||
static HRESULT (WINAPI *pDwmSetWindowAttribute)(HWND, DWORD, LPCVOID, DWORD) = NULL;
|
||||
|
||||
static int WINAPI
|
||||
stubGetSystemMetricsForDpi(int nIndex, UINT dpi UNUSED)
|
||||
{
|
||||
@ -1591,6 +1602,20 @@ _TextAreaWndProc(
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
load_dwm_func(void)
|
||||
{
|
||||
static HMODULE hLibDwm = NULL;
|
||||
hLibDwm = vimLoadLib("dwmapi.dll");
|
||||
if (hLibDwm == NULL)
|
||||
return;
|
||||
|
||||
pDwmSetWindowAttribute = (HRESULT (WINAPI *)(HWND, DWORD, LPCVOID, DWORD))
|
||||
GetProcAddress(hLibDwm, "DwmSetWindowAttribute");
|
||||
}
|
||||
|
||||
extern BOOL win11_or_later; // this is in os_win32.c
|
||||
|
||||
/*
|
||||
* Called when the foreground or background color has been changed.
|
||||
*/
|
||||
@ -1604,6 +1629,21 @@ gui_mch_new_colors(void)
|
||||
s_hwnd, GCLP_HBRBACKGROUND, (LONG_PTR)s_brush);
|
||||
InvalidateRect(s_hwnd, NULL, TRUE);
|
||||
DeleteObject(prevBrush);
|
||||
|
||||
// Set The Caption Bar
|
||||
|
||||
if (pDwmSetWindowAttribute == NULL)
|
||||
return;
|
||||
|
||||
if (win11_or_later)
|
||||
{
|
||||
const COLORREF captionColor = gui.back_pixel;
|
||||
pDwmSetWindowAttribute(s_hwnd, DWMWA_CAPTION_COLOR,
|
||||
&captionColor, sizeof(captionColor));
|
||||
const COLORREF textColor = gui.norm_pixel;
|
||||
pDwmSetWindowAttribute(s_hwnd, DWMWA_TEXT_COLOR,
|
||||
&textColor, sizeof(textColor));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -5636,6 +5676,8 @@ gui_mch_init(void)
|
||||
|
||||
load_dpi_func();
|
||||
|
||||
load_dwm_func();
|
||||
|
||||
s_dpi = pGetDpiForSystem();
|
||||
update_scrollbar_size();
|
||||
|
||||
|
||||
@ -222,8 +222,10 @@ static int suppress_winsize = 1; // don't fiddle with console
|
||||
|
||||
static WCHAR *exe_pathw = NULL;
|
||||
|
||||
static BOOL win8_or_later = FALSE;
|
||||
static BOOL win10_22H2_or_later = FALSE;
|
||||
BOOL win8_or_later = FALSE;
|
||||
BOOL win10_22H2_or_later = FALSE;
|
||||
BOOL win11_or_later = FALSE;
|
||||
|
||||
#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))
|
||||
|
||||
@ -729,6 +729,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1813,
|
||||
/**/
|
||||
1812,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user