From 9690f5ec861a4efbe2bddbcbef164c0d8e25e9e9 Mon Sep 17 00:00:00 2001 From: AnuthaDev Date: Thu, 25 Jun 2020 00:05:02 +0530 Subject: [PATCH 1/2] rudimemtary --- .../TerminalApp/MinMaxCloseControl.cpp | 7 +++++ .../TerminalApp/MinMaxCloseControl.xaml | 1 + src/cascadia/TerminalApp/TitlebarControl.idl | 3 +- .../WindowsTerminal/NonClientIslandWindow.cpp | 31 +++++++++++++++++++ .../WindowsTerminal/NonClientIslandWindow.h | 8 +++++ 5 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/cascadia/TerminalApp/MinMaxCloseControl.cpp b/src/cascadia/TerminalApp/MinMaxCloseControl.cpp index ee5f3e0d9b7..cf36582e3f8 100644 --- a/src/cascadia/TerminalApp/MinMaxCloseControl.cpp +++ b/src/cascadia/TerminalApp/MinMaxCloseControl.cpp @@ -79,6 +79,13 @@ namespace winrt::TerminalApp::implementation CloseButton().Height(maximizedHeight); break; + + case WindowVisualState::WindowVisualStateTablet: + VisualStateManager::GoToState(MaximizeButton(), L"WindowStateTablet", false); + VisualStateManager::GoToState(MinimizeButton(), L"WindowStateTablet", false); + VisualStateManager::GoToState(CloseButton(), L"WindowStateTablet", false); + break; + case WindowVisualState::WindowVisualStateNormal: case WindowVisualState::WindowVisualStateIconified: default: diff --git a/src/cascadia/TerminalApp/MinMaxCloseControl.xaml b/src/cascadia/TerminalApp/MinMaxCloseControl.xaml index 701c8720935..dc137672ad3 100644 --- a/src/cascadia/TerminalApp/MinMaxCloseControl.xaml +++ b/src/cascadia/TerminalApp/MinMaxCloseControl.xaml @@ -127,6 +127,7 @@ the MIT License. See LICENSE in the project root for license information. --> + diff --git a/src/cascadia/TerminalApp/TitlebarControl.idl b/src/cascadia/TerminalApp/TitlebarControl.idl index 104f7a2f26f..424d76e0b05 100644 --- a/src/cascadia/TerminalApp/TitlebarControl.idl +++ b/src/cascadia/TerminalApp/TitlebarControl.idl @@ -7,7 +7,8 @@ namespace TerminalApp { WindowVisualStateNormal = 0, WindowVisualStateMaximized, - WindowVisualStateIconified + WindowVisualStateIconified, + WindowVisualStateTablet }; [default_interface] runtimeclass TitlebarControl : Windows.UI.Xaml.Controls.Grid diff --git a/src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp b/src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp index 2238cf770a3..536b8357eae 100644 --- a/src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp +++ b/src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp @@ -16,6 +16,8 @@ using namespace winrt::Windows::Foundation::Numerics; using namespace ::Microsoft::Console; using namespace ::Microsoft::Console::Types; +namespace vm = winrt::Windows::UI::ViewManagement; + static constexpr int AutohideTaskbarSize = 2; NonClientIslandWindow::NonClientIslandWindow(const ElementTheme& requestedTheme) noexcept : @@ -304,6 +306,7 @@ RECT NonClientIslandWindow::_GetDragAreaRect() const noexcept void NonClientIslandWindow::OnSize(const UINT width, const UINT height) { _UpdateMaximizedState(); + _CheckTabletMode(); if (_interopWindowHandle) { @@ -354,6 +357,25 @@ void NonClientIslandWindow::_OnMaximizeChange() noexcept _UpdateFrameMargins(); } + +void NonClientIslandWindows::_CheckTabletMode(HWND hwnd) +{ + winrt::com_ptr viewSettings; + vm::UserInteractionMode mode = vm::UserInteractionMode_Mouse; + + if (viewSettings) + { + vm::UserInteractionMode currentMode; + viewSettings->get_UserInteractionMode(¤tMode); + if (g_mode != currentMode) + { + g_mode = currentMode; + _isTabletMode = true; + const auto state = winrt::TerminalApp::WindowVisualState::WindowVisualStateTablet + _titlebar.SetWindowVisualState(state); + } + } +} // Method Description: // - Called when the size of the window changes for any reason. Updates the // sizes of our child XAML Islands to match our new sizing. @@ -788,6 +810,15 @@ void NonClientIslandWindow::_UpdateFrameMargins() const noexcept return FALSE; } + WRL::ComPtr interop; + Windows::Foundation::GetActivationFactory(WRL::Wrappers::HStringReference( + RuntimeClass_Windows_UI_ViewManagement_UIViewSettings).Get(), + &interop); + + interop->GetForWindow(hwnd, IID_PPV_ARGS(&g_viewSettings)); + + _CheckTabletMode(hwnd); + // This is a hack to make the window borders dark instead of light. // It must be done before WM_NCPAINT so that the borders are rendered with // the correct theme. diff --git a/src/cascadia/WindowsTerminal/NonClientIslandWindow.h b/src/cascadia/WindowsTerminal/NonClientIslandWindow.h index 792ba6272c9..07c6fddacc2 100644 --- a/src/cascadia/WindowsTerminal/NonClientIslandWindow.h +++ b/src/cascadia/WindowsTerminal/NonClientIslandWindow.h @@ -22,6 +22,10 @@ Author(s): #include "../../types/inc/Viewport.hpp" #include #include +#include +#include +#include +#include class NonClientIslandWindow : public IslandWindow { @@ -61,6 +65,7 @@ class NonClientIslandWindow : public IslandWindow winrt::Windows::UI::Xaml::ElementTheme _theme; bool _isMaximized; + bool _isTabletMode; [[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; @@ -77,11 +82,14 @@ class NonClientIslandWindow : public IslandWindow [[nodiscard]] LRESULT _OnPaint() noexcept; [[nodiscard]] LRESULT _OnSetCursor(WPARAM wParam, LPARAM lParam) const noexcept; void _OnMaximizeChange() noexcept; + void _OnFullscreenChange() noexcept; void _OnDragBarSizeChanged(winrt::Windows::Foundation::IInspectable sender, winrt::Windows::UI::Xaml::SizeChangedEventArgs eventArgs); void _SetIsFullscreen(const bool fFullscreenEnabled) override; bool _IsTitlebarVisible() const; + void _CheckTabletMode(HWND hwnd) noexcept; + void _UpdateFrameMargins() const noexcept; void _UpdateMaximizedState(); void _UpdateIslandPosition(const UINT windowWidth, const UINT windowHeight); From 343382365d670642bc3459c19b3d7188bb096818 Mon Sep 17 00:00:00 2001 From: AnuthaDev Date: Thu, 25 Jun 2020 00:15:59 +0530 Subject: [PATCH 2/2] spelling --- .github/actions/spell-check/expect/expect.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/actions/spell-check/expect/expect.txt b/.github/actions/spell-check/expect/expect.txt index 32d4bc08b06..ca7281cb11a 100644 --- a/.github/actions/spell-check/expect/expect.txt +++ b/.github/actions/spell-check/expect/expect.txt @@ -377,6 +377,7 @@ coord coordnew COPYCOLOR CORESYSTEM +corewrappers cotaskmem countof cout @@ -2519,6 +2520,7 @@ VFT vga vgaoem viewkind +viewmanagement viewports Virt VIRTTERM @@ -2526,6 +2528,7 @@ Virtualizing vk vkey VKKEYSCAN +vm VMs VPA VPATH