Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
leonMSFT committed May 20, 2021
1 parent e3d673e commit 150efbb
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,32 @@ namespace winrt::TerminalApp::implementation
HRESULT TerminalPage::Initialize(HWND hwnd)
{
_hostingHwnd = hwnd;

TestNotifyIconFunction();

return S_OK;
}

void TerminalPage::TestNotifyIconFunction()
{
if (_hostingHwnd)
{
NOTIFYICONDATA nid{};

nid.hWnd = _hostingHwnd.value();
nid.uID = 1;
nid.uCallbackMessage = WM_APP + 1;
StringCchCopy(nid.szTip, ARRAYSIZE(nid.szTip), L"Windows Terminal");
nid.uFlags = NIF_MESSAGE | NIF_SHOWTIP | NIF_TIP;

// Add the icon to the tray
Shell_NotifyIcon(NIM_ADD, &nid);

nid.uVersion = NOTIFYICON_VERSION_4;
Shell_NotifyIcon(NIM_SETVERSION, &nid);
}
}

// Function Description:
// - Recursively check our commands to see if there's a keybinding for
// exactly their action. If there is, label that command with the text
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalApp/TerminalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ namespace winrt::TerminalApp::implementation

void _SetFocusMode(const bool inFocusMode);

void TestNotifyIconFunction();

#pragma region ActionHandlers
// These are all defined in AppActionHandlers.cpp
#define ON_ALL_ACTIONS(action) DECLARE_ACTION_HANDLER(action);
Expand Down
20 changes: 20 additions & 0 deletions src/cascadia/WindowsTerminal/AppHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ AppHost::AppHost() noexcept :
_window->MouseScrolled({ this, &AppHost::_WindowMouseWheeled });
_window->WindowActivated({ this, &AppHost::_WindowActivated });
_window->HotkeyPressed({ this, &AppHost::_GlobalHotkeyPressed });
_window->NotifyIconPressed({ this, &AppHost::_NotifyIconPressed });
_window->SetAlwaysOnTop(_logic.GetInitialAlwaysOnTop());
_window->MakeWindow();

Expand Down Expand Up @@ -917,3 +918,22 @@ void AppHost::_IsQuakeWindowChanged(const winrt::Windows::Foundation::IInspectab
{
_window->IsQuakeWindow(_logic.IsQuakeWindow());
}

void AppHost::_NotifyIconPressed()
{
// No name provided means show the MRU window.
Remoting::SummonWindowSelectionArgs args{};

// For now, just show the window where it originally was.
args.OnCurrentDesktop(true);
args.SummonBehavior().MoveToCurrentDesktop(false);
args.SummonBehavior().ToggleVisibility(false);
args.SummonBehavior().DropdownDuration(0);
args.SummonBehavior().ToMonitor(Remoting::MonitorBehavior::ToCurrent);

_windowManager.SummonWindow(args);
if (args.FoundMatch())
{
// Excellent, the window was found. We have nothing else to do here.
}
}
2 changes: 2 additions & 0 deletions src/cascadia/WindowsTerminal/AppHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,6 @@ class AppHost

void _IsQuakeWindowChanged(const winrt::Windows::Foundation::IInspectable& sender,
const winrt::Windows::Foundation::IInspectable& args);

void _NotifyIconPressed();
};
20 changes: 20 additions & 0 deletions src/cascadia/WindowsTerminal/IslandWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,26 @@ long IslandWindow::_calculateTotalSize(const bool isWidth, const long clientSize
case WM_THEMECHANGED:
UpdateWindowIconForActiveMetrics(_window.get());
return 0;
// TODO: Give this a better name, something like WT_NOTIFYICON
// WM_APP to 0xBFFF is available for use for apps.
case WM_APP + 1:
{
switch (LOWORD(lparam))
{
case NIN_SELECT:
{
_NotifyIconPressedHandlers();
break;
}
case WM_CONTEXTMENU:
{
// TODO: show the context menu
// Build it with ways to open specific windows
break;
}
}
break;
}
}

// TODO: handle messages here...
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/WindowsTerminal/IslandWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class IslandWindow :
WINRT_CALLBACK(MouseScrolled, winrt::delegate<void(til::point, int32_t)>);
WINRT_CALLBACK(WindowActivated, winrt::delegate<void()>);
WINRT_CALLBACK(HotkeyPressed, winrt::delegate<void(long)>);
WINRT_CALLBACK(NotifyIconPressed, winrt::delegate<void()>);

protected:
void ForceResize()
Expand Down

1 comment on commit 150efbb

@github-actions

This comment was marked as resolved.

Please sign in to comment.