mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
feat(windows): show icon in terminal titlebar, taskbar #20607
closes #20071
This commit is contained in:
parent
06dfedc87a
commit
730228f6db
@ -32,7 +32,7 @@ if(WIN32)
|
||||
# The following guid is just a randomly generated guid that's been pasted here.
|
||||
# It has no special meaning other than to supply it to WIX.
|
||||
set(CPACK_WIX_UPGRADE_GUID "207A1A70-7B0C-418A-A153-CA6883E38F4D")
|
||||
set(CPACK_WIX_PRODUCT_ICON ${CMAKE_CURRENT_LIST_DIR}/neovim.ico)
|
||||
set(CPACK_WIX_PRODUCT_ICON ${PROJECT_SOURCE_DIR}/runtime/neovim.ico)
|
||||
|
||||
# We use a wix patch to add further options to the installer. At present, it's just to add neovim to the path
|
||||
# on installation, however, it can be extended.
|
||||
|
@ -110,12 +110,16 @@ if(NOT APPLE)
|
||||
install_helper(
|
||||
FILES ${CMAKE_CURRENT_SOURCE_DIR}/nvim.desktop
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
|
||||
|
||||
install_helper(
|
||||
FILES ${CMAKE_CURRENT_SOURCE_DIR}/nvim.png
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps)
|
||||
endif()
|
||||
|
||||
install_helper(
|
||||
FILES ${CMAKE_CURRENT_SOURCE_DIR}/nvim.png
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps)
|
||||
|
||||
install_helper(
|
||||
FILES ${CMAKE_CURRENT_SOURCE_DIR}/neovim.ico
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime)
|
||||
|
||||
globrecurse_wrapper(RUNTIME_PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR} *.awk *.sh *.bat)
|
||||
|
||||
foreach(PROG ${RUNTIME_PROGRAMS})
|
||||
|
Before Width: | Height: | Size: 120 KiB After Width: | Height: | Size: 120 KiB |
@ -207,6 +207,57 @@ void early_init(mparm_T *paramp)
|
||||
init_signs();
|
||||
}
|
||||
|
||||
#ifdef MSWIN
|
||||
HWND hWnd = NULL;
|
||||
static HICON hOrigIconSmall = NULL;
|
||||
static HICON hOrigIcon = NULL;
|
||||
|
||||
/// Save Windows console icon to be reset later
|
||||
static void SaveWin32ConsoleIcon(void)
|
||||
{
|
||||
if ((hWnd = GetConsoleWindow()) == NULL) {
|
||||
return;
|
||||
}
|
||||
hOrigIconSmall = (HICON)SendMessage(hWnd, WM_GETICON, (WPARAM)ICON_SMALL, (LPARAM)0);
|
||||
hOrigIcon = (HICON)SendMessage(hWnd, WM_GETICON, (WPARAM)ICON_BIG, (LPARAM)0);
|
||||
}
|
||||
|
||||
static void SetConsoleIcon(HWND hWindow, HICON hIconSmall, HICON hIcon)
|
||||
{
|
||||
if (hWindow == NULL) {
|
||||
return;
|
||||
}
|
||||
if (hIconSmall != NULL) {
|
||||
SendMessage(hWnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)hIconSmall);
|
||||
}
|
||||
if (hIcon != NULL) {
|
||||
SendMessage(hWnd, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)hIcon);
|
||||
}
|
||||
}
|
||||
|
||||
/// Reset Windows console icon to original
|
||||
static void ResetWin32ConsoleIcon(void)
|
||||
{
|
||||
SetConsoleIcon(hWnd, hOrigIconSmall, hOrigIcon);
|
||||
}
|
||||
|
||||
/// Set Neovim logo as Windows console icon
|
||||
static void SetWin32ConsoleIcon(void)
|
||||
{
|
||||
const char *vimruntime = os_getenv("VIMRUNTIME");
|
||||
if (vimruntime != NULL) {
|
||||
snprintf(NameBuff, MAXPATHL, "%s" _PATHSEPSTR "neovim.ico", vimruntime);
|
||||
if (!os_path_exists(NameBuff)) {
|
||||
WLOG("neovim.ico not found: %s", NameBuff);
|
||||
} else {
|
||||
HICON hVimIcon = LoadImage(NULL, NameBuff, IMAGE_ICON, 64, 64,
|
||||
LR_LOADFROMFILE | LR_LOADMAP3DCOLORS);
|
||||
SetConsoleIcon(hWnd, hVimIcon, hVimIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MAKE_LIB
|
||||
int nvim_main(int argc, char **argv); // silence -Wmissing-prototypes
|
||||
int nvim_main(int argc, char **argv)
|
||||
@ -256,6 +307,11 @@ int main(int argc, char **argv)
|
||||
|
||||
early_init(¶ms);
|
||||
|
||||
#ifdef MSWIN
|
||||
SaveWin32ConsoleIcon();
|
||||
SetWin32ConsoleIcon();
|
||||
#endif
|
||||
|
||||
set_argv_var(argv, argc); // set v:argv
|
||||
|
||||
// Check if we have an interactive window.
|
||||
@ -721,6 +777,10 @@ void getout(int exitval)
|
||||
garbage_collect(false);
|
||||
}
|
||||
|
||||
#ifdef MSWIN
|
||||
ResetWin32ConsoleIcon();
|
||||
#endif
|
||||
|
||||
os_exit(exitval);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user