Skip to content

Commit

Permalink
mobile attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
AnuthaDev committed Jun 19, 2020
1 parent 1fdceb0 commit c5ff807
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/actions/spell-check/expect/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,7 @@ natvis
naws
nbsp
Nc
NCACTIVATE
NCCALCSIZE
NCCREATE
NCLBUTTONDOWN
Expand Down
9 changes: 9 additions & 0 deletions src/cascadia/TerminalApp/MinMaxCloseControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,20 @@ namespace winrt::TerminalApp::implementation
MaximizeButton().Height(maximizedHeight);
CloseButton().Height(maximizedHeight);
break;
case WindowVisualState::WindowVisualStateUnfocused:
VisualStateManager::GoToState(MaximizeButton(), L"WindowStateUnfocused", false);
VisualStateManager::GoToState(MinimizeButton(), L"WindowStateUnfocused", false);
VisualStateManager::GoToState(CloseButton(), L"WindowStateUnfocused", false);
break;

case WindowVisualState::WindowVisualStateFocused:
case WindowVisualState::WindowVisualStateNormal:
case WindowVisualState::WindowVisualStateIconified:
default:
VisualStateManager::GoToState(MaximizeButton(), L"WindowStateNormal", false);
VisualStateManager::GoToState(MaximizeButton(), L"WindowStateFocused", false);
VisualStateManager::GoToState(MinimizeButton(), L"WindowStateFocused", false);
VisualStateManager::GoToState(CloseButton(), L"WindowStateFocused", false);

MinimizeButton().Height(windowedHeight);
MaximizeButton().Height(windowedHeight);
Expand Down
12 changes: 12 additions & 0 deletions src/cascadia/TerminalApp/MinMaxCloseControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ the MIT License. See LICENSE in the project root for license information. -->
<StaticResource x:Key="CaptionButtonStrokePointerOver" ResourceKey="SystemControlForegroundBaseHighBrush"/>
<StaticResource x:Key="CaptionButtonStrokePressed" ResourceKey="SystemControlForegroundBaseHighBrush"/>
<SolidColorBrush x:Key="CaptionButtonBackground" Color="Transparent" />
<SolidColorBrush x:Key="CaptionButtonStrokeWindowUnfocused" Color="Red" />
<SolidColorBrush x:Key="CloseButtonBackgroundPointerOver" Color="#e81123"/>
<SolidColorBrush x:Key="CloseButtonStrokePointerOver" Color="White"/>
<SolidColorBrush x:Key="CloseButtonBackgroundPressed" Color="#f1707a"/>
Expand All @@ -38,6 +39,7 @@ the MIT License. See LICENSE in the project root for license information. -->
<StaticResource x:Key="CaptionButtonStrokePointerOver" ResourceKey="SystemControlForegroundBaseHighBrush"/>
<StaticResource x:Key="CaptionButtonStrokePressed" ResourceKey="SystemControlForegroundBaseHighBrush"/>
<SolidColorBrush x:Key="CaptionButtonBackground" Color="Transparent" />
<SolidColorBrush x:Key="CaptionButtonStrokeWindowUnfocused" Color="Red" />
<SolidColorBrush x:Key="CloseButtonBackgroundPointerOver" Color="#e81123"/>
<SolidColorBrush x:Key="CloseButtonStrokePointerOver" Color="White"/>
<SolidColorBrush x:Key="CloseButtonBackgroundPressed" Color="#f1707a"/>
Expand Down Expand Up @@ -125,6 +127,16 @@ the MIT License. See LICENSE in the project root for license information. -->
<VisualState x:Name="Disabled" />
</VisualStateGroup>

<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="WindowStateFocused" />

<VisualState x:Name="WindowStateUnfocused">
<VisualState.Setters>
<Setter Target="Path.Stroke" Value="{ThemeResource CaptionButtonStrokeWindowUnfocused}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>

<VisualStateGroup x:Name="MinMaxStates">
<VisualState x:Name="WindowStateNormal" />

Expand Down
4 changes: 3 additions & 1 deletion src/cascadia/TerminalApp/TitlebarControl.idl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ namespace TerminalApp
{
WindowVisualStateNormal = 0,
WindowVisualStateMaximized,
WindowVisualStateIconified
WindowVisualStateIconified,
WindowVisualStateFocused,
WindowVisualStateUnfocused
};

[default_interface] runtimeclass TitlebarControl : Windows.UI.Xaml.Controls.Grid
Expand Down
30 changes: 30 additions & 0 deletions src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,34 @@ int NonClientIslandWindow::_GetResizeHandleHeight() const noexcept
return 0;
}

// Method Description:
// - Responds to the WM_NCACTIVATE message by changing the focus state of
// the window.
[[nodiscard]] LRESULT NonClientIslandWindow::_OnFocusChanged(const WPARAM wParam, const LPARAM lParam) noexcept
{
const auto windowStyle = GetWindowStyle(_window.get());
const auto isIconified = WI_IsFlagSet(windowStyle, WS_ICONIC);

if (isIconified)
{
return DefWindowProc(_window.get(), WM_NCACTIVATE, wParam, lParam);
}

if (_titlebar)
{
_isFocused = wParam;
const auto state = _isFocused ? winrt::TerminalApp::WindowVisualState::WindowVisualStateFocused :
winrt::TerminalApp::WindowVisualState::WindowVisualStateUnfocused;
try
{
_titlebar.SetWindowVisualState(state);
}
CATCH_LOG();
}

return TRUE;
}

// Method Description:
// - Hit test the frame for resizing and moving.
// Arguments:
Expand Down Expand Up @@ -688,6 +716,8 @@ void NonClientIslandWindow::_UpdateFrameMargins() const noexcept
return 0;
case WM_NCCALCSIZE:
return _OnNcCalcSize(wParam, lParam);
case WM_NCACTIVATE:
return _OnFocusChanged(wParam, lParam);
case WM_NCHITTEST:
return _OnNcHitTest({ GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) });
case WM_PAINT:
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/WindowsTerminal/NonClientIslandWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class NonClientIslandWindow : public IslandWindow
winrt::Windows::UI::Xaml::ElementTheme _theme;

bool _isMaximized;
bool _isFocused;

[[nodiscard]] static LRESULT __stdcall _StaticInputSinkWndProc(HWND const window, UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept;
[[nodiscard]] LRESULT _InputSinkMessageHandler(UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept;
Expand All @@ -73,6 +74,7 @@ class NonClientIslandWindow : public IslandWindow

[[nodiscard]] LRESULT _OnNcCreate(WPARAM wParam, LPARAM lParam) noexcept override;
[[nodiscard]] LRESULT _OnNcCalcSize(const WPARAM wParam, const LPARAM lParam) noexcept;
[[nodiscard]] LRESULT _OnFocusChanged(const WPARAM wParam, const LPARAM lParam) noexcept;
[[nodiscard]] LRESULT _OnNcHitTest(POINT ptMouse) const noexcept;
[[nodiscard]] LRESULT _OnPaint() noexcept;
[[nodiscard]] LRESULT _OnSetCursor(WPARAM wParam, LPARAM lParam) const noexcept;
Expand Down

0 comments on commit c5ff807

Please sign in to comment.