Skip to content

Commit

Permalink
rudimemtary
Browse files Browse the repository at this point in the history
  • Loading branch information
AnuthaDev committed Jun 24, 2020
1 parent d8810f2 commit 9690f5e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/cascadia/TerminalApp/MinMaxCloseControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/MinMaxCloseControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ the MIT License. See LICENSE in the project root for license information. -->

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

<VisualState x:Name="WindowStateMaximized">
<VisualState.Setters>
Expand Down
3 changes: 2 additions & 1 deletion src/cascadia/TerminalApp/TitlebarControl.idl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ namespace TerminalApp
{
WindowVisualStateNormal = 0,
WindowVisualStateMaximized,
WindowVisualStateIconified
WindowVisualStateIconified,
WindowVisualStateTablet
};

[default_interface] runtimeclass TitlebarControl : Windows.UI.Xaml.Controls.Grid
Expand Down
31 changes: 31 additions & 0 deletions src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down Expand Up @@ -304,6 +306,7 @@ RECT NonClientIslandWindow::_GetDragAreaRect() const noexcept
void NonClientIslandWindow::OnSize(const UINT width, const UINT height)
{
_UpdateMaximizedState();
_CheckTabletMode();

if (_interopWindowHandle)
{
Expand Down Expand Up @@ -354,6 +357,25 @@ void NonClientIslandWindow::_OnMaximizeChange() noexcept
_UpdateFrameMargins();
}


void NonClientIslandWindows::_CheckTabletMode(HWND hwnd)
{
winrt::com_ptr<vm::IUIViewSettings> viewSettings;
vm::UserInteractionMode mode = vm::UserInteractionMode_Mouse;

if (viewSettings)
{
vm::UserInteractionMode currentMode;
viewSettings->get_UserInteractionMode(&currentMode);
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.
Expand Down Expand Up @@ -788,6 +810,15 @@ void NonClientIslandWindow::_UpdateFrameMargins() const noexcept
return FALSE;
}

WRL::ComPtr<IUIViewSettingsInterop> 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.
Expand Down
8 changes: 8 additions & 0 deletions src/cascadia/WindowsTerminal/NonClientIslandWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Author(s):
#include "../../types/inc/Viewport.hpp"
#include <dwmapi.h>
#include <wil/resource.h>
#include <windows.ui.viewmanagement.h>
#include <UIViewSettingsInterop.h>
#include <wrl/client.h>
#include <wrl/wrappers/corewrappers.h>

class NonClientIslandWindow : public IslandWindow
{
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down

1 comment on commit 9690f5e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New misspellings found, please review:

  • corewrappers
  • viewmanagement
  • vm
To accept these changes, run the following commands
perl -e '
my @expect_files=qw('".github/actions/spell-check/expect/alphabet.txt
.github/actions/spell-check/expect/expect.txt
.github/actions/spell-check/expect/web.txt"');
@ARGV=@expect_files;
my @stale=qw('"atg BKMK consoleaccessibility FFF hyperlink NRCS popclip remoting rerendered SCS shobjidl unfocuses VMs xab xb xbc xca xce xdd xffff "');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
  if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
  next if /^($re)(?:$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spell-check/expect/9690f5ec861a4efbe2bddbcbef164c0d8e25e9e9.txt";
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"corewrappers nrcs Remoting Scs Shobjidl viewmanagement vm "');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a) cmp lc($b)} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;'
git add .github/actions/spell-check/expect || echo '... you want to ensure .github/actions/spell-check/expect/9690f5ec861a4efbe2bddbcbef164c0d8e25e9e9.txt is added to your repository...'
✏️ Contributor please read this

By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.

⚠️ The command is written for posix shells. You can copy the contents of each perl command excluding the outer ' marks and dropping any '"/"' quotation mark pairs into a file and then run perl file.pl from the root of the repository to run the code. Alternatively, you can manually insert the items...

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spell-check/dictionary/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spell-check/dictionary/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spell-check/expect/.
  • ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in .github/actions/spell-check/patterns/.

See the README.md in each directory for more information.

🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The :check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉

⚠️ Reviewers

At present, the action that triggered this message will not show its ❌ in this PR unless the branch is within this repository.
Thus, you should make sure that this comment has been addressed before encouraging the merge bot to merge this PR.

Please sign in to comment.