-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(windows): set console icon later in startup #20634
Conversation
@@ -600,6 +588,12 @@ int main(int argc, char **argv) | |||
TIME_MSG("UIEnter autocommands"); | |||
} | |||
|
|||
#ifdef MSWIN | |||
if (use_builtin_ui) { | |||
os_icon_init(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason to set the icon if we are not using the TUI (use_builtin_ui
) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justinmk With use_builtin_ui
, the icon isn't being set, as of v0.9.0-dev-823+g41aa5ce3eb49
. I haven't bisected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably because of the PR where TUI was split from the main nvim process. We could remove this if
check or OR use_remote_ui
with use_builtin_ui
. I don't know which is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
er... use_builtin_ui
should be true, why isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E:\projects\neovim\master> gdb .\build\debug\bin\nvim.exe
Reading symbols from .\build\debug\bin\nvim.exe...
gdb> b main.c:303
Breakpoint 1 at 0x140001b27: file E:/projects/neovim/master/src/nvim/main.c, line 303.
gdb> r
Starting program: E:\projects\neovim\master\build\debug\bin\nvim.exe
[New Thread 1840.0x6a8]
[New Thread 1840.0x12c8]
[New Thread 1840.0x1214]
[New Thread 1840.0x2070]
[New Thread 1840.0x17c8]
[New Thread 1840.0x275c]
Thread 1 hit Breakpoint 1, wmain (argc=0x1, argv_w=0x11a4b3daa10) at E:/projects/neovim/master/src/nvim/main.c:303
303 bool use_builtin_ui = (has_term && !headless_mode && !embedded_mode && !silent_mode);
gdb> n
308 server_init(params.listen_addr);
gdb> p use_builtin_ui
$1 = 0x1
Note that the value of use_builtin_ui
is true. But I noticed that this nvim process, the one gdb is attached to, runs into this line, and after executing it, the nvim window appears. At that point, I don't have gdb's ui anymore.
Lines 380 to 382 in 2af31fc
if (ui_client_channel_id) { | |
ui_client_run(remote_ui); // NORETURN | |
} |
^This line is above/before the line where Windows taskbar+console icon is set.
Lines 591 to 596 in 2af31fc
#ifdef MSWIN | |
if (use_builtin_ui) { | |
os_icon_init(); | |
} | |
os_title_save(); | |
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. maybe we need to check ui_client_channel_id
then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. Doesn't satisfy if(ui_client_channel_id)
either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should either be if(use_builtin_ui || use_remote_ui)
or just if(use_remote_ui)
. But I'm struggling with understanding how the main and embedded processes are being run. Can't tell what the conditional should be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should either be
if(use_builtin_ui || use_remote_ui)
👍 that seems fine.
Nvim is crashing. I'll try and find out the problem. |
I don't know how to make sense of this:
That's where nvim is crashing: in |
does moving |
No. And same gdb log. |
https://github.com/neovim/neovim/actions/runs/3246436285/jobs/5325170873#step:5:765
|
Is this feature absolutely necessary? Ref. https://learn.microsoft.com/en-us/windows/console/getconsolewindow#remarks |
Problem: Windows console icon is set early in startup, but there are some cases where `os_exit` is called and we don't restore the original icon. Solution: - Move `os_icon_init()` later in the startup sequence, and only if `use_builtin_ui==true`. - Rename functions: use `os_` prefix for platform-specific code.
I agree that this feature is pointless, but not because Windows is going to make Windows Terminal the default console. The old console is always gonna be there, because of the same reason these old API are gonna be there: tons of programs use them. And many people, including me, use the old console for quick spawn-task-destroy workflow. Windows Terminal is very slow to start compared to the old console. Opening text files from file explorer by double clicking -- for this kind of task, the old console is preferable. But I do agree this is pointless, because who cares what the icon of a window is. |
Ah, I thought this was for Windows terminal too. Is there a similar API for Windows terminal? This is a small, isolated, low-risk amount of code so I think it's ok to keep it around for now. We can always remove it later. |
I looked yesterday. Couldn't find any. Windows Terminal also doesn't respect |
@3N4N would you mind testing this once more? |
Yes, it works as expected. |
No, Console Virtual Terminal Sequences (conpty) and Windows Terminal supports Window Title changes. The reason https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#window-title I think
@3N4N The Windows API should not be used unless necessary. If terminal functions and Ref. https://invisible-island.net/xterm/ctlseqs/ctlseqs.txt |
Windows CI failure on master. Same failure observed in master CI as far back as d9a80b8 (well before #20607 was merged), so unrelated.
|
Setting tab icon through VT sequence in Windows Terminal is being tracked in this issue: microsoft/terminal#1868 And thanks erw7 for the reading materials. |
Problem: After TUI refactor commit, code for setting Windows taskbar icon wasn't being executed because of a backdated conditional. Solution: Update the conditional to take TUI refactor into account. Ref: #20634 (comment)
Problem: After TUI refactor commit, code for setting Windows taskbar icon wasn't being executed because of a backdated conditional. Solution: Update the conditional to take TUI refactor into account. Ref: neovim#20634 (comment)
Problem: After TUI refactor commit, code for setting Windows taskbar icon wasn't being executed because of a backdated conditional. Solution: Update the conditional to take TUI refactor into account. Ref: neovim#20634 (comment)
Problem:
Windows console icon is set early in startup, but there are some cases where
os_exit
is called and we don't restore the original icon.Solution:
os_icon_init()
later in the startup sequence, and only ifuse_builtin_ui==true
.os_
prefix for platform-specific code.