Skip to content

Commit

Permalink
THATS RIGHT, IT HOT-RELOADS
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Apr 12, 2021
1 parent 7c2a514 commit ac8fef0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/cascadia/TerminalApp/AppLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ namespace winrt::TerminalApp::implementation
CATCH_LOG();

// Method Description:
// - Reloads the settings from the profile.json.
// - Reloads the settings from the settings.json file.
void AppLogic::_ReloadSettings()
{
// Attempt to load our settings.
Expand Down Expand Up @@ -998,6 +998,8 @@ namespace winrt::TerminalApp::implementation
_ApplyStartupTaskStateChange();

Jumplist::UpdateJumplist(_settings);

_SettingsChangedHandlers(*this, nullptr);
}

// Method Description:
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/AppLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ namespace winrt::TerminalApp::implementation

// -------------------------------- WinRT Events ---------------------------------
TYPED_EVENT(RequestedThemeChanged, winrt::Windows::Foundation::IInspectable, winrt::Windows::UI::Xaml::ElementTheme);
TYPED_EVENT(SettingsChanged, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);

private:
bool _isUwp{ false };
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/AppLogic.idl
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,6 @@ namespace TerminalApp
event Windows.Foundation.TypedEventHandler<Object, Object> SetTaskbarProgress;
event Windows.Foundation.TypedEventHandler<Object, Object> IdentifyWindowsRequested;
event Windows.Foundation.TypedEventHandler<Object, RenameWindowRequestedArgs> RenameWindowRequested;
event Windows.Foundation.TypedEventHandler<Object, Object> SettingsChanged;
}
}
22 changes: 15 additions & 7 deletions src/cascadia/WindowsTerminal/AppHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ void AppHost::Initialize()
_logic.SetTaskbarProgress({ this, &AppHost::SetTaskbarProgress });
_logic.IdentifyWindowsRequested({ this, &AppHost::_IdentifyWindowsRequested });
_logic.RenameWindowRequested({ this, &AppHost::_RenameWindowRequested });
_logic.SettingsChanged({ this, &AppHost::_HandleSettingsChanged });

_window->UpdateTitle(_logic.Title());

Expand Down Expand Up @@ -606,18 +607,19 @@ winrt::fire_and_forget AppHost::_WindowActivated()
}
}

winrt::fire_and_forget AppHost::_BecomeMonarch(const winrt::Windows::Foundation::IInspectable& /*sender*/,
const winrt::Windows::Foundation::IInspectable& /*args*/)
void AppHost::_BecomeMonarch(const winrt::Windows::Foundation::IInspectable& /*sender*/,
const winrt::Windows::Foundation::IInspectable& /*args*/)
{
// The hotkey MUST be registered on the main thread. It will fail otherwise!
co_await winrt::resume_foreground(_logic.GetRoot().Dispatcher(),
winrt::Windows::UI::Core::CoreDispatcherPriority::Normal);

_setupGlobalHotkeys();
}

void AppHost::_setupGlobalHotkeys()
winrt::fire_and_forget AppHost::_setupGlobalHotkeys()
{
// The hotkey MUST be registered on the main thread. It will fail otherwise!
co_await winrt::resume_foreground(_logic.GetRoot().Dispatcher(),
winrt::Windows::UI::Core::CoreDispatcherPriority::Normal);

// Remove all the already registered hotkeys before setting up the new ones.
_window->UnsetHotkeys(_hotkeys);

_hotkeyActions = _logic.GlobalHotkeys();
Expand Down Expand Up @@ -780,3 +782,9 @@ winrt::fire_and_forget AppHost::_RenameWindowRequested(const winrt::Windows::Fou
}
}
}

void AppHost::_HandleSettingsChanged(const winrt::Windows::Foundation::IInspectable& /*sender*/,
const winrt::Windows::Foundation::IInspectable& /*args*/)
{
_setupGlobalHotkeys();
}
8 changes: 5 additions & 3 deletions src/cascadia/WindowsTerminal/AppHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class AppHost
void _FindTargetWindow(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Microsoft::Terminal::Remoting::FindTargetWindowArgs& args);

winrt::fire_and_forget _BecomeMonarch(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::Foundation::IInspectable& args);
void _BecomeMonarch(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::Foundation::IInspectable& args);
void _GlobalHotkeyPressed(const long hotkeyIndex);
void _HandleSummon(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::Foundation::IInspectable& args);
Expand All @@ -70,6 +70,8 @@ class AppHost

GUID _CurrentDesktopGuid();

void _setupGlobalHotkeys();
winrt::fire_and_forget _setupGlobalHotkeys();
winrt::fire_and_forget _createNewTerminalWindow(winrt::Microsoft::Terminal::Settings::Model::GlobalSummonArgs args);
void _HandleSettingsChanged(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::Foundation::IInspectable& args);
};

1 comment on commit ac8fef0

@github-actions

This comment was marked as outdated.

Please sign in to comment.