terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Refrigerated window causes focus mode to show title bar

Open e82eric opened this issue 1 year ago • 3 comments

Windows Terminal version

63c3573a1

Windows build number

No response

Other Software

No response

Steps to reproduce

Set terminal to open in focus mode and the new instance behavior to create new winodw. Open windows terminal. Open new window using wt Close newly created window Open new window using wt

Expected Behavior

The newly created window will be created in focus mode without a title bar

Actual Behavior

The newly created window is created with a title title bar. explorer_vCRXtCWDMD

e82eric avatar Jan 06 '24 17:01 e82eric

I think the cause of this is that when a Refrigerated window is restored this call to Controls::Grid::SetRow(_titlebar, 0); causes the _title bar to be visible. https://github.com/microsoft/terminal/blob/63c3573a13cc96bfa3d655f0f1898ae250e2fe35/src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp#L379

And when the check to hide the titlebar happens it doesn't run because of the optimization to do nothing if the _borderless state is already set.

void IslandWindow::FocusModeChanged(const bool focusMode)
{
    // Do nothing if the value was unchanged.
    if (focusMode == _borderless)
    {
        return;
    }

    _SetIsBorderless(focusMode);
}

https://github.com/microsoft/terminal/blob/63c3573a13cc96bfa3d655f0f1898ae250e2fe35/src/cascadia/WindowsTerminal/IslandWindow.cpp#L919

I removed the optimization and no longer saw the title bar.

e82eric avatar Jan 06 '24 17:01 e82eric

Where is the FocusModeChanged call coming from? Should that caller just call _SetIsBorderless directly?

lhecker avatar Jan 08 '24 18:01 lhecker

I think it is from TerminalWindow::_pageInitialized https://github.com/microsoft/terminal/blob/375d00d0cd2c2934b0d136dcf7c295a5f99b07d5/src/cascadia/TerminalApp/TerminalWindow.cpp#L248

https://github.com/microsoft/terminal/blob/main/src/cascadia/TerminalApp/TerminalPage.cpp#L3554

This was the call stack

	WindowsTerminal.exe!AppHost::_FocusModeChanged(const winrt::Windows::Foundation::IInspectable & __formal, const winrt::Windows::Foundation::IInspectable & __formal) Line 787	C++
 	WindowsTerminal.exe!`winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Foundation::IInspectable,winrt::Windows::Foundation::IInspectable>::TypedEventHandler<winrt::Windows::Foundation::IInspectable,winrt::Windows::Foundation::IInspectable><AppHost,void (__cdecl AppHost::*)(winrt::Windows::Foundation::IInspectable const &,winrt::Windows::Foundation::IInspectable const &)>'::`1'::<lambda_295_>::operator()<winrt::Windows::Foundation::IInspectable const &,winrt::Windows::Foundation::IInspectable const &>(const winrt::Windows::Foundation::IInspectable & <args_0>, const winrt::Windows::Foundation::IInspectable & <args_1>) Line 2512	C++
 	WindowsTerminal.exe!winrt::impl::delegate<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Foundation::IInspectable,winrt::Windows::Foundation::IInspectable>,`winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Foundation::IInspectable,winrt::Windows::Foundation::IInspectable>::IInspectable<AppHost,void (__cdecl AppHost::*)(winrt::Windows::Foundation::IInspectable const &,winrt::Windows::Foundation::IInspectable const &)>'::`1'::<lambda_295_>>::Invoke(void * sender, void * args) Line 895	C++
 	TerminalApp.dll!winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Foundation::IInspectable,winrt::Windows::Foundation::IInspectable>::operator()(const winrt::Windows::Foundation::IInspectable & sender, const winrt::Windows::Foundation::IInspectable & args) Line 2525	C++
 	TerminalApp.dll!winrt::impl::invoke<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Foundation::IInspectable,winrt::Windows::Foundation::IInspectable>,winrt::TerminalApp::implementation::TerminalPage,std::nullptr_t>(const winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Foundation::IInspectable,winrt::Windows::Foundation::IInspectable> & delegate, const winrt::TerminalApp::implementation::TerminalPage & <args_0>, void * const & <args_1>) Line 5890	C++
 	TerminalApp.dll!winrt::event<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Foundation::IInspectable,winrt::Windows::Foundation::IInspectable>>::operator()<winrt::TerminalApp::implementation::TerminalPage,std::nullptr_t>(const winrt::TerminalApp::implementation::TerminalPage & <args_0>, void * const & <args_1>) Line 6043	C++
 	TerminalApp.dll!winrt::TerminalApp::implementation::TerminalPage::SetFocusMode(const bool inFocusMode) Line 3556	C++
 	TerminalApp.dll!winrt::TerminalApp::implementation::TerminalWindow::_pageInitialized(const winrt::Windows::Foundation::IInspectable & __formal, const winrt::Windows::Foundation::IInspectable & __formal) Line 253	C++
 	TerminalApp.dll!`winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Foundation::IInspectable,winrt::Windows::Foundation::IInspectable>::TypedEventHandler<winrt::Windows::Foundation::IInspectable,winrt::Windows::Foundation::IInspectable><winrt::TerminalApp::implementation::TerminalWindow,void (__cdecl winrt::TerminalApp::implementation::TerminalWindow::*)(winrt::Windows::Foundation::IInspectable const &,winrt::Windows::Foundation::IInspectable const &)>'::`1'::<lambda_490_>::operator()<winrt::Windows::Foundation::IInspectable const &,winrt::Windows::Foundation::IInspectable const &>(const winrt::Windows::Foundation::IInspectable & <args_0>, const winrt::Windows::Foundation::IInspectable & <args_1>) Line 2520	C++
 	TerminalApp.dll!winrt::impl::delegate<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Foundation::IInspectable,winrt::Windows::Foundation::IInspectable>,`winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Foundation::IInspectable,winrt::Windows::Foundation::IInspectable>::implementation<winrt::TerminalApp::implementation::TerminalWindow,void (__cdecl winrt::TerminalApp::implementation::TerminalWindow::*)(winrt::Windows::Foundation::IInspectable const &,winrt::Windows::Foundation::IInspectable const &)>'::`1'::<lambda_490_>>::Invoke(void * sender, void * args) Line 895	C++
 	TerminalApp.dll!winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Foundation::IInspectable,winrt::Windows::Foundation::IInspectable>::operator()(const winrt::Windows::Foundation::IInspectable & sender, const winrt::Windows::Foundation::IInspectable & args) Line 2525	C++
 	TerminalApp.dll!winrt::impl::invoke<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Foundation::IInspectable,winrt::Windows::Foundation::IInspectable>,winrt::TerminalApp::implementation::TerminalPage,std::nullptr_t>(const winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Foundation::IInspectable,winrt::Windows::Foundation::IInspectable> & delegate, const winrt::TerminalApp::implementation::TerminalPage & <args_0>, void * const & <args_1>) Line 5890	C++
 	TerminalApp.dll!winrt::event<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Foundation::IInspectable,winrt::Windows::Foundation::IInspectable>>::operator()<winrt::TerminalApp::implementation::TerminalPage,std::nullptr_t>(const winrt::TerminalApp::implementation::TerminalPage & <args_0>, void * const & <args_1>) Line 6043	C++
 	TerminalApp.dll!winrt::TerminalApp::implementation::TerminalPage::_CompleteInitialization::__l7::<lambda_1>::operator()() Line 692	C++
 	TerminalApp.dll!winrt::impl::delegate<winrt::Windows::UI::Core::DispatchedHandler,`winrt::TerminalApp::implementation::TerminalPage::_CompleteInitialization'::`7'::<lambda_1>>::Invoke() Line 1136	C++
 	[External Code]	
 	WindowsTerminal.exe!WindowThread::_messagePump() Line 199	C++
 	WindowsTerminal.exe!WindowThread::RunMessagePump() Line 44	C++
 	WindowsTerminal.exe!WindowEmperor::_createNewWindowThread::__l2::<lambda_1>::operator()() Line 240	C++
 	[External Code]	

Should that caller just call _SetIsBorderless directly?

It didn't look like TerminalWindow or TerminalPage had access to the IslandWindow/NonClientIsland to call IslandWindow::_SetIsBorderLess, I think communication always happens through that FocusModeChanged event.

e82eric avatar Jan 09 '24 01:01 e82eric